diff --git a/examples/reqwest-response/src/main.rs b/examples/reqwest-response/src/main.rs index b6dfeb70..cbfaae33 100644 --- a/examples/reqwest-response/src/main.rs +++ b/examples/reqwest-response/src/main.rs @@ -60,7 +60,7 @@ async fn proxy_via_reqwest(State(client): State) -> Response { } }; - let response_builder = Response::builder().status(reqwest_response.status().as_u16()); + let mut response_builder = Response::builder().status(reqwest_response.status().as_u16()); // Here the mapping of headers is required due to reqwest and axum differ on the http crate versions let mut headers = HeaderMap::with_capacity(reqwest_response.headers().len()); @@ -70,6 +70,8 @@ async fn proxy_via_reqwest(State(client): State) -> Response { (name, value) })); + *response_builder.headers_mut().unwrap() = headers; + response_builder .body(Body::from_stream(reqwest_response.bytes_stream())) // This unwrap is fine because the body is empty here