]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: use TCP Keep-Alives on DefaultTransport's connections
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 24 Feb 2014 23:20:45 +0000 (15:20 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 24 Feb 2014 23:20:45 +0000 (15:20 -0800)
Update #3362

Also set a 30 second timeout, instead of relying on the
operating system's timeout, which if often but not always 3
minutes.

LGTM=crawshaw
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/68330046

src/pkg/net/http/transport.go

index 5655d704f781f80d69fbf857ae14ce63a1cb47bf..cdad339a03c58fef84a81601d9ac6816a363c2b6 100644 (file)
@@ -30,7 +30,13 @@ import (
 // and caches them for reuse by subsequent calls. It uses HTTP proxies
 // as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and
 // $no_proxy) environment variables.
-var DefaultTransport RoundTripper = &Transport{Proxy: ProxyFromEnvironment}
+var DefaultTransport RoundTripper = &Transport{
+       Proxy: ProxyFromEnvironment,
+       Dial: (&net.Dialer{
+               Timeout:   30 * time.Second,
+               KeepAlive: 30 * time.Second,
+       }).Dial,
+}
 
 // DefaultMaxIdleConnsPerHost is the default value of Transport's
 // MaxIdleConnsPerHost.