11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst http = require('http'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall(function(req, res) { 91cb0ef41Sopenharmony_ci req.on('aborted', common.mustCall(function() { 101cb0ef41Sopenharmony_ci assert.strictEqual(this.aborted, true); 111cb0ef41Sopenharmony_ci })); 121cb0ef41Sopenharmony_ci req.on('error', common.mustCall(function(err) { 131cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'ECONNRESET'); 141cb0ef41Sopenharmony_ci assert.strictEqual(err.message, 'aborted'); 151cb0ef41Sopenharmony_ci server.close(); 161cb0ef41Sopenharmony_ci })); 171cb0ef41Sopenharmony_ci assert.strictEqual(req.aborted, false); 181cb0ef41Sopenharmony_ci res.write('hello'); 191cb0ef41Sopenharmony_ci })); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 221cb0ef41Sopenharmony_ci const req = http.get({ 231cb0ef41Sopenharmony_ci port: server.address().port, 241cb0ef41Sopenharmony_ci headers: { connection: 'keep-alive' } 251cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 261cb0ef41Sopenharmony_ci res.on('aborted', common.mustCall(() => { 271cb0ef41Sopenharmony_ci assert.strictEqual(res.aborted, true); 281cb0ef41Sopenharmony_ci })); 291cb0ef41Sopenharmony_ci res.on('error', common.expectsError({ 301cb0ef41Sopenharmony_ci code: 'ECONNRESET', 311cb0ef41Sopenharmony_ci message: 'aborted' 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci req.abort(); 341cb0ef41Sopenharmony_ci })); 351cb0ef41Sopenharmony_ci })); 361cb0ef41Sopenharmony_ci} 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci{ 391cb0ef41Sopenharmony_ci // Don't crash if no 'error' handler on server request. 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall(function(req, res) { 421cb0ef41Sopenharmony_ci req.on('aborted', common.mustCall(function() { 431cb0ef41Sopenharmony_ci assert.strictEqual(this.aborted, true); 441cb0ef41Sopenharmony_ci server.close(); 451cb0ef41Sopenharmony_ci })); 461cb0ef41Sopenharmony_ci assert.strictEqual(req.aborted, false); 471cb0ef41Sopenharmony_ci res.write('hello'); 481cb0ef41Sopenharmony_ci })); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 511cb0ef41Sopenharmony_ci const req = http.get({ 521cb0ef41Sopenharmony_ci port: server.address().port, 531cb0ef41Sopenharmony_ci headers: { connection: 'keep-alive' } 541cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 551cb0ef41Sopenharmony_ci res.on('aborted', common.mustCall(() => { 561cb0ef41Sopenharmony_ci assert.strictEqual(res.aborted, true); 571cb0ef41Sopenharmony_ci })); 581cb0ef41Sopenharmony_ci req.abort(); 591cb0ef41Sopenharmony_ci })); 601cb0ef41Sopenharmony_ci })); 611cb0ef41Sopenharmony_ci} 62