Skip to content

Commit

Permalink
handle empty list when parsing allowed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Feb 6, 2024
1 parent eded22d commit 3bc7b08
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cowboy_rest.erl
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,12 @@ uri_too_long(Req, State) ->
expect(Req, State, uri_too_long, false, fun allowed_methods/2, 414).

stringify_allowed_methods(MethodList) when is_list(MethodList) ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- MethodList >>,
Allow.
case MethodList of
[] -> <<>>;
_ ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- MethodList >>,
Allow
end.

%% allowed_methods/2 should return a list of binary methods.
allowed_methods(Req, State=#state{method=Method}) ->
Expand Down

0 comments on commit 3bc7b08

Please sign in to comment.