Skip to content

Commit

Permalink
refactor(http/retry): update more Body::data() calls (#3573)
Browse files Browse the repository at this point in the history
pr's #3564 and #3567, 1eb822f and 3204278 respectively, replaced uses
of defunct `http_body::Body` trait methods — namely, `data()` and
`trailers()`.

this commit updates two remaining uses of `data()` that were missed
in this initial pass.

see linkerd/linkerd2#8733 for more information.

Signed-off-by: katelyn martin <[email protected]>
  • Loading branch information
cratelyn authored Jan 30, 2025
1 parent 3ffda3f commit f1817f8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions linkerd/http/retry/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ mod tests {
// alternately, hyperium/http-body#140 adds a channel-backed body to `http-body-util`.
let (mut tx, body) = hyper::Body::channel();
let mut initial = ReplayBody::try_new(body, 8).expect("channel body must not be too large");
let mut replay = initial.clone();
let replay = initial.clone();

// Send enough data to reach the cap
tx.send_data(Bytes::from("aaaaaaaa")).await.unwrap();
Expand All @@ -884,11 +884,12 @@ mod tests {

// The request's replay should error, since we discarded the buffer when
// we hit the cap.
let mut replay = crate::compat::ForwardCompatibleBody::new(replay);
let err = replay
.data()
.frame()
.await
.expect("replay must yield Some(Err(..)) when capped")
.expect_err("replay must error when cappped");
.expect("yields a result")
.expect_err("yields an error when capped");
assert!(err.is::<Capped>())
}

Expand All @@ -910,7 +911,7 @@ mod tests {
assert_eq!(chunk(&mut initial).await, Some("aaaaaaaa".to_string()));
drop(initial);

let mut replay2 = replay.clone();
let replay2 = replay.clone();

// The replay will reach the cap, but it should still return data from
// the original body.
Expand All @@ -920,11 +921,12 @@ mod tests {
drop(replay);

// The second replay will fail, though, because the buffer was discarded.
let mut replay2 = crate::compat::ForwardCompatibleBody::new(replay2);
let err = replay2
.data()
.frame()
.await
.expect("replay must yield Some(Err(..)) when capped")
.expect_err("replay must error when cappped");
.expect("yields a result")
.expect_err("yields an error when capped");
assert!(err.is::<Capped>())
}

Expand Down

0 comments on commit f1817f8

Please sign in to comment.