/// <summary>
        /// Gets the container's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The container's attributes.</returns>
        public static BlobContainerProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            // Set the container properties
            BlobContainerProperties containerProperties = new BlobContainerProperties();

            containerProperties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            containerProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            containerProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            // Get lease properties
            containerProperties.LeaseStatus   = BlobHttpResponseParsers.GetLeaseStatus(response);
            containerProperties.LeaseState    = BlobHttpResponseParsers.GetLeaseState(response);
            containerProperties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(response);

            // Reading public access
            containerProperties.PublicAccess = GetAcl(response);

            // WORM policies
            string hasImmutability = response.Headers[Constants.HeaderConstants.HasImmutabilityPolicyHeader];
            containerProperties.HasImmutabilityPolicy = string.IsNullOrEmpty(hasImmutability) ? (bool?)null : bool.Parse(hasImmutability);

            string hasLegalHold = response.Headers[Constants.HeaderConstants.HasLegalHoldHeader];
            containerProperties.HasLegalHold = string.IsNullOrEmpty(hasLegalHold) ? (bool?)null : bool.Parse(hasLegalHold);

            return(containerProperties);
        }
        internal static TableResult TableOperationPostProcess(TableResult result, TableOperation operation, RESTCommand <TableResult> cmd, HttpWebResponse resp, OperationContext ctx, TableRequestOptions options, string accountName)
        {
            if (operation.OperationType != TableOperationType.Retrieve && operation.OperationType != TableOperationType.Insert)
            {
                result.Etag           = HttpResponseParsers.GetETag(resp);
                operation.Entity.ETag = result.Etag;
            }
            else if (operation.OperationType == TableOperationType.Insert && (!operation.EchoContent))
            {
                result.Etag                = HttpResponseParsers.GetETag(resp);
                operation.Entity.ETag      = result.Etag;
                operation.Entity.Timestamp = ParseETagForTimestamp(result.Etag);
            }
            else
            {
                // Parse entity
                ODataMessageReaderSettings readerSettings = new ODataMessageReaderSettings();
                readerSettings.MessageQuotas = new ODataMessageQuotas()
                {
                    MaxPartsPerBatch = TableConstants.TableServiceMaxResults, MaxReceivedMessageSize = TableConstants.TableServiceMaxPayload
                };

                if (resp.ContentType.Contains(Constants.JsonNoMetadataAcceptHeaderValue))
                {
                    result.Etag = resp.Headers[Constants.HeaderConstants.EtagHeader];
                    ReadEntityUsingJsonParser(result, operation, cmd.ResponseStream, ctx, options);
                }
                else
                {
                    ReadOdataEntity(result, operation, new HttpResponseAdapterMessage(resp, cmd.ResponseStream), ctx, readerSettings, accountName);
                }
            }

            return(result);
        }
        /// <summary>
        /// Gets the file's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The file's properties.</returns>
        public static FileProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            FileProperties properties = new FileProperties();

            properties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            properties.LastModified    = HttpResponseParsers.GetLastModified(response);
            properties.ContentLanguage = response.Headers[Constants.HeaderConstants.ContentLanguageHeader];
#else
            properties.LastModified    = response.LastModified.ToUniversalTime();
            properties.ContentLanguage = response.Headers[HttpResponseHeader.ContentLanguage];
