- From: Domenic Denicola <d@domenic.me>
- Date: Mon, 17 Nov 2014 14:50:42 +0000
- To: Takeshi Yoshino <tyoshino@google.com>, Rui Prior <rprior@dcc.fc.up.pt>
- CC: "Web Applications Working Group WG (public-webapps@w3.org)" <public-webapps@w3.org>
If I recall how Node.js does this, if you don’t provide a `Content-Length` header, it automatically sets `Transfer-Encoding: chunked` the moment you start writing to the body. What do we think of that kind of behavior for fetch requests? My opinion is that it’s pretty convenient, but I am not sure I like the implicitness. Examples, based on fetch-with-streams: ```js // non-chunked, non-streaming fetch("http://example.com/post-to-me", { method: "POST", headers: { // implicit Content-Length (I assume) }, body: "a string" }); // non-chunked, streaming fetch("http://example.com/post-to-me", { method: "POST", headers: { "Content-Length": 10 }, body(stream) { stream.write(new ArrayBuffer(5)); setTimeout(() => stream.write(new ArrayBuffer(5)), 100); setTimeout(() => stream.close(), 200); } }); // chunked, streaming fetch("http://example.com/post-to-me", { method: "POST", headers: { // implicit Transfer-Encoding: chunked? Or require it explicitly? }, body(stream) { stream.write(new ArrayBuffer(1024)); setTimeout(() => stream.write(new ArrayBuffer(1024)), 100); setTimeout(() => stream.write(new ArrayBuffer(1024)), 200); setTimeout(() => stream.close(), 300); } }); ```
Received on Monday, 17 November 2014 14:51:12 UTC