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

"The header content contains invalid characters" exception being thrown #296

Closed
siboulet opened this issue Apr 15, 2016 · 2 comments
Closed

Comments

@siboulet
Copy link

Hi,

I started having "The header content contains invalid characters" exception being thrown. When doing an OAuth request, the error callback is being called with the error, but also an exception is being thrown.

TypeError: The header content contains invalid characters
at ClientRequest.OutgoingMessage.setHeader (_http_outgoing.js:351:13)
at new ClientRequest (_http_client.js:79:14)
at Object.exports.request (http.js:31:10)
at exports.OAuth2._executeRequest (/app/node_modules/oauth/lib/oauth2.js:132:30)
at exports.OAuth2._request (/app/node_modules/oauth/lib/oauth2.js:111:8)
at exports.OAuth2.get (/app/node_modules/oauth/lib/oauth2.js:213:8)
...

I think it might be related to some recent changes in Node.JS HTTP module being more strict about HTTP headers.

This is probably due to remote end having some invalid headers, but it's not very convenient to have the exception thrown and the error should probably be handled in the callback.

I think we need to wrap the request call in try/catch block here: https://github.com/ciaranj/node-oauth/blob/master/lib/oauth2.js#L132

Similar to request/request#2164

Node.Js 4.4.0
node-oauth 0.9.14

@siboulet
Copy link
Author

After further investigation it turned out access_token was undefined in my oauth.get() call, which caused the exception to be thrown. Properly passing access_token and the exception goes away.

@sebilasse
Copy link

@siboulet How about closing this issue?
You should be able to do it yourself because you are the author ...

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

No branches or pull requests

2 participants