aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-10-08 15:07:01 +0200
committerPéter Dimitrov <[email protected]>2018-10-08 15:07:01 +0200
commit21e5a830ddcdb6efe62d46f491d7aa07e0184c89 (patch)
tree01a3b3a8a2f918b9d54a3322d149357124ac47a9 /lib/inets/src/http_client
parent89aa002c83e490ea59606a472f190e75ed1af5a2 (diff)
parentd95cfc3b4a8ea1bbd8ad6c90f1e00b0150a87d7e (diff)
downloadotp-21e5a830ddcdb6efe62d46f491d7aa07e0184c89.tar.gz
otp-21e5a830ddcdb6efe62d46f491d7aa07e0184c89.tar.bz2
otp-21e5a830ddcdb6efe62d46f491d7aa07e0184c89.zip
Merge branch 'peterdmv/inets/httpc-content-type/ERL-736/OTP-15339' into maint
* peterdmv/inets/httpc-content-type/ERL-736/OTP-15339: inets: Fix handling of 'Content-Type' (httpc) Change-Id: I8c9f48d8474dba7a83e4ecba6b8146faffb559fc
Diffstat (limited to 'lib/inets/src/http_client')
-rw-r--r--lib/inets/src/http_client/httpc_request.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/inets/src/http_client/httpc_request.erl b/lib/inets/src/http_client/httpc_request.erl
index 9db961cf9e..0f20d93bc1 100644
--- a/lib/inets/src/http_client/httpc_request.erl
+++ b/lib/inets/src/http_client/httpc_request.erl
@@ -213,9 +213,11 @@ update_body(Headers, Body) ->
update_headers(Headers, ContentType, Body, []) ->
case Body of
[] ->
- Headers#http_request_h{'content-length' = "0"};
+ Headers1 = Headers#http_request_h{'content-length' = "0"},
+ handle_content_type(Headers1, ContentType);
<<>> ->
- Headers#http_request_h{'content-length' = "0"};
+ Headers1 = Headers#http_request_h{'content-length' = "0"},
+ handle_content_type(Headers1, ContentType);
{Fun, _Acc} when is_function(Fun, 1) ->
%% A client MUST NOT generate a 100-continue expectation in a request
%% that does not include a message body. This implies that either the
@@ -245,6 +247,12 @@ body_length(Body) when is_binary(Body) ->
body_length(Body) when is_list(Body) ->
integer_to_list(length(Body)).
+%% Set 'Content-Type' when it is explicitly set.
+handle_content_type(Headers, "") ->
+ Headers;
+handle_content_type(Headers, ContentType) ->
+ Headers#http_request_h{'content-type' = ContentType}.
+
method(Method) ->
http_util:to_upper(atom_to_list(Method)).