Skip to content

Commit

Permalink
test: make sure http pipelining does not emit a warning
Browse files Browse the repository at this point in the history
See: #37937
  • Loading branch information
mcollina committed Mar 29, 2021
1 parent 330e6de commit 88eca31
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/parallel/test-http-pipelining-no-leak.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

const common = require('../common');

// This test ensures Node.js doesn't not emit any warning when receiving
// pipelined requests
// https://github.com/nodejs/node/issues/37937

const http = require('http');
const net = require('net');

const COUNT = 1e4;

let client;
const server = http
.createServer(function(req, res) {
setTimeout(function() {
req.resume();
res.end();
}, common.platformTimeout(100));
})
.listen(0, function() {
const req = [
'GET / HTTP/1.1',
`Host: localhost:${server.address().port}`,
'Connection: keep-alive'
].join('\r\n') + '\r\n\r\n';

client = net.connect(this.address().port, function() {
next();
});
client.resume();

client.on('drain', next);

let i = 0;
function next() {
if (i++ === COUNT + 10) {
client.destroy();
server.close();
return;
}
if (client.write(req, 'ascii')) {
setImmediate(next);
}
}
});

process.on('warning', common.mustNotCall());

0 comments on commit 88eca31

Please sign in to comment.