Ver código fonte

Revert to using ResponseHeaderTimeout

* Client.Timeout interrupts large response body downloads
  in progress
Rod Hynes 11 anos atrás
pai
commit
ef88e26715
2 arquivos alterados com 10 adições e 5 exclusões
  1. 1 1
      psiphon/dataStore.go
  2. 9 4
      psiphon/httpProxy.go

+ 1 - 1
psiphon/dataStore.go

@@ -548,7 +548,7 @@ func ReportAvailableRegions() {
 
 		// Some server entries do not have a region, but it makes no sense to return
 		// an empty string as an "available region".
-		if (region != "") {
+		if region != "" {
 			regions = append(regions, region)
 		}
 	}

+ 9 - 4
psiphon/httpProxy.go

@@ -87,13 +87,16 @@ func NewHttpProxy(
 		return tunneler.Dial(addr, false, nil)
 	}
 	httpTunneledRelay := &http.Transport{
-		Dial:                tunneledDialer,
-		MaxIdleConnsPerHost: HTTP_PROXY_MAX_IDLE_CONNECTIONS_PER_HOST,
+		Dial:                  tunneledDialer,
+		MaxIdleConnsPerHost:   HTTP_PROXY_MAX_IDLE_CONNECTIONS_PER_HOST,
+		ResponseHeaderTimeout: HTTP_PROXY_ORIGIN_SERVER_TIMEOUT,
 	}
 	httpTunneledClient := &http.Client{
 		Transport: httpTunneledRelay,
 		Jar:       nil, // TODO: cookie support for URL proxy?
-		Timeout:   HTTP_PROXY_ORIGIN_SERVER_TIMEOUT,
+
+		// This timeout cuts downloads of large response bodies
+		//Timeout:   HTTP_PROXY_ORIGIN_SERVER_TIMEOUT,
 	}
 
 	directDialer := func(_, addr string) (conn net.Conn, err error) {
@@ -107,7 +110,9 @@ func NewHttpProxy(
 	httpDirectClient := &http.Client{
 		Transport: httpDirectRelay,
 		Jar:       nil,
-		Timeout:   HTTP_PROXY_ORIGIN_SERVER_TIMEOUT,
+
+		// This timeout cuts downloads of large response bodies
+		//Timeout:   HTTP_PROXY_ORIGIN_SERVER_TIMEOUT,
 	}
 
 	proxy = &HttpProxy{