[tor-commits] [meek/master] Make RoundTripper a field of RequestInfo.

dcf at torproject.org dcf at torproject.org
Thu Jan 17 05:58:54 UTC 2019


commit 05491c83be510e81b704bd86bc1a5e380e6f1d14
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Jan 16 22:30:06 2019 -0700

    Make RoundTripper a field of RequestInfo.
---
 meek-client/meek-client.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 9c715a3..1b13f11 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -117,6 +117,9 @@ type RequestInfo struct {
 	// The Host header to put in the HTTP request (optional and may be
 	// different from the host name in URL).
 	Host string
+	// The RoundTripper to use to send requests. This may vary depending on
+	// the value of global options like --helper.
+	RoundTripper http.RoundTripper
 }
 
 // Make an http.Request from the payload data in buf and the request metadata in
@@ -177,15 +180,11 @@ again:
 // Send the data in buf to the remote URL, wait for a reply, and feed the reply
 // body back into conn.
 func sendRecv(buf []byte, conn net.Conn, info *RequestInfo) (int64, error) {
-	var rt http.RoundTripper = httpRoundTripper
-	if options.UseHelper {
-		rt = helperRoundTripper
-	}
 	req, err := makeRequest(buf, info)
 	if err != nil {
 		return 0, err
 	}
-	resp, err := roundTripRetries(rt, req, maxTries)
+	resp, err := roundTripRetries(info.RoundTripper, req, maxTries)
 	if err != nil {
 		return 0, err
 	}
@@ -319,6 +318,11 @@ func handler(conn *pt.SocksConn) error {
 		info.URL.Host = front
 	}
 
+	info.RoundTripper = httpRoundTripper
+	if options.UseHelper {
+		info.RoundTripper = helperRoundTripper
+	}
+
 	return copyLoop(conn, &info)
 }
 





More information about the tor-commits mailing list