Browse Source

Fixes #3284: Added support for checking multiple ETags by `yii\filters\HttpCache`.

tags/2.0.0-rc
Qiang Xue 10 years ago
parent
commit
313437f3c0
  1. 1
      framework/CHANGELOG.md
  2. 8
      framework/base/Application.php
  3. 2
      framework/filters/HttpCache.php
  4. 14
      framework/web/Request.php

1
framework/CHANGELOG.md

@ -48,6 +48,7 @@ Yii Framework 2 Change Log
- Enh #3230: Added `yii\filters\AccessControl::user` to support access control with different actors (qiangxue)
- Enh #3232: Added `export()` and `exportAsString()` methods to `yii\helpers\BaseVarDumper` (klimov-paul)
- Enh #3252: Added support for case insensitive matching using ILIKE to PostgreSQL QueryBuilder (cebe)
- Enh #3284: Added support for checking multiple ETags by `yii\filters\HttpCache` (qiangxue)
- Enh #3298: Supported configuring `View::theme` using a class name (netyum, qiangxue)
- Enh #3328: `BaseMailer` generates better text body from html body (armab)
- Enh #3472: Added configurable option to encode spaces in dropDownLists and listBoxes (kartik-v)

8
framework/base/Application.php

@ -82,12 +82,10 @@ abstract class Application extends Module
/**
* @var string the namespace that controller classes are located in.
* This namespace will be used to load controller classes by prepending it to the controller
* class name.
* The default namespace is "app\controllers".
* This namespace will be used to load controller classes by prepending it to the controller class name.
* The default namespace is `app\controllers`.
*
* See also the [guide section on autoloading][guide-concept-autoloading] to learn more about
* defining namespaces and how classes are loaded.
* Please refer to the [guide about class autoloading][guide-concept-autoloading] for more details.
*/
public $controllerNamespace = 'app\\controllers';
/**

2
framework/filters/HttpCache.php

@ -153,7 +153,7 @@ class HttpCache extends ActionFilter
if ($lastModified !== null && (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) < $lastModified)) {
return false;
} else {
return $etag === null || isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag;
return $etag === null || in_array($etag, Yii::$app->request->getEtags(), true);
}
}

14
framework/web/Request.php

@ -1136,6 +1136,20 @@ class Request extends \yii\base\Request
}
/**
* Gets the Etags.
*
* @return array The entity tags
*/
public function getETags()
{
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
return preg_split('/[\s,]+/', $_SERVER['HTTP_IF_NONE_MATCH'], -1, PREG_SPLIT_NO_EMPTY);
} else {
return [];
}
}
/**
* Returns the cookie collection.
* Through the returned cookie collection, you may access a cookie using the following syntax:
*

Loading…
Cancel
Save