Permalink
Browse files

Support all timezones for R14 series

  • Loading branch information...
1 parent b59ac98 commit 445e9190fc25e64d7f9d121cb2d2945743a02843 @rnewson rnewson committed Aug 15, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/mochiweb/mochiweb_request.erl
@@ -600,7 +600,7 @@ maybe_redirect(RelPath, FullPath, ExtraHeaders) ->
end.
maybe_serve_file(File, ExtraHeaders) ->
- case file:read_file_info(File, [{time, universal}]) of
+ case read_file_info(File) of
{ok, FileInfo} ->
LastModified = couch_util:rfc1123_date(FileInfo#file_info.mtime),
case get_header_value("if-modified-since") of
@@ -624,6 +624,25 @@ maybe_serve_file(File, ExtraHeaders) ->
not_found(ExtraHeaders)
end.
+read_file_info(File) ->
+ try
+ file:read_file_info(File, [{time, universal}])
+ catch error:undef ->
+ case file:read_file_info(File) of
+ {ok, FileInfo} ->
+ {ok, FileInfo#file_info{
+ atime=to_universal(FileInfo#file_info.atime),
+ mtime=to_universal(FileInfo#file_info.mtime),
+ ctime=to_universal(FileInfo#file_info.ctime)
+ }};
+ Else ->
+ Else
+ end
+ end.
+
+to_universal(LocalTime) ->
+ calendar:local_time_to_universal_time(LocalTime).
+
server_headers() ->
[{"Server", "MochiWeb/1.0 (" ++ ?QUIP ++ ")"},
{"Date", couch_util:rfc1123_date()}].

0 comments on commit 445e919

Please sign in to comment.