Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: deflake test-http-header-overflow #54978

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions test/parallel/test-http-header-overflow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Flags: --expose-internals

'use strict';
const { expectsError, mustCall } = require('../common');
const assert = require('assert');
Expand All @@ -10,11 +8,10 @@ const CRLF = '\r\n';
const DUMMY_HEADER_NAME = 'Cookie: ';
const DUMMY_HEADER_VALUE = 'a'.repeat(
// Plus one is to make it 1 byte too big
maxHeaderSize - DUMMY_HEADER_NAME.length + 2
maxHeaderSize - DUMMY_HEADER_NAME.length + 1
);
const PAYLOAD_GET = 'GET /blah HTTP/1.1';
const PAYLOAD = PAYLOAD_GET + CRLF +
DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE + CRLF.repeat(2);
const PAYLOAD = PAYLOAD_GET + CRLF + DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE;

const server = createServer();

Expand All @@ -23,18 +20,19 @@ server.on('connection', mustCall((socket) => {
name: 'Error',
message: 'Parse Error: Header overflow',
code: 'HPE_HEADER_OVERFLOW',
bytesParsed: maxHeaderSize + PAYLOAD_GET.length + (CRLF.length * 2) + 1,
bytesParsed: PAYLOAD.length,
rawPacket: Buffer.from(PAYLOAD)
}));

// The data is not sent from the client to ensure that it is received as a
// single chunk.
socket.push(PAYLOAD);
}));

server.listen(0, mustCall(() => {
const c = createConnection(server.address().port);
let received = '';

c.on('connect', mustCall(() => {
c.write(PAYLOAD);
}));
c.on('data', mustCall((data) => {
received += data.toString();
}));
Expand Down
Loading