From ecb3f21076e77ed79e997ba1ca653c9ae6e0c27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20=C3=81ngel=20Jimeno?= Date: Wed, 24 Aug 2022 20:55:02 +0200 Subject: [PATCH] http: prevent HTTP 'connection' header from being added twice (#2480) * http: prevent HTTP 'connection' header from being added twice * misc fix Co-authored-by: sandeep --- v2/cmd/integration-test/http.go | 2 +- v2/pkg/protocols/http/http.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/v2/cmd/integration-test/http.go b/v2/cmd/integration-test/http.go index 0fdf9f566..6f2b6e1fc 100644 --- a/v2/cmd/integration-test/http.go +++ b/v2/cmd/integration-test/http.go @@ -586,7 +586,7 @@ func (h *httpRawUnsafeRequest) Execute(filePath string) error { ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) { defer conn.Close() - _, _ = conn.Write([]byte("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 36\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThis is test raw-unsafe-matcher test")) + _, _ = conn.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 36\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThis is test raw-unsafe-matcher test")) }) defer ts.Close() diff --git a/v2/pkg/protocols/http/http.go b/v2/pkg/protocols/http/http.go index 83ed88ec7..8484a0b33 100644 --- a/v2/pkg/protocols/http/http.go +++ b/v2/pkg/protocols/http/http.go @@ -237,6 +237,7 @@ func (request *Request) Compile(options *protocols.ExecuterOptions) error { NoTimeout: false, FollowRedirects: request.Redirects, CookieReuse: request.CookieReuse, + Connection: &httpclientpool.ConnectionConfiguration{}, } // If we have request level timeout, ignore http client timeouts for _, req := range request.Raw { @@ -248,7 +249,7 @@ func (request *Request) Compile(options *protocols.ExecuterOptions) error { // if the headers contain "Connection" we need to disable the automatic keep alive of the standard library if _, hasConnectionHeader := request.Headers["Connection"]; hasConnectionHeader { - connectionConfiguration.Connection = &httpclientpool.ConnectionConfiguration{DisableKeepAlive: false} + connectionConfiguration.Connection.DisableKeepAlive = true } client, err := httpclientpool.Get(options.Options, connectionConfiguration)