mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Silence expected errors from the static_handler test suite
This commit is contained in:
parent
d2f367fba3
commit
84aea5d24d
2 changed files with 29 additions and 9 deletions
|
@ -120,7 +120,7 @@ init_dir(Req, Path, HowToAccess, Extra) when is_list(Path) ->
|
|||
init_dir(Req, Path, HowToAccess, Extra) ->
|
||||
Dir = fullpath(filename:absname(Path)),
|
||||
PathInfo = cowboy_req:path_info(Req),
|
||||
Filepath = filename:join([Dir|[escape_reserved(P, <<>>) || P <- PathInfo]]),
|
||||
Filepath = filename:join([Dir|escape_reserved(PathInfo)]),
|
||||
Len = byte_size(Dir),
|
||||
case fullpath(Filepath) of
|
||||
<< Dir:Len/binary, $/, _/binary >> ->
|
||||
|
@ -131,6 +131,9 @@ init_dir(Req, Path, HowToAccess, Extra) ->
|
|||
{cowboy_rest, Req, error}
|
||||
end.
|
||||
|
||||
escape_reserved([]) -> [];
|
||||
escape_reserved([P|Tail]) -> [escape_reserved(P, <<>>)|escape_reserved(Tail)].
|
||||
|
||||
%% We escape the slash found in path segments because
|
||||
%% a segment corresponds to a directory entry, and
|
||||
%% therefore those slashes are expected to be part of
|
||||
|
@ -315,7 +318,7 @@ forbidden(Req, State) ->
|
|||
-spec content_types_provided(Req, State)
|
||||
-> {[{binary(), get_file}], Req, State}
|
||||
when State::state().
|
||||
content_types_provided(Req, State={Path, _, Extra}) ->
|
||||
content_types_provided(Req, State={Path, _, Extra}) when is_list(Extra) ->
|
||||
case lists:keyfind(mimetypes, 1, Extra) of
|
||||
false ->
|
||||
{[{cow_mimetypes:web(Path), get_file}], Req, State};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue