Skip to content

Commit

Permalink
http: make test more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
ShogunPanda committed Feb 13, 2024
1 parent b7c9b5d commit 96e8ae6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/parallel/test-http-server-multiple-client-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ const httpServer = http.createServer(common.mustNotCall());

httpServer.once('clientError', common.mustCall((err, socket) => {
assert.strictEqual(err.code, 'HPE_INVALID_METHOD');
assert.strictEqual(err.rawPacket.toString(), 'Q');
assert.strictEqual(err.rawPacket.toString(), '1');
socket.destroy();

httpServer.once('clientError', common.mustCall((err) => {
assert.strictEqual(err.code, 'HPE_INVALID_METHOD');
assert.strictEqual(
err.rawPacket.toString(),
'WE http://example.com HTTP/1.1\r\n\r\n'
'23 http://example.com HTTP/1.1\r\n\r\n'
);
}));
}));
Expand All @@ -44,7 +44,11 @@ netServer.listen(0, common.mustCall(() => {
const socket = net.createConnection(netServer.address().port);

socket.on('connect', common.mustCall(() => {
socket.end('QWE http://example.com HTTP/1.1\r\n\r\n');
// Note: do not use letters here for the method.
// There is a very small chance that a method with that initial
// might be added in the future and thus this test might fail.
// Numbers will likely never have this issue.
socket.end('123 http://example.com HTTP/1.1\r\n\r\n');
}));

socket.on('close', () => {
Expand Down

0 comments on commit 96e8ae6

Please sign in to comment.