-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
With HTTP/1.1, if neither Content-Length nor Transfer-Encoding is present, section 4.4 of RFC 2616 suggests http-parser needs to read a response body until the connection is closed (except the response must not include a body) See also nodejs/node-v0.x-archive#2457. Fixes #72
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1733,9 +1733,20 @@ http_should_keep_alive (http_parser *parser) | |
/* HTTP/1.1 */ | ||
if (parser->flags & F_CONNECTION_CLOSE) { | ||
return 0; | ||
} else { | ||
return 1; | ||
} | ||
if (parser->type == HTTP_RESPONSE) { | ||
/* See RFC 2616 section 4.4 */ | ||
if (parser->status_code / 100 == 1 || /* 1xx e.g. Continue */ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
koichik
Author
Contributor
|
||
parser->status_code == 204 || /* No Content */ | ||
parser->status_code == 304 || /* Not Modified */ | ||
parser->flags & F_SKIPBODY) { /* response to a HEAD request */ | ||
return 1; | ||
} | ||
if (!(parser->flags & F_CHUNKED) && parser->content_length == -1) { | ||
return 0; | ||
} | ||
} | ||
return 1; | ||
} else { | ||
/* HTTP/1.0 or earlier */ | ||
if (parser->flags & F_CONNECTION_KEEP_ALIVE) { | ||
|
I believe we need to be doing this status code check for HTTP/1.0 as well.