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

Set User-Agent header in transport #1154

Merged
merged 1 commit into from
Nov 26, 2022

Conversation

daenney
Copy link
Member

@daenney daenney commented Nov 26, 2022

Currently requests set their own User-Agent. Set it in the transport instead, unless it's been explicitly set on the request. This retains the flexibility of tweaking the UA if necessary, without having to remember to set it.

@daenney daenney changed the title [chore] Set User-Agent header in transport Set User-Agent header in transport Nov 26, 2022
@daenney
Copy link
Member Author

daenney commented Nov 26, 2022

One thing I noticed is that the code used to do req.Headers.Add() for the UA instead of .Set(). This could theoretically lead to the UA header being multi-valued, but I don't think that header is allowed/specified as list-based or multi-valued. It's why I opted for checking if the header is unset in req and going with .Set() to make that more explicit. Given we're always the ones who build the req this doesn't make a difference in practice.

Currently requests set their own User-Agent. This moves it down to set
it in the transport's do() method, to guarantee it's always set on all
requests.
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit c5ae88c into superseriousbusiness:main Nov 26, 2022
@daenney daenney deleted the ua-in-transport branch November 26, 2022 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants