Skip to content

Transfer-Encoding: chunked request bodies aren't parsed, desyncing keep-alive connections #8

Description

@maedi

parse_body (lib/requests/request_parser.rb:66-73) only reads a body when `Content-Length` is present:

def parse_body(stream:, method:, headers:)
  return nil unless %w[POST PUT PATCH].include?(method)
  content_length = headers['content-length']&.first&.to_i
  return nil unless content_length&.positive?
  stream.read(content_length)
end

Transfer-Encoding: chunked is never checked, so chunked body bytes are never consumed from the stream. handle_connection reuses the same stream across requests on a keep-alive connection, so the next request's stream.gets reads leftover chunk data as if it were a new request line — garbage parses or hangs, not just a rejected single request.

Not sure if chunked support is on the roadmap already — flagging in case it's a surprise gap rather than a known one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions