Skip to content
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

net/http: figure out a better User-Agent story #13837

bradfitz opened this Issue Jan 6, 2016 · 5 comments


None yet
6 participants
Copy link

bradfitz commented Jan 6, 2016

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

/cc @okdave @rakyll @adg


This comment has been minimized.

Copy link

rakyll commented Feb 13, 2016

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?

package http

func (r *Request) AppendUserAgent(ua string) 
func (r *Request) SetUserAgent(ua string)

AppendUserAgent appends to the old user agent. If old user agent is empty, it appends to the default UA.
SetUserAgent sets the user agent to the given value.


This comment has been minimized.

Copy link

okdave commented Feb 15, 2016

To be honest, I don't see the big downside in the status quo. What problem are we trying to solve?

@bradfitz bradfitz modified the milestones: Go1.8Maybe, Go1.7 May 4, 2016


This comment has been minimized.

Copy link
Member Author

bradfitz commented May 4, 2016

Too late for Go 1.7 anyway.

@quentinmit quentinmit added the NeedsFix label Oct 10, 2016

@rsc rsc modified the milestones: Go1.9, Go1.8Maybe Oct 20, 2016

@bradfitz bradfitz modified the milestones: Go1.10, Go1.9 May 24, 2017


This comment has been minimized.

Copy link
Member Author

bradfitz commented May 24, 2017

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.

@bradfitz bradfitz removed their assignment May 24, 2017

@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017

@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018


This comment has been minimized.

Copy link

rsc commented Jun 11, 2018

@bradfitz roll into 'new HTTP client API' issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.