From 292039362a6125dfd0a163d5b0a49b800bf80b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 14 Nov 2018 19:24:39 +0100 Subject: Don't send the content-length header in empty 304 responses It's OK to send it when set explicitly, as it can be set to what the representation's size would have been. --- src/cowboy_http.erl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/cowboy_http.erl') diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index caa4932..56a4af8 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -963,6 +963,8 @@ commands(State0=#state{socket=Socket, transport=Transport, streams=Streams0, out {State1, Headers1} = case {Status, ContentLength, Version} of {204, _, 'HTTP/1.1'} -> {State0#state{out_state=done}, Headers0}; + {304, _, 'HTTP/1.1'} -> + {State0#state{out_state=done}, Headers0}; {_, undefined, 'HTTP/1.1'} -> {State0#state{out_state=chunked}, Headers0#{<<"transfer-encoding">> => <<"chunked">>}}; %% Close the connection after streaming without content-length to HTTP/1.0 client. -- cgit v1.2.3