Exemplo n.º 1
0
 public function RoundTrip($req)
 {
     if ($this->Type === HEAD_FIELD_CHECK) {
         $token = $this->Auth->SignRequest($req, $this->MimeType, $this->Type);
         $req->Header['Authorization'] = $token;
     }
     return HTTP_Utils::UCloud_Client_Do($req);
 }
Exemplo n.º 2
0
 public function __construct($method, $url, $body, $bucket, $key, $action_type = ActionType::NONE)
 {
     $this->URL = $url;
     $this->Header = array();
     $this->Body = $body;
     $this->UA = HTTP_Utils::UCloud_UserAgent();
     $this->METHOD = $method;
     $this->Bucket = $bucket;
     $this->Key = $key;
     global $CURL_TIMEOUT;
     global $UFILE_ACTION_TYPE;
     if ($CURL_TIMEOUT == null && $action_type !== ActionType::PUTFILE && $action_type !== ActionType::POSTFILE) {
         $CURL_TIMEOUT = 10;
     }
     $this->Timeout = $CURL_TIMEOUT;
 }
Exemplo n.º 3
0
 public function SignRequest($req, $mimetype = null, $type = Conf::HEAD_FIELD_CHECK)
 {
     $url = $req->URL;
     $url = parse_url($url['path']);
     $data = '';
     $data .= strtoupper($req->METHOD) . "\n";
     $data .= HTTP_Utils::UCloud_Header_Get($req->Header, 'Content-MD5') . "\n";
     if ($mimetype) {
         $data .= $mimetype . "\n";
     } else {
         $data .= HTTP_Utils::UCloud_Header_Get($req->Header, 'Content-Type') . "\n";
     }
     if ($type === Conf::HEAD_FIELD_CHECK) {
         $data .= HTTP_Utils::UCloud_Header_Get($req->Header, 'Date') . "\n";
     } else {
         $data .= HTTP_Utils::UCloud_Header_Get($req->Header, 'Expires') . "\n";
     }
     $data .= Digest::CanonicalizedResource($req->Bucket, $req->Key);
     $data .= Digest::CanonicalizedUCloudHeaders($req->Header);
     return $this->Sign($data);
 }
Exemplo n.º 4
0
 function UCloud_Delete($bucket, $key)
 {
     $err = Utils::CheckConfig(ActionType::DELETE);
     if ($err != null) {
         return array(null, $err);
     }
     $host = $bucket . Conf::UCLOUD_PROXY_SUFFIX;
     $path = "{$key}";
     $req = new HTTP_Request('DELETE', array('host' => $host, 'path' => $path), null, $bucket, $key);
     $req->Header['Content-Type'] = 'application/x-www-form-urlencoded';
     $client = new UCloud_AuthHttpClient(null);
     return HTTP_Utils::UCloud_Client_Call($client, $req);
 }