# `IMDS.HTTP`

The transport every provider uses, built on `Req`.

A request returns a plain map instead of a raise, so the providers can judge
the status code themselves. A connection failure gives the reason of the
socket error, for example `:econnrefused`, `:nxdomain` or `:timeout`.

Tests replace the network with `Req.Test`. Pass the Req options through the
`:req_options` option, for example
`req_options: [plug: {Req.Test, IMDS}]`.

# `headers`

```elixir
@type headers() :: [{binary(), binary()}]
```

# `method`

```elixir
@type method() :: :get | :put
```

# `response`

```elixir
@type response() :: %{status: non_neg_integer(), headers: headers(), body: binary()}
```

# `header`

```elixir
@spec header(response(), binary()) :: binary() | nil
```

Return the value of the first header with `name`.

The comparison ignores the case of the name. A response header name is
compared without case because HTTP does not keep the case of a name.

# `request`

```elixir
@spec request(method(), binary(), headers(), keyword()) ::
  {:ok, response()} | {:error, term()}
```

Send one request and return the status, the headers and the body.

The `:timeout` option bounds the connection and the response in
milliseconds. The `:req_options` option adds Req options with `Req.merge/2`,
so its headers are added to the provider headers.

---

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