[WK2] Responses with 302 HTTP Status Code should not be cached
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2015 02:18:10 +0000 (02:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2015 02:18:10 +0000 (02:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143028
<rdar://problem/19714040>

Reviewed by Antti Koivisto.

Source/WebKit2:

Responses with 302 HTTP Status Code should not be cached as per
RFC 7231:
http://tools.ietf.org/html/rfc7231#section-6.1

This patch updates our disk cache policy accordingly.

Test: http/tests/cache/disk-cache/disk-cache-302-status-code.html

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::canStore):

LayoutTests:

Add layout test to check that responses with 302 HTTP Status Code
are not cached.

* http/tests/cache/disk-cache/disk-cache-302-status-code-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-302-status-code.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

index 45de35a..128e195 100644 (file)
@@ -1,3 +1,17 @@
+2015-03-24  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Responses with 302 HTTP Status Code should not be cached
+        https://bugs.webkit.org/show_bug.cgi?id=143028
+        <rdar://problem/19714040>
+
+        Reviewed by Antti Koivisto.
+
+        Add layout test to check that responses with 302 HTTP Status Code
+        are not cached.
+
+        * http/tests/cache/disk-cache/disk-cache-302-status-code-expected.txt: Added.
+        * http/tests/cache/disk-cache/disk-cache-302-status-code.html: Added.
+
 2015-03-24  Zhuo Li  <zachli@apple.com>
 
         Scripts running in isolated world should not subject to a page's CSP about 'eval'.
diff --git a/LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code-expected.txt b/LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code-expected.txt
new file mode 100644 (file)
index 0000000..46f37e1
--- /dev/null
@@ -0,0 +1,17 @@
+Test that responses with HTTP status code 302 are not cached
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 2 tests
+
+response headers: {"Status":"302","Location":"/","Cache-control":"max-age=0"}
+response source: Network
+
+response headers: {"Status":"302","Location":"/","Cache-control":"max-age=100"}
+response source: Network
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code.html b/LayoutTests/http/tests/cache/disk-cache/disk-cache-302-status-code.html
new file mode 100644 (file)
index 0000000..0128125
--- /dev/null
@@ -0,0 +1,20 @@
+<script src="/js-test-resources/js-test-pre.js"></script>
+<script src="resources/cache-test.js"></script>
+<body>
+<script>
+
+var tests =
+[
+ { responseHeaders: {'Status': '302', 'Location': '/', 'Cache-control': 'max-age=0' }, includeBody: false },
+ { responseHeaders: {'Status': '302', 'Location': '/', 'Cache-control': 'max-age=100' }, includeBody: false },
+];
+
+description("Test that responses with HTTP status code 302 are not cached");
+
+debug("running " + tests.length + " tests");
+debug("");
+
+runTests(tests);
+
+</script>
+<script src="/js-test-resources/js-test-post.js"></script>
index 06b300f..8868e21 100644 (file)
@@ -1,3 +1,22 @@
+2015-03-24  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Responses with 302 HTTP Status Code should not be cached
+        https://bugs.webkit.org/show_bug.cgi?id=143028
+        <rdar://problem/19714040>
+
+        Reviewed by Antti Koivisto.
+
+        Responses with 302 HTTP Status Code should not be cached as per
+        RFC 7231:
+        http://tools.ietf.org/html/rfc7231#section-6.1
+
+        This patch updates our disk cache policy accordingly.
+
+        Test: http/tests/cache/disk-cache/disk-cache-302-status-code.html
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::canStore):
+
 2015-03-24  Anders Carlsson  <andersca@apple.com>
 
         Fix crash in WebKit::RemoteObjectRegistry::sendInvocation
index f99b2d9..94a0f12 100644 (file)
@@ -324,7 +324,6 @@ static StoreDecision canStore(const WebCore::ResourceRequest& originalRequest, c
     case 204: // No Content
     case 300: // Multiple Choices
     case 301: // Moved Permanently
-    case 302: // Found
     case 307: // Temporary Redirect
     case 404: // Not Found
     case 410: // Gone