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

Axios doesn't see the User-agent header #3844

Closed
Viiprogrammer opened this issue Jun 19, 2021 · 5 comments
Closed

Axios doesn't see the User-agent header #3844

Viiprogrammer opened this issue Jun 19, 2021 · 5 comments

Comments

@Viiprogrammer
Copy link

Describe the bug

Axios doesn't see the User-agent header

To Reproduce

const axios = require('axios');

axios.get('https://postman-echo.com/get', {
	headers: {
		'User-agent': 'USER'
	},
})
.then(function (response) {
	console.log(response.data.headers['user-agent']); //Returns - axios/0.21.1
})
const axios = require('axios');

axios.get('https://postman-echo.com/get', {
	headers: {
		'User-Agent': 'USER'
	},
})
.then(function (response) {
	console.log(response.data.headers['user-agent']); //Returns - USER
})
const axios = require('axios');

axios.get('https://postman-echo.com/get', {
	headers: {
		'user-agent': 'USER'
	},
})
.then(function (response) {
	console.log(response.data.headers['user-agent']); //Returns - USER
})

Expected behavior

axios.get('https://postman-echo.com/get', {
	headers: {
		'User-agent': 'USER'
	},
})
.then(function (response) {
	console.log(response.data.headers['user-agent']); //Returns - USER
})

Environment

  • Axios Version [0.21.1]
  • Adapter [none]
  • Browser [none]
  • Browser Version [none]
  • Node.js Version [v15.12.0]
  • OS: [Windows 7]
  • Additional Library Versions [none]

Additional context/Screenshots

None

@lichader
Copy link

lichader commented Jun 23, 2021

@Viiprogrammer
Based on this line, I think you can only use User-Agent or user-agent.

@Viiprogrammer
Copy link
Author

@lichader

If you read https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers, then the title of the headers should not be case-sensitive.

The axios documentation does not specify that the headers are case sensitive.

@lichader
Copy link

lichader commented Jul 9, 2021

Yes. I was just stating the current behaviour, which doesn't mean I think this behaviour is correct. HTTP headers should be case insensitive.

@ranjan-purbey
Copy link

Fixed by #2880

@jasonsaayman
Copy link
Member

Closed see above

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 a pull request may close this issue.

4 participants