~go-bot/goose/trunk

« back to all changes in this revision

Viewing changes to http/client.go

[r=wallyworld] Do not overwrite http.Client's transport

Ensure that http.Client's transport has DisableKeepAlives=true
without ovwrwriting the transport itself.

https://codereview.appspot.com/14840043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        // See https://code.google.com/p/go/issues/detail?id=4677
30
30
        // We need to force the connection to close each time so that we don't
31
31
        // hit the above Go bug.
32
 
        http.DefaultTransport = &http.Transport{
33
 
                Proxy:             http.ProxyFromEnvironment,
34
 
                DisableKeepAlives: true,
 
32
        roundTripper := http.DefaultClient.Transport
 
33
        if transport, ok := roundTripper.(*http.Transport); ok {
 
34
                transport.DisableKeepAlives = true
35
35
        }
 
36
        http.DefaultTransport.(*http.Transport).DisableKeepAlives = true
36
37
}
37
38
 
38
39
type Client struct {