Skip to content

Commit

Permalink
test: reduce number of written chunks
Browse files Browse the repository at this point in the history
Reduce chances of write errors while the request is sent.

Refs: #56756
PR-URL: #56757
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Stefan Stojanovic <[email protected]>
  • Loading branch information
lpinca authored Jan 27, 2025
1 parent 04f147b commit 50d405a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ server.listen(0, common.mustCall(() => {

sendDelayedRequestHeaders = common.mustCall(() => {
setTimeout(() => {
client.write('POST / HTTP/1.1\r\n');
client.write('Content-Length: 20\r\n');
client.write('Connection: close\r\n\r\n');
client.write('12345678901234567890\r\n\r\n');
client.write(
'POST / HTTP/1.1\r\n' +
'Content-Length: 20\r\n' +
'Connection: close\r\n\r\n' +
'12345678901234567890\r\n\r\n'
);
}, common.platformTimeout(headersTimeout * 2)).unref();
});
}));
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ server.listen(0, common.mustCall(() => {
}));

client.resume();
client.write('GET / HTTP/1.1\r\n');
client.write('Connection: close\r\n');
client.write('X-CRASH: ');
client.write(
'GET / HTTP/1.1\r\n' +
'Connection: close\r\n' +
'X-CRASH: '
);

sendDelayedRequestHeaders = common.mustCall(() => {
setTimeout(() => {
Expand Down
11 changes: 6 additions & 5 deletions test/parallel/test-http-server-request-timeout-delayed-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ server.listen(0, common.mustCall(() => {
}));

client.resume();
client.write('POST / HTTP/1.1\r\n');
client.write('Host: example.com\r\n');
client.write('Content-Length: 20\r\n');
client.write('Connection: close\r\n');
client.write('\r\n');
client.write(
'POST / HTTP/1.1\r\n' +
'Host: example.com\r\n' +
'Content-Length: 20\r\n' +
'Connection: close\r\n\r\n'
);

sendDelayedRequestBody = common.mustCall(() => {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ server.listen(0, common.mustCall(() => {

sendDelayedRequestHeaders = common.mustCall(() => {
setTimeout(() => {
client.write('POST / HTTP/1.1\r\n');
client.write('Content-Length: 20\r\n');
client.write('Connection: close\r\n\r\n');
client.write('12345678901234567890\r\n\r\n');
client.write(
'POST / HTTP/1.1\r\n' +
'Content-Length: 20\r\n' +
'Connection: close\r\n\r\n' +
'12345678901234567890\r\n\r\n'
);
}, common.platformTimeout(requestTimeout * 2)).unref();
});
}));
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ server.listen(0, common.mustCall(() => {
}));

client.resume();
client.write('POST / HTTP/1.1\r\n');
client.write('Host: example.com\r\n');
client.write('Content-Length: 20\r\n');
client.write('Connection: close\r\n');
client.write('\r\n');
client.write('1234567890');
client.write(
'POST / HTTP/1.1\r\n' +
'Host: example.com\r\n' +
'Content-Length: 20\r\n' +
'Connection: close\r\n\r\n' +
'1234567890'
);

sendDelayedRequestBody = common.mustCall(() => {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ server.listen(0, common.mustCall(() => {
}));

client.resume();
client.write('GET / HTTP/1.1\r\n');
client.write('Connection: close\r\n');
client.write('X-CRASH: ');
client.write(
'GET / HTTP/1.1\r\n' +
'Connection: close\r\n' +
'X-CRASH: '
);

sendDelayedRequestHeaders = common.mustCall(() => {
setTimeout(() => {
Expand Down

0 comments on commit 50d405a

Please sign in to comment.