anchor.diff:  			State
   	end.
   
  -commands(State, _, []) ->
  -	State;
  +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}, StreamID,
  -		[{response, StatusCode, Headers0, Body}|Tail]) ->
  +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),
  -	Response = cow_http2:headers(StreamID, nofin, HeaderBlock),
   	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, Response),
  -			commands(State#state{encode_state=EncodeState}, StreamID,
  +			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, [
  -				Response,
  +				cow_http2:headers(StreamID, nofin, HeaderBlock),
   				cow_http2:data(StreamID, fin, Body)
   			]),
  -			commands(State#state{encode_state=EncodeState}, StreamID, Tail)
  +			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}, StreamID,
  -		[{headers, StatusCode, Headers0}|Tail]) ->
  +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}, StreamID, Tail);
  +	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.
  
positive.code: 			end,
  			try Handler:data(StreamID, IsFin, Data, StreamState0) of
  				{Commands, StreamState} ->
  					Streams = lists:keyreplace(StreamID, #stream.id, Streams0,
  						Stream#stream{state=StreamState, body_length=Len}),
  					commands(State#state{streams=Streams}, StreamID, Commands)
  			catch Class:Reason ->
  				error_logger:error_msg("Exception occurred in ~s:data(~p, ~p, ~p, ~p) with reason ~p:~p.",
  					[Handler, StreamID, IsFin0, Data, StreamState0, Class, Reason]),
  
negative.code: 	id = undefined :: cowboy_stream:streamid(),
  	state = undefined :: any(),
  	%% Whether we finished sending data.
  	local = idle :: idle | cowboy_stream:fin(),
  	%% Whether we finished receiving data.
  	remote = nofin :: cowboy_stream:fin(),
  	%% Request body length.
  