Пример #1
0
        // see http://msdn.microsoft.com/en-us/library/dd179428.aspx for authentication details
        public HttpResponse DoBlobStoreRequest(string containername, string blobname, string method, Hashtable headers, byte[] data, string content_type, string query_string)
        {
            string path = "/";

            if (containername != null)
            {
                containername = LegalizeContainerName(containername);
                path          = path + containername;
                if (blobname != null)
                {
                    path = path + "/" + blobname;
                }
            }

            StorageUtils.AddDateHeader(headers);
            StorageUtils.AddVersionHeader(headers);

            string auth_header = StorageUtils.MakeSharedKeyLiteHeader(StorageUtils.services.blob, this.azure_storage_account, this.azure_b64_secret, method, path, query_string, content_type, headers);

            headers["Authorization"] = "SharedKeyLite " + this.azure_storage_account + ":" + auth_header;

            Uri uri = new Uri(string.Format("http://{0}{1}{2}", this.azure_blob_host, path, query_string));

            //return StorageUtils.DoStorageRequest(method, headers, data, content_type, uri);
            return(HttpUtils.RetryStorageRequestExpectingServiceAvailable(method, headers, data, content_type, uri));
        }
Пример #2
0
 public static HttpResponse RetryStorageRequestExpectingServiceAvailable(string method, Hashtable headers, byte[] data, string content_type, Uri uri, int wait_secs, int max_tries, TimeSpan timeout_secs)
 {
     try
     {
         return(GenUtils.Actions.Retry <HttpResponse>(
                    delegate()
         {
             try
             {
                 return StorageUtils.DoStorageRequest(method, headers, data, content_type, uri);
             }
             catch                             // (Exception e)
             {
                 //GenUtils.PriorityLogMsg("exception", "RetryStorageRequest: " + uri, e.Message + e.StackTrace);
                 throw new Exception("RetryStorageRequestException");
             }
         },
                    CompletedIfStatusNotServiceUnavailable,
                    completed_delegate_object: null,
                    wait_secs: wait_secs,
                    max_tries: max_tries,
                    timeout_secs: timeout_secs));
     }
     catch (Exception e)
     {
         GenUtils.LogMsg("exception", "RetryStorageRequest: " + uri, e.Message + e.StackTrace);
         return(new HttpResponse(HttpStatusCode.ServiceUnavailable, uri.ToString(), null, new Dictionary <string, string>()));
     }
 }
Пример #3
0
        // generic table request
        public HttpResponse DoTableStoreRequest(string request_path, string query_string, string method, Hashtable headers, byte[] data)
        {
            string path = "/";

            if (request_path != null)
            {
                path += request_path;
            }

            StorageUtils.AddDateHeader(headers);
            StorageUtils.AddVersionHeader(headers);
            headers.Add("DataServiceVersion", DataServiceVersion);
            headers.Add("MaxDataServiceVersion", MaxDataServiceVersion);
            string auth_header = StorageUtils.MakeSharedKeyLiteHeader(StorageUtils.services.table, this.azure_storage_name, this.azure_b64_secret, http_method: null, path: path, query_string: null, content_type: TABLE_STORAGE_CONTENT_TYPE, headers: headers);

            headers["Authorization"] = "SharedKeyLite " + this.azure_storage_name + ":" + auth_header;

            if (query_string != null)
            {
                path = path + "?" + query_string;
            }

            Uri uri = new Uri(string.Format("{0}://{1}{2}", this.scheme, this.azure_table_host, path));

            // return StorageUtils.DoStorageRequest(method, headers, data: data, content_type: TABLE_STORAGE_CONTENT_TYPE, uri: uri);
            return(HttpUtils.RetryStorageRequestExpectingServiceAvailable(method, headers, data: data, content_type: TABLE_STORAGE_CONTENT_TYPE, uri: uri));
        }