@@ -373,8 +373,8 @@ function socketCloseListener() {
373
373
// This socket error fired before we started to
374
374
// receive a response. The error needs to
375
375
// fire on the request.
376
- req . emit ( 'error' , createHangUpError ( ) ) ;
377
376
req . socket . _hadError = true ;
377
+ req . emit ( 'error' , createHangUpError ( ) ) ;
378
378
}
379
379
380
380
// Too bad. That output wasn't getting written.
@@ -397,10 +397,10 @@ function socketErrorListener(err) {
397
397
debug ( 'SOCKET ERROR:' , err . message , err . stack ) ;
398
398
399
399
if ( req ) {
400
- req . emit ( 'error' , err ) ;
401
400
// For Safety. Some additional errors might fire later on
402
401
// and we need to make sure we don't double-fire the error event.
403
402
req . socket . _hadError = true ;
403
+ req . emit ( 'error' , err ) ;
404
404
}
405
405
406
406
// Handle any pending data
@@ -433,8 +433,8 @@ function socketOnEnd() {
433
433
if ( ! req . res && ! req . socket . _hadError ) {
434
434
// If we don't have a response then we know that the socket
435
435
// ended prematurely and we need to emit an error on the request.
436
- req . emit ( 'error' , createHangUpError ( ) ) ;
437
436
req . socket . _hadError = true ;
437
+ req . emit ( 'error' , createHangUpError ( ) ) ;
438
438
}
439
439
if ( parser ) {
440
440
parser . finish ( ) ;
@@ -455,8 +455,8 @@ function socketOnData(d) {
455
455
debug ( 'parse error' , ret ) ;
456
456
freeParser ( parser , req , socket ) ;
457
457
socket . destroy ( ) ;
458
- req . emit ( 'error' , ret ) ;
459
458
req . socket . _hadError = true ;
459
+ req . emit ( 'error' , ret ) ;
460
460
} else if ( parser . incoming && parser . incoming . upgrade ) {
461
461
// Upgrade or CONNECT
462
462
var bytesParsed = ret ;
0 commit comments