Merge branch '3.3' into 3.4

This commit is contained in:
Daniel Hensby 2016-08-18 22:20:42 +01:00
commit d306c884c7
No known key found for this signature in database
GPG Key ID: E38EC566FE29EB66
2 changed files with 12 additions and 0 deletions

View File

@ -302,6 +302,9 @@ class HTTP {
} }
public static function register_etag($etag) { public static function register_etag($etag) {
if (0 !== strpos('"')) {
$etag = sprintf('"%s"', $etag);
}
self::$etag = $etag; self::$etag = $etag;
} }
@ -450,6 +453,11 @@ class HTTP {
$responseHeaders['ETag'] = self::$etag; $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 // Now that we've generated them, either output them or attach them to the SS_HTTPResponse as appropriate
foreach($responseHeaders as $k => $v) { foreach($responseHeaders as $k => $v) {
if($body) { if($body) {

View File

@ -254,6 +254,10 @@ EOT
if(!headers_sent($file, $line)) { if(!headers_sent($file, $line)) {
header($_SERVER['SERVER_PROTOCOL'] . " $this->statusCode " . $this->getStatusDescription()); header($_SERVER['SERVER_PROTOCOL'] . " $this->statusCode " . $this->getStatusDescription());
foreach($this->headers as $header => $value) { 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); header("$header: $value", true, $this->statusCode);
} }
} else { } else {