An interceptor for :httpc, the HTTP client of Erlang/OTP, and the clients built on it,
like Tesla's default adapter, Tesla.Adapter.Httpc.
Implementation notes:
- Synchronous and asynchronous requests are intercepted, including the
:receiveroption. - The
:streamoption works like in:httpc, for 200 and 206 responses. Streaming to the calling process sends the body in onestreammessage. With{:self, :once}, the stream is sent without waiting for:httpc.stream_next/1, like:httpcsends a body that has already arrived. - A fake's response gets an HTTP/1.1 status line, with the standard reason phrase of its status.
- Like in
:httpc, a request's content type replaces itscontent-typeheader. Loopback.HTTPErrorreasons are returned the way:httpcreturns them::timeoutas:timeout,:closedas:socket_closed_remotely, and the other reasons as{:failed_connect, [...]}.- Asynchronous requests that fakes handle get request IDs of their own, which work with
:httpc.cancel_request/1,2. - Requests that fakes handle ignore the HTTP options, like
:timeout, and the profile, and don't need:inetsto be started.