anchor.diff:          ]).
   
   -export([
  -         at_rest/2,
            at_rest/3,
            wait_response/2,
            receive_data/2,
  
positive.code:     ok.
  
  %% state functions
  at_rest({asyncget, Url, Headers}, #{pid := Pid} = _State) ->
      StreamRef = gun:get(Pid, Url, Headers),
      NewState = clean_state(),
      {next_state, wait_response, NewState#{pid := Pid, stream := StreamRef}};
  at_rest({asyncget, Url, Headers, HandleEvent}, #{pid := Pid} = _State) ->
      StreamRef = gun:get(Pid, Url, Headers),
      NewState = clean_state(),
      {next_state, wait_response, NewState#{pid := Pid, stream := StreamRef, handle_event := HandleEvent}}.
  
  at_rest({get, Url, Headers}, From, #{pid := Pid} = _State) ->
      StreamRef = gun:get(Pid, Url, Headers),
  
  
negative.code:         {undefined, undefined} ->
              gen_fsm:sync_send_event(Pid, {get, Url, Headers});
          {undefined, Async} ->
              gen_fsm:sync_send_event(Pid, {asyncget, Url, Headers});
          _ ->
              gen_fsm:sync_send_event(Pid, {asyncget, Url, Headers, HandleEvent})
      end.
  
  -spec pop(Pid :: pid()) -> {binary()}.
  