lib/db, lib/discover: Minor cleanup (#8217)
This commit is contained in:
+2
-10
@@ -420,26 +420,18 @@ type contextClient struct {
|
||||
}
|
||||
|
||||
func (c *contextClient) Get(ctx context.Context, url string) (*http.Response, error) {
|
||||
// For <go1.13 compatibility. Use the following commented line once that
|
||||
// isn't required anymore.
|
||||
// req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Cancel = ctx.Done()
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
func (c *contextClient) Post(ctx context.Context, url, ctype string, data io.Reader) (*http.Response, error) {
|
||||
// For <go1.13 compatibility. Use the following commented line once that
|
||||
// isn't required anymore.
|
||||
// req, err := http.NewRequestWithContext(ctx, "POST", url, data)
|
||||
req, err := http.NewRequest("POST", url, data)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", url, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Cancel = ctx.Done()
|
||||
req.Header.Set("Content-Type", ctype)
|
||||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user