test: reduce number of written chunks

Reduce chances of write errors while the request is sent.

Refs: https://github.com/nodejs/node/pull/56756
PR-URL: https://github.com/nodejs/node/pull/56757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
Luigi Pinca
2025-01-27 11:35:11 +01:00
committed by GitHub
parent 04f147b024
commit 50d405a2b6
6 changed files with 35 additions and 25 deletions

View File

@@ -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();
});
}));

View File

@@ -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(() => {

View File

@@ -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(() => {

View File

@@ -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();
});
}));

View File

@@ -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(() => {

View File

@@ -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(() => {