summaryrefslogtreecommitdiff
path: root/lib/inets/src/http_server/mod_esi.erl
diff options
context:
space:
mode:
authorPéter Dimitrov <peterdmv@erlang.org>2018-08-27 15:56:19 +0200
committerPéter Dimitrov <peterdmv@erlang.org>2018-08-27 15:56:19 +0200
commit30b5899883282b746b55fbf59b73211bbd071ddd (patch)
treef15195c299ff08d1578c90599952191eb96e1f16 /lib/inets/src/http_server/mod_esi.erl
parent8bb0d5d4049b6b2ec41f6cc3e154e9f688029bef (diff)
parentc492a313ce2893fdb8d5f1215b95d437a00c92de (diff)
downloaderlang-30b5899883282b746b55fbf59b73211bbd071ddd.tar.gz
Merge branch 'peterdmv/inets/fix_http_server/OTP-15241' into maint-20
* peterdmv/inets/fix_http_server/OTP-15241: inets: Do not use chunked encoding with 1xx, 204, 304 Change-Id: I4dc1cb6dc62cc5a090d49248c5fbfbb23f33004f
Diffstat (limited to 'lib/inets/src/http_server/mod_esi.erl')
-rw-r--r--lib/inets/src/http_server/mod_esi.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl
index 3206d957d9..9fbedce6aa 100644
--- a/lib/inets/src/http_server/mod_esi.erl
+++ b/lib/inets/src/http_server/mod_esi.erl
@@ -394,7 +394,16 @@ deliver_webpage_chunk(#mod{config_db = Db} = ModData, Pid, Timeout) ->
Continue;
{Headers, Body} ->
{ok, NewHeaders, StatusCode} = httpd_esi:handle_headers(Headers),
- IsDisableChunkedSend = httpd_response:is_disable_chunked_send(Db),
+ %% All 1xx (informational), 204 (no content), and 304 (not modified)
+ %% responses MUST NOT include a message-body, and thus are always
+ %% terminated by the first empty line after the header fields.
+ %% This implies that chunked encoding MUST NOT be used for these
+ %% status codes.
+ IsDisableChunkedSend =
+ httpd_response:is_disable_chunked_send(Db) orelse
+ StatusCode =:= 204 orelse %% No Content
+ StatusCode =:= 304 orelse %% Not Modified
+ (100 =< StatusCode andalso StatusCode =< 199), %% Informational
case (ModData#mod.http_version =/= "HTTP/1.1") or
(IsDisableChunkedSend) of
true ->
@@ -405,8 +414,8 @@ deliver_webpage_chunk(#mod{config_db = Db} = ModData, Pid, Timeout) ->
send_headers(ModData, StatusCode,
[{"transfer-encoding",
"chunked"} | NewHeaders])
- end,
- handle_body(Pid, ModData, Body, Timeout, length(Body),
+ end,
+ handle_body(Pid, ModData, Body, Timeout, length(Body),
IsDisableChunkedSend);
timeout ->
send_headers(ModData, 504, [{"connection", "close"}]),