Ejemplo n.º 1
0
 /**
  * @return array
  * @throws Aliyun_Log_Exception
  */
 private function send($method, $project, $body, $resource, $params, $headers)
 {
     if ($body) {
         $headers['Content-Length'] = strlen($body);
         if (isset($headers["x-log-bodyrawsize"]) == false) {
             $headers["x-log-bodyrawsize"] = 0;
         }
         $headers['Content-MD5'] = Aliyun_Log_Util::calMD5($body);
     } else {
         $headers['Content-Length'] = 0;
         $headers["x-log-bodyrawsize"] = 0;
         $headers['Content-Type'] = '';
         // If not set, http request will add automatically.
     }
     $headers['x-log-apiversion'] = API_VERSION;
     $headers['x-log-signaturemethod'] = 'hmac-sha1';
     if (strlen($this->stsToken) > 0) {
         $headers['x-acs-security-token'] = $this->stsToken;
     }
     if (is_null($project)) {
         $headers['Host'] = $this->logHost;
     } else {
         $headers['Host'] = "{$project}.{$this->logHost}";
     }
     $headers['Date'] = $this->GetGMT();
     $signature = Aliyun_Log_Util::getRequestAuthorization($method, $resource, $this->accessKey, $this->stsToken, $params, $headers);
     $headers['Authorization'] = "LOG {$this->accessKeyId}:{$signature}";
     $url = $resource;
     if ($params) {
         $url .= '?' . Aliyun_Log_Util::urlEncode($params);
     }
     if ($this->isRowIp) {
         $url = "http://{$this->endpoint}{$url}";
     } else {
         if (is_null($project)) {
             $url = "http://{$this->endpoint}{$url}";
         } else {
             $url = "http://{$project}.{$this->endpoint}{$url}";
         }
     }
     return $this->sendRequest($method, $url, $body, $headers);
 }