Commit 313437f3 by Qiang Xue

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

parent 05525f18
......@@ -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)
......
......@@ -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';
/**
......
......@@ -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);
}
}
......
......@@ -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:
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment