Skip to content

Commit bca8e7e

Browse files
committed
NFC: simplify internals of http::response::try_from_incoming
1 parent ec2b222 commit bca8e7e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/http/response.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use http::StatusCode;
22
use wasip2::http::types::IncomingResponse;
33

44
use crate::http::body::{Body, BodyHint};
5-
use crate::http::error::{Context, Error};
5+
use crate::http::error::Error;
66
use crate::http::fields::{HeaderMap, header_map_from_wasi};
77

88
pub use http::response::{Builder, Response};
@@ -22,10 +22,8 @@ pub(crate) fn try_from_incoming(incoming: IncomingResponse) -> Result<Response<B
2222
let body = Body::from_incoming(incoming_body, hint);
2323

2424
let mut builder = Response::builder().status(status);
25-
26-
if let Some(headers_mut) = builder.headers_mut() {
27-
*headers_mut = headers;
28-
}
29-
30-
builder.body(body).context("building response")
25+
*builder.headers_mut().expect("builder has not errored") = headers;
26+
Ok(builder
27+
.body(body)
28+
.expect("response builder should not error"))
3129
}

0 commit comments

Comments
 (0)