Closed
Description
The documentation for Client.Do
says "Generally Get, Post, or PostForm will be used instead of Do." However, there is no way to pass a context.Context
into those methods, so we cannot, for example, set a per-request timeout without resorting to Do
. I propose adding the following new methods to http.Client
.
GetContext(ctx context.Context, url string) (resp *Response, err error)
HeadContext(ctx context.Context, url string) (resp *Response, err error)
PostContext(ctx context.Context, url, contentType string, body io.Reader) (resp *Response, err error)
PostFormContext(ctx context.Context, url string, data url.Values) (resp *Response, err error)
This would effectively deprecate the existing Get
, Head
, Post
, and PostForm
methods.
We should also make a corresponding global function for each of these, and deprecate the existing http.Get
, http.Head
, http.Post
, and http.PostForm
functions.