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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When reading the body of
http::Request<hyper::body::Incoming>, you have to rely onIncoming::poll_framewhich can returnhyper::Error. Is there a better way to transform such an error into anhttp::Responsethat doesn't always assumehttp::StatusCode::BAD_REQUESTis the appropriate status code? Is the best one can do is rely on theboolmethods ofError? If so, whatStatusCodeshould be used for each of those methods?Presumably
Error::is_timeoutshould meanStatusCode::REQUEST_TIMEOUTis sent, but is that even possible if one doesn't set a timer viaBuilder::timer? What about the others?Error::is_parse_too_largeseems to imply eitherStatusCode::PAYLOAD_TOO_LARGEorStatusCode::URI_TOO_LONG. I'm guessing that sinceRequest::urireturns&Urithat it must beStatusCode::PAYLOAD_TOO_LARGEsince theRequestwouldn't have been able to be constructed if it wereStatusCode::URI_TOO_LONG.Does it make sense to add a
status_codemethod toErrorthat returnsOption<StatusCode>? It would only returnSomewhen it make sense (e.g., when returned fromIncoming::poll_frameon the server).Beta Was this translation helpful? Give feedback.
All reactions