Deal with Body cloning / Allow phased sends from `HttpClient`
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
As described in https://github.com/http-rs/surf/pull/195 (Redirects), but more severely in order to address https://github.com/http-rs/surf/issues/169 (Retries) some form of either body cloning and/or phased client sending is necessary.
The easier case is probably phased sending, required for Redirects. Phased sending would partially solve the issue for Retries, but only partially, although enough to implement a sort-of working Retry middleware.
The problem here is that in some cases we don't want the Body stream to be consumed, or at least not right when we send the request headers.
### Ideal for Redirects:
- Send headers, await a partial response. If it's 3XX don't bother sending the body and go through the redirect first.
- (I hope I understand http enough that the above is actually possible. If not, it is the same as Retry.)
### Ideal for Retries:
- Body stream can be duplicated (Cloned), i.e. in the case of a file, a new FD to the same file, through the same transforms.
- Ideally it would be duplicate-able after the request is sent and fails, so that we don't have to allocate up front, but maybe that's just the price to pay for Retries.
- This is needed so that we can make a second identical request including body from an `http_types::Request`.
Contributor guide
Assessment
This issue has not been assessed yet.