http-client icon indicating copy to clipboard operation
http-client copied to clipboard

fix: curl - avoid zero-sized HEAD bodies

Open Fishrock123 opened this issue 4 years ago • 3 comments

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

Fishrock123 avatar Aug 30 '21 17:08 Fishrock123

Confirmed working: https://github.com/http-rs/surf/issues/321#issuecomment-908750099

Fishrock123 avatar Aug 30 '21 22:08 Fishrock123

@sagebind if you wouldn't mind, I'd like to know if this patch looks correct to you.

Fishrock123 avatar Aug 30 '21 22:08 Fishrock123

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.

sagebind avatar Sep 01 '21 02:09 sagebind