Take a look at the NPM module http-parser-js [1], it's a drop-in 
replacement for the native http parser bindings.  As well as being pure JS 
and having better performance in some circumstances, it's also more lenient 
(I've used it to deal with a very similar situation of a server returning a 
header with no name).  I'm not completely sure it will handle your exact 
use case, but updating it so that it does should be easy and we'd take the 
PR.  If it doesn't just work, it's easy to add a new test with your raw 
response [2], and once it's reproduced it's easy to fix ;).

[1] https://www.npmjs.com/package/http-parser-js
[2] 
https://github.com/creationix/http-parser-js/commit/0d56e191ea2fc46231393657168ccd5901ec339c

On Tuesday, December 8, 2015 at 4:58:46 PM UTC-8, Rob Wilkerson wrote:
>
> I have a situation where I have some code running locally that has to 
> communicate with another device on the same network. To do so, I'm making a 
> straight http request to http://192.168.0.1, a request that returns a 
> bunch of data in the response body. The problem I'm having is that the 
> device itself returns invalid headers:
>
> $ 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
>
> Note the duplicate "HTTP/1.0 200 OK" header. Other tools (e.g. Chrome, 
> curl, python) that I've tried at least handle the bad headers "gracefully", 
> but node simply dies with a HPE_INVALID_HEADER_TOKEN error. It's not 
> incorrect, of course, but I need a workaround. My code will be installed on 
> hundreds of thousands of desktops talking to hundreds of thousands of these 
> devices. We simply can't update all of the devices to fix the headers.
>
> All I care about is the response body. Is there any way to get node to be 
> more lenient and ignore the bad header? Do I have any options here?
>
> Any thoughts would be much appreciated. I'm completely stuck here.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/fedaba34-9610-43ba-9a8f-05d79de82635%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to