New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getIsPjax method to Request, and add X-PJAX-URL header when redirect from pjax request #2531

merged 2 commits into from Feb 24, 2014
Jump to file or symbol
Failed to load files and symbols.
+12 −1
Diff settings


Just for now

@@ -291,6 +291,15 @@ public function getIsAjax()
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
* 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 @@ public function redirect($url, $statusCode = 302)
$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);