mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
const file = path.join(common.tmpDir, 'http-pipe-fs-test.txt');
|
|
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
|
const stream = fs.createWriteStream(file);
|
|
req.pipe(stream);
|
|
stream.on('close', function() {
|
|
res.writeHead(200);
|
|
res.end();
|
|
});
|
|
}, 2)).listen(0, function() {
|
|
http.globalAgent.maxSockets = 1;
|
|
|
|
for (let i = 0; i < 2; ++i) {
|
|
(function(i) {
|
|
const req = http.request({
|
|
port: server.address().port,
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Length': 5
|
|
}
|
|
}, function(res) {
|
|
res.on('end', function() {
|
|
console.error('res' + i + ' end');
|
|
if (i === 2) {
|
|
server.close();
|
|
}
|
|
});
|
|
res.resume();
|
|
});
|
|
req.on('socket', function(s) {
|
|
console.error('req' + i + ' start');
|
|
});
|
|
req.end('12345');
|
|
}(i + 1));
|
|
}
|
|
});
|