Skip to main content

Module fetch

Module fetch 

Source
Expand description

Pure-Rust W3C fetch() Engine with Headers, AbortController, and HTTP Framing.

Structs§

AbortController
W3C AbortController used to cancel in-flight network requests.
AbortSignal
W3C AbortSignal signaling cancellation of asynchronous requests.
FormData
Multipart form data builder.
Headers
Case-insensitive HTTP Header map conforming to W3C Fetch spec.
ParsedUrl
Parsed URL components.
RequestInit
Configuration options for an HTTP request.
Response
HTTP Response representation.

Enums§

FetchError
Errors occurring during HTTP fetch requests.
RequestCredentials
W3C Fetch credentials mode governing cookie inclusion in cross-origin requests.
RequestMode
W3C Fetch request mode governing Cross-Origin Resource Sharing.

Constants§

MAX_DECOMPRESSED_SIZE
Maximum allowable decompressed payload size in bytes (Decompression bomb protection).
MAX_HEADER_SIZE
Maximum allowable HTTP header size in bytes (RFC 7230 / Slowloris DoS prevention).
MAX_RESPONSE_BODY_SIZE
Maximum allowable HTTP response body size in bytes (128 MB).

Functions§

compute_origin
Computes the serialized origin (scheme + host + port) for an HTTP/HTTPS URL per RFC 6454 / W3C Fetch.
decode_chunked_body
Decodes HTTP/1.1 chunked transfer encoded payloads.
decompress_body
Decompresses body bytes based on HTTP Content-Encoding (gzip, deflate, br) with strict decompression bomb expansion limits.
fetch
Executes an HTTP or HTTPS fetch request, following standard HTTP redirects and enforcing W3C CORS rules.
fetch_single
Executes a single HTTP or HTTPS fetch request without following redirects.
is_cors_simple_request
Checks whether an HTTP request qualifies as a CORS-simple request under W3C Fetch spec. Returns (is_simple, list_of_custom_headers).
parse_http_response
Parses raw HTTP/1.1 response bytes into a structured Response.
read_http_response
Reads an HTTP/1.1 response from a synchronous byte stream, enforcing RFC 7230 framing. Terminates immediately upon reading Content-Length bytes or the terminal chunk 0\r\n\r\n, preventing hangs on persistent keep-alive connections.
resolve_redirect_url
Resolves a redirect location header against the base URL.