Skip to content
Browse files

Ajax: Use weak ETag header in tests

  • Loading branch information...
1 parent ed29193 commit d2aa969206aa1b7738b911cdaf29038f249b5066 @gnarf gnarf committed with dmethvin Nov 26, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 test/data/etag.php
View
7 test/data/etag.php
@@ -4,13 +4,16 @@
$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;

0 comments on commit d2aa969

Please sign in to comment.
Something went wrong with that request. Please try again.