0

I'm not the first to ask this question and I understand that Node might be pretty strict about the headers it's sent, but my eye doesn't see anything outlandish in the response headers so I'm hoping for an explanation, if not a fix.

I have Node making a GET request to a very specific, internal resource. I've tried making this request via request-promise, request and the standard http library (just to be thorough). The request works perfectly fine via curl or when loaded in a browser. My node request fails with the HPE_INVALID_HEADER_TOKEN error.

$ curl -IS 'http://192.168.0.1/getdeviceinfo/info.bin'
HTTP/1.1 200 OK
Date: Wed, 02 Dec 2015 16:42:45 GMT
Server: nostradamus 1.9.5
Connection: close
Etag: Aug 28 2015, 07:57:20
Transfer-Encoding: chunked
HTTP/1.0 200 OK
Content-Type: text/html

I know you won't be able to access that URL, but does anyone see anything in those headers on which you'd expect a Node request to choke? I have no control over the headers, but it would at least be nice to know which one is causing the hassle.

1 Answer 1

1

The HTTP/1.0 200 OK before the Content-Type should not be in the headers like that, that is why node is complaining. The server is sending a malformed response.

Sign up to request clarification or add additional context in comments.

3 Comments

Damn. Yeah, I see it now. Within the node context, do I have any options for working around this to ultimately access the body of the request? The responding server is actually a device to which the requestor is connected and there are millions in the wild. Rolling out header updates is a difficult proposition...at best.
I had a very similar issue to this. The source website was sending a Link header with HTML inside which was crashing Node. To get around it I wrote a separate script which cURLed the data I needed then called that from my Node scripts
Do you have any more details you could share on this? I don't even know where to go to learn how to recognize malformed headers. I also have access to the server I'm getting this issue on but don't understand what needs to be fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.