-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Introduce the ability to return 413: payload too large for requests #3040
Merged
Commits on Dec 25, 2022
-
Introduce the ability to return 413: payload too large for requests
When recieving large payload objects, the server can often slowdown or get fully exhausted if bunch of requests with large payload body size come in. When request with large payload come, lot of the time is spent reading it into then, writing it to the IO for rack, before the request is passed to the rails app for further processing. While there are some workarounds around limiting large request sizes, like at nginx layer by setting `client_max_body_size`, which would return a `413` back to the client, today that is not possible with puma. This would be a very nice feature to have, especially when there is no reverse proxy in between client and server. This approach - allows a user to set `http_content_length_limit_exceeded` via a config variable (defaults to `nil`). This value is then compared against `Content-Length` http header before reading the body into buffer. If the user value is higher than the header value, the request body is not loaded and an immediate `413` (`Payload too large`) http response is returned, from `Puma::Request.handle_request`. Without having to buffer in the huge request and return the `413` immediately to the clients that send a `Content-Length` - is a nice feature and helpful protection to have.
Configuration menu - View commit details
-
Copy full SHA for 1034577 - Browse repository at this point
Copy the full SHA 1034577View commit details -
Compare and limit against body bytesize when no content-length
http header is present.
Configuration menu - View commit details
-
Copy full SHA for 2d9178b - Browse repository at this point
Copy the full SHA 2d9178bView commit details -
Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for fbb1a9d - Browse repository at this point
Copy the full SHA fbb1a9dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 33d29d0 - Browse repository at this point
Copy the full SHA 33d29d0View commit details -
Configuration menu - View commit details
-
Copy full SHA for c1ab5c5 - Browse repository at this point
Copy the full SHA c1ab5c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 248ca88 - Browse repository at this point
Copy the full SHA 248ca88View commit details -
Configuration menu - View commit details
-
Copy full SHA for dc2b6ee - Browse repository at this point
Copy the full SHA dc2b6eeView commit details
Commits on Dec 26, 2022
-
Configuration menu - View commit details
-
Copy full SHA for dead2b4 - Browse repository at this point
Copy the full SHA dead2b4View commit details
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.