summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2013-03-19 23:16:07 +0100
committerDave Cottlehuber <dch@apache.org>2013-03-19 23:25:16 +0100
commit09b034911aed037839978d7e3f4905a4004fb74e (patch)
treeb7e55a1960da64d4d642dc573e6fffdfd5bd84eb
parentce495b256dc053d21807fae1b9bc330376d0d6fe (diff)
downloadcouchdb-1696-update-mochiweb-2-4-2.tar.gz
COUCHDB-627 - Support all timezones1696-update-mochiweb-2-4-2
Forward-ported over top of MochiWeb 2.4.2, comprising specific chunks of b1a049bb, 445e919, 010522e, 317c97f lost during MochiWeb upgrade. Some timezones are incorrectly handled by OTP's calendar module. The ironic thing is that we only ever need the time in GMT (for HTTP response headers and the log file). This patch duplicates httpd_util:rfc1123_date/0 and /1 but uses universal time everywhere, avoiding the broken conversion code. - Support all timezones for R14 series. - the _dst variant does exist in R14B04. - Fix local to universal handling. Also relates to COUCHDB-1513, a duplicate of COUCHDB-627.
-rw-r--r--src/mochiweb/mochiweb_cookies.erl4
-rw-r--r--src/mochiweb/mochiweb_request.erl6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mochiweb/mochiweb_cookies.erl b/src/mochiweb/mochiweb_cookies.erl
index 1cc4e91f3..3b71f4e18 100644
--- a/src/mochiweb/mochiweb_cookies.erl
+++ b/src/mochiweb/mochiweb_cookies.erl
@@ -50,9 +50,9 @@ cookie(Key, Value, Options) ->
RawAge ->
When = case proplists:get_value(local_time, Options) of
undefined ->
- calendar:local_time();
+ calendar:universal_time();
LocalTime ->
- LocalTime
+ calendar:local_time_to_universal_time_dst(LocalTime)
end,
Age = case RawAge < 0 of
true ->
diff --git a/src/mochiweb/mochiweb_request.erl b/src/mochiweb/mochiweb_request.erl
index 1b431d37a..2727fc731 100644
--- a/src/mochiweb/mochiweb_request.erl
+++ b/src/mochiweb/mochiweb_request.erl
@@ -621,9 +621,9 @@ maybe_redirect(RelPath, FullPath, ExtraHeaders,
end.
maybe_serve_file(File, ExtraHeaders, {?MODULE, [_Socket, _Method, _RawPath, _Version, _Headers]}=THIS) ->
- case file:read_file_info(File) of
+ case file:read_file_info(File, [{time, universal}]) of
{ok, FileInfo} ->
- LastModified = httpd_util:rfc1123_date(FileInfo#file_info.mtime),
+ LastModified = couch_util:rfc1123_date(FileInfo#file_info.mtime),
case get_header_value("if-modified-since", THIS) of
LastModified ->
respond({304, ExtraHeaders, ""}, THIS);
@@ -647,7 +647,7 @@ maybe_serve_file(File, ExtraHeaders, {?MODULE, [_Socket, _Method, _RawPath, _Ver
server_headers() ->
[{"Server", "MochiWeb/1.0 (" ++ ?QUIP ++ ")"},
- {"Date", httpd_util:rfc1123_date()}].
+ {"Date", couch_util:rfc1123_date()}].
make_code(X) when is_integer(X) ->
[integer_to_list(X), [" " | httpd_util:reason_phrase(X)]];