summaryrefslogtreecommitdiff
path: root/lib/http.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-09 18:46:39 -0800
committerkoichik <koichik@improvement.jp>2013-03-10 18:34:41 +0900
commite2400f88d85f67fb241a30f8f527f60f464bc04c (patch)
treeacceed3f3fd4aa5739ce438089e1298dc75bc68a /lib/http.js
parent21a99664aedb12e06de6d5f6e5c76ad4811e6587 (diff)
downloadandroid-node-v8-e2400f88d85f67fb241a30f8f527f60f464bc04c.tar.gz
android-node-v8-e2400f88d85f67fb241a30f8f527f60f464bc04c.tar.bz2
android-node-v8-e2400f88d85f67fb241a30f8f527f60f464bc04c.zip
http: Do not setTimeout a not-yet-existent socket
Fixes #4967
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();
};