Return 413 when POST body exceeds post_copy_size during request buffering
#12817
+184
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While fixing another issue I came across the following crash:
and it happens when a request body exceeded
proxy.config.http.post_copy_sizeduring buffering, as the above ATS would crash or maybe(couldn't get this) return incorrect error responses (403??).So, after some(heavy) back and forth with
Claude(AI)we came across this fix.My main question here is, does it make sense to try to respond
413in this case as earlier as possible?Summary
This PR fixes the handling of oversized POST request bodies when
proxy.config.http.request_buffer_enabledis true.Problem
When request buffering is enabled, ATS buffers the POST body . If the body exceeds post_copy_size:
Solution
For requests with known Content-Length:
For chunked requests (size unknown upfront):
NOTE: I've changed
post_slow_server.test.pyso it runs in CI, it does ok locally, but just in case. I will be removing it after it runs.