Commit 54368828 by Qiang Xue

Merge pull request #2531 from tof06/master

Add getIsPjax method to Request, and add X-PJAX-URL header when redirect from pjax request
parents 976532c1 61767861
......@@ -292,6 +292,15 @@ class Request extends \yii\base\Request
}
/**
* Returns wheter this is a PJAX request
* @return boolean wether this is a PJAX request
*/
public function getIsPjax ()
{
return $this->getIsAjax() && isset($_SERVER['HTTP_X_PJAX']) && $_SERVER['HTTP_X_PJAX']==true;
}
/**
* Returns whether this is an Adobe Flash or Flex request.
* @return boolean whether this is an Adobe Flash or Adobe Flex request.
*/
......
......@@ -678,7 +678,9 @@ class Response extends \yii\base\Response
$url = Yii::$app->getRequest()->getHostInfo() . $url;
}
if (Yii::$app->getRequest()->getIsAjax()) {
if (Yii::$app->getRequest()->getIsPjax()) {
$this->getHeaders()->set('X-PJAX-URL', $url);
} elseif (Yii::$app->getRequest()->getIsAjax()) {
$this->getHeaders()->set('X-Redirect', $url);
} else {
$this->getHeaders()->set('Location', $url);
......
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