Skip to content

Commit

Permalink
update after addaleax' review
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Dec 15, 2017
1 parent e9eb792 commit 5e1369f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ object, so any HTTP response sent, including response headers and payload,
*must* be written directly to the `socket` object. Care must be taken to
ensure the response is a properly formatted HTTP response message.

> `err` is an instance of `Error` with two extra columns:
>
> + `bytesParsed`: the bytes count of request packet that Node.js may parse correctly;
> + `rawPacket`: the raw packet of current request.
`err` is an instance of `Error` with two extra columns:

+ `bytesParsed`: the bytes count of request packet that Node.js may have parsed correctly;
+ `rawPacket`: the raw packet of current request.

### Event: 'close'
<!-- YAML
Expand Down
8 changes: 4 additions & 4 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,11 @@ function socketOnError(e) {
function onParserExecuteCommon(server, socket, parser, state, ret, d) {
resetSocketTimeout(server, socket, state);

if (!d)
d = parser.getCurrentBuffer();

if (ret instanceof Error) {
ret.rawPacket = d || parser.getCurrentBuffer();
ret.rawPacket = d;
debug('parse error', ret);
socketOnError.call(socket, ret);
} else if (parser.incoming && parser.incoming.upgrade) {
Expand All @@ -485,9 +488,6 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) {
var req = parser.incoming;
debug('SERVER upgrade or connect', req.method);

if (!d)
d = parser.getCurrentBuffer();

socket.removeListener('data', state.onData);
socket.removeListener('end', state.onEnd);
socket.removeListener('close', state.onClose);
Expand Down

0 comments on commit 5e1369f

Please sign in to comment.