-
Notifications
You must be signed in to change notification settings - Fork 213
Description
This feature was already tried to be implemented. However, when sending the request, the body is consumed (due to being dyn Read), so it can't be sent again for the 307 or 308 redirect, which requires the same request to be sent again.
Lines 237 to 238 in 5b75dec
| // reinstate this with expect-100 | |
| // 307 | 308 | _ => connect(unit, method, use_pooled, redirects - 1, body), |
From what I can tell so far after looking at the source, we can reset any Payload back to the beginning, except the generic Reader(Box<dyn Read + 'static>). If this reader also implemented Seek, we would be able to get its position before starting the body-write, and reset it to that position on a 307 / 308 to read from it again. However, this would be a breaking API change to Request::send(&mut self, reader: impl Read + 'static) -> Response as the argument now also needs to implement Seek. (Additionally, io::Empty currently doesn't implement Seek, for which I opened rust-lang/rust#78029.)
Another option would be to require the reader to be Clone, however I'd see that as a strictly worse version of Seek.