Skip to content

Commit

Permalink
http2 and forward proxies don't mix in go yet
Browse files Browse the repository at this point in the history
  • Loading branch information
rboyer committed Nov 8, 2023
1 parent 38ed20b commit c1e754b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test-integ/topoutil/asserter_blankspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ func (a *Asserter) checkBlankspaceNameViaHTTPWithCallback(
t.Helper()

var (
node = service.Node
addr = fmt.Sprintf("%s:%d", node.LocalAddress(), service.PortOrDefault(upstream.PortName))
client = a.mustGetHTTPClient(t, node.Cluster)
node = service.Node
internalPort = service.PortOrDefault(upstream.PortName)
addr = fmt.Sprintf("%s:%d", node.LocalAddress(), internalPort)
client = a.mustGetHTTPClient(t, node.Cluster)
)

if useHTTP2 {
// We can't use the forward proxy for http2, so use the exposed port on localhost instead.
exposedPort := node.ExposedPort(internalPort)
require.True(t, exposedPort > 0)

addr = fmt.Sprintf("%s:%d", "127.0.0.1", exposedPort)

// This will clear the proxy field on the transport.
client = EnableHTTP2(client)
}

Expand Down
3 changes: 3 additions & 0 deletions test-integ/topoutil/http2.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (

// EnableHTTP2 returns a new shallow copy of client that has been tweaked to do
// h2c (cleartext http2).
//
// Note that this clears the Client.Transport.Proxy trick because http2 and
// http proxies are incompatible currently in Go.
func EnableHTTP2(client *http.Client) *http.Client {
// Shallow copy, and swap the transport
client2 := *client
Expand Down

0 comments on commit c1e754b

Please sign in to comment.