mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
7 years ago
|
'use strict';
|
||
|
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const { get, createServer } = require('http');
|
||
|
|
||
|
// res.writable should not be set to false after it has finished sending
|
||
|
// Ref: https://github.com/nodejs/node/issues/15029
|
||
|
|
||
7 years ago
|
let internal;
|
||
7 years ago
|
let external;
|
||
|
|
||
|
// Proxy server
|
||
|
const server = createServer(common.mustCall((req, res) => {
|
||
|
get(`http://127.0.0.1:${internal.address().port}`, common.mustCall((inner) => {
|
||
7 years ago
|
const listener = common.mustCall(() => {
|
||
7 years ago
|
assert.strictEqual(res.writable, true);
|
||
7 years ago
|
});
|
||
|
|
||
|
// on CentOS 5, 'finish' is emitted
|
||
|
res.on('finish', listener);
|
||
|
// everywhere else, 'close' is emitted
|
||
|
res.on('close', listener);
|
||
|
|
||
7 years ago
|
inner.pipe(res);
|
||
|
}));
|
||
|
})).listen(0, () => {
|
||
7 years ago
|
// Http server
|
||
|
internal = createServer((req, res) => {
|
||
|
res.writeHead(200);
|
||
|
setImmediate(common.mustCall(() => {
|
||
|
external.abort();
|
||
|
res.end('Hello World\n');
|
||
|
}));
|
||
|
}).listen(0, () => {
|
||
|
external = get(`http://127.0.0.1:${server.address().port}`);
|
||
|
external.on('error', common.mustCall((err) => {
|
||
|
server.close();
|
||
|
internal.close();
|
||
|
}));
|
||
|
});
|
||
7 years ago
|
});
|