Respond with 414 when a line exceeds the maximum line length - #238
Open
trevorturk wants to merge 1 commit into
Open
Respond with 414 when a line exceeds the maximum line length#238trevorturk wants to merge 1 commit into
trevorturk wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves HTTP/1 server behavior when an incoming request line or header line exceeds maximum_line_length, ensuring the peer receives a proper HTTP response (414) instead of an unexplained EOF caused by LineLengthError escaping next_request.
Changes:
- Rescue
Protocol::HTTP1::LineLengthErrorinAsync::HTTP::Protocol::HTTP1::Server#next_requestand send a414viafail_requestbefore re-raising. - Add HTTP/1.1 server specs asserting
414for over-long request lines and header lines.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/async/http/protocol/http1/server.rb | Catch LineLengthError during request parsing and write a 414 response before re-raising to avoid silent connection close. |
| test/async/http/protocol/http11.rb | Add regression tests for 414 responses when request line or header lines exceed the configured maximum length. |
trevorturk
force-pushed
the
graceful-line-length-response
branch
from
August 1, 2026 13:02
77a168e to
278606c
Compare
Contributor
Author
|
Good idea, updated, force pushed back into a single commit. |
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.
Fixes #237.
Previously, when a request line or header line exceeded
maximum_line_length,LineLengthErrorpropagated pastnext_request(it doesn't include theBadRequestmarker), so the server closed the connection without writing anything and the peer saw an unexplained EOF.This PR rescues
LineLengthErrorinnext_requestand uses the existingfail_requestpath to respond with 414 before re-raising, matching the existingBadRequest→ 400 handling. The request-line and header-line cases can't be distinguished at the rescue site, so both get 414 as the more common case — happy to split the error by phase in protocol-http1 and map 414/431 instead if you'd prefer that precision.Types of Changes
Contribution