google-api-go-client icon indicating copy to clipboard operation
google-api-go-client copied to clipboard

User agent prefix

Open kenegozi opened this issue 4 years ago • 2 comments

Per the RFC at https://tools.ietf.org/html/rfc2616#section-14.43, "By convention, the product tokens are listed in order of their significance for identifying the application."

Support specifying a prefix to the user agent, so that a user could specify a more significant identifier for their requests.

kenegozi avatar May 20 '20 16:05 kenegozi

It sounds like we should simply swap the order to match the spec. Also, some more ideas here: #494

broady avatar May 20 '20 22:05 broady

imo when setting a UserAgent field the expected behavior is to replace the user agent, not to append or prepend. Changing it in any way would be a breaking change though which is why I proposed a new field explicitly called UserAgentPrefix.

Interestingly enough, WithUserAgent() in NewService() would replace the agent, however it would not work with a custom http client provided via WithHttpClient.

A reasonable way forward (instead of the one proposed here) would be to mark UserAgent as obsolete, and have WithUserAgent work with a provided http client. I am happy to work on that change if preferred.

kenegozi avatar May 21 '20 01:05 kenegozi