Request API — Aquilia Documentation
Comprehensive guide and documentation for Request API in the Aquilia framework. View API reference, examples, and implementation patterns.
HTTP Client / Core API request.py Low-level request construction primitives for AquilaHTTP. This module defines immutable request objects, URL/header/body validation, and the request builder used by AsyncHTTPClient and HTTPSession . 1. Overview request.py is the canonical request-shaping boundary for the HTTP client subsystem. It is split into two layers: • HTTPClientRequest: immutable payload consumed by transport and interception stacks. • RequestBuilder: mutable fluent DSL that validates and materializes HTTPClientRequest. 2. Architecture and Design • RequestBuilder stores mutable assembly state in private slots for low-overhead chaining. • build() emits HTTPClientRequest dataclass instances to isolate downstream processing from mutation. • Header names/values are validated to prevent malformed request lines and header injection issues. • JSON/form serialization occurs at build time, not transport time, so faults are deterministic. 3. API Reference class HTTPMethod(str, Enum): GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE, CONNECT HeadersType = Mapping[str, str] | list[tuple[str, str]] | None ParamsType = Mapping[str, str | int | float | bool | None] | list[tuple[str, str]] | None CookiesType = Mapping[str, str] | None DataType = Mapping[str, Any] | str | bytes | None JsonType = Any ContentType = str | bytes | AsyncIterator[bytes] | BinaryIO | None def _normalize_header_name(name: str) -> str: # Title-Case normalization return name.title() def _validate_header_name(name: str) -> None: # Raises InvalidHeaderFault on empty or control chars pass 4. Hardening and Edge Cases • Dotted keys and complex query structures are fully supported and urlencoded automatically. • Request headers are strictly validated to prevent CR-LF injection vectors. )
Go to Homepage