Skip to content

Commit a277d91

Browse files
committed
Add cow_http_hd:allow/1
1 parent 8e02c78 commit a277d91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/cow_http_hd.erl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
-export([parse_access_control_request_method/1]).
4141
-export([parse_age/1]).
4242
-export([parse_allow/1]).
43+
-export([allow/1]).
4344
% @todo -export([parse_alternates/1]). RFC2295
4445
% @todo -export([parse_authentication_info/1]). RFC2617
4546
-export([parse_authorization/1]).
@@ -1018,6 +1019,22 @@ horse_parse_allow() ->
10181019
).
10191020
-endif.
10201021

1022+
-spec allow([binary()]) -> binary().
1023+
allow([]) ->
1024+
<<>>;
1025+
allow(Methods) ->
1026+
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- Methods >>,
1027+
Allow.
1028+
1029+
-ifdef(TEST).
1030+
allow_test_() ->
1031+
Tests = [
1032+
{[], <<>>},
1033+
{[<<"GET">>, <<"HEAD">>, <<"PUT">>], <<"GET, HEAD, PUT">>}
1034+
],
1035+
[{R, fun() -> R = allow(V) end} || {V, R} <- Tests].
1036+
-endif.
1037+
10211038
%% Authorization header.
10221039
%%
10231040
%% We support Basic, Digest and Bearer schemes only.

0 commit comments

Comments
 (0)