Title: [181920] trunk
Revision
181920
Author
[email protected]
Date
2015-03-24 16:46:03 -0700 (Tue, 24 Mar 2015)

Log Message

[WK2] Responses with 204 HTTP Status Code should be cacheable by default
https://bugs.webkit.org/show_bug.cgi?id=143020
<rdar://problem/20281529>

Reviewed by Antti Koivisto.

Source/WebKit2:

Make responses with 204 HTTP Status Code cacheable by default, as
per RFC 7231:
http://tools.ietf.org/html/rfc7231#section-6.3.5

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

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

LayoutTests:

Add test to make sure that responses with 204 HTTP Status Code are
cacheable by default.

* http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-204-status-code.html: Added.
* http/tests/cache/disk-cache/resources/cache-test.js:
Re-introduce support for generating responses with only headers (no body).
This was mistakenly dropped when I rebased my patch for r181895.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181919 => 181920)


--- trunk/LayoutTests/ChangeLog	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/LayoutTests/ChangeLog	2015-03-24 23:46:03 UTC (rev 181920)
@@ -1,3 +1,20 @@
+2015-03-24  Chris Dumez  <[email protected]>
+
+        [WK2] Responses with 204 HTTP Status Code should be cacheable by default
+        https://bugs.webkit.org/show_bug.cgi?id=143020
+        <rdar://problem/20281529>
+
+        Reviewed by Antti Koivisto.
+
+        Add test to make sure that responses with 204 HTTP Status Code are
+        cacheable by default.
+
+        * http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt: Added.
+        * http/tests/cache/disk-cache/disk-cache-204-status-code.html: Added.
+        * http/tests/cache/disk-cache/resources/cache-test.js:
+        Re-introduce support for generating responses with only headers (no body).
+        This was mistakenly dropped when I rebased my patch for r181895.
+
 2015-03-24  Beth Dakin  <[email protected]>
 
         Another attempted test fix after http://trac.webkit.org/changeset/181907

Added: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt (0 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code-expected.txt	2015-03-24 23:46:03 UTC (rev 181920)
@@ -0,0 +1,17 @@
+Test that responses with HTTP status code 204 are cacheable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+running 2 tests
+
+response headers: {"Status":"204","Cache-control":"max-age=0"}
+response source: Network
+
+response headers: {"Status":"204","Cache-control":"max-age=100"}
+response source: Disk cache
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code.html (0 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-204-status-code.html	2015-03-24 23:46:03 UTC (rev 181920)
@@ -0,0 +1,20 @@
+<script src=""
+<script src=""
+<body>
+<script>
+
+var tests =
+[
+ { responseHeaders: {'Status': '204', 'Cache-control': 'max-age=0' }, includeBody: false },
+ { responseHeaders: {'Status': '204', 'Cache-control': 'max-age=100' }, includeBody: false },
+];
+
+description("Test that responses with HTTP status code 204 are cacheable");
+
+debug("running " + tests.length + " tests");
+debug("");
+
+runTests(tests);
+
+</script>
+<script src=""

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-no-body.html (181919 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-no-body.html	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-validation-no-body.html	2015-03-24 23:46:03 UTC (rev 181920)
@@ -34,7 +34,7 @@
 
 description("Test permutations of various cache headers");
 
-var tests = generateTests(testMatrix, false /* withBody */);
+var tests = generateTests(testMatrix, false /* includeBody */);
 
 debug("running " + tests.length + " tests");
 debug("");

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js (181919 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js	2015-03-24 23:46:03 UTC (rev 181920)
@@ -38,10 +38,12 @@
     return value;
 }
 
-function generateTestURL(test)
+function generateTestURL(test, includeBody)
 {
+    includeBody = typeof includeBody !== 'undefined' ? includeBody : true;
     var uniqueTestId = Math.floor((Math.random() * 1000000000000));
-    var testURL = "resources/generate-response.cgi?uniqueId=" + uniqueTestId++ + "&Content-type=text/plain";
+    var cgi_script = "resources/generate-response.cgi?include-body=" + (includeBody ? "1" : "0");
+    var testURL = cgi_script + "&uniqueId=" + uniqueTestId++ + "&Content-type=text/plain";
     for (var header in test.responseHeaders)
         testURL += '&' + header + '=' + makeHeaderValue(test.responseHeaders[header]);
     return testURL;
@@ -50,7 +52,7 @@
 function loadResource(test, onload)
 {
     if (!test.url)
-        test.url = ""
+        test.url = "" test.includeBody);
 
     test.xhr = new XMLHttpRequest();
     test.xhr._onload_ = onload;
@@ -115,8 +117,9 @@
     }
 }
 
-function generateTests(testMatrix)
+function generateTests(testMatrix, includeBody)
 {
+    includeBody = typeof includeBody !== 'undefined' ? includeBody : true;
     var tests = [];
 
     var testCount = 1;
@@ -138,6 +141,7 @@
                 mergeFields(test[field], component[field]);
             }
         }
+        test.includeBody = includeBody;
         tests.push(test);
     }
     return tests;

