Fixing automatic keep alive handling with manual connection header
@@ -298,7 +298,21 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
}
}
if resp == nil {
+
+ var disableKeepAliveOrigin bool
+ hasConnectionHeader := request.request.Header.Get("Connection") != ""
+ // if the request contains the connection header we need to disable automatic keep alive settings
+ if hasConnectionHeader {
+ disableKeepAliveOrigin = r.httpClient.HTTPClient.Transport.(*http.Transport).DisableKeepAlives
+ r.httpClient.HTTPClient.Transport.(*http.Transport).DisableKeepAlives = false
+ }
+
resp, err = r.httpClient.Do(request.request)
+
+ // now we should restore the settings
+ if hasConnectionHeader {
+ r.httpClient.HTTPClient.Transport.(*http.Transport).DisableKeepAlives = disableKeepAliveOrigin
+ }
}
}
