mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
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 <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
b0dd43cd63
commit
6c0da34905
3 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,12 @@ const server = http.createServer(common.mustCall(function(req, res) {
|
|||
}));
|
||||
|
||||
server.on('clientError', common.mustCall(function(err, socket) {
|
||||
assert.strictEqual(err instanceof Error, true);
|
||||
assert.strictEqual(err.code, 'HPE_INVALID_METHOD');
|
||||
assert.strictEqual(err.bytesParsed, 1);
|
||||
assert.strictEqual(err.message, 'Parse Error');
|
||||
assert.strictEqual(err.rawPacket.toString(), 'Oopsie-doopsie\r\n');
|
||||
|
||||
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
|
||||
|
||||
server.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue