summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2014-03-11 13:47:11 +0000
committerbdrewery <bdrewery@FreeBSD.org>2014-03-11 13:47:11 +0000
commitef589c91da3d72a1fc035e8c70d4196a7c8f2d3e (patch)
tree0ce3c12676d03889bf5f8e00f5b808a7b11fbdd1
parent446e208ee2930dfe281158c48b8376365820cab9 (diff)
downloadFreeBSD-src-ef589c91da3d72a1fc035e8c70d4196a7c8f2d3e.zip
FreeBSD-src-ef589c91da3d72a1fc035e8c70d4196a7c8f2d3e.tar.gz
Support Last-Modified behind proxies which return UTC instead of GMT.
The standard states that GMT must be used, but that UTC is equivalent. Still parse UTC as otherwise this causes problems for pkg(8). It will refetch the repository every time 'pkg update' or other remote operations are used behind these proxies. RFC2616: "All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception. For the purposes of HTTP, GMT is exactly equal to UTC (Coordinated Universal Time)."" Approved by: bapt (mentor) Reviewed by: des, peter Sponsored by: EMC / Isilon Storage Division MFC after: 1 week
-rw-r--r--lib/libfetch/http.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index b2feedb..cbbb8a8 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -876,6 +876,12 @@ http_parse_mtime(const char *p, time_t *mtime)
strncpy(locale, setlocale(LC_TIME, NULL), sizeof(locale));
setlocale(LC_TIME, "C");
r = strptime(p, "%a, %d %b %Y %H:%M:%S GMT", &tm);
+ /*
+ * Some proxies use UTC in response, but it should still be
+ * parsed. RFC2616 states GMT and UTC are exactly equal for HTTP.
+ */
+ if (r == NULL)
+ r = strptime(p, "%a, %d %b %Y %H:%M:%S UTC", &tm);
/* XXX should add support for date-2 and date-3 */
setlocale(LC_TIME, locale);
if (r == NULL)
OpenPOWER on IntegriCloud