mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
Bugfix: sendBody wasn't setting encoding
This commit is contained in:
16
src/http.js
16
src/http.js
@@ -160,6 +160,7 @@ function OutgoingMessage () {
|
|||||||
node.EventEmitter.call(this);
|
node.EventEmitter.call(this);
|
||||||
|
|
||||||
this.output = [];
|
this.output = [];
|
||||||
|
this.outputEncodings = [];
|
||||||
|
|
||||||
this.closeOnFinish = false;
|
this.closeOnFinish = false;
|
||||||
this.chunked_encoding = false;
|
this.chunked_encoding = false;
|
||||||
@@ -171,8 +172,8 @@ function OutgoingMessage () {
|
|||||||
node.inherits(OutgoingMessage, node.EventEmitter);
|
node.inherits(OutgoingMessage, node.EventEmitter);
|
||||||
|
|
||||||
OutgoingMessage.prototype.send = function (data, encoding) {
|
OutgoingMessage.prototype.send = function (data, encoding) {
|
||||||
data.encoding = data.constructor === String ? encoding || "ascii" : "raw";
|
|
||||||
this.output.push(data);
|
this.output.push(data);
|
||||||
|
this.outputEncodings.push(encoding || "raws");
|
||||||
};
|
};
|
||||||
|
|
||||||
OutgoingMessage.prototype.sendHeaderLines = function (first_line, headers) {
|
OutgoingMessage.prototype.sendHeaderLines = function (first_line, headers) {
|
||||||
@@ -235,10 +236,10 @@ OutgoingMessage.prototype.sendHeaderLines = function (first_line, headers) {
|
|||||||
|
|
||||||
OutgoingMessage.prototype.sendBody = function (chunk, encoding) {
|
OutgoingMessage.prototype.sendBody = function (chunk, encoding) {
|
||||||
if (this.chunked_encoding) {
|
if (this.chunked_encoding) {
|
||||||
this.send(chunk.length.toString(16));
|
this.send(chunk.length.toString(16), "ascii");
|
||||||
this.send(CRLF);
|
this.send(CRLF, "ascii");
|
||||||
this.send(chunk, encoding);
|
this.send(chunk, encoding);
|
||||||
this.send(CRLF);
|
this.send(CRLF, "ascii");
|
||||||
} else {
|
} else {
|
||||||
this.send(chunk, encoding);
|
this.send(chunk, encoding);
|
||||||
}
|
}
|
||||||
@@ -371,8 +372,11 @@ function flushMessageQueue (connection, queue) {
|
|||||||
if (connection.readyState !== "open" && connection.readyState !== "writeOnly") {
|
if (connection.readyState !== "open" && connection.readyState !== "writeOnly") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var out = message.output.shift();
|
|
||||||
connection.send(out, out.encoding);
|
var data = message.output.shift();
|
||||||
|
var encoding = message.outputEncodings.shift();
|
||||||
|
|
||||||
|
connection.send(data, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message.finished) break;
|
if (!message.finished) break;
|
||||||
|
|||||||
Reference in New Issue
Block a user