Skip to content

Commit 96e8ae6

Browse files
committed
http: make test more resilient
1 parent b7c9b5d commit 96e8ae6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/parallel/test-http-server-multiple-client-error.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ const httpServer = http.createServer(common.mustNotCall());
2828

2929
httpServer.once('clientError', common.mustCall((err, socket) => {
3030
assert.strictEqual(err.code, 'HPE_INVALID_METHOD');
31-
assert.strictEqual(err.rawPacket.toString(), 'Q');
31+
assert.strictEqual(err.rawPacket.toString(), '1');
3232
socket.destroy();
3333

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

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

5054
socket.on('close', () => {

0 commit comments

Comments
 (0)