From bdaadec7881c56835a31473cbe6cd165b816e4b0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Jul 2023 17:37:01 +0200 Subject: [PATCH] testutil: use dummyhost for non-tcp connections Signed-off-by: Sebastiaan van Stijn (cherry picked from commit e1db9e9848435042922512b3b5f6dc97f627af00) Signed-off-by: Sebastiaan van Stijn --- integration-cli/docker_api_attach_test.go | 5 +++++ testutil/request/request.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go index 6d31c51ec3..401087ab2e 100644 --- a/integration-cli/docker_api_attach_test.go +++ b/integration-cli/docker_api_attach_test.go @@ -236,6 +236,11 @@ func requestHijack(method, endpoint string, data io.Reader, ct, daemon string, m req.URL.Scheme = "http" req.URL.Host = hostURL.Host + if hostURL.Scheme == "unix" || hostURL.Scheme == "npipe" { + // Override host header for non-tcp connections. + req.Host = client.DummyHost + } + for _, opt := range modifiers { opt(req) } diff --git a/testutil/request/request.go b/testutil/request/request.go index d5f559c666..6a91dc9b37 100644 --- a/testutil/request/request.go +++ b/testutil/request/request.go @@ -125,6 +125,11 @@ func newRequest(endpoint string, opts *Options) (*http.Request, error) { } req.URL.Host = hostURL.Host + if hostURL.Scheme == "unix" || hostURL.Scheme == "npipe" { + // Override host header for non-tcp connections. + req.Host = client.DummyHost + } + for _, config := range opts.requestModifiers { if err := config(req); err != nil { return nil, err