# `HTTP.RequestCompletion`
[🔗](https://github.com/gsmlg-dev/http_fetch/blob/v0.21.17/apps/http_fetch/lib/http/request_completion.ex#L1)

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.

# `result`

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

# `t`

```elixir
@opaque t()
```

# `abort_and_await`

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

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

# `await`

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

Waits for cleanup with a finite timeout in milliseconds.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
