Skip to content

Respond with 414 when a line exceeds the maximum line length - #238

Open
trevorturk wants to merge 1 commit into
socketry:mainfrom
trevorturk:graceful-line-length-response
Open

Respond with 414 when a line exceeds the maximum line length#238
trevorturk wants to merge 1 commit into
socketry:mainfrom
trevorturk:graceful-line-length-response

Conversation

@trevorturk

Copy link
Copy Markdown
Contributor

Fixes #237.

Previously, when a request line or header line exceeded maximum_line_length, LineLengthError propagated past next_request (it doesn't include the BadRequest marker), so the server closed the connection without writing anything and the peer saw an unexplained EOF.

This PR rescues LineLengthError in next_request and uses the existing fail_request path to respond with 414 before re-raising, matching the existing BadRequest → 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

  • Bug fix.

Contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP/1 server closes the connection without a response when a line exceeds maximum_line_length

1 participant