[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [meek/master] Modify http.DefaultTransport directly, don't use a copy.



commit 0ee2dfb6e2868c432fbe05e8ee8080584e8e03d2
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Wed Apr 19 22:59:07 2017 -0700

    Modify http.DefaultTransport directly, don't use a copy.
    
    I don't see a reason to make a copy when this is all we use; also
    "go vet" complained:
    
    meek-client.go:403: assignment copies lock value to httpTransport: net/http.Transport contains sync.Mutex
---
 meek-client/meek-client.go | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 8cbc84a..c3eadc4 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -82,9 +82,10 @@ const (
 
 var ptInfo pt.ClientInfo
 
-// This is the RoundTripper used to make all our requests (when --helper is not
-// used).
-var httpTransport http.Transport
+// We use this RoundTripper to make all our requests (when --helper is not
+// used). We use the defaults, except we take control of the Proxy setting
+// (notably, disabling the default ProxyFromEnvironment).
+var httpTransport *http.Transport = http.DefaultTransport.(*http.Transport)
 
 // Store for command line options.
 var options struct {
@@ -396,11 +397,8 @@ func main() {
 		}
 	}
 
-	// We make a copy of DefaultTransport because we want the default Dial
-	// and TLSHandshakeTimeout settings. But we want to disable the default
-	// ProxyFromEnvironment setting. Proxy is overridden below if
-	// options.ProxyURL is set.
-	httpTransport = *http.DefaultTransport.(*http.Transport)
+	// Disable the default ProxyFromEnvironment setting. httpTransport.Proxy
+	// is overridden below if options.ProxyURL is set.
 	httpTransport.Proxy = nil
 
 	// Command-line proxy overrides managed configuration.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits