Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorReid Burke <me@reidburke.com>2011-07-08 08:04:27 +0400
committerkoichik <koichik@improvement.jp>2011-07-19 19:24:17 +0400
commit973153d1ccdbb06f9067f3698578e8a5685a87c4 (patch)
tree7a4171610eb7bd3d1942120cf138e4ba6c5184e2 /lib
parent9f9a4cb9284794cea04098735f0dcc4c771db153 (diff)
Properly respond to HEAD during end(body) hot path
During write(), _hasBody is checked to make sure a body is allowed -- this is now also checked during end(body) when write() isn't used. Concise final chunk for HEAD req's res.end(data). Instead of simply clearing data, check _hasBody earlier to avoid sending cruft when chunkedEncoding is used. Fixes #1291.
Diffstat (limited to 'lib')
-rw-r--r--lib/http.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/http.js b/lib/http.js
index 14befd15dfe..e5291fbf9a9 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -652,6 +652,12 @@ OutgoingMessage.prototype.end = function(data, encoding) {
this._implicitHeader();
}
+ if (data && !this._hasBody) {
+ console.error('This type of response MUST NOT have a body. ' +
+ 'Ignoring data passed to end().');
+ data = false;
+ }
+
var ret;
var hot = this._headerSent === false &&
@@ -667,6 +673,7 @@ OutgoingMessage.prototype.end = function(data, encoding) {
// res.writeHead();
// res.end(blah);
// HACKY.
+
if (this.chunkedEncoding) {
var l = Buffer.byteLength(data, encoding).toString(16);
ret = this.connection.write(this._header + l + CRLF +