|
|
@ -372,7 +372,17 @@ OutgoingMessage.prototype.finish = function () { |
|
|
|
throw new Error("finish() has been renamed to close()."); |
|
|
|
}; |
|
|
|
|
|
|
|
var closeWarning; |
|
|
|
|
|
|
|
OutgoingMessage.prototype.close = function (data, encoding) { |
|
|
|
if (!closeWarning) { |
|
|
|
closeWarning = "OutgoingMessage.prototype.close has been renamed to end()"; |
|
|
|
sys.error(closeWarning); |
|
|
|
} |
|
|
|
return this.end(data, encoding); |
|
|
|
}; |
|
|
|
|
|
|
|
OutgoingMessage.prototype.end = function (data, encoding) { |
|
|
|
if (data) this.write(data, encoding); |
|
|
|
if (this.chunkedEncoding) this._send("0\r\n\r\n"); // last chunk
|
|
|
|
this.finished = true; |
|
|
@ -436,19 +446,34 @@ sys.inherits(ClientRequest, OutgoingMessage); |
|
|
|
exports.ClientRequest = ClientRequest; |
|
|
|
|
|
|
|
ClientRequest.prototype.finish = function () { |
|
|
|
throw new Error( "finish() has been renamed to close() and no longer takes " |
|
|
|
throw new Error( "finish() has been renamed to end() and no longer takes " |
|
|
|
+ "a response handler as an argument. Manually add a 'response' listener " |
|
|
|
+ "to the request object." |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
var clientRequestCloseWarning; |
|
|
|
|
|
|
|
ClientRequest.prototype.close = function () { |
|
|
|
if (!clientRequestCloseWarning) { |
|
|
|
clientRequestCloseWarning = "Warning: ClientRequest.prototype.close has been renamed to end()"; |
|
|
|
sys.error(clientRequestCloseWarning); |
|
|
|
} |
|
|
|
if (arguments.length > 0) { |
|
|
|
throw new Error( "ClientRequest.prototype.end does not take any arguments. " |
|
|
|
+ "Add a response listener manually to the request object." |
|
|
|
); |
|
|
|
} |
|
|
|
return this.end(); |
|
|
|
}; |
|
|
|
|
|
|
|
ClientRequest.prototype.end = function () { |
|
|
|
if (arguments.length > 0) { |
|
|
|
throw new Error( "ClientRequest.prototype.close does not take any arguments. " |
|
|
|
throw new Error( "ClientRequest.prototype.end does not take any arguments. " |
|
|
|
+ "Add a response listener manually to the request object." |
|
|
|
); |
|
|
|
} |
|
|
|
OutgoingMessage.prototype.close.call(this); |
|
|
|
OutgoingMessage.prototype.end.call(this); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -509,7 +534,7 @@ function connectionListener (socket) { |
|
|
|
freeParser(parser); |
|
|
|
|
|
|
|
if (responses.length == 0) { |
|
|
|
socket.close(); |
|
|
|
socket.end(); |
|
|
|
} else { |
|
|
|
responses[responses.length-1].closeOnFinish = true; |
|
|
|
} |
|
|
@ -525,7 +550,7 @@ function connectionListener (socket) { |
|
|
|
res.shouldKeepAlive = shouldKeepAlive; |
|
|
|
res.addListener('flush', function () { |
|
|
|
if (flushMessageQueue(socket, responses)) { |
|
|
|
socket.close(); |
|
|
|
socket.end(); |
|
|
|
} |
|
|
|
}); |
|
|
|
responses.push(res); |
|
|
@ -582,7 +607,7 @@ function Client ( ) { |
|
|
|
parser.finish(); |
|
|
|
|
|
|
|
debug("self got end closing. readyState = " + self.readyState); |
|
|
|
self.close(); |
|
|
|
self.end(); |
|
|
|
}); |
|
|
|
|
|
|
|
self.addListener("close", function (e) { |
|
|
@ -604,7 +629,7 @@ function Client ( ) { |
|
|
|
|
|
|
|
res.addListener('end', function ( ) { |
|
|
|
debug("request complete disconnecting. readyState = " + self.readyState); |
|
|
|
self.close(); |
|
|
|
self.end(); |
|
|
|
}); |
|
|
|
|
|
|
|
currentRequest.emit("response", res); |
|
|
@ -697,7 +722,7 @@ exports.cat = function (url, encoding_, headers_) { |
|
|
|
req.addListener('response', function (res) { |
|
|
|
if (res.statusCode < 200 || res.statusCode >= 300) { |
|
|
|
if (callback) callback(res.statusCode); |
|
|
|
client.close(); |
|
|
|
client.end(); |
|
|
|
return; |
|
|
|
} |
|
|
|
res.setBodyEncoding(encoding); |
|
|
@ -711,5 +736,5 @@ exports.cat = function (url, encoding_, headers_) { |
|
|
|
if (callback) callback(err); |
|
|
|
}); |
|
|
|
|
|
|
|
req.close(); |
|
|
|
req.end(); |
|
|
|
}; |
|
|
|