diff options
author | Henrik Nord <[email protected]> | 2015-10-06 11:03:55 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2015-10-06 11:03:55 +0200 |
commit | b99010e5f188097fd9a83204ac6ce2dcd048e640 (patch) | |
tree | 2b789952bc80fd1585dde569116cc604f9962ab7 /lib/inets/src/http_server/httpd_custom.erl | |
parent | 7283245d4a3fd6b59f0b0f2748cad5c61733622d (diff) | |
parent | 4f9905824002bebc33c2914669b4c364927cb0ee (diff) | |
download | otp-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.erl | 31 |
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, "-"), |