Browse Source

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.
v0.7.4-release
Ryan 16 years ago
parent
commit
887f056923
  1. 9
      src/http.js
  2. 6
      website/api.html

9
src/http.js

@ -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);

6
website/api.html

@ -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

Loading…
Cancel
Save