Title: [200326] trunk
Revision
200326
Author
[email protected]
Date
2016-05-02 11:05:46 -0700 (Mon, 02 May 2016)

Log Message

Do not reuse cache entries with conditional headers
https://bugs.webkit.org/show_bug.cgi?id=157205
rdar://problem/25856933

Reviewed by Chris Dumez.

Source/WebCore:

Test: http/tests/xmlhttprequest/if-modified-since-0.html

* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::canReuse):
CachedResourceLoader::determineRevalidationPolicy asserts that the request is not conditional,
which means that it does not have any headers like If-Modified-Since.  They are usually different,
because we put the timestamp in the If-Modified-Since header, so it fails the canReuse test because
time has passed since the last If-Modified-Since header was sent.  When a user sets the If-Modified-Since
manually to something that is constant, we reuse cache entries when we should not.
* platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
(-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]):
Set the source so we can use it in Internals.

LayoutTests:

* http/tests/xmlhttprequest/if-modified-since-0-expected.txt: Added.
* http/tests/xmlhttprequest/if-modified-since-0.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200325 => 200326)


--- trunk/LayoutTests/ChangeLog	2016-05-02 17:38:15 UTC (rev 200325)
+++ trunk/LayoutTests/ChangeLog	2016-05-02 18:05:46 UTC (rev 200326)
@@ -1,3 +1,14 @@
+2016-04-29  Alex Christensen  <[email protected]>
+
+        Do not reuse cache entries with conditional headers
+        https://bugs.webkit.org/show_bug.cgi?id=157205
+        rdar://problem/25856933
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/xmlhttprequest/if-modified-since-0-expected.txt: Added.
+        * http/tests/xmlhttprequest/if-modified-since-0.html: Added.
+
 2016-05-01  Skachkov Oleksandr  <[email protected]>
 
         Class contructor and methods shouldn't have "arguments" and "caller"

Added: trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0-expected.txt (0 => 200326)


--- trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0-expected.txt	2016-05-02 18:05:46 UTC (rev 200326)
@@ -0,0 +1,3 @@
+ALERT: PASS
+ALERT: PASS
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0.html (0 => 200326)


--- trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/if-modified-since-0.html	2016-05-02 18:05:46 UTC (rev 200326)
@@ -0,0 +1,29 @@
+<script>
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var req1 = new XMLHttpRequest();
+req1._onreadystatechange_ = function () {
+    if (this.readyState == 4) {
+        alert(internals.xhrResponseSource(req1) == "Network" ? "PASS" : "FAIL");
+        var req2 = new XMLHttpRequest();
+        req2._onreadystatechange_ = function () {
+            if (this.readyState == 4) {
+                alert(internals.xhrResponseSource(req2) == "Network" ? "PASS" : "FAIL");
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }
+        }
+        req2.open("GET", "resources/get.txt");
+        req2.setRequestHeader("If-Modified-Since", "0");
+        req2.send(null);
+    }
+};
+req1.open("GET", "resources/get.txt");
+req1.setRequestHeader("If-Modified-Since", "0");
+req1.send(null);
+
+</script>

Modified: trunk/Source/WebCore/ChangeLog (200325 => 200326)


--- trunk/Source/WebCore/ChangeLog	2016-05-02 17:38:15 UTC (rev 200325)
+++ trunk/Source/WebCore/ChangeLog	2016-05-02 18:05:46 UTC (rev 200326)
@@ -1,3 +1,24 @@
+2016-04-29  Alex Christensen  <[email protected]>
+
+        Do not reuse cache entries with conditional headers
+        https://bugs.webkit.org/show_bug.cgi?id=157205
+        rdar://problem/25856933
+
+        Reviewed by Chris Dumez.
+
+        Test: http/tests/xmlhttprequest/if-modified-since-0.html
+
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::canReuse):
+        CachedResourceLoader::determineRevalidationPolicy asserts that the request is not conditional,
+        which means that it does not have any headers like If-Modified-Since.  They are usually different,
+        because we put the timestamp in the If-Modified-Since header, so it fails the canReuse test because
+        time has passed since the last If-Modified-Since header was sent.  When a user sets the If-Modified-Since
+        manually to something that is constant, we reuse cache entries when we should not.
+        * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]):
+        Set the source so we can use it in Internals.
+
 2016-05-02  Yoav Weiss  <[email protected]>
 
         Speculatively fix the cmake build

Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (200325 => 200326)


--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2016-05-02 17:38:15 UTC (rev 200325)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp	2016-05-02 18:05:46 UTC (rev 200326)
@@ -254,6 +254,9 @@
     if (m_resourceRequest.allowCookies() != newRequest.allowCookies())
         return false;
 
+    if (newRequest.isConditional())
+        return false;
+
     // Ensure most headers match the existing headers before continuing.
     // Note that the list of ignored headers includes some headers explicitly related to caching.
     // A more detailed check of caching policy will be performed later, this is simply a list of

Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm (200325 => 200326)


--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm	2016-05-02 17:38:15 UTC (rev 200325)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm	2016-05-02 18:05:46 UTC (rev 200326)
@@ -142,10 +142,6 @@
 
 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)r
 {
-#if !PLATFORM(IOS)
-    UNUSED_PARAM(connection);
-#endif
-
     LOG(Network, "Handle %p delegate connection:%p didReceiveResponse:%p (HTTP status %d, reported MIMEType '%s')", m_handle, connection, r, [r respondsToSelector:@selector(statusCode)] ? [(id)r statusCode] : 0, [[r MIMEType] UTF8String]);
 
     if (!m_handle || !m_handle->client())
@@ -170,6 +166,7 @@
 #endif
     
     ResourceResponse resourceResponse(r);
+    resourceResponse.setSource(ResourceResponse::Source::Network);
 #if ENABLE(WEB_TIMING)
     ResourceHandle::getConnectionTimingData(connection, resourceResponse.resourceLoadTiming());
 #else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to