mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
239ebf0244
Move test-http-server-keep-alive-timeout-slow-server and test-http-server-keep-alive-timeout-slow-client-headers from parallel to sequential to resolve test flakiness on freebsd10-64. Fixes: https://github.com/nodejs/node/issues/14033 Refs: https://github.com/nodejs/node/pull/9317 PR-URL: https://github.com/nodejs/node/pull/14377 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustCall((req, res) => {
|
|
if (req.url === '/first') {
|
|
res.end('ok');
|
|
return;
|
|
}
|
|
setTimeout(() => {
|
|
res.end('ok');
|
|
}, common.platformTimeout(500));
|
|
}, 2));
|
|
|
|
server.keepAliveTimeout = common.platformTimeout(200);
|
|
|
|
const agent = new http.Agent({
|
|
keepAlive: true,
|
|
maxSockets: 1
|
|
});
|
|
|
|
function request(path, callback) {
|
|
const port = server.address().port;
|
|
const req = http.request({ agent, path, port }, common.mustCall((res) => {
|
|
assert.strictEqual(res.statusCode, 200);
|
|
|
|
res.setEncoding('utf8');
|
|
|
|
let result = '';
|
|
res.on('data', (chunk) => {
|
|
result += chunk;
|
|
});
|
|
|
|
res.on('end', common.mustCall(() => {
|
|
assert.strictEqual(result, 'ok');
|
|
callback();
|
|
}));
|
|
}));
|
|
req.end();
|
|
}
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
request('/first', () => {
|
|
request('/second', () => {
|
|
server.close();
|
|
});
|
|
});
|
|
}));
|