11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { get, createServer } = require('http'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// res.writable should not be set to false after it has finished sending 81cb0ef41Sopenharmony_ci// Ref: https://github.com/nodejs/node/issues/15029 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cilet internal; 111cb0ef41Sopenharmony_cilet external; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// Proxy server 141cb0ef41Sopenharmony_ciconst server = createServer(common.mustCall((req, res) => { 151cb0ef41Sopenharmony_ci const listener = common.mustCall(() => { 161cb0ef41Sopenharmony_ci assert.strictEqual(res.writable, true); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci // on CentOS 5, 'finish' is emitted 201cb0ef41Sopenharmony_ci res.on('finish', listener); 211cb0ef41Sopenharmony_ci // Everywhere else, 'close' is emitted 221cb0ef41Sopenharmony_ci res.on('close', listener); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci get(`http://127.0.0.1:${internal.address().port}`, common.mustCall((inner) => { 251cb0ef41Sopenharmony_ci inner.pipe(res); 261cb0ef41Sopenharmony_ci })); 271cb0ef41Sopenharmony_ci})).listen(0, () => { 281cb0ef41Sopenharmony_ci // Http server 291cb0ef41Sopenharmony_ci internal = createServer((req, res) => { 301cb0ef41Sopenharmony_ci res.writeHead(200); 311cb0ef41Sopenharmony_ci setImmediate(common.mustCall(() => { 321cb0ef41Sopenharmony_ci external.abort(); 331cb0ef41Sopenharmony_ci res.end('Hello World\n'); 341cb0ef41Sopenharmony_ci })); 351cb0ef41Sopenharmony_ci }).listen(0, () => { 361cb0ef41Sopenharmony_ci external = get(`http://127.0.0.1:${server.address().port}`); 371cb0ef41Sopenharmony_ci external.on('error', common.mustCall(() => { 381cb0ef41Sopenharmony_ci server.close(); 391cb0ef41Sopenharmony_ci internal.close(); 401cb0ef41Sopenharmony_ci })); 411cb0ef41Sopenharmony_ci }); 421cb0ef41Sopenharmony_ci}); 43