aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/etag.php
blob: 66eca4bb12e032cf8a84843bbf6597af28b6201b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
error_reporting(0);

$ts = $_REQUEST['ts'];
$etag = md5($ts);

$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: W/\"" . $etag . "\"");

if ( $ifNoneMatch ) {
	echo "OK: " . $etag;
} else {
	echo "FAIL";
}

?>