#endif

            properties.ContentDisposition = response.Headers[Constants.HeaderConstants.ContentDispositionResponseHeader];
            properties.ContentEncoding    = response.Headers[HttpResponseHeader.ContentEncoding];

            // For range gets, only look at 'x-ms-content-md5' for overall MD5
            if (response.Headers[HttpResponseHeader.ContentRange] != null)
            {
                properties.ContentMD5 = response.Headers[Constants.HeaderConstants.FileContentMD5Header];
            }
            else
            {
                properties.ContentMD5 = response.Headers[HttpResponseHeader.ContentMd5];
            }

            properties.ContentType  = response.Headers[HttpResponseHeader.ContentType];
            properties.CacheControl = response.Headers[HttpResponseHeader.CacheControl];

            string fileEncryption = response.Headers[Constants.HeaderConstants.ServerEncrypted];
            properties.IsServerEncrypted = string.Equals(fileEncryption, Constants.HeaderConstants.TrueHeader, StringComparison.OrdinalIgnoreCase);

            // Get the content length. Prioritize range and x-ms over content length for the special cases.
            string rangeHeader             = response.Headers[HttpResponseHeader.ContentRange];
            string contentLengthHeader     = response.Headers[Constants.HeaderConstants.ContentLengthHeader];
            string fileContentLengthHeader = response.Headers[Constants.HeaderConstants.FileContentLengthHeader];
            if (!string.IsNullOrEmpty(rangeHeader))
            {
                properties.Length = long.Parse(rangeHeader.Split('/')[1], CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(fileContentLengthHeader))
            {
                properties.Length = long.Parse(fileContentLengthHeader, CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(contentLengthHeader))
            {
                // On Windows Phone, ContentLength property is not always same as Content-Length header,
                // so we try to parse the header first.
                properties.Length = long.Parse(contentLengthHeader, CultureInfo.InvariantCulture);
            }
            else
            {
                properties.Length = response.ContentLength;
            }

            return(properties);
        }
Exemplo n.º 4
0
        public static void ETagHeader(HttpResponseMessage response)
        {
            Assert.IsNotNull(response);
            Assert.IsNotNull(HttpResponseParsers.GetETag(response));
            Regex eTagRegex = new Regex(@"^""0x[A-F0-9]{15,}""$");

            Assert.IsTrue(eTagRegex.IsMatch(HttpResponseParsers.GetETag(response)));
        }
        internal static TableResult TableOperationPreProcess(TableResult result, TableOperation operation, HttpWebResponse resp, Exception ex)
        {
            result.HttpStatusCode = (int)resp.StatusCode;

            if (operation.OperationType == TableOperationType.Retrieve)
            {
                if (resp.StatusCode != HttpStatusCode.OK && resp.StatusCode != HttpStatusCode.NotFound)
                {
                    CommonUtility.AssertNotNull("ex", ex);
                    throw ex;
                }
            }
            else
            {
                if (ex != null)
                {
                    throw ex;
                }
                else if (operation.OperationType == TableOperationType.Insert)
                {
                    if (operation.EchoContent)
                    {
                        if (resp.StatusCode != HttpStatusCode.Created)
                        {
                            throw ex;
                        }
                    }
                    else
                    {
                        if (resp.StatusCode != HttpStatusCode.NoContent)
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    if (resp.StatusCode != HttpStatusCode.NoContent)
                    {
                        throw ex;
                    }
                }
            }

            string etag = HttpResponseParsers.GetETag(resp);

            if (etag != null)
            {
                result.Etag = etag;
                if (operation.Entity != null)
                {
                    operation.Entity.ETag = result.Etag;
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the container's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The container's attributes.</returns>
        public static BlobContainerProperties GetProperties(HttpWebResponse response)
        {
            // Set the container properties
            BlobContainerProperties containerProperties = new BlobContainerProperties();

            containerProperties.ETag         = HttpResponseParsers.GetETag(response);
            containerProperties.LastModified = response.LastModified.ToUniversalTime();

            // Get lease properties
            containerProperties.LeaseStatus   = BlobHttpResponseParsers.GetLeaseStatus(response);
            containerProperties.LeaseState    = BlobHttpResponseParsers.GetLeaseState(response);
            containerProperties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(response);

            return(containerProperties);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the directory's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The directory's attributes.</returns>
        public static FileDirectoryProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            FileDirectoryProperties directoryProperties = new FileDirectoryProperties();

            directoryProperties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            directoryProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            directoryProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            return(directoryProperties);
        }
Exemplo n.º 8
0
        internal static TableResult TableOperationPreProcess <T>(TableResult result, TableOperation operation, HttpWebResponse resp, Exception ex, StorageCommandBase <T> cmd, OperationContext ctx)
        {
            result.HttpStatusCode = (int)resp.StatusCode;

            if (operation.OperationType == TableOperationType.Retrieve)
            {
                if (resp.StatusCode != HttpStatusCode.OK && resp.StatusCode != HttpStatusCode.NotFound)
                {
                    throw StorageException.TranslateException(ex, cmd.CurrentResult);
                }
            }
            else
            {
                if (ex != null)
                {
                    throw StorageException.TranslateException(ex, cmd.CurrentResult);
                }
                else if (operation.OperationType == TableOperationType.Insert)
                {
                    if (resp.StatusCode != HttpStatusCode.Created)
                    {
                        throw StorageException.TranslateException(ex, cmd.CurrentResult);
                    }
                }
                else
                {
                    if (resp.StatusCode != HttpStatusCode.NoContent)
                    {
                        throw StorageException.TranslateException(ex, cmd.CurrentResult);
                    }
                }
            }

            string etag = HttpResponseParsers.GetETag(resp);

            if (etag != null)
            {
                result.Etag = etag;
                if (operation.Entity != null)
                {
                    operation.Entity.ETag = result.Etag;
                }
            }

            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the share's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The share's attributes.</returns>
        public static FileShareProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            // Set the share properties
            FileShareProperties shareProperties = new FileShareProperties();

            shareProperties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            shareProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            shareProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            return(shareProperties);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the blob's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The blob's properties.</returns>
        public static BlobProperties GetProperties(HttpWebResponse response)
        {
            BlobProperties properties = new BlobProperties();

            properties.LastModified    = response.LastModified.ToUniversalTime();
            properties.ContentEncoding = response.Headers[HttpResponseHeader.ContentEncoding];
            properties.ContentLanguage = response.Headers[HttpResponseHeader.ContentLanguage];
            properties.ContentMD5      = response.Headers[HttpResponseHeader.ContentMd5];
            properties.ContentType     = response.Headers[HttpResponseHeader.ContentType];
            properties.CacheControl    = response.Headers[HttpResponseHeader.CacheControl];
            properties.ETag            = HttpResponseParsers.GetETag(response);

            string blobType = response.Headers[Constants.HeaderConstants.BlobType];

            // Get blob type
            if (!string.IsNullOrEmpty(blobType))
            {
                properties.BlobType = (BlobType)Enum.Parse(typeof(BlobType), blobType, true);
            }

            // Get lease properties
            properties.LeaseStatus   = GetLeaseStatus(response);
            properties.LeaseState    = GetLeaseState(response);
            properties.LeaseDuration = GetLeaseDuration(response);

            // Get the content length. Prioritize range and x-ms over content length for the special cases.
            string rangeHeader         = response.Headers[HttpResponseHeader.ContentRange];
            string contentLengthHeader = response.Headers[Constants.HeaderConstants.ContentLengthHeader];

            if (!string.IsNullOrEmpty(rangeHeader))
            {
                properties.Length = long.Parse(rangeHeader.Split('/')[1]);
            }
            else if (!string.IsNullOrEmpty(contentLengthHeader))
            {
                properties.Length = long.Parse(contentLengthHeader);
            }
            else
            {
                properties.Length = response.ContentLength;
            }

            return(properties);
        }
        /// <summary>
        /// Gets the directory's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The directory's attributes.</returns>
        public static FileDirectoryProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            FileDirectoryProperties directoryProperties = new FileDirectoryProperties();

            directoryProperties.ETag = HttpResponseParsers.GetETag(response);
            string directoryEncryption = response.Headers[Constants.HeaderConstants.ServerEncrypted];

            directoryProperties.IsServerEncrypted = string.Equals(directoryEncryption, Constants.HeaderConstants.TrueHeader, StringComparison.OrdinalIgnoreCase);

#if WINDOWS_PHONE
            directoryProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            directoryProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            return(directoryProperties);
        }
Exemplo n.º 12
0
        internal static TableResult TableOperationPostProcess(TableResult result, TableOperation operation, RESTCommand <TableResult> cmd, HttpWebResponse resp, OperationContext ctx)
        {
            if (operation.OperationType != TableOperationType.Retrieve && operation.OperationType != TableOperationType.Insert)
            {
                result.Etag           = HttpResponseParsers.GetETag(resp);
                operation.Entity.ETag = result.Etag;
            }
            else
            {
                // Parse entity
                ODataMessageReaderSettings readerSettings = new ODataMessageReaderSettings();
                readerSettings.MessageQuotas = new ODataMessageQuotas()
                {
                    MaxPartsPerBatch = TableConstants.TableServiceMaxResults, MaxReceivedMessageSize = TableConstants.TableServiceMaxPayload
                };

                ReadOdataEntity(result, operation, new HttpResponseAdapterMessage(resp, cmd.ResponseStream), ctx, readerSettings);
            }

            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the container's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The container's attributes.</returns>
        public static BlobContainerProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            // Set the container properties
            BlobContainerProperties containerProperties = new BlobContainerProperties();

            containerProperties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            containerProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            containerProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            // Get lease properties
            containerProperties.LeaseStatus   = BlobHttpResponseParsers.GetLeaseStatus(response);
            containerProperties.LeaseState    = BlobHttpResponseParsers.GetLeaseState(response);
            containerProperties.LeaseDuration = BlobHttpResponseParsers.GetLeaseDuration(response);

            return(containerProperties);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the share's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The share's attributes.</returns>
        public static FileShareProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            // Set the share properties
            FileShareProperties shareProperties = new FileShareProperties();

            shareProperties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            shareProperties.LastModified = HttpResponseParsers.GetLastModified(response);
#else
            shareProperties.LastModified = response.LastModified.ToUniversalTime();
#endif

            string quota = response.Headers[Constants.HeaderConstants.ShareQuota];
            if (!string.IsNullOrEmpty(quota))
            {
                shareProperties.Quota = int.Parse(quota, CultureInfo.InvariantCulture);
            }

            return(shareProperties);
        }
        /// <summary>
        /// Gets the blob's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The blob's properties.</returns>
        public static BlobProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            BlobProperties properties = new BlobProperties();

            properties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            properties.Created         = HttpResponseParsers.GetCreated(response);
            properties.LastModified    = HttpResponseParsers.GetLastModified(response);
            properties.ContentLanguage = response.Headers[Constants.HeaderConstants.ContentLanguageHeader];
#else
            string created = response.Headers[Constants.HeaderConstants.CreationTimeHeader];
            properties.Created = string.IsNullOrEmpty(created) ? (DateTimeOffset?)null : DateTimeOffset.Parse(created).ToUniversalTime();

            properties.LastModified    = response.LastModified.ToUniversalTime();
            properties.ContentLanguage = response.Headers[HttpResponseHeader.ContentLanguage];
#endif

            properties.ContentDisposition = response.Headers[Constants.HeaderConstants.ContentDispositionResponseHeader];
            properties.ContentEncoding    = response.Headers[HttpResponseHeader.ContentEncoding];

            // For range gets, only look at 'x-ms-blob-content-md5' for overall MD5
            if (response.Headers[HttpResponseHeader.ContentRange] != null)
            {
                properties.ContentMD5 = response.Headers[Constants.HeaderConstants.BlobContentMD5Header];
            }
            else
            {
                properties.ContentMD5 = response.Headers[HttpResponseHeader.ContentMd5];
            }

            properties.ContentType  = response.Headers[HttpResponseHeader.ContentType];
            properties.CacheControl = response.Headers[HttpResponseHeader.CacheControl];

            string blobEncryption = response.Headers[Constants.HeaderConstants.ServerEncrypted];
            properties.IsServerEncrypted = string.Equals(blobEncryption, Constants.HeaderConstants.TrueHeader, StringComparison.OrdinalIgnoreCase);

            string incrementalCopy = response.Headers[Constants.HeaderConstants.IncrementalCopyHeader];
            properties.IsIncrementalCopy = string.Equals(incrementalCopy, Constants.HeaderConstants.TrueHeader, StringComparison.OrdinalIgnoreCase);

            // Get blob type
            string blobType = response.Headers[Constants.HeaderConstants.BlobType];
            if (!string.IsNullOrEmpty(blobType))
            {
                properties.BlobType = (BlobType)Enum.Parse(typeof(BlobType), blobType, true);
            }

            // Get lease properties
            properties.LeaseStatus   = GetLeaseStatus(response);
            properties.LeaseState    = GetLeaseState(response);
            properties.LeaseDuration = GetLeaseDuration(response);

            // Get the content length. Prioritize range and x-ms over content length for the special cases.
            string rangeHeader             = response.Headers[HttpResponseHeader.ContentRange];
            string contentLengthHeader     = response.Headers[Constants.HeaderConstants.ContentLengthHeader];
            string blobContentLengthHeader = response.Headers[Constants.HeaderConstants.BlobContentLengthHeader];
            if (!string.IsNullOrEmpty(rangeHeader))
            {
                properties.Length = long.Parse(rangeHeader.Split('/')[1], CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(blobContentLengthHeader))
            {
                properties.Length = long.Parse(blobContentLengthHeader, CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(contentLengthHeader))
            {
                // On Windows Phone, ContentLength property is not always same as Content-Length header,
                // so we try to parse the header first.
                properties.Length = long.Parse(contentLengthHeader, CultureInfo.InvariantCulture);
            }
            else
            {
                properties.Length = response.ContentLength;
            }

            // Get sequence number
            string sequenceNumber = response.Headers[Constants.HeaderConstants.BlobSequenceNumber];
            if (!string.IsNullOrEmpty(sequenceNumber))
            {
                properties.PageBlobSequenceNumber = long.Parse(sequenceNumber, CultureInfo.InvariantCulture);
            }

            // Get committed block count
            string comittedBlockCount = response.Headers[Constants.HeaderConstants.BlobCommittedBlockCount];
            if (!string.IsNullOrEmpty(comittedBlockCount))
            {
                properties.AppendBlobCommittedBlockCount = int.Parse(comittedBlockCount, CultureInfo.InvariantCulture);
            }

            // Get the tier of the blob
            string premiumPageBlobTierInferredString = response.Headers[Constants.HeaderConstants.AccessTierInferredHeader];
            if (!string.IsNullOrEmpty(premiumPageBlobTierInferredString))
            {
                properties.BlobTierInferred = Convert.ToBoolean(premiumPageBlobTierInferredString);
            }

            string blobTierString = response.Headers[Constants.HeaderConstants.AccessTierHeader];

            StandardBlobTier?   standardBlobTier;
            PremiumPageBlobTier?premiumPageBlobTier;
            BlobHttpResponseParsers.GetBlobTier(properties.BlobType, blobTierString, out standardBlobTier, out premiumPageBlobTier);
            properties.StandardBlobTier    = standardBlobTier;
            properties.PremiumPageBlobTier = premiumPageBlobTier;

            if ((properties.PremiumPageBlobTier.HasValue || properties.StandardBlobTier.HasValue) && !properties.BlobTierInferred.HasValue)
            {
                properties.BlobTierInferred = false;
            }

            // Get the rehydration status
            string rehydrationStatusString = response.Headers[Constants.HeaderConstants.ArchiveStatusHeader];
            properties.RehydrationStatus = BlobHttpResponseParsers.GetRehydrationStatus(rehydrationStatusString);

            // Get the time the tier of the blob was last modified
            string accessTierChangeTimeString = response.Headers[Constants.HeaderConstants.AccessTierChangeTimeHeader];
            if (!string.IsNullOrEmpty(accessTierChangeTimeString))
            {
                properties.BlobTierLastModifiedTime = DateTimeOffset.Parse(accessTierChangeTimeString, CultureInfo.InvariantCulture);
            }

            return(properties);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the blob's properties from the response.
        /// </summary>
        /// <param name="response">The web response.</param>
        /// <returns>The blob's properties.</returns>
        public static BlobProperties GetProperties(HttpWebResponse response)
        {
            CommonUtility.AssertNotNull("response", response);

            BlobProperties properties = new BlobProperties();

            properties.ETag = HttpResponseParsers.GetETag(response);

#if WINDOWS_PHONE
            properties.LastModified    = HttpResponseParsers.GetLastModified(response);
            properties.ContentLanguage = response.Headers[Constants.HeaderConstants.ContentLanguageHeader];
#else
            properties.LastModified    = response.LastModified.ToUniversalTime();
            properties.ContentLanguage = response.Headers[HttpResponseHeader.ContentLanguage];
#endif

            properties.ContentDisposition = response.Headers[Constants.HeaderConstants.ContentDispositionResponseHeader];
            properties.ContentEncoding    = response.Headers[HttpResponseHeader.ContentEncoding];
            properties.ContentMD5         = response.Headers[HttpResponseHeader.ContentMd5];
            properties.ContentType        = response.Headers[HttpResponseHeader.ContentType];
            properties.CacheControl       = response.Headers[HttpResponseHeader.CacheControl];

            // Get blob type
            string blobType = response.Headers[Constants.HeaderConstants.BlobType];
            if (!string.IsNullOrEmpty(blobType))
            {
                properties.BlobType = (BlobType)Enum.Parse(typeof(BlobType), blobType, true);
            }

            // Get lease properties
            properties.LeaseStatus   = GetLeaseStatus(response);
            properties.LeaseState    = GetLeaseState(response);
            properties.LeaseDuration = GetLeaseDuration(response);

            // Get the content length. Prioritize range and x-ms over content length for the special cases.
            string rangeHeader             = response.Headers[HttpResponseHeader.ContentRange];
            string contentLengthHeader     = response.Headers[Constants.HeaderConstants.ContentLengthHeader];
            string blobContentLengthHeader = response.Headers[Constants.HeaderConstants.BlobContentLengthHeader];
            if (!string.IsNullOrEmpty(rangeHeader))
            {
                properties.Length = long.Parse(rangeHeader.Split('/')[1], CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(blobContentLengthHeader))
            {
                properties.Length = long.Parse(blobContentLengthHeader, CultureInfo.InvariantCulture);
            }
            else if (!string.IsNullOrEmpty(contentLengthHeader))
            {
                // On Windows Phone, ContentLength property is not always same as Content-Length header,
                // so we try to parse the header first.
                properties.Length = long.Parse(contentLengthHeader, CultureInfo.InvariantCulture);
            }
            else
            {
                properties.Length = response.ContentLength;
            }

            // Get sequence number
            string sequenceNumber = response.Headers[Constants.HeaderConstants.BlobSequenceNumber];
            if (!string.IsNullOrEmpty(sequenceNumber))
            {
                properties.PageBlobSequenceNumber = long.Parse(sequenceNumber, CultureInfo.InvariantCulture);
            }

            // Get committed block count
            string comittedBlockCount = response.Headers[Constants.HeaderConstants.BlobCommittedBlockCount];
            if (!string.IsNullOrEmpty(comittedBlockCount))
            {
                properties.AppendBlobCommittedBlockCount = int.Parse(comittedBlockCount, CultureInfo.InvariantCulture);
            }

            return(properties);
        }