aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server/httpd_custom.erl
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2015-10-06 11:03:55 +0200
committerHenrik Nord <[email protected]>2015-10-06 11:03:55 +0200
commitb99010e5f188097fd9a83204ac6ce2dcd048e640 (patch)
tree2b789952bc80fd1585dde569116cc604f9962ab7 /lib/inets/src/http_server/httpd_custom.erl
parent7283245d4a3fd6b59f0b0f2748cad5c61733622d (diff)
parent4f9905824002bebc33c2914669b4c364927cb0ee (diff)
downloadotp-b99010e5f188097fd9a83204ac6ce2dcd048e640.tar.gz
otp-b99010e5f188097fd9a83204ac6ce2dcd048e640.tar.bz2
otp-b99010e5f188097fd9a83204ac6ce2dcd048e640.zip
Merge branch 'maint'
Conflicts: OTP_VERSION
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, "-"),