anchor.diff:      catch
           _:Reason -> {error, Reason}
       end.
  +
  +%% @doc Send data when the
  +-spec data(connection(), body()) -> ok.
  +data(Conn, Data) ->
  +    data(Conn, Data, nofin).
  +
  +-spec data(connection(), body(), fin | nofin) -> ok.
  +data(Conn, Data, FinNoFin) ->
  +    gen_fsm:send_event(Conn, {data, Data, FinNoFin}).
   
   %% @doc Returns a list of all received events up to now.
   -spec events(Pid :: pid()) -> [{nofin | fin, reference(), binary()}].
  
positive.code: 
  -behaviour(gen_fsm).
  
  -export([
           start/0,
           stop/0,
           start_link/4,
           open/2,
           open/3,
           open/4,
           close/1,
           %% get
           get/2,
           get/3,
           get/4,
           %% post
           post/5,
           %% delete
           delete/4,
           %% head
           head/4,
           %% options
           options/4,
           %% patch
           patch/5,
           %% put
           put/5,
           %% generic request
           request/6,
           %% events
           events/1
          ]).
  
  -export([
           init/1,
           handle_event/3,
           handle_sync_event/4,
           handle_info/3,
           terminate/3,
           code_change/4
          ]).
  
  -export([
           at_rest/2,
           wait_response/2,
           receive_data/2,
           receive_chunk/2,
           parse_event/1
          ]).
  
  %Work request handlers
  -export([
           at_rest/3,
           wait_response/3,
           receive_data/3,
           receive_chunk/3
          ]).
  
  -type response() ::
          #{
             status_code => integer(),
             header => map(),
             body => binary()
           }.
  -type result() :: {ok, reference() | response()} | {error, term()}.
  -type headers() :: #{}.
  -type options() ::
          #{
             async => boolean(),
             async_mode => binary | sse,
             handle_event => fun((fin | nofin, reference(), binary()) -> any()),
             basic_auth => {string(), string()},
             timeout => pos_integer() | infinity %% Default 5000 ms
           }.
  -type http_verb() :: get | post | head | delete | patch | put | options.
  
  -type connection_type() :: http | https.
  
  -type open_opts() ::
          #{
             %% transport_opts are passed to Ranch's TCP transport, which is
             %% -itself- a thin layer over gen_tcp.
             transport_opts => [],
             %% timeout is passed to gun:await_up. Default if not specified
             %% is 5000 ms.
             timeout => pos_integer() | infinity
           }.
  
  -type event() ::
          #{
             id    => binary(),
             event => binary(),
             data  => binary()
           }.
  
  -export_type([event/0]).
  
  %% @doc Starts the application and all the ones it depends on.
  -spec start() -> {ok, [atom()]}.
  
negative.code: %% @private
  -spec at_rest(any(), state()) -> {next_state, atom(), state()}.
  at_rest(timeout, State) ->
      io:format("at_rest timeout~n"),
      case get_work(State) of
          no_work ->
              {next_state, at_rest, State};
  