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

Use read_file_info/2 with {time, universal} option

This commit is contained in:
Sergey Rublev 2013-06-07 21:44:58 +07:00
parent 1fc69977da
commit d6c9bb27ad

View file

@ -233,7 +233,7 @@ rest_init(Req, Opts) ->
end. end.
rest_init(Req, Opts, Filepath) -> rest_init(Req, Opts, Filepath) ->
Fileinfo = file:read_file_info(Filepath), Fileinfo = file:read_file_info(Filepath, [{time, universal}]),
Mimetypes = case lists:keyfind(mimetypes, 1, Opts) of Mimetypes = case lists:keyfind(mimetypes, 1, Opts) of
false -> {fun path_to_mimetypes/2, []}; false -> {fun path_to_mimetypes/2, []};
{_, {{M, F}, E}} -> {fun M:F/2, E}; {_, {{M, F}, E}} -> {fun M:F/2, E};
@ -290,7 +290,7 @@ forbidden(Req, #state{fileinfo={ok, #file_info{access=Access}}}=State) ->
-spec last_modified(Req, #state{}) -spec last_modified(Req, #state{})
-> {calendar:datetime(), Req, #state{}} when Req::cowboy_req:req(). -> {calendar:datetime(), Req, #state{}} when Req::cowboy_req:req().
last_modified(Req, #state{fileinfo={ok, #file_info{mtime=Modified}}}=State) -> last_modified(Req, #state{fileinfo={ok, #file_info{mtime=Modified}}}=State) ->
{erlang:localtime_to_universaltime(Modified), Req, State}. {Modified, Req, State}.
%% @private Generate the ETag header value for this file. %% @private Generate the ETag header value for this file.
%% The ETag header value is only generated if the resource is a file that %% The ETag header value is only generated if the resource is a file that