diff options
Diffstat (limited to 'app/Core/Http')
-rw-r--r-- | app/Core/Http/Client.php | 13 | ||||
-rw-r--r-- | app/Core/Http/Request.php | 13 | ||||
-rw-r--r-- | app/Core/Http/Response.php | 7 |
3 files changed, 28 insertions, 5 deletions
diff --git a/app/Core/Http/Client.php b/app/Core/Http/Client.php index c6bf36a6..12b0a1cb 100644 --- a/app/Core/Http/Client.php +++ b/app/Core/Http/Client.php @@ -34,6 +34,19 @@ class Client extends Base const HTTP_USER_AGENT = 'Kanboard'; /** + * Send a GET HTTP request + * + * @access public + * @param string $url + * @param string[] $headers + * @return string + */ + public function get($url, array $headers = array()) + { + return $this->doRequest('GET', $url, '', $headers); + } + + /** * Send a GET HTTP request and parse JSON response * * @access public diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php index 1b3036d5..e0df2d3c 100644 --- a/app/Core/Http/Request.php +++ b/app/Core/Http/Request.php @@ -29,7 +29,12 @@ class Request extends Base * Constructor * * @access public - * @param \Pimple\Container $container + * @param \Pimple\Container $container + * @param array $server + * @param array $get + * @param array $post + * @param array $files + * @param array $cookies */ public function __construct(Container $container, array $server = array(), array $get = array(), array $post = array(), array $files = array(), array $cookies = array()) { @@ -211,7 +216,11 @@ class Request extends Base */ public function isHTTPS() { - return isset($this->server['HTTPS']) && $this->server['HTTPS'] !== '' && $this->server['HTTPS'] !== 'off'; + if ($this->getServerVariable('HTTP_X_FORWARDED_PROTO') === 'https') { + return true; + } + + return $this->getServerVariable('HTTPS') !== '' && $this->server['HTTPS'] !== 'off'; } /** diff --git a/app/Core/Http/Response.php b/app/Core/Http/Response.php index 7fefddeb..d098f519 100644 --- a/app/Core/Http/Response.php +++ b/app/Core/Http/Response.php @@ -68,11 +68,12 @@ class Response extends Base * * @access public * @param string $url Redirection URL + * @param boolean $self If Ajax request and true: refresh the current page */ - public function redirect($url) + public function redirect($url, $self = false) { - if ($this->request->getServerVariable('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest') { - header('X-Ajax-Redirect: '.$url); + if ($this->request->isAjax()) { + header('X-Ajax-Redirect: '.($self ? 'self' : $url)); } else { header('Location: '.$url); } |