Skip to content
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

Raise Http{Request,Response}BodyError when Content-Length doesn't match #7591

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Nov 28, 2023

Instead of InternalError, raise a more specific request or response body size error when the number of bytes written to the outgoing body doesn't match the expectation set by the Content-Length header.

This change does overload the meaning of the http-{request,response}-body-size errors, as they were previously defined as meaning specifically that the body was too large, while this PR uses them to mean that the body length didn't match the expected length.

Addresses WebAssembly/wasi-http#83

@elliottt elliottt requested a review from a team as a code owner November 28, 2023 00:47
@elliottt elliottt requested review from alexcrichton and pchickey and removed request for a team November 28, 2023 00:47
@elliottt elliottt changed the title Raise Http{Request,Response}BodyError when too much is written Raise Http{Request,Response}BodyError when Content-Length doesn't match Nov 28, 2023
@pchickey
Copy link
Contributor

We never documented what the option<u64> payload in those error variants means - I guess I expected it to mean the expected content-length (none given, or some set value) rather than the number of bytes provided for the body. I guess either way is OK, I have a slight preference for the expected value rather than the got value, but we need to document what it should mean in the wit.

Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, We discussed the expected vs got payload in chat,

@elliottt :
| the original rfc says that the size should be the received size, not the expected size: https://www.rfc-editor.org/rfc/rfc9209#section-2.3.21.

@elliottt elliottt added this pull request to the merge queue Nov 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 29, 2023
@elliottt elliottt added this pull request to the merge queue Nov 29, 2023
Merged via the queue into bytecodealliance:main with commit 8cf0d42 Nov 29, 2023
18 checks passed
@elliottt elliottt deleted the trevor/body-error branch November 29, 2023 19:50
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