-
Notifications
You must be signed in to change notification settings - Fork 7.3k
HTTP parser fails if server returns no headers #1711
Comments
Responding from a server with
Is invalid HTTP. When the parser reaches the end of the HTTP/1.1 servers default to The relevant branch in http-parser is https://github.com/ry/http-parser/blob/c0ecab0516147401b5fd02a2272ebfb5dce8deb4/http_parser.c#L1564-1571 and here https://gist.github.com/8d854170ac16c39fdc74 is a test I was using to determine this. @mnot am I correct or should this be interpreted as a zero-length message? |
@ry I Thought that too, but reading this: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4 "Both types of message consist of a start-line, zero or more header fields (also known as "headers"), an empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields, and possibly a message-body" That made me think that headers are optional since it's worded as "zero or more". |
@davglass headers are indeed optional but you will need either a Transfer-Encoding or a Content-Length or a Connection: close in order to have a response with a body using HTTP/1.1. The response
is valid |
See: The relevant rule is the catch-all;
I.e., it's all body. |
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 point 5. camilo@imacsita:~> curl -vvvv http://localhost:8500
|
I've got the same problem. Receiving
Node.js:
|
hi everybody, regards |
is this still happening with nodejs 0.6.1, I haven't try it out. |
Confirmed. A HTTP/1.0 response body without headers works, a HTTP/0.9 response does not. |
HTTP/0.9 - fails with a parse error HTTP/1.0 - works HTTP/1.1 - fails with an empty response body See #1711.
(Failing) test added in 4f38c5e. |
HTTP/0.9 - fails with a parse error HTTP/1.0 - works HTTP/1.1 - fails with an empty response body See nodejs#1711.
HTTP/0.9 - fails with a parse error HTTP/1.0 - works HTTP/1.1 - fails with an empty response body See nodejs#1711.
Main fix was in 3abebf which added HTTP/0.9 support to http parser. Changed test because HTTP 1.1 mandates keep-alive when no headers are given. Fixes nodejs#1711
kindly guide me how can i parse header response using c++ |
I was doing some low-level scraping on a few of my devices (Cable Modem, X10 system, ADT alarm system) and noticed that all of these embedded devices return no headers in their http responses. It returns a status code, but no headers. With no headers being sent, the Node HTTP parser fails (silently in 0.4.11 and with a parse error in 0.5.x)
Here is a repro case:
https://gist.github.com/1217143
I couldn't find an entry in the spec that "required" headers to be sent from the server, but I feel that the parser shouldn't choke if no headers are returned, since curl/wget/links all work as expected.
The text was updated successfully, but these errors were encountered: