mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
http: refactor headersTimeout and requestTimeout logic
PR-URL: https://github.com/nodejs/node/pull/41263 Fixes: https://github.com/nodejs/node/issues/33440 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
1 parent
9d6af7d1fe
commit
3caa2c1a00
33 files changed
+858
-413
No files matched your search
@@ -32,10 +32,11 @@ function main({ len, n, c, duration }) {
|
||||
send(n);
|
||||
});
|
||||
|
||||
server.listen(common.PORT, () => {
|
||||
server.listen(0, () => {
|
||||
bench.http({
|
||||
connections: c,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -32,7 +32,6 @@ function main({ dur, len, type, method }) {
|
||||
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
|
||||
agent: new http.Agent({ maxSockets: 1 }),
|
||||
host: '127.0.0.1',
|
||||
port: common.PORT,
|
||||
path: '/',
|
||||
method: 'POST'
|
||||
};
|
||||
@@ -40,16 +39,17 @@ function main({ dur, len, type, method }) {
|
||||
const server = http.createServer((req, res) => {
|
||||
res.end();
|
||||
});
|
||||
server.listen(options.port, options.host, () => {
|
||||
server.listen(0, options.host, () => {
|
||||
setTimeout(done, dur * 1000);
|
||||
bench.start();
|
||||
pummel();
|
||||
pummel(server.address().port);
|
||||
});
|
||||
|
||||
function pummel() {
|
||||
function pummel(port) {
|
||||
options.port = port;
|
||||
const req = http.request(options, (res) => {
|
||||
nreqs++;
|
||||
pummel(); // Line up next request.
|
||||
pummel(port); // Line up next request.
|
||||
res.resume();
|
||||
});
|
||||
if (method === 'write') {
|
||||
|
||||
@@ -48,10 +48,11 @@ function main({ len, type, method, c, duration }) {
|
||||
fn(res);
|
||||
});
|
||||
|
||||
server.listen(common.PORT, () => {
|
||||
server.listen(0, () => {
|
||||
bench.http({
|
||||
connections: c,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -27,11 +27,12 @@ function main({ len, n, duration }) {
|
||||
res.writeHead(200, headers);
|
||||
res.end();
|
||||
});
|
||||
server.listen(common.PORT, () => {
|
||||
server.listen(0, () => {
|
||||
bench.http({
|
||||
path: '/',
|
||||
connections: 10,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ function main({ connections, headers, w, duration }) {
|
||||
res.end();
|
||||
});
|
||||
|
||||
server.listen(common.PORT, () => {
|
||||
server.listen(0, () => {
|
||||
const headers = {
|
||||
'Content-Type': 'text/plain',
|
||||
'Accept': 'text/plain',
|
||||
@@ -34,7 +34,8 @@ function main({ connections, headers, w, duration }) {
|
||||
path: '/',
|
||||
connections,
|
||||
headers,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const PORT = common.PORT;
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
res: ['normal', 'setHeader', 'setHeaderWH'],
|
||||
@@ -17,16 +16,16 @@ const c = 50;
|
||||
// setHeader: statusCode = status, setHeader(...) x2
|
||||
// setHeaderWH: setHeader(...), writeHead(status, ...)
|
||||
function main({ res, duration }) {
|
||||
process.env.PORT = PORT;
|
||||
const server = require('../fixtures/simple-http-server.js')
|
||||
.listen(PORT)
|
||||
.listen(0)
|
||||
.on('listening', () => {
|
||||
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
|
||||
|
||||
bench.http({
|
||||
path: path,
|
||||
connections: c,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -13,14 +13,15 @@ const bench = common.createBenchmark(main, {
|
||||
|
||||
function main({ type, len, chunks, c, chunkedEnc, duration }) {
|
||||
const server = require('../fixtures/simple-http-server.js')
|
||||
.listen(common.PORT)
|
||||
.listen(0)
|
||||
.on('listening', () => {
|
||||
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
||||
|
||||
bench.http({
|
||||
path,
|
||||
connections: c,
|
||||
duration
|
||||
duration,
|
||||
port: server.address().port,
|
||||
}, () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
|
||||
|
||||
function main({ n }) {
|
||||
const server = require('../fixtures/simple-http-server.js')
|
||||
.listen(common.PORT)
|
||||
.listen(0)
|
||||
.on('listening', () => {
|
||||
bench.start();
|
||||
doBench(server.address(), n, () => {
|
||||
|
||||
Reference in new issue
Block a user