aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server/httpd_custom.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2015-10-05 11:00:48 +0200
committerErlang/OTP <[email protected]>2015-10-05 11:00:48 +0200
commitcf1351a19b7c3edd613d1c8cde139f917f7583cb (patch)
tree9de64d7e8d87d7e6b494f209c0d3529a572806cc /lib/inets/src/http_server/httpd_custom.erl
parent1523be48ab4071b158412f4b06fe9c8d6ba3e73c (diff)
parentc4bd1ea37ac2ace2bed1b82962248efb3e780b5d (diff)
downloadotp-cf1351a19b7c3edd613d1c8cde139f917f7583cb.tar.gz
otp-cf1351a19b7c3edd613d1c8cde139f917f7583cb.tar.bz2
otp-cf1351a19b7c3edd613d1c8cde139f917f7583cb.zip
Merge branch 'ia/inets/custom-header-add-default/OTP-13013' into maint-18
* ia/inets/custom-header-add-default/OTP-13013: inets: Prepare for release inets: Add new customize function response_default_headers inets: Add behaviour httpd_custom_api
Diffstat (limited to 'lib/inets/src/http_server/httpd_custom.erl')
-rw-r--r--lib/inets/src/http_server/httpd_custom.erl31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/inets/src/http_server/httpd_custom.erl b/lib/inets/src/http_server/httpd_custom.erl
index a1fe058bd1..2b9701ef75 100644
--- a/lib/inets/src/http_server/httpd_custom.erl
+++ b/lib/inets/src/http_server/httpd_custom.erl
@@ -20,16 +20,27 @@
%%
-module(httpd_custom).
--export([response_header/1, request_header/1]).
--export([customize_headers/3]).
+-export([response_header/1, request_header/1, response_default_headers/0]).
+-export([customize_headers/3, response_default_headers/1]).
--include_lib("inets/src/inets_app/inets_internal.hrl").
+-include("../inets_app/inets_internal.hrl").
+
+-behaviour(httpd_custom_api).
+
+%%--------------------------------------------------------------------
+%% Behavior API -----------------------------------
+%%--------------------------------------------------------------------
response_header(Header) ->
{true, httpify(Header)}.
request_header(Header) ->
{true, Header}.
+response_default_headers() ->
+ [].
+%%--------------------------------------------------------------------
+%% Internal API -----------------------------------
+%%--------------------------------------------------------------------
customize_headers(?MODULE, Function, Arg) ->
?MODULE:Function(Arg);
customize_headers(Module, Function, Arg) ->
@@ -43,6 +54,20 @@ customize_headers(Module, Function, Arg) ->
?MODULE:Function(Arg)
end.
+response_default_headers(?MODULE) ->
+ response_default_headers();
+response_default_headers(Module) ->
+ try Module:response_default_headers() of
+ Defaults ->
+ [{http_util:to_lower(Key), Value} || {Key, Value} <- Defaults,
+ is_list(Key), is_list(Value)]
+ catch
+ _:_ ->
+ ?MODULE:response_default_headers()
+ end.
+%%--------------------------------------------------------------------
+%% Internal functions -----------------------------------
+%%--------------------------------------------------------------------
httpify({Key0, Value}) ->
%% make sure first letter is capital (defacto standard)
Words1 = string:tokens(Key0, "-"),