anchor.diff:  -export([info/3]).
   -export([terminate/3]).
   
  +-export([proc_lib_hack/3]).
   -export([execute/3]).
   -export([resume/5]).
   
   -record(state, {
  +	ref = undefined :: ranch:ref(),
   	pid = undefined :: pid(),
   	read_body_ref = undefined :: reference(),
   	read_body_length = 0 :: non_neg_integer(),
  
positive.code: terminate(_StreamID, _Reason, _State) ->
  	ok.
  
  %% Request process.
  
  %% @todo
  %-spec execute(cowboy_req:req(), #state{}, cowboy_middleware:env(), [module()])
  
negative.code: -spec info(_,_,_) -> _.
  info(_StreamID, {'EXIT', Pid, normal}, State=#state{pid=Pid}) ->
  	{[stop], State};
  %% @todo Transition.
  %% In the future it would be better to simplify things
  %% and only catch this at the stream level.
  %%
  %% Maybe we don't need specific error messages
  %% for every single callbacks anymore?
  info(_StreamID, Exit = {'EXIT', Pid, {cowboy_handler, _}}, State=#state{pid=Pid}) ->
  	%% No crash report; one has already been sent.
  	{[
  		{response, 500, #{<<"content-length">> => <<"0">>}, <<>>},
  		{internal_error, Exit, 'Stream process crashed.'}
  	], State};
  info(_StreamID, {'EXIT', Pid, {_Reason, [_, {cow_http_hd, _, _, _}|_]}}, State=#state{pid=Pid}) ->
  	%% @todo Have an option to enable/disable this specific crash report?
  	%%report_crash(Ref, StreamID, Pid, Reason, Stacktrace),
  	%% @todo Headers? Details in body? More stuff in debug only?
  	{[{response, 400, #{}, <<>>}, stop], State};
  info(StreamID, Exit = {'EXIT', Pid, {Reason, Stacktrace}}, State=#state{ref=Ref, pid=Pid}) ->
  	report_crash(Ref, StreamID, Pid, Reason, Stacktrace),
  	{[
  		{response, 500, #{<<"content-length">> => <<"0">>}, <<>>},
  		{internal_error, Exit, 'Stream process crashed.'}
  	], State};
  %% Request body, no body buffer but IsFin=fin.
  info(_StreamID, {read_body, Ref, _}, State=#state{pid=Pid, read_body_is_fin=fin, read_body_buffer= <<>>}) ->
  	Pid ! {request_body, Ref, fin, <<>>},
  