# `Loopback.Interceptors.Hackney`
[🔗](https://github.com/stefanchrobot/loopback/blob/v0.1.0/lib/loopback/interceptors/hackney.ex#L1)

An interceptor for [hackney](https://hexdocs.pm/hackney), and the clients built on it,
like HTTPoison and `Tesla.Adapter.Hackney`.

It supports hackney 1.x and 4.x, and replies the way the installed version does. For
example, hackney 1.x returns a reference to read the body from with `:hackney.body/1`,
and hackney 4.x returns the body itself.

Implementation notes:

  * A request that needs a connection after it returns, like one whose body is read
    later, one whose request body is sent with `:hackney.send_body/2`, or an asynchronous
    one, gets a process that stands in for the connection. Its PID is the request's
    reference, also in hackney 1.x, which uses references for its own connections.
    The other calls, like `:hackney.body/1`, have to be made while that process runs:
    until the body is read, or the process that made the request exits.
  * Request bodies can be binaries, iolists, `{:form, fields}`, `{:multipart, parts}`,
    `:stream`, sent with `:hackney.send_body/2`, and in hackney 1.x `{:file, path}`.
    Other bodies, like functions, raise.
  * A request with a `:stream` body reaches the fakes in `:hackney.start_response/1`.
    A request passed through is sent then, and the body has to be read with the
    reference that `:hackney.start_response/1` returns, like HTTPoison and Tesla do.
  * The headers that hackney adds itself, like `content-length`, aren't added to the
    request that fakes receive.
  * A fake's response arrives in one piece: `:hackney.stream_body/1` returns the whole
    body as one chunk, and an asynchronous response sends it as one message.
  * Options that control the connection, like `:recv_timeout`, apply only to requests
    passed through.

# `body`

# `body`

# `close`

# `finish_send_body`

# `request`

# `request`

# `request`

# `request`

# `request`

# `send_body`

# `skip_body`

# `start_response`

# `stream_body`

# `stream_next`

---

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