- remove leading http[s] to let createBaseUri() generate secure/unsecure base URI

- if secure is set to true add 's' to http
This commit is contained in:
Bjoern Schiessle 2012-06-29 11:59:47 +02:00
parent bd908affa3
commit 60ec46f706
1 changed files with 7 additions and 3 deletions

View File

@ -20,10 +20,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
private static $tempFiles=array(); private static $tempFiles=array();
public function __construct($params){ public function __construct($params){
$this->host=$params['host']; $host = $params['host'];
//remove leading http[s], will be generated in createBaseUri()
if (substr($host,0,8) == "https://") $host = substr($host, 8);
else if (substr($host,0,7) == "http://") $host = substr($host, 7);
$this->host=$host;
$this->user=$params['user']; $this->user=$params['user'];
$this->password=$params['password']; $this->password=$params['password'];
$this->secure=isset($params['secure'])?(bool)$params['secure']:false; $this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false;
$this->root=isset($params['root'])?$params['root']:'/'; $this->root=isset($params['root'])?$params['root']:'/';
if(!$this->root || $this->root[0]!='/'){ if(!$this->root || $this->root[0]!='/'){
$this->root='/'.$this->root; $this->root='/'.$this->root;
@ -46,7 +50,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
private function createBaseUri(){ private function createBaseUri(){
$baseUri='http'; $baseUri='http';
if($this->secure){ if($this->secure){
$baseUri.'s'; $baseUri.='s';
} }
$baseUri.='://'.$this->host.$this->root; $baseUri.='://'.$this->host.$this->root;
return $baseUri; return $baseUri;