summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shorin <kxepal@apache.org>2016-03-06 17:24:56 +0300
committerAlexander Shorin <kxepal@apache.org>2016-03-06 21:46:36 +0300
commit051cdc36cb0b7c9104204ea54abd02115b3d848f (patch)
tree68eaef925102c766fd9674f6ec97bbcaf95f08a7
parent921006fa49b362e5673a6aae4586e832ec325dc6 (diff)
downloadcouchdb-051cdc36cb0b7c9104204ea54abd02115b3d848f.tar.gz
Fix favicon caching on leap year
COUCHDB-2956
-rw-r--r--src/couchdb/couch_httpd_misc_handlers.erl8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index 20a1bf30f..dbf698c0a 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -45,12 +45,14 @@ handle_welcome_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) ->
- {{Year,Month,Day},Time} = erlang:universaltime(),
- OneYearFromNow = {{Year+1,Month,Day},Time},
+ {DateNow, TimeNow} = calendar:universal_time(),
+ DaysNow = calendar:date_to_gregorian_days(DateNow),
+ DaysWhenExpires = DaysNow + 365,
+ DateWhenExpires = calendar:gregorian_days_to_date(DaysWhenExpires),
CachingHeaders = [
%favicon should expire a year from now
{"Cache-Control", "public, max-age=31536000"},
- {"Expires", couch_util:rfc1123_date(OneYearFromNow)}
+ {"Expires", couch_util:rfc1123_date({DateWhenExpires, TimeNow})}
],
couch_httpd:serve_file(Req, "favicon.ico", DocumentRoot, CachingHeaders);