Return 413 when POST body exceeds post_copy_size during request buffering#12817
Draft
brbzull0 wants to merge 1 commit intoapache:masterfrom
Draft
Return 413 when POST body exceeds post_copy_size during request buffering#12817brbzull0 wants to merge 1 commit intoapache:masterfrom
post_copy_size during request buffering#12817brbzull0 wants to merge 1 commit intoapache:masterfrom
Conversation
…ffering
When request_buffer_enabled is true and a POST/PUT body exceeds
post_copy_size, ATS now properly returns 413 Content Too Large instead
of crashing or returning incorrect error responses.
This change addresses two scenarios:
1. Requests with known Content-Length:
- Check Content-Length against post_copy_size upfront in HandleRequest()
- For requests with "Expect: 100-continue", perform the check BEFORE
sending "100 Continue" to avoid wasting bandwidth on bodies that
will be rejected
2. Chunked transfer encoding requests:
- Since body size is unknown upfront, detect overflow during buffering
- Set request_body_too_large flag and use HTTP_TUNNEL_EVENT_PRECOMPLETE
for graceful tunnel completion
- HttpSM checks the flag and calls PostBodyTooLarge to send 413
Contributor
Author
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.