a Go HTTP client with timeouts
Latest commit 31f0106 Jul 1, 2016 @mreiferson committed on GitHub Merge pull request #24 from gtank/license-fix
add copyright line to LICENSE
Failed to load latest commit information.
.gitignore Added custom redirect handler Oct 1, 2012
.travis.yml rewrite for go 1.1: Jun 8, 2013
LICENSE add copyright line to LICENSE Jun 30, 2016
README.md Fixes #17 add some docs re client re-use Apr 25, 2014
httpclient_test.go add feature of set tcp send buffer or receive buffer. Oct 14, 2015



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.


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", "", 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.