11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_cifunction request(server) {
71cb0ef41Sopenharmony_ci  http.get({
81cb0ef41Sopenharmony_ci    port: server.address().port,
91cb0ef41Sopenharmony_ci    path: '/',
101cb0ef41Sopenharmony_ci  }, (res) => {
111cb0ef41Sopenharmony_ci    res.resume();
121cb0ef41Sopenharmony_ci  });
131cb0ef41Sopenharmony_ci}
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci{
161cb0ef41Sopenharmony_ci  const server = http.createServer((req, res) => {
171cb0ef41Sopenharmony_ci    //  Hack to not remove parser out of server.connectionList
181cb0ef41Sopenharmony_ci    //  See `freeParser` in _http_common.js
191cb0ef41Sopenharmony_ci    req.socket.parser.free = common.mustCall();
201cb0ef41Sopenharmony_ci    req.socket.on('close', common.mustCall(() => {
211cb0ef41Sopenharmony_ci      server.close();
221cb0ef41Sopenharmony_ci    }));
231cb0ef41Sopenharmony_ci    res.end('ok');
241cb0ef41Sopenharmony_ci  }).listen(0, common.mustCall(() => {
251cb0ef41Sopenharmony_ci    request(server);
261cb0ef41Sopenharmony_ci  }));
271cb0ef41Sopenharmony_ci}
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci{
301cb0ef41Sopenharmony_ci  const server = http.createServer((req, res) => {
311cb0ef41Sopenharmony_ci    // See `freeParser` in _http_common.js
321cb0ef41Sopenharmony_ci    const { parser } = req.socket;
331cb0ef41Sopenharmony_ci    parser.free = common.mustCall(() => {
341cb0ef41Sopenharmony_ci      setImmediate(common.mustCall(() => {
351cb0ef41Sopenharmony_ci        parser.close();
361cb0ef41Sopenharmony_ci      }));
371cb0ef41Sopenharmony_ci    });
381cb0ef41Sopenharmony_ci    req.socket.on('close', common.mustCall(() => {
391cb0ef41Sopenharmony_ci      setImmediate(common.mustCall(() => {
401cb0ef41Sopenharmony_ci        server.close();
411cb0ef41Sopenharmony_ci      }));
421cb0ef41Sopenharmony_ci    }));
431cb0ef41Sopenharmony_ci    res.end('ok');
441cb0ef41Sopenharmony_ci  }).listen(0, common.mustCall(() => {
451cb0ef41Sopenharmony_ci    request(server);
461cb0ef41Sopenharmony_ci  }));
471cb0ef41Sopenharmony_ci}
48