anchor.diff:    {ok, Req2} = cowboy_req:reply(StatusCode, Req),
     terminate(Req2, State).
   
  +terminate(Req, State = #state{env = Env, conn = Conn, backend = Conn}) ->
  +  proxy_terminate(Req, State),
  +  {ok, Req, [{result, ok}|Env]};
   terminate(Req, State = #state{env = Env, conn = Conn}) ->
     proxy_terminate(Req, State),
     ok = gun:close(Conn),
  
positive.code:   ],
    case gun:open(Host, Port, Opts) of
      {ok, Conn} ->
        %% TODO handle a closed upstream connection
        next(Req, State#state{conn = Conn}, fun format_path/2);
      {error, _Error} ->
        next(Req, State, 502)
    end.
  
  format_path(Req, State = #state{backend = {_, _, _, BasePath}}) ->
  
negative.code:       next(Req2, State2, fun open_connection/2)
    end.
  
  open_connection(Req, State = #state{backend = Conn}) when is_pid(Conn) ->
    next(Req, State#state{conn = Conn}, fun format_path/2);
  open_connection(Req, State = #state{backend = {Proto, Host, Port, _Path}, timeout = Timeout}) ->
    Opts = [
      {retry, fast_key:get(retry, State#state.env, 1)},
  