0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

handle empty list when parsing allowed methods

This commit is contained in:
geeksilva97 2024-02-06 10:21:17 -03:00
parent eded22d1aa
commit 3bc7b08e3d

View file

@ -325,8 +325,12 @@ uri_too_long(Req, State) ->
expect(Req, State, uri_too_long, false, fun allowed_methods/2, 414). expect(Req, State, uri_too_long, false, fun allowed_methods/2, 414).
stringify_allowed_methods(MethodList) when is_list(MethodList) -> stringify_allowed_methods(MethodList) when is_list(MethodList) ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- MethodList >>, case MethodList of
Allow. [] -> <<>>;
_ ->
<< ", ", Allow/binary >> = << << ", ", M/binary >> || M <- MethodList >>,
Allow
end.
%% allowed_methods/2 should return a list of binary methods. %% allowed_methods/2 should return a list of binary methods.
allowed_methods(Req, State=#state{method=Method}) -> allowed_methods(Req, State=#state{method=Method}) ->