|
|
@@ -133,10 +133,8 @@ class Minz_Request {
|
|
|
|
|
|
/**
|
|
|
* Return true if the request is over HTTPS, false otherwise (HTTP)
|
|
|
- *
|
|
|
- * @return boolean
|
|
|
*/
|
|
|
- public static function isHttps() {
|
|
|
+ public static function isHttps(): bool {
|
|
|
$header = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '';
|
|
|
if ('' != $header) {
|
|
|
return 'https' === strtolower($header);
|
|
|
@@ -159,10 +157,7 @@ class Minz_Request {
|
|
|
return filter_var("{$protocol}://{$host}{$port}{$prefix}{$path}", FILTER_SANITIZE_URL);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private static function extractProtocol() {
|
|
|
+ private static function extractProtocol(): string {
|
|
|
if (self::isHttps()) {
|
|
|
return 'https';
|
|
|
}
|
|
|
@@ -202,10 +197,7 @@ class Minz_Request {
|
|
|
return self::isHttps() ? 443 : 80;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private static function extractPortForUrl() {
|
|
|
+ private static function extractPortForUrl(): string {
|
|
|
if (self::isHttps() && 443 !== $port = self::extractPort()) {
|
|
|
return ":{$port}";
|
|
|
}
|
|
|
@@ -215,10 +207,7 @@ class Minz_Request {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private static function extractPrefix() {
|
|
|
+ private static function extractPrefix(): string {
|
|
|
if ('' != $prefix = ($_SERVER['HTTP_X_FORWARDED_PREFIX'] ?? '')) {
|
|
|
return rtrim($prefix, '/ ');
|
|
|
}
|
|
|
@@ -235,13 +224,11 @@ class Minz_Request {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Return the base_url from configuration and add a suffix if given.
|
|
|
- *
|
|
|
- * @return string base_url with a suffix.
|
|
|
+ * Return the base_url from configuration
|
|
|
*/
|
|
|
- public static function getBaseUrl() {
|
|
|
+ public static function getBaseUrl(): string {
|
|
|
$conf = Minz_Configuration::get('system');
|
|
|
- $url = rtrim($conf->base_url, '/\\');
|
|
|
+ $url = trim($conf->base_url, ' /\\"');
|
|
|
return filter_var($url, FILTER_SANITIZE_URL);
|
|
|
}
|
|
|
|
|
|
@@ -397,17 +384,11 @@ class Minz_Request {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private static function extractContentType() {
|
|
|
+ private static function extractContentType(): string {
|
|
|
return strtolower(trim($_SERVER['CONTENT_TYPE'] ?? ''));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return boolean
|
|
|
- */
|
|
|
- public static function isPost() {
|
|
|
+ public static function isPost(): bool {
|
|
|
return 'POST' === ($_SERVER['REQUEST_METHOD'] ?? '');
|
|
|
}
|
|
|
|