11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst common = require('../common'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst { fork } = require('child_process'); 81cb0ef41Sopenharmony_ciconst http = require('http'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') { 111cb0ef41Sopenharmony_ci process.once('message', (req, socket) => { 121cb0ef41Sopenharmony_ci const res = new http.ServerResponse(req); 131cb0ef41Sopenharmony_ci res.assignSocket(socket); 141cb0ef41Sopenharmony_ci res.end(); 151cb0ef41Sopenharmony_ci }); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci process.send('ready'); 181cb0ef41Sopenharmony_ci return; 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst { kTimeout } = require('internal/timers'); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_cilet child; 241cb0ef41Sopenharmony_cilet socket; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => { 271cb0ef41Sopenharmony_ci const r = { 281cb0ef41Sopenharmony_ci method: req.method, 291cb0ef41Sopenharmony_ci headers: req.headers, 301cb0ef41Sopenharmony_ci path: req.path, 311cb0ef41Sopenharmony_ci httpVersionMajor: req.httpVersionMajor, 321cb0ef41Sopenharmony_ci query: req.query, 331cb0ef41Sopenharmony_ci }; 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci socket = res.socket; 361cb0ef41Sopenharmony_ci child.send(r, socket); 371cb0ef41Sopenharmony_ci server.close(); 381cb0ef41Sopenharmony_ci})); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 411cb0ef41Sopenharmony_ci child = fork(__filename, [ 'child' ]); 421cb0ef41Sopenharmony_ci child.once('message', (msg) => { 431cb0ef41Sopenharmony_ci assert.strictEqual(msg, 'ready'); 441cb0ef41Sopenharmony_ci const req = http.request({ 451cb0ef41Sopenharmony_ci port: server.address().port, 461cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 471cb0ef41Sopenharmony_ci res.on('data', () => {}); 481cb0ef41Sopenharmony_ci res.on('end', common.mustCall(() => { 491cb0ef41Sopenharmony_ci assert.strictEqual(socket[kTimeout], null); 501cb0ef41Sopenharmony_ci assert.strictEqual(socket.parser, null); 511cb0ef41Sopenharmony_ci assert.strictEqual(socket._httpMessage, null); 521cb0ef41Sopenharmony_ci })); 531cb0ef41Sopenharmony_ci })); 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci req.end(); 561cb0ef41Sopenharmony_ci }); 571cb0ef41Sopenharmony_ci})); 58