aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server/httpd_esi.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2017-10-24 17:55:24 +0200
committerIngela Anderton Andin <[email protected]>2017-11-01 10:53:17 +0100
commit2cc5ba70cbbc6b3ace81a2a0324417c3b65265bb (patch)
treeb8fc8b1e746933fc89f838f32c31b8c8d39a2801 /lib/inets/src/http_server/httpd_esi.erl
parenta98379d0519c28f9bc9b673ed2c09fb1ad52456e (diff)
downloadotp-2cc5ba70cbbc6b3ace81a2a0324417c3b65265bb.tar.gz
otp-2cc5ba70cbbc6b3ace81a2a0324417c3b65265bb.tar.bz2
otp-2cc5ba70cbbc6b3ace81a2a0324417c3b65265bb.zip
inets: httpd - do not hardcode 302 status for location
If a status code is provide by the ESI script that status code should have precedence over internal defaults. Also remove RFC 2616 requirement that URI must be absolute, that requirement is relaxed by RFC 7231.
Diffstat (limited to 'lib/inets/src/http_server/httpd_esi.erl')
-rw-r--r--lib/inets/src/http_server/httpd_esi.erl25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/inets/src/http_server/httpd_esi.erl b/lib/inets/src/http_server/httpd_esi.erl
index 9406b47802..fd50934d00 100644
--- a/lib/inets/src/http_server/httpd_esi.erl
+++ b/lib/inets/src/http_server/httpd_esi.erl
@@ -66,7 +66,7 @@ handle_headers("") ->
{ok, [], 200};
handle_headers(Headers) ->
NewHeaders = string:tokens(Headers, ?CRLF),
- handle_headers(NewHeaders, [], 200).
+ handle_headers(NewHeaders, [], 200, true).
%%%========================================================================
%%% Internal functions
@@ -80,21 +80,17 @@ parse_headers([?CR, ?LF, ?CR, ?LF | Rest], Acc) ->
parse_headers([Char | Rest], Acc) ->
parse_headers(Rest, [Char | Acc]).
-handle_headers([], NewHeaders, StatusCode) ->
+handle_headers([], NewHeaders, StatusCode, _) ->
{ok, NewHeaders, StatusCode};
-handle_headers([Header | Headers], NewHeaders, StatusCode) ->
+handle_headers([Header | Headers], NewHeaders, StatusCode, NoESIStatus) ->
{FieldName, FieldValue} = httpd_response:split_header(Header, []),
case FieldName of
"location" ->
- case http_request:is_absolut_uri(FieldValue) of
- true ->
- handle_headers(Headers,
- [{FieldName, FieldValue} | NewHeaders],
- 302);
- false ->
- {proceed, FieldValue}
- end;
+ handle_headers(Headers,
+ [{FieldName, FieldValue} | NewHeaders],
+ 302, NoESIStatus);
+
"status" ->
NewStatusCode =
case httpd_util:split(FieldValue," ",2) of
@@ -103,8 +99,9 @@ handle_headers([Header | Headers], NewHeaders, StatusCode) ->
_ ->
200
end,
- handle_headers(Headers, NewHeaders, NewStatusCode);
+ handle_headers(Headers, NewHeaders, NewStatusCode, false);
_ ->
handle_headers(Headers,
- [{FieldName, FieldValue}| NewHeaders], StatusCode)
- end.
+ [{FieldName, FieldValue}| NewHeaders], StatusCode,
+ NoESIStatus)
+ end.