Diff
Modified: branches/safari-601-branch/LayoutTests/ChangeLog (190493 => 190494)
--- branches/safari-601-branch/LayoutTests/ChangeLog 2015-10-02 13:56:56 UTC (rev 190493)
+++ branches/safari-601-branch/LayoutTests/ChangeLog 2015-10-02 13:57:02 UTC (rev 190494)
@@ -1,5 +1,32 @@
2015-10-02 Matthew Hanson <[email protected]>
+ Merge r188690. rdar://problem/22802006
+
+ 2015-08-20 Chris Dumez <[email protected]>
+
+ [Cocoa] Treat Epoch as invalid value for "Last-Modified" header
+ https://bugs.webkit.org/show_bug.cgi?id=148162
+ rdar://problem/22330837
+
+ Reviewed by Antti Koivisto.
+
+ Add better layout test coverage for using the "Last-Modified" header to
+ compute heuristic freshness. In particular, it adds coverage for the
+ following values: Epoch, malformed date.
+
+ * http/tests/cache/disk-cache/disk-cache-last-modified-expected.txt: Added.
+ * http/tests/cache/disk-cache/disk-cache-last-modified.html: Added.
+ New test.
+
+ * http/tests/cache/disk-cache/resources/cache-test.js:
+ (makeHeaderValue):
+ makeHeaderValue() was not resolving 'now(-1000)' into a date. This means that the
+ tests using it would end up sending an invalid "Last-Modified" header which our
+ networking code was translating to Epoch. We now ignore Epoch as Last-Modified
+ value for computing heuristic freshness to not cache due to malformed headers.
+
+2015-10-02 Matthew Hanson <[email protected]>
+
Merge r188640. rdar://problem/22802005
2015-08-19 Chris Dumez <[email protected]>
Added: branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified-expected.txt (0 => 190494)
--- branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified-expected.txt (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified-expected.txt 2015-10-02 13:57:02 UTC (rev 190494)
@@ -0,0 +1,41 @@
+Covers uses of 'Last-Modified' header to compute heuristic freshness.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 3 tests
+
+--------Testing loads from disk cache--------
+response headers: {"Last-Modified":"Thu, 01 Jan 2000 00:00:00 GMT"}
+response source: Disk cache
+
+response headers: {"Last-Modified":"Thu, 01 Jan 1970 00:00:00 GMT"}
+response source: Network
+
+response headers: {"Last-Modified":"invalid"}
+response source: Network
+
+--------Testing loads through memory cache (XHR behavior)--------
+response headers: {"Last-Modified":"Thu, 01 Jan 2000 00:00:00 GMT"}
+response source: Memory cache
+
+response headers: {"Last-Modified":"Thu, 01 Jan 1970 00:00:00 GMT"}
+response source: Network
+
+response headers: {"Last-Modified":"invalid"}
+response source: Network
+
+--------Testing loads through memory cache (subresource behavior)--------
+response headers: {"Last-Modified":"Thu, 01 Jan 2000 00:00:00 GMT"}
+response source: Memory cache
+
+response headers: {"Last-Modified":"Thu, 01 Jan 1970 00:00:00 GMT"}
+response source: Network
+
+response headers: {"Last-Modified":"invalid"}
+response source: Network
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified.html (0 => 190494)
--- branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified.html (rev 0)
+++ branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/disk-cache-last-modified.html 2015-10-02 13:57:02 UTC (rev 190494)
@@ -0,0 +1,21 @@
+<script src=""
+<script src=""
+<body>
+<script>
+
+var tests =
+[
+ { responseHeaders: {'Last-Modified': 'Thu, 01 Jan 2000 00:00:00 GMT' } }, // Heuristic freshness.
+ { responseHeaders: {'Last-Modified': 'Thu, 01 Jan 1970 00:00:00 GMT' } }, // Epoch.
+ { responseHeaders: {'Last-Modified': 'invalid' } }, // Invalid date
+];
+
+description("Covers uses of 'Last-Modified' header to compute heuristic freshness.");
+
+debug("running " + tests.length + " tests");
+debug("");
+
+runTests(tests);
+
+</script>
+<script src=""
Modified: branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js (190493 => 190494)
--- branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js 2015-10-02 13:56:56 UTC (rev 190493)
+++ branches/safari-601-branch/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js 2015-10-02 13:57:02 UTC (rev 190494)
@@ -33,6 +33,8 @@
return (new Date(new Date().getTime() + serverClientTimeDelta)).toUTCString();
if (value == 'now(100)')
return (new Date(new Date().getTime() + serverClientTimeDelta + 100 * 1000)).toUTCString();
+ if (value == 'now(-1000)')
+ return (new Date(new Date().getTime() - serverClientTimeDelta - 1000 * 1000)).toUTCString()
if (value == 'unique()')
return "" + uniqueIdCounter++;
return value;
Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (190493 => 190494)
--- branches/safari-601-branch/Source/WebCore/ChangeLog 2015-10-02 13:56:56 UTC (rev 190493)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog 2015-10-02 13:57:02 UTC (rev 190494)
@@ -1,5 +1,33 @@
2015-10-02 Matthew Hanson <[email protected]>
+ Merge r188690. rdar://problem/22802006
+
+ 2015-08-20 Chris Dumez <[email protected]>
+
+ [Cocoa] Treat Epoch as invalid value for "Last-Modified" header
+ https://bugs.webkit.org/show_bug.cgi?id=148162
+ rdar://problem/22330837
+
+ Reviewed by Antti Koivisto.
+
+ Ignore "Last-Modified" header when computing heuristic freshness if it
+ is Epoch. CFNetwork currently converts a malformed date for Last-Modified
+ into Epoch so there is no way for us to distinguish Epoch from invalid
+ input. Without this, we would end up with cached resources that have a
+ giant lifetime (> 4 years) due to a malformed HTTP header.
+
+ Some Websites (e.g. www.popehat.com) also wrongly return Epoch as
+ Last-Modified value and we would end up caching it overly aggressively.
+ Now that we consider Epoch as an invalid value for Last-Modified, it will
+ also work around this content bug.
+
+ Test: http/tests/cache/disk-cache/disk-cache-last-modified.html
+
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::lastModified):
+
+2015-10-02 Matthew Hanson <[email protected]>
+
Merge r189102. rdar://problem/22802034
2015-08-28 Timothy Horton <[email protected]>
Modified: branches/safari-601-branch/Source/WebCore/platform/network/ResourceResponseBase.cpp (190493 => 190494)
--- branches/safari-601-branch/Source/WebCore/platform/network/ResourceResponseBase.cpp 2015-10-02 13:56:56 UTC (rev 190493)
+++ branches/safari-601-branch/Source/WebCore/platform/network/ResourceResponseBase.cpp 2015-10-02 13:57:02 UTC (rev 190494)
@@ -425,6 +425,13 @@
if (!m_haveParsedLastModifiedHeader) {
m_lastModified = parseDateValueInHeader(m_httpHeaderFields, HTTPHeaderName::LastModified);
+#if PLATFORM(COCOA)
+ // CFNetwork converts malformed dates into Epoch so we need to treat Epoch as
+ // an invalid value (rdar://problem/22352838).
+ const std::chrono::system_clock::time_point epoch;
+ if (m_lastModified && m_lastModified.value() == epoch)
+ m_lastModified = Nullopt;
+#endif
m_haveParsedLastModifiedHeader = true;
}
return m_lastModified;