anchor.diff:  %
   %The message body is the octets after decoding any transfer
   %codings. (RFC7230 3.3)
  -%
  -%content_length_0_when_no_body(Config) ->
  -%content_length_response(Config) ->
  -%When the length is known in advance, the server must send a
  -%content-length header, including if the length is 0. (RFC7230 3.3.2, RFC7230 3.3.3)
  -%
  -%chunked_response(Config) ->
  -%When the length is not known in advance, the chunked transfer-encoding
  -%must be used. (RFC7230 3.3.2, RFC7230 3.3.3)
  -%
  +
  +content_length_0_when_no_body(Config) ->
  +	doc("When the length is known in advance, the server must send a "
  +		"content-length header, including if the length is 0. (RFC7230 3.3.2, RFC7230 3.3.3)"),
  +	#{code := 200, headers := RespHeaders} = do_raw(Config, [
  +		"GET /resp/reply2/200 HTTP/1.1\r\n"
  +		"Host: localhost\r\n"
  +		"\r\n"]),
  +	{_, <<"0">>} = lists:keyfind(<<"content-length">>, 1, RespHeaders),
  +	ok.
  +
  +content_length_response(Config) ->
  +	doc("When the length is known in advance, the server must send a "
  +		"content-length header. (RFC7230 3.3.2, RFC7230 3.3.3)"),
  +	#{code := 200, headers := RespHeaders} = do_raw(Config, [
  +		"GET / HTTP/1.1\r\n"
  +		"Host: localhost\r\n"
  +		"\r\n"]),
  +	{_, <<"12">>} = lists:keyfind(<<"content-length">>, 1, RespHeaders),
  +	ok.
  +
  +chunked_response(Config) ->
  +	doc("When the length is not known in advance, the chunked transfer-encoding "
  +		"must be used. (RFC7230 3.3.2, RFC7230 3.3.3)"),
  +	#{code := 200, headers := RespHeaders} = do_raw(Config, [
  +		"GET /resp/stream_reply2/200 HTTP/1.1\r\n"
  +		"Host: localhost\r\n"
  +		"\r\n"]),
  +	{_, <<"chunked">>} = lists:keyfind(<<"transfer-encoding">>, 1, RespHeaders),
  +	%% @todo We probably want to check the body received too.
  +	ok.
  +
   %compat_no_content_length_or_transfer_encoding_close_on_body_end(Config) ->
   %For compatibility purposes a server can send no content-length or
   %transfer-encoding header. In this case the connection must be
   %closed after the response has been sent fully. (RFC7230 3.3.2, RFC7230 3.3.3)
  -%
  -%no_content_length_if_transfer_encoding(Config) ->
  -%The content-length header must not be sent when a transfer-encoding
  -%header already exists. (RFC7230 3.3.2)
  -%
  +
  +no_content_length_if_transfer_encoding(Config) ->
  +	doc("The content-length header must not be sent when a transfer-encoding "
  +		"header already exists. (RFC7230 3.3.2)"),
  +	#{code := 200, headers := RespHeaders} = do_raw(Config, [
  +		"GET /resp/stream_reply2/200 HTTP/1.1\r\n"
  +		"Host: localhost\r\n"
  +		"\r\n"]),
  +	false = lists:keyfind(<<"content-length">>, 1, RespHeaders),
  +	ok.
  +
   %@todo
   %The server must not apply the chunked transfer-encoding more than
   %once. (RFC7230 3.3.1)
   %
   %@todo
   %The server must apply the chunked transfer-encoding last. (RFC7230 3.3.1)
  -%
  -%http10_request_no_transfer_encoding_in_response(Config) ->
  -%The transfer-encoding header must not be sent in responses to
  -%HTTP/1.0 requests, or in responses that use the HTTP/1.0 version.
  -%No transfer codings must be applied in these cases. (RFC7230 3.3.1)
  -%
  +
  +http10_request_no_transfer_encoding_in_response(Config) ->
  +	doc("The transfer-encoding header must not be sent in responses to "
  +		"HTTP/1.0 requests, or in responses that use the HTTP/1.0 version. "
  +		"No transfer codings must be applied in these cases. (RFC7230 3.3.1)"),
  +	Client = raw_open(Config),
  +	ok = raw_send(Client, [
  +		"GET /resp/stream_reply2/200 HTTP/1.0\r\n"
  +		"Host: localhost\r\n"
  +		"\r\n"]),
  +	{_, 200, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),
  +	{RespHeaders, Rest2} = cow_http:parse_headers(Rest),
  +	false = lists:keyfind(<<"content-length">>, 1, RespHeaders),
  +	false = lists:keyfind(<<"transfer-encoding">>, 1, RespHeaders),
  +	Body = <<0:8000000>>,
  +	{ok, Body} = raw_recv(Client, byte_size(Body), 5000),
  +	%% The end of body is indicated by a connection close.
  +	{error, timeout} = raw_recv(Client, 0, 1000),
  +	ok.
  +
   %```
   %TE = #t-codings
   %
  
positive.code: %no_body_in_204_response(Config) ->
  %no_body_in_304_response(Config) ->
  %1xx, 204 and 304 responses never include a message body. (RFC7230 3.3)
  %
  %same_content_length_as_get_in_head_response(Config) ->
  %same_transfer_encoding_as_get_in_head_response(Config) ->
  %same_content_length_as_200_in_304_response(Config) ->
  %same_transfer_encoding_as_200_in_304_response(Config) ->
  %Responses to HEAD requests and 304 responses can include a
  %content-length or transfer-encoding header. Their value must
  %be the same as if the request was an unconditional GET. (RFC7230 3.3, RFC7230 3.3.1, RFC7230 3.3.2)
  %
  %no_transfer_encoding_in_100_response(Config) ->
  %no_transfer_encoding_in_101_response(Config) ->
  %no_transfer_encoding_in_102_response(Config) ->
  %no_transfer_encoding_in_204_response(Config) ->
  %%% @todo CONNECT no_transfer_encoding_in_2xx_response_to_connect_request(Config) ->
  %no_content_length_in_100_response(Config) ->
  %no_content_length_in_101_response(Config) ->
  %no_content_length_in_102_response(Config) ->
  %no_content_length_in_204_response(Config) ->
  %%% @todo CONNECT no_content_length_in_2xx_response_to_connect_request(Config) ->
  %1xx, 204 responses and "2xx responses to CONNECT requests" must
  %not include a content-length or transfer-encoding header. (RFC7230 3.3.1, RFC7230 3.3.2)
  %
  %```
  %message-body = *OCTET
  
negative.code: %@todo
  %A server must close the connection after sending or
  %receiving a "close" once the response has been sent. (RFC7230 6.6)
  
  close_request_close_response(Config) ->
  	doc("A server must send a \"close\" in a response to a request "
  		"containing a \"close\". (RFC7230 6.6)"),
  	#{code := 200, headers := RespHeaders} = do_raw(Config, [
  		"GET / HTTP/1.1\r\n"
  		"Host: localhost\r\n"
  		"Connection: close\r\n"
  		"\r\n"]),
  	{_, <<"close">>} = lists:keyfind(<<"connection">>, 1, RespHeaders),
  	ok.
  
  %% Response body.
  
  no_body_in_head_response(Config) ->
  	doc("Responses to HEAD requests never include a message body. (RFC7230 3.3)"),
  	Client = raw_open(Config),
  	ok = raw_send(Client, [
  		"HEAD / HTTP/1.1\r\n"
  		"Host: localhost\r\n"
  		"\r\n"]),
  	{_, 200, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),
  	{Headers, <<>>} = cow_http:parse_headers(Rest),
  	{_, LengthBin} = lists:keyfind(<<"content-length">>, 1, Headers),
  	Length = binary_to_integer(LengthBin),
  	{error, timeout} = raw_recv(Client, Length, 1000),
  	ok.
  
  %% @todo test different ways to send a body in response
  
  %%% @todo Implement CONNECT
  %2xx responses to CONNECT requests never include a message
  %body. (RFC7230 3.3)
  