mirror of https://github.com/nodejs/node.git
Bugfix for sendBody() and chunked utf8 strings
Http expects chunked byte offsets and ignores the encoding specified in the header. This patch makes node behave accordingly. Bug report: http://groups.google.com/group/nodejs/browse_thread/thread/ab701d49cb059317
This commit is contained in:
parent
7371fcb312
commit
bffee5eda4
|
@ -283,7 +283,7 @@ OutgoingMessage.prototype.sendHeaderLines = function (first_line, headers) {
|
|||
|
||||
OutgoingMessage.prototype.sendBody = function (chunk, encoding) {
|
||||
if (this.chunked_encoding) {
|
||||
this.send(chunk.length.toString(16));
|
||||
this.send(process._byteLength(chunk, encoding).toString(16));
|
||||
this.send(CRLF);
|
||||
this.send(chunk, encoding);
|
||||
this.send(CRLF);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
process.mixin(require("./common"));
|
||||
var http = require("http");
|
||||
var PORT = 8888;
|
||||
|
||||
var UTF8_STRING = "Il était tué";
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
res.sendHeader(200, {"Content-Type": "text/plain; charset=utf8"});
|
||||
res.sendBody(UTF8_STRING, 'utf8');
|
||||
res.finish();
|
||||
});
|
||||
server.listen(PORT);
|
||||
|
||||
http.cat("http://localhost:"+PORT+"/", "utf8")
|
||||
.addCallback(function (data) {
|
||||
assertEquals(UTF8_STRING, data);
|
||||
server.close();
|
||||
})
|
||||
.addErrback(function() {
|
||||
assertUnreachable('http.cat should succeed in < 1000ms');
|
||||
})
|
||||
.timeout(1000);
|
Loading…
Reference in New Issue