refactor(http/retry): replayed body is not optional #3585
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ReplayBody<B>
is slightly inconsistent about how it represents the exhaustion of the innerB
-typed body.first, in
poll_data()
we poll the inner body, and note that we consider aNone
value forBodyState::rest
to mean that there is no more work to do.then, in
Body::is_end_stream()
, we write the following to check that the stream is done:note in particular the call to
Option::and_then(..)
.this means that, should the inner body be
None
, we could accidentally begin reporting the stream as not finished. this is backwards!this commit makes a change to the definition of
BodyState<B>
. it no longer treats its inner body as optional. we never drop the inner bodyB
, to facilitate gracefully replaying bodies that were interrupted when initially being polled.a bare
B
means that various bits of control are now simpler, without having to account for theOption<T>
state.this is front-running other work to port the
ReplayBody<B>
to http-body 1.0. see linkerd/linkerd2#8733.