-
-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Adding ability to omit User-Agent header #3703
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MikeBishop
commented
Mar 23, 2021
@MikeBishop please can you add tests for this change? |
jasonsaayman
approved these changes
Mar 29, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
mastermatt
added a commit
to mastermatt/axios
that referenced
this pull request
Sep 6, 2021
Play nice with axios#3703
jasonsaayman
added a commit
that referenced
this pull request
Sep 7, 2021
* Caseless header comparing in HTTP adapter. It was adding User-Agent and removing Authorization, but only when existing headers had the exact right casing. Node uses caseless logic when managing headers. This was causing some requests to have `User-Agent` appended to the headers object and overriding provided agent strings. Also included is an update to not override the `Content-Length` if it was already defined in the options. It can be desirable to manually specify a content length that does not match the data on hand. Especially for testing. * Fix eslint error * fixup: update state UA logic Play nice with #3703 Co-authored-by: Jay <jasonsaayman@gmail.com>
This was referenced Sep 9, 2021
mbargiel
pushed a commit
to mbargiel/axios
that referenced
this pull request
Jan 27, 2022
* Adding ability to omit User-Agent header * Update line to be more compact * Add unit tests for user-agent cases Co-authored-by: Jay <jasonsaayman@gmail.com>
mbargiel
pushed a commit
to mbargiel/axios
that referenced
this pull request
Jan 27, 2022
* Caseless header comparing in HTTP adapter. It was adding User-Agent and removing Authorization, but only when existing headers had the exact right casing. Node uses caseless logic when managing headers. This was causing some requests to have `User-Agent` appended to the headers object and overriding provided agent strings. Also included is an update to not override the `Content-Length` if it was already defined in the options. It can be desirable to manually specify a content length that does not match the data on hand. Especially for testing. * Fix eslint error * fixup: update state UA logic Play nice with axios#3703 Co-authored-by: Jay <jasonsaayman@gmail.com>
redsky030511
added a commit
to redsky030511/axios-server
that referenced
this pull request
May 13, 2024
* Caseless header comparing in HTTP adapter. It was adding User-Agent and removing Authorization, but only when existing headers had the exact right casing. Node uses caseless logic when managing headers. This was causing some requests to have `User-Agent` appended to the headers object and overriding provided agent strings. Also included is an update to not override the `Content-Length` if it was already defined in the options. It can be desirable to manually specify a content length that does not match the data on hand. Especially for testing. * Fix eslint error * fixup: update state UA logic Play nice with axios/axios#3703 Co-authored-by: Jay <jasonsaayman@gmail.com>
Jupev6
added a commit
to Jupev6/axios
that referenced
this pull request
Aug 11, 2024
* Caseless header comparing in HTTP adapter. It was adding User-Agent and removing Authorization, but only when existing headers had the exact right casing. Node uses caseless logic when managing headers. This was causing some requests to have `User-Agent` appended to the headers object and overriding provided agent strings. Also included is an update to not override the `Content-Length` if it was already defined in the options. It can be desirable to manually specify a content length that does not match the data on hand. Especially for testing. * Fix eslint error * fixup: update state UA logic Play nice with axios/axios#3703 Co-authored-by: Jay <jasonsaayman@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3702.
Old behavior:
headers["User-Agent"]
(or"user-agent"
, not repeated hereafter) is falsy or absent, override with the Axios User-Agent stringheaders["User-Agent"]
is present and truthy, use itNew behavior:
headers["User-Agent"]
is absent, override with the Axios User-Agent stringheaders["User-Agent"]
is present and truthy, use itheaders["User-Agent"]
is present and falsy, omit the headerThis maintains the existing behavior for any reasonable usage, but enables explicit action to omit the UA header when desired.