How do I get the size of the ServiceResponse
body?
#3766
Answered
by
robjtede
SamuelMarks
asked this question in
Q&A
-
Expected BehaviorYou can see my debug code here, the test succeeds but I'm unable to trivially determine the size of the body (I want to; in my test; check it's 0) let resp = actix_web::test::call_service(&app, test_profile_api::remove(&token)).await;
let headers = resp.headers();
println!("{:#?}", resp.response.body());
assert_eq!(
resp.status(),
actix_web::http::StatusCode::from_u16(204u16).unwrap()
); Current BehaviorIt's not in the header (Content-Size I was seeking) or elsewhere. Possible Solutionresp.into_body().try_into_bytes().unwrap() Then guess I can call Steps to Reproduce (for bugs) |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Sep 11, 2025
Replies: 1 comment
-
use actix_web::body::MessageBody as _;
res.response().body().size() the content-length header is set much later, using info from this method |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SamuelMarks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the content-length header is set much later, using info from this method