http.request

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Immutable HTTP request.

Frozen metadata with async body access. The request is honest about what it is: received data that doesn't change.

Immutable HTTP request.

Frozen metadata with async body access. The request is honest about what it is: received data that doesn't change.

http.request

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

_valid_htmx_element_id
function
def _valid_htmx_element_id(value: str) -> bool

Return whether value is safe to use as a canonical DOM id.

Parameters

Name Type Default Description
value str
_parse_htmx_element_ref
function
def _parse_htmx_element_ref(value: str | None) -> tuple[str | None, str | None]

Parse htmx 4tag#idmetadata without treating selectors as ids.

Parameters

Name Type Default Description
value str | None
RequestUrlScope
class

Request-local public URL prefix.

Middleware can attach this to a copiedRequestwhen the app routes a local path through a tenant or base-path public URL. It applies only to app-root paths, leaving external URLs, anchors, and relative paths alone.

HtmxDetails
class

Parsed htmx request headers with caching.

Attached torequest.htmx. Truthy when HX-Requestis present, providing typed access to all htmx request headers. Values are computed once and cached for the lifetime of the request.

_LazyQueryParams
class

QueryParams that parses on first access.

_LazyCookies
class

Cookies that parse on first access.

Request
class

An immutable HTTP request.

Metadata (method, path, headers, etc.) is frozen at creation. Body is accessed asynchronously via.body(), .json(), .form().

Query params and cookies are parsed lazily on first access (not at creation).

Request-scoped auth and session accessors are deliberately asymmetric, mirroring their underlying primitives:

  • request.user never raises — returns AnonymousUserwhen AuthMiddlewareis absent or the request is anonymous (mirrors chirp.middleware.auth.current_user).
  • request.session raises LookupError when SessionMiddleware is absent (mirrorschirp.middleware.sessions.get_session). It does not returnNone, so request.session.get("x")is the ergonomic, and a missing-middleware misconfiguration fails loud rather than silently reading from a non-existent session.

View source · /home/runner/work/chirp/chirp/site/../src/chirp/http/request.py:1