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

how to avoid sending user-agent header? #1479

Closed
oprogramador opened this issue Apr 22, 2019 · 4 comments · Fixed by #1495
Closed

how to avoid sending user-agent header? #1479

oprogramador opened this issue Apr 22, 2019 · 4 comments · Fixed by #1495

Comments

@oprogramador
Copy link
Contributor

In unirest, when I don't specify user-agent header, it's just not sent. However superagent sends node-superagent/5.0.2.

.set('user-agent', undefined) fails with TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "user-agent"

.set('user-agent', '') sends { 'user-agent': '' }

.set('user-agent', null) sends { 'user-agent': 'null' }

@apoorv-mishra
Copy link
Contributor

@niftylettuce Not familiar with codebase much, but after digging a bit, it seems like user-agent is set here and here(for redirects). Do you suggest we remove those calls to resolve this issue?

@niftylettuce
Copy link
Collaborator

Yes, I am completely OK with removing the user-agent added altogether.

Please submit a PR

@falkenhawk
Copy link

.unset('User-Agent') would have worked

@natanavra
Copy link

This should be in the docs so users know they must explicitly set a User Agent as some CDNs block requests without it

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.

5 participants