New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/net/http2: Transport ignores net/http.Transport.Proxy once connected #25793
Comments
(CC: @bradfitz and @tombergan for x/net/http2.) |
tl;dr net/http executes Proxy whenever RoundTrip isn't delegated to alternate round tripper ( If you use See for more details: Slide A, Slide B, Video. Also I don’t think DisableKeepAlive has any effect on http2 which uses long lived connections. |
cc: @odeke-em |
This might be tricky to fix with the current interface between the two packages. It'll need some thinking. Worst case we could document it at least, but I'd rather fix it. |
What version of Go are you using (
go version
)?go1.10.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I've set up an HTTP2 client and server. The client does a few concurrent requests to the sever. The client's http.Transport has a Proxy function set which alters the requests's context. The http.Transport.DisableKeepAlives flag is also set to true.
Upon receiving the response, the contents of the context gets printed out.
My code in playground: https://play.golang.org/p/bx4GvEZ-suw
Can't be run in playground though, because of the HTTP/2 package and needed cert and key.
To get the cert + key run:
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.pem -days 365 -nodes
in the directory of the file.What did you expect to see?
The context of every request altered, like so: (what happens if the http.Transport doesn't get configured for HTTP2)
What did you see instead?
Almost none of the requests passed through the http.Transport.Proxy function, even though the no keepalives flag has been set:
Not using HTTP2 on the client side seems to solve the issue completely. Playing with the 10ms processing time on the server and 10ms waiting time between starting goroutines either resolves the issue or make it worse. However this is not something you (should) have control over in a production environment.
This might be related to: #25620, however that one is on TCP level (where the http.Transport.Proxy is called, but not respected), while here the function isn't called at all.
The text was updated successfully, but these errors were encountered: