anchor.diff:  %% and terminate the stream if this is the end of it.
   
   %% DATA frame.
  -frame(State=#state{handler=Handler, streams=Streams0}, {data, StreamID, IsFin0, Data}) ->
  -	case lists:keyfind(StreamID, #stream.id, Streams0) of
  +frame(State=#state{handler=Handler, streams=Streams}, {data, StreamID, IsFin0, Data}) ->
  +	case lists:keyfind(StreamID, #stream.id, Streams) of
   		Stream = #stream{state=StreamState0, remote=nofin, body_length=Len0} ->
   			Len = Len0 + byte_size(Data),
   			IsFin = case IsFin0 of
  
positive.code: 	Transport:send(Socket, cow_http2:rst_stream(StreamID, Reason)),
  	stream_terminate(State, StreamID, StreamError).
  
  stream_terminate(State=#state{socket=Socket, transport=Transport,
  		handler=Handler, streams=Streams0, children=Children0}, StreamID, Reason) ->
  	case lists:keytake(StreamID, #stream.id, Streams0) of
  		{value, #stream{state=StreamState, local=nofin}, Streams} when Reason =:= normal ->
  			Transport:send(Socket, cow_http2:data(StreamID, fin, <<>>)),
  			stream_call_terminate(StreamID, Reason, Handler, StreamState),
  
negative.code: 			State
  	end.
  
  commands(State, Stream, []) ->
  	after_commands(State, Stream);
  %% Send response headers.
  %%
  %% @todo Kill the stream if it sent a response when one has already been sent.
  %% @todo Keep IsFin in the state.
  %% @todo Same two things above apply to DATA, possibly promise too.
  commands(State=#state{socket=Socket, transport=Transport, encode_state=EncodeState0},
  		Stream=#stream{id=StreamID, local=idle}, [{response, StatusCode, Headers0, Body}|Tail]) ->
  	Headers = Headers0#{<<":status">> => integer_to_binary(StatusCode)},
  	{HeaderBlock, EncodeState} = headers_encode(Headers, EncodeState0),
  	case Body of
  		<<>> ->
  			Transport:send(Socket, cow_http2:headers(StreamID, fin, HeaderBlock)),
  			commands(State#state{encode_state=EncodeState}, Stream#stream{local=fin}, Tail);
  		{sendfile, O, B, P} ->
  			Transport:send(Socket, cow_http2:headers(StreamID, nofin, HeaderBlock)),
  			commands(State#state{encode_state=EncodeState}, Stream#stream{local=nofin},
  				[{sendfile, fin, O, B, P}|Tail]);
  		_ ->
  			Transport:send(Socket, [
  				cow_http2:headers(StreamID, nofin, HeaderBlock),
  				cow_http2:data(StreamID, fin, Body)
  			]),
  			commands(State#state{encode_state=EncodeState}, Stream#stream{local=fin}, Tail)
  	end;
  %% @todo response when local!=idle
  %% Send response headers and initiate chunked encoding.
  commands(State=#state{socket=Socket, transport=Transport, encode_state=EncodeState0},
  		Stream=#stream{id=StreamID, local=idle}, [{headers, StatusCode, Headers0}|Tail]) ->
  	Headers = Headers0#{<<":status">> => integer_to_binary(StatusCode)},
  	{HeaderBlock, EncodeState} = headers_encode(Headers, EncodeState0),
  	Transport:send(Socket, cow_http2:headers(StreamID, nofin, HeaderBlock)),
  	commands(State#state{encode_state=EncodeState}, Stream#stream{local=nofin}, Tail);
  %% @todo headers when local!=idle
  %% Send a response body chunk.
  %%
  %% @todo WINDOW_UPDATE stuff require us to buffer some data.
  