Skip to content

blackbull.request

blackbull.request

Request body and cookie helpers.

Provides:

  • read_body: buffers all ASGI http.request chunks into a single bytes object.
  • parse_cookies: parses the Cookie request header into a dict[str, str].

parse_cookies(scope)

Parse the Cookie request header from an ASGI scope into a dict.

Works identically for HTTP/1.1, HTTP/2, and WebSocket scopes. HTTP/1.1 sends a single combined Cookie header; HTTP/2 may split it into multiple fields (RFC 7540 ยง8.1.2.5). This function uses Headers.getlist to collect all cookie fields before joining and parsing, so both wire formats produce the same result.

read_body(receive) async

Read the complete request body from the ASGI receive channel.