当前位置: 首页>>代码示例>>C#>>正文


C# RequestHeaders类代码示例

本文整理汇总了C#中RequestHeaders的典型用法代码示例。如果您正苦于以下问题:C# RequestHeaders类的具体用法?C# RequestHeaders怎么用?C# RequestHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RequestHeaders类属于命名空间,在下文中一共展示了RequestHeaders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Request

        public Request(string method, Url url, IHttpUtility httpUtility, RequestStream body = null, IDictionary<string, IEnumerable<string>> headers = null, string ip = null)
        {
            method.ArgumentNullOrEmptyCheck("method");
            url.ArgumentNullCheck("url");
            url.Path.ArgumentNullOrEmptyCheck("url.Path");
            url.Scheme.ArgumentNullOrEmptyCheck("url.Scheme");
            httpUtility.ArgumentNullCheck("httpUtility");

            this.httpUtility = httpUtility;

            Items = new Dictionary<string, object>();

            UserHostAddress = ip;

            Url = url;

            Method = method;

            Query = url.Query.AsQueryDictionary(httpUtility);

            Body = body ?? RequestStream.FromStream(new MemoryStream());

            Headers = new RequestHeaders(headers ?? new Dictionary<string, IEnumerable<string>>());

            ParseFormData();
        }
开发者ID:UStack,项目名称:UWeb,代码行数:26,代码来源:Request.cs

