/** * Constructor * * @param string $verb Verb * @param string $bucket Bucket name * @param string $uri Object URI * @param string $endpoint SCS endpoint URI * @return mixed */ function __construct($verb, $bucket = '', $uri = '', $endpoint = 'sinacloud.net') { $this->endpoint = $endpoint; $this->verb = $verb; $this->bucket = $bucket; $this->uri = $uri !== '' ? '/' . str_replace('%2F', '/', rawurlencode($uri)) : '/'; //if ($this->bucket !== '') // $this->resource = '/'.$this->bucket.$this->uri; //else // $this->resource = $this->uri; if ($this->bucket !== '') { if ($this->__dnsBucketName($this->bucket)) { $this->headers['Host'] = $this->bucket . '.' . $this->endpoint; $this->resource = '/' . $this->bucket . $this->uri; } else { $this->headers['Host'] = $this->endpoint; $this->uri = $this->uri; if ($this->bucket !== '') { $this->uri = '/' . $this->bucket . $this->uri; } $this->bucket = ''; $this->resource = $this->uri; } } else { $this->headers['Host'] = $this->endpoint; $this->resource = $this->uri; } //$this->headers['Date'] = gmdate('D, d M Y H:i:s T'); $this->headers['Date'] = gmdate('D, d M Y H:i:s T', SCS::__getTime()); $this->response = new STDClass(); $this->response->error = false; $this->response->body = null; $this->response->headers = array(); $this->setParameter('formatter', 'json'); }