-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Proxy connection buffer necessary? #7327
Comments
Hi @flowchartsman, thanks for writing in. We are currently short of bandwidth, please feel free to send us a PR for this, will be happy to review. Thanks! |
I'll try to figure out why this buffer was introduced and if we still need it by going though the code and commit history. |
From my understanding, the standard library code is specifically for proxying In the case of gRPC however, we can't assume that TLS is always used and that the client initiates communication. Users can provide their own channel encryption/authentication implementations using the Credentials API. If some |
I believe in most cases TLS is used, so maybe checking for Will discuss this with other maintainers. |
I've raised a PR with a unit test for the buffering behaviour and also to discard the buffer when possible: #7424 |
While attempting to implement a proxied connection via configuration value (as opposed to as provided by env), I noticed the following type in
internal/transport/proxy.go
:The description seems to indicate that this type exists due to a concern that the
*bufio.Reader
wrapping thenet.Conn
will read more bytes than is necessary to fulfill the call tohttp.ReadResponse
indoHTTPConnectHandshake
and potentially consume some of the initial bytes of TLS exchange; however the code that serves the same purpose inhttp.Transport
asserts that this won't happen since the TLS host will not respond until the conn is written to again, making the*bufio.Reader
safe to throw away.Has anyone ever actually observed the reader getting more than just the
CONNECT
response, or is this just an overabundance of caution? I may have missed something, but this doesn't seem too different from the way it's done inhttp.Transport
.I don't know how much it would affect throughput or anything, but it's certainly wasteful to have another buffered reader in between you and the
net.Conn
if you don't need it.I removed the wrapper in favor of returning the
conn
directly fromdoHTTPConnectHandshake
, and all of the tests still pass, though that's not necessarily compelling proof for a negative. I can try and make a stronger case if needed--just have to figure out if it can be effectively tested.The text was updated successfully, but these errors were encountered: