public Task<HttpResponseMessage> Put(StorageUri uri, string message) { var verb = "PUT"; var httpClient = _GetHttpClient(uri, verb, message, _textPlainContentType); var stringContent = new StringContent(message, Encoding.UTF8); return httpClient.PutAsync(uri.ToUriString(), stringContent); }
private static string _FormatMessage(string operationName, StorageUri uri, HttpResponseMessage httpResponseMessage) { return string.Format("Attempt to {0} {1} failed with HttpStatusCode {2}. Details: {3}", operationName, uri, httpResponseMessage.StatusCode, httpResponseMessage.Content.ReadAsStringAsync().Result); }
public string Build(string verb, string content, StorageUri uri, AzureStorageAccountInfo accountInfo, HttpRequestHeaders headers, string contentType) { var ifMatch = ""; var md5 = ""; var canonicalizedHeaderString = _GetCanonicalizedHeaders(headers); var canonResource = _GetCanonicalizedResource(new Uri(uri.ToUriString()), accountInfo.Account); var authorizationHeader = _GetAuthorizationHeader(verb, content, ifMatch, canonicalizedHeaderString, canonResource, md5, accountInfo, contentType); return authorizationHeader; }
private void _AddAuthorizationHeaderToHttpClient(HttpClient httpClient, StorageUri uri, string verb, string content, string contentType) { var authorizationHeaderValue = new AuthorizationHeaderBuilder().Build(verb, content, uri, _accountInfo, httpClient.DefaultRequestHeaders, contentType); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("SharedKey", authorizationHeaderValue); }
public Task<HttpResponseMessage> Put(StorageUri uri, IEnumerable<NameValueHeaderValue> additionalHeaders) { var verb = "PUT"; var httpClient = _GetHttpClient(uri, verb, "", "", additionalHeaders); return httpClient.PutAsync(uri.ToUriString(), null); }
public Task<HttpResponseMessage> Put(StorageUri uri) { var verb = "PUT"; var httpClient = _GetHttpClient(uri, verb, "", ""); return httpClient.PutAsync(uri.ToUriString(), null); }
public Task<HttpResponseMessage> Get(StorageUri uri) { var verb = "GET"; var httpClient = _GetHttpClient(uri, verb, "", ""); return httpClient.GetAsync(uri.ToUriString()); }
public Task<HttpResponseMessage> Delete(StorageUri uri) { var verb = "DELETE"; var httpClient = _GetHttpClient(uri, verb, "", ""); return httpClient.DeleteAsync(uri.ToUriString()); }
private HttpClient _GetHttpClient(StorageUri uri, string verb, string content, string contentType, IEnumerable<NameValueHeaderValue> additionalHeaders) { var httpClientHandler = new HttpClientHandler(); var httpClient = new HttpClient(httpClientHandler); _AddHeadersToHttpClient(httpClient); foreach (var additionalHeader in additionalHeaders) httpClient.DefaultRequestHeaders.Add(additionalHeader.Name, additionalHeader.Value); _AddAuthorizationHeaderToHttpClient(httpClient, uri, verb, content, contentType); return httpClient; }
private HttpClient _GetHttpClient(StorageUri uri, string verb, string content, string contentType) { return _GetHttpClient(uri, verb, content, contentType, new NameValueHeaderValue[0]); }
public AzureStorageException(string operationName, StorageUri uri, HttpResponseMessage httpResponseMessage) : base(_FormatMessage(operationName, uri, httpResponseMessage)) { }