* Switch to new vendor style. * Fix metrics generate command. * Fix miekg/dns types_generate. * Use generated copies of files. * Update miekg to latest. Fixes a problem with `go generate`. * Set GO15VENDOREXPERIMENT. * Build in letsencrypt/boulder. * fix travis more. * Exclude vendor instead of godeps. * Replace some ... * Fix unformatted cmd * Fix errcheck for vendorexp * Add GO15VENDOREXPERIMENT to Makefile. * Temp disable errcheck. * Restore master fetch. * Restore errcheck. * Build with 1.6 also. * Match statsd.*" * Skip errcheck unles Go1.6. * Add other ignorepkg. * Fix errcheck. * move errcheck * Remove go1.6 requirement. * Put godep-restore with errcheck. * Remove go1.6 dep. * Revert master fetch revert. * Remove -r flag from godep save. * Set GO15VENDOREXPERIMENT in Dockerfile and remove _worskpace. * Fix Godep version. |
||
|---|---|---|
| .. | ||
| .gitignore | ||
| .travis.yml | ||
| LICENSE | ||
| README.md | ||
| httpclient.go | ||
README.md
go-httpclient
requires Go 1.1+ as of v0.4.0 the API has been completely re-written for Go 1.1 (for a Go
1.0.x compatible release see 1adef50)
Provides an HTTP Transport that implements the RoundTripper interface and
can be used as a built in replacement for the standard library's, providing:
- connection timeouts
- request timeouts
This is a thin wrapper around http.Transport that sets dial timeouts and uses
Go's internal timer scheduler to call the Go 1.1+ CancelRequest() API.
Example
transport := &httpclient.Transport{
ConnectTimeout: 1*time.Second,
RequestTimeout: 10*time.Second,
ResponseHeaderTimeout: 5*time.Second,
}
defer transport.Close()
client := &http.Client{Transport: transport}
req, _ := http.NewRequest("GET", "http://127.0.0.1/test", nil)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
Note: you will want to re-use a single client object rather than creating one for each request, otherwise you will end up leaking connections.
Reference Docs
For API docs see godoc.
