11cb0ef41Sopenharmony_ciimport { skipIfInspectorDisabled, mustCall } from '../common/index.mjs'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciskipIfInspectorDisabled(); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciimport startCLI from '../common/debugger.js'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciimport assert from 'assert'; 81cb0ef41Sopenharmony_ciimport http from 'http'; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst host = '127.0.0.1'; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci{ 131cb0ef41Sopenharmony_ci const server = http.createServer((req, res) => { 141cb0ef41Sopenharmony_ci res.statusCode = 400; 151cb0ef41Sopenharmony_ci res.end('Bad Request'); 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci server.listen(0, mustCall(async () => { 191cb0ef41Sopenharmony_ci const port = server.address().port; 201cb0ef41Sopenharmony_ci const cli = startCLI([`${host}:${port}`]); 211cb0ef41Sopenharmony_ci try { 221cb0ef41Sopenharmony_ci const code = await cli.quit(); 231cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 241cb0ef41Sopenharmony_ci } finally { 251cb0ef41Sopenharmony_ci server.close(); 261cb0ef41Sopenharmony_ci } 271cb0ef41Sopenharmony_ci })); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci{ 311cb0ef41Sopenharmony_ci const server = http.createServer((req, res) => { 321cb0ef41Sopenharmony_ci res.statusCode = 200; 331cb0ef41Sopenharmony_ci res.end('some data that is invalid json'); 341cb0ef41Sopenharmony_ci }); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci server.listen(0, host, mustCall(async () => { 371cb0ef41Sopenharmony_ci const port = server.address().port; 381cb0ef41Sopenharmony_ci const cli = startCLI([`${host}:${port}`]); 391cb0ef41Sopenharmony_ci try { 401cb0ef41Sopenharmony_ci const code = await cli.quit(); 411cb0ef41Sopenharmony_ci assert.strictEqual(code, 1); 421cb0ef41Sopenharmony_ci } finally { 431cb0ef41Sopenharmony_ci server.close(); 441cb0ef41Sopenharmony_ci } 451cb0ef41Sopenharmony_ci })); 461cb0ef41Sopenharmony_ci} 47