]> source.dussan.org Git - jquery.git/commitdiff
Ajax: Use weak ETag header in tests
authorCorey Frang <gnarf37@gmail.com>
Tue, 26 Nov 2013 18:45:39 +0000 (12:45 -0600)
committerDave Methvin <dave.methvin@gmail.com>
Tue, 26 Nov 2013 19:16:12 +0000 (14:16 -0500)
See http://en.wikipedia.org/wiki/HTTP_ETag#Strong_and_weak_validation

Close gh-1448
(cherry picked from commit d2aa969206aa1b7738b911cdaf29038f249b5066)

test/data/etag.php

index f6abc26e43a6b7573e6a2eac0930e4bba1424250..66eca4bb12e032cf8a84843bbf6597af28b6201b 100644 (file)
@@ -4,13 +4,16 @@ error_reporting(0);
 $ts = $_REQUEST['ts'];
 $etag = md5($ts);
 
-$ifNoneMatch = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false;
+$ifNoneMatch = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : "";
+preg_match('/"([^"]+)"/', $ifNoneMatch, $matches);
+$ifNoneMatch = isset($matches[1]) ? $matches[1] : false;
+
 if ($ifNoneMatch == $etag) {
        header('HTTP/1.0 304 Not Modified');
        die; // stop processing
 }
 
-header("Etag: " . $etag);
+header("Etag: W/\"" . $etag . "\"");
 
 if ( $ifNoneMatch ) {
        echo "OK: " . $etag;