refactor(http/retry): PeekTrailersBody<B>
only peeks empty bodies
#3509
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.
this commit makes a small, subtle change to the
PeekTrailersBody<B>
http response body middleware.to help facilitate upgrading to http-body 1.x, we remove some tricky logic that involves
Body
interfaces that no longer exist after the 0.4 release.currently, a
PeekTrailersBody<B>
is not fully consistent about the conditions in which it will peek the trailers of a response body: the inner body is allowed to yield either (a) zero DATA frames, in which case the body will be.await
'ed and polled until the trailers are obtained, or (b) one DATA frame, so long as the inner body immediately yields a trailer.meanwhile, the documentation comment for the type claims:
we won't have distinct
data()
andtrailers()
interfaces in the 1.0 release. we have a singleBodyExt::frame()
method.consequently, porting this middleware as-is would be somewhat difficult. we might have to hold two frames, should we receive one frame,
now_or_never()
the second frame, and discover that we've been provided a second data frame rather than the trailers.this all runs slightly against the invariants of
Body
, see this comment originally added in 7f817b5:this isn't quite true, as
Trailers
is just a wrapper callingpoll_trailers
:https://docs.rs/http-body/0.4.6/src/http_body/next.rs.html#28-30
so, let's remove this. doing so will make the task of porting this middleware to http-body 1.0 in the short term, and additionally prevents any potential future misbehavior due to inner bodies not handling this eager trailer polling gracefully.
see linkerd/linkerd2#8733.
see #3504.