Skip to content

Conversation

@pchickey
Copy link
Contributor

@pchickey pchickey commented Jan 6, 2026

This change eliminates some error-handling control flow in try_from_incoming which is unreachable, and replaces it with expect:

The http::response::Builder keeps internal state of whether the builder has errored, which is only reachable by passing Builder::header an erroring TryInto<HeaderName> or TryInto<HeaderValue>. Since the Builder::header method is never used, we know Builder::headers_mut will never give the None case, nor will Builder::body give the error case. So, rather than treat those as control flow, we unwrap if this invariant is ever broken because that would only be possible due to some unrecoverable bug in wstd, rather than incorrect use or invalid input.

This is a nonfunctional change and really just serves the next person who has to examine try_from_incoming and figure out exactly what error case it encountered, and save them reasoning through that those bits of control flow are actually unreachable.

@pchickey pchickey force-pushed the pch/simplify_http_response_from_incoming branch from bca8e7e to be9bc23 Compare January 6, 2026 00:23
@pchickey pchickey requested a review from yoshuawuyts January 6, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants