Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static HttpRequestMessage 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);
            HttpRequestMessage request   = null;
            OperationContext   opContext = new OperationContext();

            try
            {
                request = FileHttpRequestMessageFactory.Get(uri, context.Timeout, null, accessCondition, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials);
            }
            catch (InvalidOperationException)
            {
                if (valid)
                {
                    Assert.Fail();
                }
            }
            if (valid)
            {
                Assert.IsNotNull(request);
                Assert.IsNotNull(request.Method);
                Assert.AreEqual(HttpMethod.Get, request.Method);
                FileTestUtils.RangeHeader(request, null);
            }
            return(request);
        }