summaryrefslogtreecommitdiff
path: root/lib/http.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/http.js')
-rw-r--r--lib/http.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/http.js b/lib/http.js
index 1f52d31514..2f4bcc51e2 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -445,6 +445,9 @@ function OutgoingMessage() {
this.finished = false;
this._hangupClose = false;
+
+ this.socket = null;
+ this.connection = null;
}
util.inherits(OutgoingMessage, Stream);
@@ -455,7 +458,12 @@ exports.OutgoingMessage = OutgoingMessage;
OutgoingMessage.prototype.setTimeout = function(msecs, callback) {
if (callback)
this.on('timeout', callback);
- this.socket.setTimeout(msecs);
+ if (!this.socket) {
+ this.once('socket', function(socket) {
+ socket.setTimeout(msecs);
+ });
+ } else
+ this.socket.setTimeout(msecs);
};
@@ -1056,6 +1064,7 @@ ServerResponse.prototype.assignSocket = function(socket) {
socket.on('close', onServerResponseClose);
this.socket = socket;
this.connection = socket;
+ this.emit('socket', socket);
this._flush();
};