From b448c4fde627f27793b74965043e113f78cfb8d0 Mon Sep 17 00:00:00 2001 From: Andrei Nesterov Date: Sun, 6 Mar 2016 19:30:17 +0300 Subject: Add cow_http_hd:access_control_max_age/1 --- src/cow_http_hd.erl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/cow_http_hd.erl') 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. -- cgit v1.2.3