-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't allocate until we know it's worth it #420
Don't allocate until we know it's worth it #420
Conversation
…batch request This works around the serde limitations around `untagged` enums and `RawValue`.
Also, rework the way we return errors: prefer JSON-RPC errors according to spec (application/json) wherever sensible.
utils/src/hyper_helpers.rs
Outdated
/// Returns `Err` if the body was too large or the body couldn't be read. | ||
pub async fn read_response_to_body( | ||
pub async fn read_body( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relevant changes are in this function.
return Ok::<_, HyperError>(response::too_large("The request was too large")) | ||
} | ||
|
||
let (body, mut is_single) = match read_body(&parts.headers, body, max_request_body_size).await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the relevant change of the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same stuff, marking as approved since those are easy fixes :)
For http server, check first byte before allocating space for the body.
Also re-work error handling and prefer sending JSON-RPC-style errors (JSON doc, spec'd error codes) combined with http status codes.
Alternative to #419
Closes #296