anchor.diff:  res_status(Req, State = #state{conn = Conn, ref = Ref, timeout = Timeout, res_headers = ResHeaders}) ->
     case gun:await(Conn, Ref, Timeout) of
       {response, Fin, Status, Headers} ->
  +      Chunked = fast_key:get(<<"transfer-encoding">>, Headers) =:= <<"chunked">>,
         next(Req, State#state{res_status = Status,
                               res_headers = filter_headers(Headers, ResHeaders),
  -                            res_has_body = Fin =:= nofin}, fun res_headers/2);
  +                            res_has_body = Fin =:= nofin,
  +                            res_chunked = Chunked}, fun res_headers/2);
       {error, timeout} ->
         next(Req, State, 504);
       {error, Reason} ->
  
positive.code:       no_call
    end.
  
  send(Req, State, Data, Next) ->
    case cowboy_req:chunk(Data, Req) of
      ok ->
        next(Req, State, Next);
  
negative.code:                              res_headers = FilteredHeaders}, fun reply/2)
    end.
  
  reply(Req, State = #state{res_has_body = true}) ->
    next(Req, State, fun res_body/2);
  reply(Req, State = #state{res_status = Status, res_headers = Headers}) ->
    {ok, Req2} = cowboy_req:reply(Status, Headers, Req),
    terminate(Req2, State).
  
  res_body(Req, State = #state{res_status = Status, res_headers = Headers, res_chunked = true}) ->
    case exported(Req, State, res_body, 3) of
      true ->
        next(Req, State#state{res_chunked = false}, fun transform_res_body/2);
      _ ->
        {ok, Req2} = cowboy_req:chunked_reply(Status, Headers, Req),
        next(Req2, State, fun chunk_res_body/2)
    end;
  res_body(Req, State) ->
    next(Req, State, fun transform_res_body/2).
  
  transform_res_body(Req, State = #state{conn = Conn, ref = Ref, timeout = Timeout}) ->
    case gun:await_body(Conn, Ref, Timeout) of
      {ok, Body} ->
        case call(Req, State, res_body, Body) of
          no_call ->
            send(Req, State, Body, fun terminate/2);
          ?HANDLE_ERROR(State);
          {Body2, Req2, HandlerState} ->
            send(Req2, State#state{handler_state = HandlerState}, Body2, fun terminate/2)
        end;
      {error, timeout} ->
        next(Req, State, 504);
      {error, Reason} ->
  