@@ -575,15 +575,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
575
575
} , milisecs ) ;
576
576
}
577
577
578
- // handle errors on the underlying socket, that may be closed while writing
579
- // for an example case, see test/long_string_spec.js. we make sure this
580
- // scenario ocurred by verifying the socket's writable & destroyed states.
581
- function on_socket_end ( ) {
582
- if ( returned && ! this . writable && this . destroyed === false ) {
583
- this . destroy ( ) ;
584
- had_error ( new Error ( 'Remote end closed socket abruptly.' ) )
585
- }
586
- }
587
578
588
579
debug ( 'Making request #' + count , request_opts ) ;
589
580
request = protocol . request ( request_opts , function ( resp ) {
@@ -833,7 +824,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
833
824
if ( timer ) clearTimeout ( timer ) ;
834
825
} )
835
826
836
- // handle socket 'end' event to ensure we don't get delayed EPIPE errors.
827
+ // set response timeout once we get a valid socket
837
828
request . once ( 'socket' , function ( socket ) {
838
829
if ( socket . connecting ) {
839
830
socket . once ( 'connect' , function ( ) {
@@ -842,15 +833,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
842
833
} else {
843
834
set_timeout ( 'response' , config . response_timeout ) ;
844
835
}
845
-
846
- // socket.once('close', function(e) {
847
- // console.log('socket closed!', e);
848
- // })
849
-
850
- if ( ! socket . on_socket_end ) {
851
- socket . on_socket_end = on_socket_end ;
852
- socket . once ( 'end' , function ( ) { process . nextTick ( on_socket_end . bind ( socket ) ) } ) ;
853
- }
854
836
} )
855
837
856
838
if ( post_data ) {
0 commit comments