HTTP.RequestCompletion (http_fetch v0.21.17)

Copy Markdown View Source

A request-scoped cleanup barrier obtained from HTTP.Promise.completion/1.

Supported for HTTP/1 (including reuse) and HTTP/2 requests, manual/error redirects, and direct TCP or OTP TLS transport, including explicit HTTP and HTTPS proxies. HTTP proxies support HTTP/1 forwarding and HTTP/1 or HTTP/2 CONNECT tunnels to HTTPS origins. HTTPS proxies support HTTP/1 forwarding to HTTP origins. Nested TLS and proxy h2c routes remain unsupported. Awaiting the Promise or monitoring its response stream alone does not establish request cleanup.

A finite timeout covers the entire wait. :ok confirms termination of tracked request resources; {:error, :cleanup_pending} leaves cleanup in progress. {:error, :cleanup_unconfirmed} means evidence was lost (for example, an owner died without completing cleanup, or TLS setup failed before a socket exposing its receiver/sender could be tracked). TCP closure and dial-worker termination alone cannot confirm cleanup of those missing TLS processes. Repeated and concurrent waits are safe from any process. Success also requires the lifecycle tracker to terminate. This is a logical resource barrier: it does not certify native timer, alias, monitor, signal-buffer or deferred ERTS reclamation, allocator carriers, RSS, kernel memory return, or remote receipt of request bytes. Pooled completion confirms return of an HTTP/1 connection or release of the HTTP/2 stream and reservation; healthy shared connections remain open.

Summary

Functions

Cancels this request and awaits cleanup using the same finite deadline.

Waits for cleanup with a finite timeout in milliseconds.

Types

result()

@type result() ::
  :ok
  | {:error,
     :cleanup_pending | :cleanup_unconfirmed | {:unsupported_completion, atom()}}

t()

@opaque t()

Functions

abort_and_await(handle, timeout \\ 5000)

@spec abort_and_await(t(), non_neg_integer()) :: result()

Cancels this request and awaits cleanup using the same finite deadline.

await(handle, timeout \\ 5000)

@spec await(t(), non_neg_integer()) :: result()

Waits for cleanup with a finite timeout in milliseconds.