Add An Importable default_user_agent
Function
#3226
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a
default_user_agent
function (corresponding to requests.utils.default_user_agent) and allows it to be imported usingfrom httpx import default_user_agent
to allow different projects to check what user-agent should be expected by default from the clients they're using (for unit-tests, for example).This value existed as a constant variable named
USER_AGENT
(accessible only usinghttpx._client.USER_AGENT
) which I didn't necessarily have to convert to a function, but I thought it would be better as a function both because it will be implemented similarly torequests
, and because it will allow more flexibility in the future, in case it will need to be dynamically calculated (changing it to a function from a variable if needed in the future will break backwards compatibility).Don't think this change requires any unit-tests or docs to be updated (didn't find any matching section), but if you think it does, let me know and I'll try to add those.
Checklist