mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00
http: do not emit end after aborted
IncomingMessage will no longer emit end after aborted. PR-URL: https://github.com/nodejs/node/pull/27984 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
4ca61f40fe
commit
5f80df8820
7 changed files with 44 additions and 11 deletions
|
@ -1,9 +1,13 @@
|
|||
// Flags: --expose-internals
|
||||
|
||||
'use strict';
|
||||
const { expectsError, mustCall } = require('../common');
|
||||
const assert = require('assert');
|
||||
const { createServer, maxHeaderSize } = require('http');
|
||||
const { createConnection } = require('net');
|
||||
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
const CRLF = '\r\n';
|
||||
const DUMMY_HEADER_NAME = 'Cookie: ';
|
||||
const DUMMY_HEADER_VALUE = 'a'.repeat(
|
||||
|
@ -17,11 +21,14 @@ const PAYLOAD = PAYLOAD_GET + CRLF +
|
|||
const server = createServer();
|
||||
|
||||
server.on('connection', mustCall((socket) => {
|
||||
// Legacy parser gives sligthly different response.
|
||||
// This discripancy is not fixed on purpose.
|
||||
const legacy = getOptionValue('--http-parser') === 'legacy';
|
||||
socket.on('error', expectsError({
|
||||
type: Error,
|
||||
message: 'Parse Error: Header overflow',
|
||||
code: 'HPE_HEADER_OVERFLOW',
|
||||
bytesParsed: maxHeaderSize + PAYLOAD_GET.length,
|
||||
bytesParsed: maxHeaderSize + PAYLOAD_GET.length - (legacy ? -1 : 0),
|
||||
rawPacket: Buffer.from(PAYLOAD)
|
||||
}));
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue