caddyhttp: return 413 for oversized body placeholders#7692
Conversation
|
I agree with the concept, but the implementation might have too many side effects. Changing how errors for all placeholders are handled has far-reaching effects. Needs deeper analysis. |
|
I think we can at limit record if the body is truncated and if the body is being limited by max bytes. Request body placeholder was introduced for debugging, and it's also possible for users to want to view the truncated body while knowing it's truncated and limited by the handler. In general, placeholders give users the freedom to manage caddy's behaviour. We can start just by setting the two aforementioned placeholders. @chris-morgan, do you think this approach is ok, or do you prefer an implicit |
|
I don’t know about how it gets implemented (you’ve got various different considerations because of things like reverse proxying), but I think a normal person will expect (a) that So I’m a little bit surprised to see it being patched in placeholders, though perhaps the broader “content-length is greater than max_size, 413 immediately” could be treated as a breaking change. But really, I’m just a weird user who’s having fun stretching Caddy in unusual directions. You can definitely just raise an eyebrow at my shenanigans and say things are good enough and you prefer things to be broken in this way rather than messing with other things, though I’d hope for a couple of minor documentation tweaks in that case. |
|
I think the issue is real and Chris’ expectation is reasonable but I agree with Francis that this PR changes too much generic placeholder behaviour to be comfortable merging as-is.
I would prefer a narrower PR here; handle |
Fixes #7691
Summary:
http.MaxBytesErrorfromrequest_body max_sizeinto an HTTP 413 handler errorvars/vars_regexpmatchers{http.request.body}usageTests:
go test ./modules/caddyhttp ./modules/caddyhttp/templates -count=1go test ./caddytest/integration -run 'TestRespondWithJSON|TestRequestBodyPlaceholderRespectsMaxSize' -count=1git diff --checkAssistance Disclosure
This PR was implemented with assistance from Hermes Agent (OpenAI Codex/GPT-5.5). The changes were reviewed and verified with the targeted tests listed above.