Write no User-Agent when it is set to nil or the empty string - #28
Open
Mootjelh wants to merge 1 commit into
Open
Write no User-Agent when it is set to nil or the empty string#28Mootjelh wants to merge 1 commit into
Mootjelh wants to merge 1 commit into
Conversation
net/http and the HTTP/2 path here send none; HTTP/1.1 wrote an empty User-Agent: line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For bogdanfinn/tls-client#140.
net/http sends no User-Agent when the header is set to nil or to the empty string, and the HTTP/2 path in this package does the same; the comment above
didUAsays so. The HTTP/1.1 writer did not. It added Go's own only when the key was missing, and a present, empty one then went out as an emptyUser-Agent:line. Measured through a proxy that records the CONNECT header lines as they arrive, from tls-client withWithConnectHeaders(http.Header{"User-Agent": {""}, ...}):Connection: keep-alive,Host: 127.0.0.1:...,User-Agent:with nothing after the colon.The writer now leaves the header out of the write when it is present and empty, in either spelling, and still adds the default when it is missing. That is one exclude map handed to
writeSubset, so the caller's header map is not touched beyond whatwritealready did.TestRequestWriteOmitsAnEmptyUserAgentcovers both spellings with nil and with "", and the two controls: no header givesUser-Agent: Go-http-client/1.1, a value goes out as given. On master it fails on the empty line.For tls-client this means
WithConnectHeaders(http.Header{"User-Agent": {""}})sends a CONNECT with Host and nothing else, which is what #140 asks for, once the client pins a release with this in it.