mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[feature/request-class] Add is_secure method to request for HTTPS
PHPBB3-9716
This commit is contained in:
parent
24e9fb24d1
commit
a48889fed8
4 changed files with 33 additions and 0 deletions
|
@ -121,6 +121,13 @@ interface phpbb_request_interface
|
||||||
*/
|
*/
|
||||||
public function is_ajax();
|
public function is_ajax();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current request is happening over HTTPS.
|
||||||
|
*
|
||||||
|
* @return bool True if the request is secure.
|
||||||
|
*/
|
||||||
|
public function is_secure();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all variable names for a given super global
|
* Returns all variable names for a given super global
|
||||||
*
|
*
|
||||||
|
|
|
@ -326,6 +326,16 @@ class phpbb_request implements phpbb_request_interface
|
||||||
return $this->header('X-Requested-With') == 'XMLHttpRequest';
|
return $this->header('X-Requested-With') == 'XMLHttpRequest';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current request is happening over HTTPS.
|
||||||
|
*
|
||||||
|
* @return bool True if the request is secure.
|
||||||
|
*/
|
||||||
|
public function is_secure()
|
||||||
|
{
|
||||||
|
return $this->server('HTTPS') == 'on';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all variable names for a given super global
|
* Returns all variable names for a given super global
|
||||||
*
|
*
|
||||||
|
|
|
@ -57,6 +57,11 @@ class phpbb_mock_request implements phpbb_request_interface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function is_secure()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function variable_names($super_global = phpbb_request_interface::REQUEST)
|
public function variable_names($super_global = phpbb_request_interface::REQUEST)
|
||||||
{
|
{
|
||||||
return array_keys($this->data[$super_global]);
|
return array_keys($this->data[$super_global]);
|
||||||
|
|
|
@ -117,6 +117,17 @@ class phpbb_request_test extends phpbb_test_case
|
||||||
$this->assertTrue($this->request->is_ajax());
|
$this->assertTrue($this->request->is_ajax());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_is_secure()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->request->is_secure());
|
||||||
|
|
||||||
|
$this->request->enable_super_globals();
|
||||||
|
$_SERVER['HTTPS'] = 'on';
|
||||||
|
$this->request = new phpbb_request($this->type_cast_helper);
|
||||||
|
|
||||||
|
$this->assertTrue($this->request->is_secure());
|
||||||
|
}
|
||||||
|
|
||||||
public function test_variable_names()
|
public function test_variable_names()
|
||||||
{
|
{
|
||||||
$expected = array('test', 'unset');
|
$expected = array('test', 'unset');
|
||||||
|
|
Loading…
Add table
Reference in a new issue