File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,6 +322,10 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
322322 req = req .WithContext (requestContext )
323323 defer finishRequest ()
324324
325+ // explicitly discard request body to avoid data races in certain RoundTripper implementations
326+ // see https://github.com/golang/go/issues/61596#issuecomment-1652345131
327+ defer req .Body .Close ()
328+
325329 // Bug fix which goproxy fails to provide request
326330 // information URL in the context when does HTTPS MITM
327331 ctx .Req = req
@@ -364,12 +368,7 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request
364368 if ! proxy .KeepHeader {
365369 RemoveProxyHeaders (ctx , req )
366370 }
367- resp , err = func () (* http.Response , error ) {
368- // explicitly discard request body to avoid data races in certain RoundTripper implementations
369- // see https://github.com/golang/go/issues/61596#issuecomment-1652345131
370- defer req .Body .Close ()
371- return ctx .RoundTrip (req )
372- }()
371+ resp , err = ctx .RoundTrip (req )
373372 if err != nil {
374373 ctx .Warnf ("Cannot read TLS response from mitm'd server %v" , err )
375374 return false
You can’t perform that action at this time.
0 commit comments