Skip to content

Limit the number of informational responses per request - #319

Merged
hsbt merged 1 commit into
masterfrom
limit-informational-responses
Aug 26, 2026
Merged

Limit the number of informational responses per request#319
hsbt merged 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>
@hsbt
hsbt force-pushed the limit-informational-responses branch from 7fc58e6 to 39cf5f6 Compare August 26, 2026 00:22
@hsbt
hsbt merged commit c49514e into master Aug 26, 2026
52 checks passed
@hsbt
hsbt deleted the limit-informational-responses branch August 26, 2026 00:32
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