anchor.diff:  
   -spec init(cowboy_stream:streamid(), cowboy_req:req(), cowboy:opts())
   	-> {[{spawn, pid(), timeout()}], #state{}}.
  -init(_StreamID, Req=#{ref := Ref}, Opts) ->
  +init(StreamID, Req=#{ref := Ref}, Opts) ->
   	Env = maps:get(env, Opts, #{}),
   	Middlewares = maps:get(middlewares, Opts, [cowboy_router, cowboy_handler]),
   	Shutdown = maps:get(shutdown_timeout, Opts, 5000),
   	Pid = proc_lib:spawn_link(?MODULE, request_process, [Req, Env, Middlewares]),
   	Expect = expect(Req),
  -	{[{spawn, Pid, Shutdown}], #state{ref=Ref, pid=Pid, expect=Expect}}.
  +	{Commands, Next} = cowboy_stream:init(StreamID, Req, Opts),
  +	{[{spawn, Pid, Shutdown}|Commands],
  +		#state{next=Next, ref=Ref, pid=Pid, expect=Expect}}.
   
   %% Ignore the expect header in HTTP/1.0.
   expect(#{version := 'HTTP/1.0'}) ->
  
positive.code: 		_ -> 400
  	end,
  	%% @todo Headers? Details in body? More stuff in debug only?
  	{[{error_response, Status, #{<<"content-length">> => <<"0">>}, <<>>}, stop], State};
  info(StreamID, Exit = {'EXIT', Pid, {Reason, Stacktrace}}, State=#state{ref=Ref, pid=Pid}) ->
  	report_crash(Ref, StreamID, Pid, Reason, Stacktrace),
  	{[
  		{error_response, 500, #{<<"content-length">> => <<"0">>}, <<>>},
  		{internal_error, Exit, 'Stream process crashed.'}
  	], State};
  %% Request body, auto mode, no body buffered.
  info(_StreamID, {read_body, Ref, auto, infinity}, State=#state{read_body_buffer= <<>>}) ->
  	{[], State#state{
  		read_body_ref=Ref,
  		read_body_length=auto}};
  %% Request body, auto mode, body buffered or complete.
  info(_StreamID, {read_body, Ref, auto, infinity}, State=#state{pid=Pid,
  		read_body_is_fin=IsFin, read_body_buffer=Buffer, body_length=BodyLen}) ->
  	send_request_body(Pid, Ref, IsFin, BodyLen, Buffer),
  	{[{flow, byte_size(Buffer)}], State#state{read_body_buffer= <<>>}};
  %% Request body, body buffered large enough or complete.
  %%
  %% We do not send a 100 continue response if the client
  %% already started sending the body.
  info(_StreamID, {read_body, Ref, Length, _}, State=#state{pid=Pid,
  		read_body_is_fin=IsFin, read_body_buffer=Buffer, body_length=BodyLen})
  		when IsFin =:= fin; byte_size(Buffer) >= Length ->
  	send_request_body(Pid, Ref, IsFin, BodyLen, Buffer),
  	{[], State#state{read_body_buffer= <<>>}};
  %% Request body, not enough to send yet.
  info(StreamID, {read_body, Ref, Length, Period}, State=#state{expect=Expect}) ->
  	Commands = case Expect of
  		continue -> [{inform, 100, #{}}, {flow, Length}];
  		undefined -> [{flow, Length}]
  	end,
  	%% @todo Handle the case where Period =:= infinity.
  	TRef = erlang:send_after(Period, self(), {{self(), StreamID}, {read_body_timeout, Ref}}),
  	{Commands, State#state{
  		read_body_ref=Ref,
  		read_body_timer_ref=TRef,
  		read_body_length=Length}};
  %% Request body reading timeout; send what we got.
  info(_StreamID, {read_body_timeout, Ref}, State=#state{pid=Pid, read_body_ref=Ref,
  		read_body_is_fin=IsFin, read_body_buffer=Buffer, body_length=BodyLen}) ->
  	send_request_body(Pid, Ref, IsFin, BodyLen, Buffer),
  	{[], State#state{read_body_ref=undefined, read_body_timer_ref=undefined, read_body_buffer= <<>>}};
  info(_StreamID, {read_body_timeout, _}, State) ->
  	{[], State};
  %% Response.
  %%
  %% We reset the expect field when a 100 continue response
  %% is sent or when any final response is sent.
  info(_StreamID, Inform = {inform, Status, _}, State0) ->
  	State = case cow_http:status_to_integer(Status) of
  		100 -> State0#state{expect=undefined};
  		_ -> State0
  	end,
  	{[Inform], State};
  info(_StreamID, Response = {response, _, _, _}, State) ->
  	{[Response], State#state{expect=undefined}};
  info(_StreamID, Headers = {headers, _, _}, State) ->
  	{[Headers], State#state{expect=undefined}};
  info(_StreamID, Data = {data, _, _}, State) ->
  	{[Data], State};
  info(_StreamID, Trailers = {trailers, _}, State) ->
  	{[Trailers], State};
  info(_StreamID, Push = {push, _, _, _, _, _, _, _}, State) ->
  	{[Push], State};
  info(_StreamID, SwitchProtocol = {switch_protocol, _, _, _}, State) ->
  	{[SwitchProtocol], State#state{expect=undefined}};
  %% Stray message.
  info(_StreamID, _Info, State) ->
  	{[], State}.
  
  -spec terminate(cowboy_stream:streamid(), cowboy_stream:reason(), #state{}) -> ok.
  terminate(_StreamID, _Reason, _State) ->
  	ok.
  
  -spec early_error(cowboy_stream:streamid(), cowboy_stream:reason(),
  	cowboy_stream:partial_req(), Resp, cowboy:opts()) -> Resp
  
negative.code: -export([execute/3]).
  -export([resume/5]).
  
  -record(state, {
  	next :: any(),
  	ref = undefined :: ranch:ref(),
  	pid = undefined :: pid(),
  	expect = undefined :: undefined | continue,
  