From f82439b6a03c87ae48d16fee479db10eb3b4a3d1 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Thu, 14 Dec 2017 12:40:32 +0800 Subject: [PATCH] http: add rawPacket in err of `clientError` event The `rawPacket` is the current buffer that just parsed. Adding this buffer to the error object of `clientError` event is to make it possible that developers can log the broken packet. PR-URL: https://github.com/nodejs/node/pull/17672 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/http.md | 11 +++++++++++ lib/_http_server.js | 1 + test/parallel/test-http-server-client-error.js | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 9f06296e6e2584..928ed0d972b472 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -734,6 +734,11 @@ changes: description: The default action of calling `.destroy()` on the `socket` will no longer take place if there are listeners attached for `clientError`. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/17672 + description: The rawPacket is the current buffer that just parsed. Adding + this buffer to the error object of clientError event is to make + it possible that developers can log the broken packet. --> * `exception` {Error} @@ -765,6 +770,12 @@ 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 have parsed + correctly; ++ `rawPacket`: the raw packet of current request. + ### Event: 'close'