diff --git a/pkg/util/cloudinfo/cloudinfo.go b/pkg/util/cloudinfo/cloudinfo.go index 16b3f8e26253..4357db505e77 100644 --- a/pkg/util/cloudinfo/cloudinfo.go +++ b/pkg/util/cloudinfo/cloudinfo.go @@ -14,6 +14,7 @@ import ( "context" "encoding/json" "io/ioutil" + "net/http" "regexp" "time" @@ -165,7 +166,7 @@ func (cli *client) getAzureInstanceMetadata( func (cli *client) getInstanceMetadata( ctx context.Context, url string, headers []metadataReqHeader, ) ([]byte, error) { - req, err := httputil.NewRequestWithContext(ctx, "GET", url, nil) + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err != nil { return nil, err } diff --git a/pkg/util/httputil/client.go b/pkg/util/httputil/client.go index 12925cb11bc6..ae945958605d 100644 --- a/pkg/util/httputil/client.go +++ b/pkg/util/httputil/client.go @@ -65,7 +65,7 @@ func Post( // Get does like http.Client.Get but uses the provided context and obeys its cancellation. func (c *Client) Get(ctx context.Context, url string) (resp *http.Response, err error) { - req, err := NewRequestWithContext(ctx, "GET", url, nil) + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func (c *Client) Get(ctx context.Context, url string) (resp *http.Response, err // Head does like http.Client.Head but uses the provided context and obeys its cancellation. func (c *Client) Head(ctx context.Context, url string) (resp *http.Response, err error) { - req, err := NewRequestWithContext(ctx, "HEAD", url, nil) + req, err := http.NewRequestWithContext(ctx, "HEAD", url, nil) if err != nil { return nil, err } @@ -85,7 +85,7 @@ func (c *Client) Head(ctx context.Context, url string) (resp *http.Response, err func (c *Client) Post( ctx context.Context, url, contentType string, body io.Reader, ) (resp *http.Response, err error) { - req, err := NewRequestWithContext(ctx, "POST", url, body) + req, err := http.NewRequestWithContext(ctx, "POST", url, body) if err != nil { return nil, err } diff --git a/pkg/util/httputil/req_go112.go b/pkg/util/httputil/req_go112.go deleted file mode 100644 index aa02dd83dea7..000000000000 --- a/pkg/util/httputil/req_go112.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2019 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -// +build !go1.13 - -package httputil - -import ( - "context" - "io" - "net/http" -) - -// NewRequestWithContext provides the same interface as the Go 1.13 function -// in http but ignores the context argument. -// -// This is transition code until the repository is upgraded to use Go -// 1.13. In the meantime, the callers rely on requests eventually -// succeeding or failing with a timeout if the remote server does not -// provide a response on time. -// -// TODO(knz): remove this when the repo does not use 1.12 any more. -func NewRequestWithContext( - ctx context.Context, method, url string, body io.Reader, -) (*http.Request, error) { - return http.NewRequest(method, url, body) -} diff --git a/pkg/util/httputil/req_go113.go b/pkg/util/httputil/req_go113.go deleted file mode 100644 index d939ecb260d5..000000000000 --- a/pkg/util/httputil/req_go113.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -// +build go1.13 - -package httputil - -import ( - "context" - "io" - "net/http" -) - -// NewRequestWithContext aliases http.NewRequestWithContext. -// TODO(knz): this can be removed when the repo is upgraded to use go 1.13. -func NewRequestWithContext( - ctx context.Context, method, url string, body io.Reader, -) (*http.Request, error) { - return http.NewRequestWithContext(ctx, method, url, body) -}