function Request::isSecure
Checks whether the request is secure or not.
This method can read the client protocol from the "X-Forwarded-Proto" header when trusted proxies were set via "setTrustedProxies()".
The "X-Forwarded-Proto" header must contain the protocol: "https" or "http".
3 calls to Request::isSecure()
- Request::getScheme in vendor/
symfony/ http-foundation/ Request.php - Gets the request's scheme.
- Request::getTrustedValues in vendor/
symfony/ http-foundation/ Request.php - This method is rather heavy because it splits and merges headers, and it's called by many other methods such as getPort(), isSecure(), getHost(), getClientIps(), getBaseUrl() etc. Thus, we try to cache the results for best performance.
- Request::preferSafeContent in vendor/
symfony/ http-foundation/ Request.php - Checks whether the client browser prefers safe content or not according to RFC8674.
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1059
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public function isSecure() : bool {
if ($this->isFromTrustedProxy() && ($proto = $this->getTrustedValues(self::HEADER_X_FORWARDED_PROTO))) {
return \in_array(strtolower($proto[0]), [
'https',
'on',
'ssl',
'1',
], true);
}
$https = $this->server
->get('HTTPS');
return $https && 'off' !== strtolower($https);
}