Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 341b6d9

Browse filesBrowse files
lpincatargos
authored andcommitted
test: deflake test-http-header-overflow
Skip the network and push the data directly to the receiving socket so that it is guaranteed to be received as a single chunk. Fixes: #46291 PR-URL: #54978 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a929c71 commit 341b6d9
Copy full SHA for 341b6d9

File tree

Expand file treeCollapse file tree

1 file changed

+7
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-9
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-header-overflow.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-header-overflow.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Flags: --expose-internals
2-
31
'use strict';
42
const { expectsError, mustCall } = require('../common');
53
const assert = require('assert');
@@ -10,11 +8,10 @@ const CRLF = '\r\n';
108
const DUMMY_HEADER_NAME = 'Cookie: ';
119
const DUMMY_HEADER_VALUE = 'a'.repeat(
1210
// Plus one is to make it 1 byte too big
13-
maxHeaderSize - DUMMY_HEADER_NAME.length + 2
11+
maxHeaderSize - DUMMY_HEADER_NAME.length + 1
1412
);
1513
const PAYLOAD_GET = 'GET /blah HTTP/1.1';
16-
const PAYLOAD = PAYLOAD_GET + CRLF +
17-
DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE + CRLF.repeat(2);
14+
const PAYLOAD = PAYLOAD_GET + CRLF + DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE;
1815

1916
const server = createServer();
2017

@@ -23,18 +20,19 @@ server.on('connection', mustCall((socket) => {
2320
name: 'Error',
2421
message: 'Parse Error: Header overflow',
2522
code: 'HPE_HEADER_OVERFLOW',
26-
bytesParsed: maxHeaderSize + PAYLOAD_GET.length + (CRLF.length * 2) + 1,
23+
bytesParsed: PAYLOAD.length,
2724
rawPacket: Buffer.from(PAYLOAD)
2825
}));
26+
27+
// The data is not sent from the client to ensure that it is received as a
28+
// single chunk.
29+
socket.push(PAYLOAD);
2930
}));
3031

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

35-
c.on('connect', mustCall(() => {
36-
c.write(PAYLOAD);
37-
}));
3836
c.on('data', mustCall((data) => {
3937
received += data.toString();
4038
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.