aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_lib
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2017-03-31 12:58:34 +0200
committerErlang/OTP <[email protected]>2017-03-31 12:58:34 +0200
commitcb1b5ecaf0fb8740e114b127efd0b86f279e9f7f (patch)
tree8e11b23e22f8ee2699d1673015e94d34372a8774 /lib/inets/src/http_lib
parent42d3750f90f729b0aaa6e77a6e621e3d3798b76a (diff)
parenta13e73d70d2af0a686701a3c8b16b82b664abd19 (diff)
downloadotp-cb1b5ecaf0fb8740e114b127efd0b86f279e9f7f.tar.gz
otp-cb1b5ecaf0fb8740e114b127efd0b86f279e9f7f.tar.bz2
otp-cb1b5ecaf0fb8740e114b127efd0b86f279e9f7f.zip
Merge branch 'voltone/inets/httpc_redirect_normalize_host/PR-1381/OTP-14301' into maint-19
* voltone/inets/httpc_redirect_normalize_host/PR-1381/OTP-14301: Omit port from Host header on redirect to well-known port
Diffstat (limited to 'lib/inets/src/http_lib')
-rw-r--r--lib/inets/src/http_lib/http_request.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/inets/src/http_lib/http_request.erl b/lib/inets/src/http_lib/http_request.erl
index c77b616f0d..4c50edb5ef 100644
--- a/lib/inets/src/http_lib/http_request.erl
+++ b/lib/inets/src/http_lib/http_request.erl
@@ -22,7 +22,7 @@
-include("http_internal.hrl").
--export([headers/2, http_headers/1, is_absolut_uri/1, key_value/1]).
+-export([headers/2, http_headers/1, is_absolut_uri/1, key_value/1, normalize_host/3]).
key_value(KeyValueStr) ->
@@ -85,6 +85,22 @@ is_absolut_uri("https://" ++ _) ->
is_absolut_uri(_) ->
false.
+%%-------------------------------------------------------------------------
+%% normalize_host(Scheme, Host, Port) -> string()
+%% Scheme - http | https
+%% Host - string()
+%% Port - integer()
+%%
+%% Description: returns a normalized Host header value, with the port
+%% number omitted for well-known ports
+%%-------------------------------------------------------------------------
+normalize_host(https, Host, 443 = _Port) ->
+ Host;
+normalize_host(http, Host, 80 = _Port) ->
+ Host;
+normalize_host(_Scheme, Host, Port) ->
+ Host ++ ":" ++ integer_to_list(Port).
+
%%%========================================================================
%%% Internal functions
%%%========================================================================