Commit 06cad3f5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Revert "Do not duplicate http.DefaultTransport"

This reverts commit d79f8563.

Kamil pointed out that shallow-copying http.DefaultTransport
accidentally gives us a references to a lot of things that probably
not be shared.
parent d79f8563
...@@ -17,6 +17,12 @@ var DefaultDialer = &net.Dialer{ ...@@ -17,6 +17,12 @@ var DefaultDialer = &net.Dialer{
KeepAlive: 30 * time.Second, KeepAlive: 30 * time.Second,
} }
var DefaultTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment, // from http.DefaultTransport
Dial: DefaultDialer.Dial, // from http.DefaultTransport
TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
}
type RoundTripper struct { type RoundTripper struct {
Socket string Socket string
ProxyHeadersTimeout time.Duration ProxyHeadersTimeout time.Duration
...@@ -61,8 +67,7 @@ func (t *RoundTripper) configureRoundTripper() { ...@@ -61,8 +67,7 @@ func (t *RoundTripper) configureRoundTripper() {
return return
} }
// Clone http.DefaultTransport. Needs a cast from http.RoundTripper to *http.Transport. tr := *DefaultTransport
tr := *(http.DefaultTransport.(*http.Transport))
tr.ResponseHeaderTimeout = t.ProxyHeadersTimeout tr.ResponseHeaderTimeout = t.ProxyHeadersTimeout
if t.Socket != "" { if t.Socket != "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment