summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/irequest.php65
-rw-r--r--lib/public/util.php12
2 files changed, 73 insertions, 4 deletions
diff --git a/lib/public/irequest.php b/lib/public/irequest.php
index b5ea1fa95da..814fc0251cf 100644
--- a/lib/public/irequest.php
+++ b/lib/public/irequest.php
@@ -134,4 +134,69 @@ interface IRequest {
* @return string
*/
public function getId();
+
+ /**
+ * Returns the remote address, if the connection came from a trusted proxy
+ * and `forwarded_for_headers` has been configured then the IP address
+ * specified in this header will be returned instead.
+ * Do always use this instead of $_SERVER['REMOTE_ADDR']
+ * @return string IP address
+ */
+ public function getRemoteAddress();
+
+ /**
+ * Returns the server protocol. It respects reverse proxy servers and load
+ * balancers.
+ * @return string Server protocol (http or https)
+ */
+ public function getServerProtocol();
+
+ /**
+ * Returns the request uri, even if the website uses one or more
+ * reverse proxies
+ * @return string
+ */
+ public function getRequestUri();
+
+ /**
+ * Get raw PathInfo from request (not urldecoded)
+ * @throws \Exception
+ * @return string|false Path info or false when not found
+ */
+ public function getRawPathInfo();
+
+ /**
+ * Get PathInfo from request
+ * @throws \Exception
+ * @return string|false Path info or false when not found
+ */
+ public function getPathInfo();
+
+ /**
+ * Returns the script name, even if the website uses one or more
+ * reverse proxies
+ * @return string the script name
+ */
+ public function getScriptName();
+
+ /**
+ * Checks whether the user agent matches a given regex
+ * @param array $agent array of agent names
+ * @return bool true if at least one of the given agent matches, false otherwise
+ */
+ public function isUserAgent(array $agent);
+
+ /**
+ * Returns the unverified server host from the headers without checking
+ * whether it is a trusted domain
+ * @return string Server host
+ */
+ public function getInsecureServerHost();
+
+ /**
+ * Returns the server host from the headers, or the first configured
+ * trusted domain if the host isn't in the trusted list
+ * @return string Server host
+ */
+ public function getServerHost();
}
diff --git a/lib/public/util.php b/lib/public/util.php
index 7f1974a421d..e6e14a26e01 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -234,9 +234,10 @@ class Util {
/**
* Returns the server host, even if the website uses one or more reverse proxy
* @return string the server host
+ * @deprecated Use \OCP\IRequest::getServerHost
*/
public static function getServerHost() {
- return(\OC_Request::serverHost());
+ return \OC::$server->getRequest()->getServerHost();
}
/**
@@ -285,25 +286,28 @@ class Util {
/**
* Returns the server protocol. It respects reverse proxy servers and load balancers
* @return string the server protocol
+ * @deprecated Use \OCP\IRequest::getServerProtocol
*/
public static function getServerProtocol() {
- return(\OC_Request::serverProtocol());
+ return \OC::$server->getRequest()->getServerProtocol();
}
/**
* Returns the request uri, even if the website uses one or more reverse proxies
* @return string the request uri
+ * @deprecated Use \OCP\IRequest::getRequestUri
*/
public static function getRequestUri() {
- return(\OC_Request::requestUri());
+ return \OC::$server->getRequest()->getRequestUri();
}
/**
* Returns the script name, even if the website uses one or more reverse proxies
* @return string the script name
+ * @deprecated Use \OCP\IRequest::getScriptName
*/
public static function getScriptName() {
- return(\OC_Request::scriptName());
+ return \OC::$server->getRequest()->getScriptName();
}
/**