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

fix(Accept): Normalize accept header in request config #1698

merged 1 commit into from Aug 7, 2018


Copy link

commented Jul 25, 2018

Overriding the accept header is case sensitive wrt the defaults object.


axios.get('/foo', {
	headers: { accept: 'text/html' }

Expected behavior:

GET /foo HTTP/1.1
Accept: text/html

Actual behavior:

GET /foo HTTP/1.1
Accept: application/json, text/plain, */*, text/html


axios.get('/foo', {
	headers: { Accept: 'text/html' }

Works as expected.


Normalize the header before merging into the final headers object, just like we do for Content-Type.

Fixing accept header normalization
Fixes override behavior for `accept` header, when case does not match
the one used in defaults.js

@wejendorp wejendorp force-pushed the wejendorp:patch-1 branch from c5c9db9 to 4a8ec5b Jul 25, 2018


This comment has been minimized.

Copy link

commented Aug 7, 2018

Good catch, thanks!

This could be more efficient since we're now iterating over all headers twice in order to handle both 'Content-Type' and 'Accept', but I'm okay with it since it shouldn't be a noticeable performance difference.

@emilyemorehouse emilyemorehouse merged commit b4c5d35 into axios:master Aug 7, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.