function Request::getProtocolVersion
Returns the protocol version.
If the application is behind a proxy, the protocol version used in the requests between the client and the proxy and between the proxy and the server might be different. This returns the former (from the "Via" header) if the proxy is trusted (see "setTrustedProxies()"), otherwise it returns the latter (from the "SERVER_PROTOCOL" server parameter).
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1384
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public function getProtocolVersion() : ?string {
if ($this->isFromTrustedProxy()) {
preg_match('~^(HTTP/)?([1-9]\\.[0-9]) ~', $this->headers
->get('Via') ?? '', $matches);
if ($matches) {
return 'HTTP/' . $matches[2];
}
}
return $this->server
->get('SERVER_PROTOCOL');
}