Deleted: trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response-no-body.cgi (181919 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response-no-body.cgi	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response-no-body.cgi	2015-03-24 23:46:03 UTC (rev 181920)
@@ -1,17 +0,0 @@
-#!/usr/bin/perl -w
-
-use CGI;
-use HTTP::Date;
-
-my $query = new CGI;
-@names = $query->param;
-
-if ($query->http && $query->http("If-None-Match") eq "match") {
-    print "Status: 304\n";
-}
-
-foreach (@names) {
-    next if ($_ eq "uniqueId");
-    print $_ . ": " . $query->param($_) . "\n";
-}
-print "\n";

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response.cgi (181919 => 181920)


--- trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response.cgi	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response.cgi	2015-03-24 23:46:03 UTC (rev 181920)
@@ -5,6 +5,7 @@
 
 my $query = new CGI;
 @names = $query->param;
+my $includeBody = $query->param('include-body') || 0;
 
 my $hasStatusCode = 0;
 if ($query->http && $query->http("If-None-Match") eq "match") {
@@ -14,8 +15,9 @@
 
 foreach (@names) {
     next if ($_ eq "uniqueId");
+    next if ($_ eq "include-body");
     next if ($_ eq "Status" and $hasStatusCode);
     print $_ . ": " . $query->param($_) . "\n";
 }
 print "\n";
-print "test";
+print "test" if $includeBody;

Modified: trunk/Source/WebKit2/ChangeLog (181919 => 181920)


--- trunk/Source/WebKit2/ChangeLog	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-24 23:46:03 UTC (rev 181920)
@@ -1,3 +1,20 @@
+2015-03-24  Chris Dumez  <[email protected]>
+
+        [WK2] Responses with 204 HTTP Status Code should be cacheable by default
+        https://bugs.webkit.org/show_bug.cgi?id=143020
+        <rdar://problem/20281529>
+
+        Reviewed by Antti Koivisto.
+
+        Make responses with 204 HTTP Status Code cacheable by default, as
+        per RFC 7231:
+        http://tools.ietf.org/html/rfc7231#section-6.3.5
+
+        Test: http/tests/cache/disk-cache/disk-cache-204-status-code.html
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::canStore):
+
 2015-03-24  Enrica Casucci  <[email protected]>
 
         [iOS] Remove unused keyboard code in WKSelectPopover class.

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (181919 => 181920)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2015-03-24 23:37:34 UTC (rev 181919)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2015-03-24 23:46:03 UTC (rev 181920)
@@ -321,6 +321,7 @@
     switch (response.httpStatusCode()) {
     case 200: // OK
     case 203: // Non-Authoritative Information
+    case 204: // No Content
     case 300: // Multiple Choices
     case 301: // Moved Permanently
     case 302: // Found
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to