示例2: Should_return_empty_enumerable_when_accept_headers_are_not_available

        public void Should_return_empty_enumerable_when_accept_headers_are_not_available()
        {
            // Given
            var rawHeaders = new Dictionary<string, IEnumerable<string>>();

            // When
            var headers = new RequestHeaders(rawHeaders);
            
            // Then
            headers.Accept.ShouldHaveCount(0);
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:11,代码来源:RequestHeadersFixture.cs

示例3: SetUp

        public void SetUp()
        {
            httpRequest = new StubCurrentHttpRequest();

            var container = StructureMapContainerFacility.GetBasicFubuContainer();
            theHeaderValues = httpRequest.Headers;

            container.Inject<ICurrentHttpRequest>(httpRequest);

            theHeaders = container.GetInstance<RequestHeaders>();
        }
开发者ID:NeilSorensen,项目名称:fubumvc,代码行数:11,代码来源:RequestHeadersIntegratedTester.cs

示例4: SetUp

        public void SetUp()
        {
            var container = StructureMapContainerFacility.GetBasicFubuContainer();
            theHeaderValues = new KeyValues();

            theRequest = new RequestData();
            theRequest.AddValues(RequestDataSource.Header, theHeaderValues);

            container.Inject<IRequestData>(theRequest);

            theHeaders = container.GetInstance<RequestHeaders>();
        }
开发者ID:ruizbennett,项目名称:fubumvc,代码行数:12,代码来源:RequestHeadersIntegratedTester.cs

示例5: Should_ignore_case_of_accept_charset_header_name_when_retrieving_values

        public void Should_ignore_case_of_accept_charset_header_name_when_retrieving_values(string headerName)
        {
            // Given
            var expectedValues = new[] { "utf-8", "iso-8859-5" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { headerName, expectedValues } };

            // When
            var headers = new RequestHeaders(rawHeaders);

            // Then
            headers.AcceptCharset.ShouldBeSameAs(expectedValues);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:12,代码来源:RequestHeadersFixture.cs

示例6: Should_be_null_when_date_headers_are_invalid

        public void Should_be_null_when_date_headers_are_invalid()
        {
            // Given
            var expectedValues = new[] { "Bad Date Header" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Date", expectedValues } };

            // When
            var headers = new RequestHeaders(rawHeaders);

            // Then
            headers.Date.ShouldBeNull();
        }
开发者ID:davidoleary,项目名称:Nancy,代码行数:12,代码来源:RequestHeadersFixture.cs

示例7: Should_ignore_case_of_accept_encoding_header_name_when_retrieving_values

        public void Should_ignore_case_of_accept_encoding_header_name_when_retrieving_values(string headerName)
        {
            // Given
            var expectedValues = new[] { "compress", "sdch" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { headerName, expectedValues } };

            // When
            var headers = new RequestHeaders(rawHeaders);

            // Then
            headers.AcceptEncoding.ShouldBeSameAs(expectedValues);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:12,代码来源:RequestHeadersFixture.cs

示例8: Should_ignore_case_of_accept_header_name_when_retrieving_values

        public void Should_ignore_case_of_accept_header_name_when_retrieving_values(string headerName)
        {
            // Given
            var expectedValues = new[] { "text/plain", "text/ninja" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { headerName, expectedValues } };

            // When
            var headers = new RequestHeaders(rawHeaders);

            // Then
            headers.Accept.ShouldBeSameAs(expectedValues);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:12,代码来源:RequestHeadersFixture.cs

示例9: Should_header_values_when_available_using_indexer

        public void Should_header_values_when_available_using_indexer()
        {
            // Given
            var expectedValues = new[] { "fakeValue1", "fakeValue2" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "some-header", expectedValues } };
            var headers = new RequestHeaders(rawHeaders);

            // When
            var result = headers["some-header"];

            // Then
            result.ShouldBeSameAs(expectedValues);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:13,代码来源:RequestHeadersFixture.cs

示例10: Should_default_accept_language_header_values_to_quality_one_if_not_explicitly_defined

        public void Should_default_accept_language_header_values_to_quality_one_if_not_explicitly_defined()
        {
            // Given
            var values = new[] { "en-US" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Accept-Language", values } };

            // When
            var headers = new RequestHeaders(rawHeaders).AcceptLanguage.ToList();

            // Then
            headers.Count.ShouldEqual(1);
            headers[0].Item1.ShouldEqual("en-US");
            headers[0].Item2.ShouldEqual(1m);
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:14,代码来源:RequestHeadersFixture.cs

示例11: Should_allow_accept_authorization_to_be_overwritten

        public void Should_allow_accept_authorization_to_be_overwritten()
        {
            // Given
            var rawHeaders =
                new Dictionary<string, IEnumerable<string>> { { "Authorization", new[] { "Basic 12345LDKJDFJDDSFDFvfdf==" } } };

            var headers =
                new RequestHeaders(rawHeaders) { Authorization = "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" };

            // When
            var values = headers.Authorization;

            // Then
            values.ShouldEqual("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:15,代码来源:RequestHeadersFixture.cs

示例12: PomonaRequest

 public PomonaRequest(string url,
                      string relativePath,
                      HttpMethod method = HttpMethod.Get,
                      RequestHeaders headers = null,
                      Stream body = null,
                      DynamicDictionary query = null)
 {
     if (url == null)
         throw new ArgumentNullException(nameof(url));
     Method = method;
     Url = url;
     RelativePath = relativePath;
     Body = body;
     this.headers = headers;
     Query = query ?? new DynamicDictionary();
 }
开发者ID:Pomona,项目名称:Pomona,代码行数:16,代码来源:PomonaRequest.cs

示例13: Should_return_all_accept_headers_when_multiple_are_available

        public void Should_return_all_accept_headers_when_multiple_are_available()
        {
            // Given
            var rawHeaders = 
                new Dictionary<string, IEnumerable<string>>
                {
                    { "Accept", new[] { "text/plain", "text/ninja" } }
                };

            // When
            var headers = new RequestHeaders(rawHeaders).Accept.ToList();

            // Then
            headers.ShouldHaveCount(2);
            headers[0].Item1.ShouldEqual("text/plain");
            headers[1].Item1.ShouldEqual("text/ninja");
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:17,代码来源:RequestHeadersFixture.cs

示例14: Should_return_all_header_names_when_keys_are_retrieved

        public void Should_return_all_header_names_when_keys_are_retrieved()
        {
            // Given
            var rawHeaders = 
                new Dictionary<string, IEnumerable<string>>
                {
                    {"accept", null},
                    {"charset", null}
                };

            var headers = new RequestHeaders(rawHeaders);

            // When
            var keys = headers.Keys.ToList();

            // Then
            keys.ShouldHaveCount(2);
            keys.First().ShouldEqual("accept");
            keys.Last().ShouldEqual("charset");
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:20,代码来源:RequestHeadersFixture.cs

示例15: Should_allow_accept_encoding_headers_to_be_overwritten

        public void Should_allow_accept_encoding_headers_to_be_overwritten()
        {
            // Given
            var expectedValues = new[] {
                "compress",
                "gzip",
            };

            var rawHeaders =
                new Dictionary<string, IEnumerable<string>> { { "Accept-Encoding", new[] { "sdch" } } };

            var headers =
                new RequestHeaders(rawHeaders) { AcceptEncoding = expectedValues };

            // When
            var values = headers.AcceptEncoding.ToList();

            // Then
            values[0].ShouldEqual("compress");
            values[1].ShouldEqual("gzip");
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:21,代码来源:RequestHeadersFixture.cs


注:本文中的RequestHeaders类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。