11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst http = require('http'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci{ 71cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall((req, res) => { 81cb0ef41Sopenharmony_ci assert.strictEqual(res.closed, false); 91cb0ef41Sopenharmony_ci req.pipe(res); 101cb0ef41Sopenharmony_ci res.on('error', common.mustNotCall()); 111cb0ef41Sopenharmony_ci res.on('close', common.mustCall(() => { 121cb0ef41Sopenharmony_ci assert.strictEqual(res.closed, true); 131cb0ef41Sopenharmony_ci res.end('asd'); 141cb0ef41Sopenharmony_ci process.nextTick(() => { 151cb0ef41Sopenharmony_ci server.close(); 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci })); 181cb0ef41Sopenharmony_ci })).listen(0, () => { 191cb0ef41Sopenharmony_ci http 201cb0ef41Sopenharmony_ci .request({ 211cb0ef41Sopenharmony_ci port: server.address().port, 221cb0ef41Sopenharmony_ci method: 'PUT' 231cb0ef41Sopenharmony_ci }) 241cb0ef41Sopenharmony_ci .on('response', (res) => { 251cb0ef41Sopenharmony_ci res.destroy(); 261cb0ef41Sopenharmony_ci }) 271cb0ef41Sopenharmony_ci .write('asd'); 281cb0ef41Sopenharmony_ci }); 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci{ 321cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall((req, res) => { 331cb0ef41Sopenharmony_ci assert.strictEqual(res.closed, false); 341cb0ef41Sopenharmony_ci req.pipe(res); 351cb0ef41Sopenharmony_ci res.on('error', common.mustNotCall()); 361cb0ef41Sopenharmony_ci res.on('close', common.mustCall(() => { 371cb0ef41Sopenharmony_ci assert.strictEqual(res.closed, true); 381cb0ef41Sopenharmony_ci process.nextTick(() => { 391cb0ef41Sopenharmony_ci server.close(); 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci const err = new Error('Destroy test'); 431cb0ef41Sopenharmony_ci res.destroy(err); 441cb0ef41Sopenharmony_ci assert.strictEqual(res.errored, err); 451cb0ef41Sopenharmony_ci })).listen(0, () => { 461cb0ef41Sopenharmony_ci http 471cb0ef41Sopenharmony_ci .request({ 481cb0ef41Sopenharmony_ci port: server.address().port, 491cb0ef41Sopenharmony_ci method: 'PUT' 501cb0ef41Sopenharmony_ci }) 511cb0ef41Sopenharmony_ci .on('error', common.mustCall()) 521cb0ef41Sopenharmony_ci .write('asd'); 531cb0ef41Sopenharmony_ci }); 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci} 56