Merge pull request #3748 from owncloud/fixing-3740-master

in case $_SERVER['HTTP_HOST']) is not set let's return localhost - bette...
This commit is contained in:
Thomas Müller 2013-07-01 15:08:08 -07:00
commit fbdf46b76e
1 changed files with 14 additions and 8 deletions

View File

@ -9,7 +9,7 @@
class OC_Request {
/**
* @brief Check overwrite condition
* @returns true/false
* @returns bool
*/
private static function isOverwriteCondition($type = '') {
$regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/';
@ -19,7 +19,7 @@ class OC_Request {
/**
* @brief Returns the server host
* @returns the server host
* @returns string the server host
*
* Returns the server host, even if the website uses one or more
* reverse proxies
@ -40,7 +40,13 @@ class OC_Request {
}
}
else{
$host = $_SERVER['HTTP_HOST'];
if (isset($_SERVER['HTTP_HOST'])) {
return $_SERVER['HTTP_HOST'];
}
if (isset($_SERVER['SERVER_NAME'])) {
return $_SERVER['SERVER_NAME'];
}
return 'localhost';
}
return $host;
}
@ -48,7 +54,7 @@ class OC_Request {
/**
* @brief Returns the server protocol
* @returns the server protocol
* @returns string the server protocol
*
* Returns the server protocol. It respects reverse proxy servers and load balancers
*/
@ -70,7 +76,7 @@ class OC_Request {
/**
* @brief Returns the request uri
* @returns the request uri
* @returns string the request uri
*
* Returns the request uri, even if the website uses one or more
* reverse proxies
@ -85,7 +91,7 @@ class OC_Request {
/**
* @brief Returns the script name
* @returns the script name
* @returns string the script name
*
* Returns the script name, even if the website uses one or more
* reverse proxies
@ -139,7 +145,7 @@ class OC_Request {
/**
* @brief Check if this is a no-cache request
* @returns true for no-cache
* @returns boolean true for no-cache
*/
static public function isNoCache() {
if (!isset($_SERVER['HTTP_CACHE_CONTROL'])) {
@ -150,7 +156,7 @@ class OC_Request {
/**
* @brief Check if the requestor understands gzip
* @returns true for gzip encoding supported
* @returns boolean true for gzip encoding supported
*/
static public function acceptGZip() {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {