What is the recommended way to transform an Incoming
hyper::Error
into http::Response
on the server?
#3854
zacknewman
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When reading the body of
http::Request<hyper::body::Incoming>
, you have to rely onIncoming::poll_frame
which can returnhyper::Error
. Is there a better way to transform such an error into anhttp::Response
that doesn't always assumehttp::StatusCode::BAD_REQUEST
is the appropriate status code? Is the best one can do is rely on thebool
methods ofError
? If so, whatStatusCode
should be used for each of those methods?Presumably
Error::is_timeout
should meanStatusCode::REQUEST_TIMEOUT
is sent, but is that even possible if one doesn't set a timer viaBuilder::timer
? What about the others?Error::is_parse_too_large
seems to imply eitherStatusCode::PAYLOAD_TOO_LARGE
orStatusCode::URI_TOO_LONG
. I'm guessing that sinceRequest::uri
returns&Uri
that it must beStatusCode::PAYLOAD_TOO_LARGE
since theRequest
wouldn't have been able to be constructed if it wereStatusCode::URI_TOO_LONG
.Does it make sense to add a
status_code
method toError
that returnsOption<StatusCode>
? It would only returnSome
when it make sense (e.g., when returned fromIncoming::poll_frame
on the server).Beta Was this translation helpful? Give feedback.
All reactions