diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-06 15:23:00 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-06 15:23:00 +0200 |
commit | 79524ce163985c0ecfd22715080fc6fd12aeaf06 (patch) | |
tree | 14b97eaf19a26bdc86651b536c7b1717a461518a /lib | |
parent | 191f1b2d49afe980f43bdf6c0cc2c8cbb7f88c91 (diff) | |
parent | 80a232da6a5470e248979cfde7b1e4e2237b8284 (diff) | |
download | nextcloud-server-79524ce163985c0ecfd22715080fc6fd12aeaf06.tar.gz nextcloud-server-79524ce163985c0ecfd22715080fc6fd12aeaf06.zip |
Merge pull request #19605 from owncloud/add-get-http-protocol
Add \OCP\IRequest::getHttpProtocol
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/appframework/http/request.php | 21 | ||||
-rw-r--r-- | lib/public/irequest.php | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index 29414b92f7c..cfd903bffe5 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -553,6 +553,27 @@ class Request implements \ArrayAccess, \Countable, IRequest { } /** + * Returns the used HTTP protocol. + * + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. + */ + public function getHttpProtocol() { + $claimedProtocol = strtoupper($this->server['SERVER_PROTOCOL']); + + $validProtocols = [ + 'HTTP/1.0', + 'HTTP/1.1', + 'HTTP/2', + ]; + + if(in_array($claimedProtocol, $validProtocols, true)) { + return $claimedProtocol; + } + + return 'HTTP/1.1'; + } + + /** * Returns the request uri, even if the website uses one or more * reverse proxies * @return string diff --git a/lib/public/irequest.php b/lib/public/irequest.php index 20fa543dd69..acfc4f3f1d0 100644 --- a/lib/public/irequest.php +++ b/lib/public/irequest.php @@ -168,6 +168,14 @@ interface IRequest { public function getServerProtocol(); /** + * Returns the used HTTP protocol. + * + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. + * @since 8.2.0 + */ + public function getHttpProtocol(); + + /** * Returns the request uri, even if the website uses one or more * reverse proxies * @return string |