Do not assume transfer-encoding: chunked as default on requests.

If users do not send transfer-encoding or content-length headers, then I
will not add any additional. Content-Length: 0 is assumed if there aren't
other headers and chunked encoding is rare.
pull/22966/head
Ryan 2009-06-06 23:57:15 +02:00
parent 5558bc4e6e
commit 887f056923
2 changed files with 11 additions and 4 deletions

View File

@ -359,16 +359,17 @@ node.http.Client = function (port, host) {
header += "Connection: keep-alive\r\n";
}
if (sent_content_length_header == false && sent_transfer_encoding_header == false) {
header += "Transfer-Encoding: chunked\r\n";
chunked_encoding = true;
}
header += CRLF;
var output = [];
send(output, header);
this.sendBody = function (chunk, encoding) {
if (sent_content_length_header == false && chunked_encoding == false) {
throw "Content-Length header (or Transfer-Encoding:chunked) not set";
return;
}
if (chunked_encoding) {
send(output, chunk.length.toString(16));
send(output, CRLF);

View File

@ -750,6 +750,12 @@ req.finish(function (res) {
by Node. Returns a <code>ClientRequest</code> object.
</p>
<p>
Do remember to include the <code>Content-Length</code> header if you
plan on sending a body. If you plan on streaming the body, perhaps
set <code>Transfer-Encoding: chunked</code>.
</p>
<p>
Important: the request is not complete. This method only sends
the header of the request. One needs to call