Hello,
It seems that window.fetch in the browser will treat Content-Length and Transfer-Encoding differently compared to node-fetch. This causes some headache as a receiving server will have to treat these results differently (stream vs no stream).
This is how I'm calling fetch (both on the client and the server)
fetch("http://localhost:5000/users", { method: "POST" });
Using node-fetch in Node 4.1 yields the following headers on the receiving server:
Transfer-Encoding: chunked
Content-Length:
Where as using window.fetch in Chrome 45.0.2454.85 produces the following:
I'm not sure about this, but my guess is that Transfer-Encoding: chunkedshould only be applied in the cases where you're providing a stream as body. As in this instance: https://github.com/bitinn/node-fetch/blob/master/test/test.js#L436
Otherwise, it should set the content-length header. I.e something like this:
options.headers['Content-Length'] = Buffer.byteLength(body);
I may have misunderstood the spec, so let me know if this fits within the scope of this project or not. If so, I'm happy to submit a PR.
Regards,
Daniel
Hello,
It seems that window.fetch in the browser will treat
Content-LengthandTransfer-Encodingdifferently compared to node-fetch. This causes some headache as a receiving server will have to treat these results differently (stream vs no stream).This is how I'm calling fetch (both on the client and the server)
Using node-fetch in Node 4.1 yields the following headers on the receiving server:
Where as using
window.fetchin Chrome 45.0.2454.85 produces the following:I'm not sure about this, but my guess is that
Transfer-Encoding: chunkedshould only be applied in the cases where you're providing a stream as body. As in this instance: https://github.com/bitinn/node-fetch/blob/master/test/test.js#L436Otherwise, it should set the
content-lengthheader. I.e something like this:I may have misunderstood the spec, so let me know if this fits within the scope of this project or not. If so, I'm happy to submit a PR.
Regards,
Daniel