|
@ -110,6 +110,7 @@ function OutgoingMessage (connection) { |
|
|
this.use_chunked_encoding_by_default = true; |
|
|
this.use_chunked_encoding_by_default = true; |
|
|
|
|
|
|
|
|
this.flushing = false; |
|
|
this.flushing = false; |
|
|
|
|
|
this.headWritten = false; |
|
|
|
|
|
|
|
|
this.finished = false; |
|
|
this.finished = false; |
|
|
} |
|
|
} |
|
@ -215,6 +216,10 @@ OutgoingMessage.prototype.sendBody = function () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutgoingMessage.prototype.write = function (chunk, encoding) { |
|
|
OutgoingMessage.prototype.write = function (chunk, encoding) { |
|
|
|
|
|
if ( (this instanceof ServerResponse) && !this.headWritten) { |
|
|
|
|
|
throw new Error("writeHead() must be called before write()") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
encoding = encoding || "ascii"; |
|
|
encoding = encoding || "ascii"; |
|
|
if (this.chunked_encoding) { |
|
|
if (this.chunked_encoding) { |
|
|
this._send(process._byteLength(chunk, encoding).toString(16)); |
|
|
this._send(process._byteLength(chunk, encoding).toString(16)); |
|
@ -279,6 +284,7 @@ ServerResponse.prototype.writeHead = function (statusCode) { |
|
|
var status_line = "HTTP/1.1 " + statusCode.toString() + " " |
|
|
var status_line = "HTTP/1.1 " + statusCode.toString() + " " |
|
|
+ reasonPhrase + CRLF; |
|
|
+ reasonPhrase + CRLF; |
|
|
this.sendHeaderLines(status_line, headers); |
|
|
this.sendHeaderLines(status_line, headers); |
|
|
|
|
|
this.headWritten = true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// TODO eventually remove sendHeader(), writeHeader()
|
|
|
// TODO eventually remove sendHeader(), writeHeader()
|
|
|