Skip to content

Commit

Permalink
Add cow_http_hd:allow/1
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Feb 10, 2025
1 parent 8e02c78 commit a277d91
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cow_http_hd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
-export([parse_access_control_request_method/1]).
-export([parse_age/1]).
-export([parse_allow/1]).
-export([allow/1]).
% @todo -export([parse_alternates/1]). RFC2295
% @todo -export([parse_authentication_info/1]). RFC2617
-export([parse_authorization/1]).
Expand Down Expand Up @@ -1018,6 +1019,22 @@ horse_parse_allow() ->
).
-endif.

-spec allow([binary()]) -> binary().
allow([]) ->
<<>>;
allow(Methods) ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- Methods >>,
Allow.

-ifdef(TEST).
allow_test_() ->
Tests = [
{[], <<>>},
{[<<"GET">>, <<"HEAD">>, <<"PUT">>], <<"GET, HEAD, PUT">>}
],
[{R, fun() -> R = allow(V) end} || {V, R} <- Tests].
-endif.

%% Authorization header.
%%
%% We support Basic, Digest and Bearer schemes only.
Expand Down

0 comments on commit a277d91

Please sign in to comment.