Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: figure out a better User-Agent story #13837
Fork of some discussion in #13685
Let's figure out User-Agents in Go 1.7: perhaps an optional func field on http1 and http2 Transports to modify the User-Agent before it's sent out?
SetUserAgent func(old string) string
Or fields for the default value to set if unset? Or a field to append? Maybe those are the two common requests.
In any case, the stdlib's private http2 Transport should use the public http1.Transport's same options, and this should all have new clientserver_test.go additions similar to https://go-review.googlesource.com/18284
I don't know why we may like to handle it in the Transport layer. Can we have a setter and an appender on *Request?
AppendUserAgent appends to the old user agent. If old user agent is empty, it appends to the default UA.
The problem here is there are too many RoundTripper wrapper implementations which just set or append User-Agents.
Somebody should do an audit (including those inside gocloud) here in this bug before anything happens, though. Maybe it's not as bad as I remember.