mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
ed3604cd64
PR-URL: https://github.com/nodejs/node/pull/45597 Fixes: https://github.com/nodejs/node/issues/39033 Co-authored-by: Luigi Pinca <luigipinca@gmail.com> Co-authored-by: mscdex <mscdex@users.noreply.github.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
36 lines
946 B
JavaScript
36 lines
946 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const net = require('net');
|
|
const assert = require('assert');
|
|
|
|
function request(socket) {
|
|
socket.write('GET / HTTP/1.1\r\n');
|
|
socket.write('Connection: keep-alive\r\n');
|
|
socket.write('Host: localhost\r\n');
|
|
socket.write('\r\n\r\n');
|
|
}
|
|
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
res.end('ok');
|
|
}));
|
|
|
|
server.on('dropRequest', common.mustCall((request, socket) => {
|
|
assert.strictEqual(request instanceof http.IncomingMessage, true);
|
|
assert.strictEqual(socket instanceof net.Socket, true);
|
|
server.close();
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const socket = net.connect(server.address().port);
|
|
socket.on('connect', common.mustCall(() => {
|
|
request(socket);
|
|
request(socket);
|
|
}));
|
|
socket.on('data', common.mustCallAtLeast());
|
|
socket.on('close', common.mustCall());
|
|
}));
|
|
|
|
server.maxRequestsPerSocket = 1;
|