net/http: client will only send a single user-agent header value #41738
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
I expected the server to receive two Content-Type values ("A" & "B") and two User-Agent values ("C" & "D").
What did you see instead?
The server did receive two Content-Type values as expected, but only the first User-Agent value ("C") was received.
Is this a bug or oversight, or is there a good reason for the Go HTTP client to not send multiple user-agent values?
The
http.Header
type models HTTP headers, which can appear multiple times in the same request/response, by using amap[string][]string
(note the[]string
value). The following snippet demonstrates that some headers, such asUser-Agent
are only sent once by the Go HTTP client in an outgoing HTTP request:The output of the above program is as follows:
However, using other tools (such as cURL) it is possible to send multiple
User-Agent
headers:Why does Go disallow multiple
User-Agent
values?For reference, I believe this is the code that limits the User-Agent to a single value:
https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L8025-L8028
Is this a bug or oversight, or is there a good reason for the Go HTTP client to not send multiple user-agent values?
The text was updated successfully, but these errors were encountered: