Content-length header not checked for streaming body
dvic opened this issue · 3 comments
The docs mention Request body streaming also works though content-length header must be explicitly set
. However, there is no error returned when you omit this header.
We've only found about this today where we hit #309 / sneako/finch#265 and the corresponding workaround was not working. It turned out we were not passing the content-length header (with it, the workaround works just fine).
So the question is, should we reject streaming requests without a content-length header?
Update: setting content-length doesn't seem to affect the workaround after all, it was a flaky coincidence apparently.
Regardless, the question remains whether or not we should reject streaming requests without content-length :)
The piece of documentation you're citing is about AWS signature and the content-length is required due to some implementation details at the moment. It's not a general requirement however and this works:
iex> Req.put!("https://httpbin.org/anything", body: Stream.duplicate("foo", 3)).body["data"]
"foofoofoo"
You were hitting a different bug: #309 (comment). I just released a new version and if you upgrade you should be good to go but let me know otherwise!
The piece of documentation you're citing is about AWS signature and the content-length is required due to some implementation details at the moment. It's not a general requirement however and this works:
iex> Req.put!("https://httpbin.org/anything", body: Stream.duplicate("foo", 3)).body["data"] "foofoofoo"You were hitting a different bug: #309 (comment). I just released a new version and if you upgrade you should be good to go but let me know otherwise!
Ahhh clear, thanks for the quick revert fix!