mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding Flash client detection to RequestHandler
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6460 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
5e8a2fb7f4
commit
d301d7a566
2 changed files with 21 additions and 0 deletions
|
@ -238,6 +238,15 @@ class RequestHandlerComponent extends Object {
|
||||||
function isAjax() {
|
function isAjax() {
|
||||||
return env('HTTP_X_REQUESTED_WITH') === "XMLHttpRequest";
|
return env('HTTP_X_REQUESTED_WITH') === "XMLHttpRequest";
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns true if the current HTTP request is coming from a Flash-based client
|
||||||
|
*
|
||||||
|
* @return boolean True if call is from Flash
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function isFlash() {
|
||||||
|
return env('HTTP_USER_AGENT') === "Shockwave Flash";
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns true if the current request is over HTTPS, false otherwise.
|
* Returns true if the current request is over HTTPS, false otherwise.
|
||||||
*
|
*
|
||||||
|
|
|
@ -46,6 +46,18 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testRequestTypes() {
|
||||||
|
$this->assertFalse($this->RequestHandler->isFlash());
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash';
|
||||||
|
$this->assertTrue($this->RequestHandler->isFlash());
|
||||||
|
unset($_SERVER['HTTP_USER_AGENT']);
|
||||||
|
|
||||||
|
$this->assertFalse($this->RequestHandler->isAjax());
|
||||||
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||||
|
$this->assertTrue($this->RequestHandler->isAjax());
|
||||||
|
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||||
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
unset($this->RequestHandler);
|
unset($this->RequestHandler);
|
||||||
unset($this->Controller);
|
unset($this->Controller);
|
||||||
|
|
Loading…
Add table
Reference in a new issue