Copyright 2016 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
package ctxhttp // import "golang.org/x/net/context/ctxhttp"

import (
	
	
	
	
	
)
Do sends an HTTP request with the provided http.Client and returns an HTTP response. If the client is nil, http.DefaultClient is used. The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.
func ( context.Context,  *http.Client,  *http.Request) (*http.Response, error) {
	if  == nil {
		 = http.DefaultClient
	}
If we got an error, and the context has been canceled, the context's error is probably more useful.
	if  != nil {
		select {
		case <-.Done():
			 = .Err()
		default:
		}
	}
	return , 
}
Get issues a GET request via the Do function.
func ( context.Context,  *http.Client,  string) (*http.Response, error) {
	,  := http.NewRequest("GET", , nil)
	if  != nil {
		return nil, 
	}
	return Do(, , )
}
Head issues a HEAD request via the Do function.
func ( context.Context,  *http.Client,  string) (*http.Response, error) {
	,  := http.NewRequest("HEAD", , nil)
	if  != nil {
		return nil, 
	}
	return Do(, , )
}
Post issues a POST request via the Do function.
func ( context.Context,  *http.Client,  string,  string,  io.Reader) (*http.Response, error) {
	,  := http.NewRequest("POST", , )
	if  != nil {
		return nil, 
	}
	.Header.Set("Content-Type", )
	return Do(, , )
}
PostForm issues a POST request via the Do function.
func ( context.Context,  *http.Client,  string,  url.Values) (*http.Response, error) {
	return Post(, , , "application/x-www-form-urlencoded", strings.NewReader(.Encode()))