aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_http_hd.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/cow_http_hd.erl')
-rw-r--r--src/cow_http_hd.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl
index 4207b19..4496949 100644
--- a/src/cow_http_hd.erl
+++ b/src/cow_http_hd.erl
@@ -117,6 +117,7 @@
-export([access_control_allow_methods/1]).
-export([access_control_allow_origin/1]).
-export([access_control_expose_headers/1]).
+-export([access_control_max_age/1]).
-type etag() :: {weak | strong, binary()}.
-export_type([etag/0]).
@@ -3344,6 +3345,24 @@ horse_access_control_expose_headers() ->
).
-endif.
+%% @doc Build the Access-Control-Max-Age header.
+
+-spec access_control_max_age(non_neg_integer()) -> iodata().
+access_control_max_age(MaxAge) -> integer_to_binary(MaxAge).
+
+-ifdef(TEST).
+access_control_max_age_test_() ->
+ Tests = [
+ {0, <<"0">>},
+ {42, <<"42">>},
+ {69, <<"69">>},
+ {1337, <<"1337">>},
+ {3495, <<"3495">>},
+ {1234567890, <<"1234567890">>}
+ ],
+ [{V, fun() -> R = access_control_max_age(V) end} || {V, R} <- Tests].
+-endif.
+
%% Internal.
%% Only return if the list is not empty.