FIX ETag header now properly quoted

This commit is contained in:
Daniel Hensby 2016-07-28 16:26:36 +01:00
parent 66668450ed
commit 56f0b72e8d
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
2 changed files with 12 additions and 0 deletions

View File

@ -302,6 +302,9 @@ class HTTP {
}
public static function register_etag($etag) {
if (0 !== strpos('"')) {
$etag = sprintf('"%s"', $etag);
}
self::$etag = $etag;
}
@ -447,6 +450,11 @@ class HTTP {
$responseHeaders['ETag'] = self::$etag;
}
// etag needs to be a quoted string according to HTTP spec
if (!empty($responseHeaders['ETag']) && 0 !== strpos($responseHeaders['ETag'], '"')) {
$responseHeaders['ETag'] = sprintf('"%s"', $responseHeaders['ETag']);
}
// Now that we've generated them, either output them or attach them to the SS_HTTPResponse as appropriate
foreach($responseHeaders as $k => $v) {
if($body) {

View File

@ -254,6 +254,10 @@ EOT
if(!headers_sent($file, $line)) {
header($_SERVER['SERVER_PROTOCOL'] . " $this->statusCode " . $this->getStatusDescription());
foreach($this->headers as $header => $value) {
//etags need to be quoted
if (strcasecmp('etag', $header) === 0 && 0 !== strpos($value, '"')) {
$value = sprintf('"%s"', $value);
}
header("$header: $value", true, $this->statusCode);
}
} else {