|
@ -182,12 +182,12 @@ function socketCloseListener() { |
|
|
res.emit('close'); |
|
|
res.emit('close'); |
|
|
}); |
|
|
}); |
|
|
res.push(null); |
|
|
res.push(null); |
|
|
} else if (!req.res && !req._hadError) { |
|
|
} else if (!req.res && !req.socket._hadError) { |
|
|
// This socket error fired before we started to
|
|
|
// This socket error fired before we started to
|
|
|
// receive a response. The error needs to
|
|
|
// receive a response. The error needs to
|
|
|
// fire on the request.
|
|
|
// fire on the request.
|
|
|
req.emit('error', createHangUpError()); |
|
|
req.emit('error', createHangUpError()); |
|
|
req._hadError = true; |
|
|
req.socket._hadError = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Too bad. That output wasn't getting written.
|
|
|
// Too bad. That output wasn't getting written.
|
|
@ -214,7 +214,7 @@ function socketErrorListener(err) { |
|
|
req.emit('error', err); |
|
|
req.emit('error', err); |
|
|
// For Safety. Some additional errors might fire later on
|
|
|
// For Safety. Some additional errors might fire later on
|
|
|
// and we need to make sure we don't double-fire the error event.
|
|
|
// and we need to make sure we don't double-fire the error event.
|
|
|
req._hadError = true; |
|
|
req.socket._hadError = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (parser) { |
|
|
if (parser) { |
|
@ -229,11 +229,11 @@ function socketOnEnd() { |
|
|
var req = this._httpMessage; |
|
|
var req = this._httpMessage; |
|
|
var parser = this.parser; |
|
|
var parser = this.parser; |
|
|
|
|
|
|
|
|
if (!req.res) { |
|
|
if (!req.res && !req.socket._hadError) { |
|
|
// If we don't have a response then we know that the socket
|
|
|
// 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.
|
|
|
// ended prematurely and we need to emit an error on the request.
|
|
|
req.emit('error', createHangUpError()); |
|
|
req.emit('error', createHangUpError()); |
|
|
req._hadError = true; |
|
|
req.socket._hadError = true; |
|
|
} |
|
|
} |
|
|
if (parser) { |
|
|
if (parser) { |
|
|
parser.finish(); |
|
|
parser.finish(); |
|
@ -253,7 +253,7 @@ function socketOnData(d, start, end) { |
|
|
freeParser(parser, req); |
|
|
freeParser(parser, req); |
|
|
socket.destroy(); |
|
|
socket.destroy(); |
|
|
req.emit('error', ret); |
|
|
req.emit('error', ret); |
|
|
req._hadError = true; |
|
|
req.socket._hadError = true; |
|
|
} else if (parser.incoming && parser.incoming.upgrade) { |
|
|
} else if (parser.incoming && parser.incoming.upgrade) { |
|
|
// Upgrade or CONNECT
|
|
|
// Upgrade or CONNECT
|
|
|
var bytesParsed = ret; |
|
|
var bytesParsed = ret; |
|
|