aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/httpc_SUITE.erl
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-04-17 10:00:54 +0200
committerPéter Dimitrov <[email protected]>2018-04-17 10:00:54 +0200
commite2dadbf64f36f4f05347d0ef9c22adf350a23365 (patch)
treea6afe06be763b0b227427063f2467ff0b3de4279 /lib/inets/test/httpc_SUITE.erl
parent40dc6b9fed7d51a204e0d69b7bba7e8cb6496ae5 (diff)
parentfd2af907bc854e5dc92fbd71efdab096be572573 (diff)
downloadotp-e2dadbf64f36f4f05347d0ef9c22adf350a23365.tar.gz
otp-e2dadbf64f36f4f05347d0ef9c22adf350a23365.tar.bz2
otp-e2dadbf64f36f4f05347d0ef9c22adf350a23365.zip
Merge branch 'peterdmv/httpc_delete_requests/ERL-536/OTP-15006'
* peterdmv/httpc_delete_requests/ERL-536/OTP-15006: inets: Fix broken handling of header Content-Type Change-Id: I8d6f23d830961f71a198377351f14b0e97dcd44b
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r--lib/inets/test/httpc_SUITE.erl29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
index 1116fdb1b6..cd14476f9d 100644
--- a/lib/inets/test/httpc_SUITE.erl
+++ b/lib/inets/test/httpc_SUITE.erl
@@ -151,6 +151,7 @@ only_simulated() ->
relaxed,
multipart_chunks,
get_space,
+ delete_no_body,
stream_fun_server_close
].
@@ -1375,7 +1376,16 @@ unix_domain_socket(Config) when is_list(Config) ->
= httpc:request(put, {URL, [], [], ""}, [], []),
{ok, {{_,200,_}, [_ | _], _}}
= httpc:request(get, {URL, []}, [], []).
-
+%%-------------------------------------------------------------------------
+delete_no_body(doc) ->
+ ["Test that a DELETE request without Body does not send a Content-Type header - Solves ERL-536"];
+delete_no_body(Config) when is_list(Config) ->
+ URL = url(group_name(Config), "/delete_no_body.html", Config),
+ %% Simulated server replies 500 if 'Content-Type' header is present
+ {ok, {{_,200,_}, _, _}} =
+ httpc:request(delete, {URL, []}, [], []),
+ {ok, {{_,500,_}, _, _}} =
+ httpc:request(delete, {URL, [], "text/plain", "TEST"}, [], []).
%%--------------------------------------------------------------------
@@ -1882,6 +1892,13 @@ auth_header([{"authorization", Value} | _]) ->
auth_header([_ | Tail]) ->
auth_header(Tail).
+content_type_header([]) ->
+ not_found;
+content_type_header([{"content-type", Value}|_]) ->
+ {ok, string:strip(Value)};
+content_type_header([_|T]) ->
+ content_type_header(T).
+
handle_auth("Basic " ++ UserInfo, Challange, DefaultResponse) ->
case string:tokens(base64:decode_to_string(UserInfo), ":") of
["alladin", "sesame"] = Auth ->
@@ -2312,7 +2329,15 @@ handle_uri(_,"/http_1_1_send_oct_and_connection_close.html",_,_,Socket,_) ->
"X-Socket-Stat-Send-Oct: " ++ integer_to_list(get_stat(Socket, send_oct)) ++ "\r\n" ++
"Connection: close\r\n" ++
"\r\n";
-
+handle_uri(_,"/delete_no_body.html", _,Headers,_, DefaultResponse) ->
+ Error = "HTTP/1.1 500 Internal Server Error\r\n" ++
+ "Content-Length:0\r\n\r\n",
+ case content_type_header(Headers) of
+ {ok, _} ->
+ Error;
+ not_found ->
+ DefaultResponse
+ end;
handle_uri(_,_,_,_,_,DefaultResponse) ->
DefaultResponse.