11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { finished } = require('stream'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst http = require('http'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst server = http.createServer(function(req, res) { 91cb0ef41Sopenharmony_ci let closed = false; 101cb0ef41Sopenharmony_ci res 111cb0ef41Sopenharmony_ci .on('close', common.mustCall(() => { 121cb0ef41Sopenharmony_ci closed = true; 131cb0ef41Sopenharmony_ci finished(res, common.mustCall(() => { 141cb0ef41Sopenharmony_ci server.close(); 151cb0ef41Sopenharmony_ci })); 161cb0ef41Sopenharmony_ci })) 171cb0ef41Sopenharmony_ci .end(); 181cb0ef41Sopenharmony_ci finished(res, common.mustCall(() => { 191cb0ef41Sopenharmony_ci assert.strictEqual(closed, true); 201cb0ef41Sopenharmony_ci })); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci}).listen(0, function() { 231cb0ef41Sopenharmony_ci http 241cb0ef41Sopenharmony_ci .request({ 251cb0ef41Sopenharmony_ci port: this.address().port, 261cb0ef41Sopenharmony_ci method: 'GET' 271cb0ef41Sopenharmony_ci }) 281cb0ef41Sopenharmony_ci .on('response', function(res) { 291cb0ef41Sopenharmony_ci res.resume(); 301cb0ef41Sopenharmony_ci }) 311cb0ef41Sopenharmony_ci .end(); 321cb0ef41Sopenharmony_ci}); 33