|
|
@ -1071,6 +1071,14 @@ ClientRequest.prototype.abort = function() { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function createHangUpError() { |
|
|
|
var error = new Error('socket hang up'); |
|
|
|
error.code = 'ECONNRESET'; |
|
|
|
return error; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ClientRequest.prototype.onSocket = function(socket) { |
|
|
|
var req = this; |
|
|
|
process.nextTick(function () { |
|
|
@ -1128,7 +1136,7 @@ ClientRequest.prototype.onSocket = function(socket) { |
|
|
|
if (!req.res) { |
|
|
|
// If we don't have a response then we know that the socket
|
|
|
|
// ended prematurely and we need to emit an error on the request.
|
|
|
|
req.emit('error', new Error("Request ended prematurely.")); |
|
|
|
req.emit('error', createHangUpError()); |
|
|
|
req._hadError = true; |
|
|
|
} |
|
|
|
parser.finish(); |
|
|
@ -1148,9 +1156,7 @@ ClientRequest.prototype.onSocket = function(socket) { |
|
|
|
// This socket error fired before we started to
|
|
|
|
// receive a response. The error needs to
|
|
|
|
// fire on the request.
|
|
|
|
var error = new Error('socket hang up'); |
|
|
|
error.code = 'ECONNRESET'; |
|
|
|
req.emit('error', error); |
|
|
|
req.emit('error', createHangUpError()); |
|
|
|
} |
|
|
|
} |
|
|
|
socket.on('close', closeListener); |
|
|
|