http-client
http-client copied to clipboard
fix: curl - avoid zero-sized HEAD bodies
If there is no body then don't construct a zero-lengthed body.
Fixes: https://github.com/http-rs/surf/issues/321 Fixes: https://github.com/http-rs/surf/issues/218
Confirmed working: https://github.com/http-rs/surf/issues/321#issuecomment-908750099
@sagebind if you wouldn't mind, I'd like to know if this patch looks correct to you.
This doesn't seem to be aiming to correct the right thing here. The problem is that Isahc understands three different scenarios:
- A request with a body of known size, including 0. (
Body::from_reader_sized) - A request with a body of unknown size. (
Body::from_reader) - A request without a body. (
Body::empty, or equivalently())
The problem is that Surf never indicates the third case to Isahc, only one of the first two cases.