Skip to content

Limit the number of informational responses per request - #319

Open
hsbt wants to merge 1 commit into
masterfrom
limit-informational-responses
Open

Limit the number of informational responses per request#319
hsbt wants to merge 1 commit into
masterfrom
limit-informational-responses

Conversation

@hsbt

@hsbt hsbt commented Aug 5, 2026

Copy link
Copy Markdown
Member

transport_request reads informational (1xx) responses in a loop with no bound on the count. MAX_RESPONSE_HEADER_LENGTH only limits each response individually, so a peer that keeps sending interim responses keeps the client in the loop indefinitely. read_timeout does not help because it only applies to a single read. This adds Net::HTTPResponse::MAX_INFORMATIONAL_RESPONSES, set to 100, and raises Net::HTTPBadResponse when a request receives more than that before the final response. CPython's http.client uses the same value (_MAXINTERIMRESPONSES). With this cap the total header size per request is also bounded.

A peer that keeps sending 1xx responses keeps the client in the read
loop of transport_request indefinitely, since the per-response header
limit resets for each response. Cap the count at 100, the same value
CPython's http.client uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant