示例#1
0
        public void CanWeParseHttpStatusCode()
        {
            byte[] input = Encoding.ASCII.GetBytes(SampleHttpResponse);
            int    statusCode;
            var    result = HttpParser.GetHttpHeaders(input, input.IndexOf(ByteArrayExtensionsTests.BODY_CRLF), out statusCode);

            Assert.AreEqual(statusCode, 200);
        }
示例#2
0
        public void CanWeParseRandomHeaders()
        {
            byte[] input = Encoding.ASCII.GetBytes(SampleHttpResponse);
            int    statusCode;
            var    result = HttpParser.GetHttpHeaders(input, input.IndexOf(ByteArrayExtensionsTests.BODY_CRLF), out statusCode);

            Assert.True(result.Count == 14);
            Assert.True(result["Date"] == "Wed, 06 Mar 2013 01:34:38 GMT");
        }
示例#3
0
        public void Redirect301Request()
        {
            byte[] input = Encoding.ASCII.GetBytes(SampleRedirectResponse);
            int    statusCode;
            var    headers  = HttpParser.GetHttpHeaders(input, input.IndexOf(ByteArrayExtensionsTests.BODY_CRLF), out statusCode);
            var    response = new SimpleHttpResponse(statusCode, null, headers);

            Assert.AreEqual(statusCode, 301);
            Assert.AreEqual(response.Location, @"https://1000genomes.s3.amazonaws.com/release/20110521/ALL.chr9.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz?AWSAccessKeyId=AKIAIYDIF27GS5AAXHQQ&Expires=1427000627&Signature=PFrSu5ZXoUl17mCRg3HwDORfkg4%3D");
        }
示例#4
0
        public void CanWeParseHttpStatusAndConvertToInt()
        {
            byte[] input = Encoding.ASCII.GetBytes(SampleHttpResponse);
            int    statusCode;
            var    result   = HttpParser.GetHttpHeaders(input, input.IndexOf(ByteArrayExtensionsTests.BODY_CRLF), out statusCode);
            var    response = new SimpleHttpResponse(statusCode, input, result);

            Assert.True(response.StatusCode == 200);
            Assert.True(response.WasSuccessful);
            Assert.True(response.IsStatusCodeRetryable);
        }
示例#5
0
        public void MultipleHeadersWithTheSameKey()
        {
            byte[] input = Encoding.ASCII.GetBytes(SampleRedirectWithMultipleCookiesResponse);
            int    statusCode;
            var    result = HttpParser.GetHttpHeaders(input, input.IndexOf(ByteArrayExtensionsTests.BODY_CRLF),
                                                      out statusCode);
            var response = new SimpleHttpResponse(statusCode, input, result);

            Assert.True(response.StatusCode == 301);

            Assert.True(response.Headers["Set-Cookie"].Contains("blah"));
        }