0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Don't include a content-length in 204 responses

This commit is contained in:
Loïc Hoguin 2017-11-29 21:38:10 +01:00
parent 8d9404e9b6
commit b0519af42a
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
2 changed files with 6 additions and 1 deletions

View file

@ -725,6 +725,11 @@ reply(Status, Headers, SendFile = {sendfile, _, Len, _}, Req)
do_reply(Status, Headers#{
<<"content-length">> => integer_to_binary(Len)
}, SendFile, Req);
%% 204 responses must not include content-length. (RFC7230 3.3.1, RFC7230 3.3.2)
reply(Status=204, Headers, Body, Req) ->
do_reply(Status, Headers, Body, Req);
reply(Status= <<"204",_/bits>>, Headers, Body, Req) ->
do_reply(Status, Headers, Body, Req);
reply(Status, Headers, Body, Req)
when is_integer(Status); is_binary(Status) ->
do_reply(Status, Headers#{