public static HttpWebRequest GetFileRequest(FileContext context, string shareName, string fileName, AccessCondition accessCondition) { bool valid = FileTests.ShareNameValidator(shareName) && FileTests.FileNameValidator(fileName); Uri uri = FileTests.ConstructGetUri(context.Address, shareName, fileName); HttpWebRequest request = null; OperationContext opContext = new OperationContext(); try { request = FileHttpWebRequestFactory.Get(uri, context.Timeout, accessCondition, true, opContext); } catch (InvalidOperationException) { if (valid) { Assert.Fail(); } } if (valid) { Assert.IsNotNull(request); Assert.IsNotNull(request.Method); Assert.AreEqual("GET", request.Method); FileTestUtils.RangeHeader(request, null); } return(request); }
/// <summary> /// Constructs a web request to return a specified range of the file's content, together with its properties and metadata. /// </summary> /// <param name="uri">The absolute URI to the file.</param> /// <param name="timeout">The server timeout interval, in seconds.</param> /// <param name="offset">The byte offset at which to begin returning content.</param> /// <param name="count">The number of bytes to return, or null to return all bytes through the end of the file.</param> /// <param name="rangeContentMD5">If set to <c>true</c>, request an MD5 header for the specified range.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param> /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param> /// <returns>A web request to use to perform the operation.</returns> public static HttpWebRequest Get(Uri uri, int?timeout, long?offset, long?count, bool rangeContentMD5, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) { return(FileHttpWebRequestFactory.Get(uri, timeout, offset, count, rangeContentMD5, null /* shareSnapshot */, accessCondition, useVersionHeader, operationContext)); }
/// <summary> /// Constructs a web request to get the file's content, properties, and metadata. /// </summary> /// <param name="uri">The absolute URI to the file.</param> /// <param name="timeout">The server timeout interval.</param> /// <param name="accessCondition">The access condition to apply to the request.</param> /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param> /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param> /// <returns>A web request for performing the operation.</returns> public static HttpWebRequest Get(Uri uri, int?timeout, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext) { return(FileHttpWebRequestFactory.Get(uri, timeout, null /* shareSnapshot */, accessCondition, useVersionHeader, operationContext)); }