• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RequestHeaders类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Should_return_all_header_values_when_values_are_retrieved

        public void Should_return_all_header_values_when_values_are_retrieved()
        {
            // Given
            var rawHeaders =
                new Dictionary<string, IEnumerable<string>>
                {
                    {"accept", new[] {"text/plain", "text/html"}},
                    {"charset", new[] {"utf-8"}}
                };

            var headers = new RequestHeaders(rawHeaders);

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

            // Then
            values.ShouldHaveCount(2);
            values.First().ShouldHaveCount(2);
            values.First().First().ShouldEqual("text/plain");
            values.First().Last().ShouldEqual("text/html");
            values.Last().First().ShouldEqual("utf-8");
        }
开发者ID:Borzoo,项目名称:Nancy,代码行数:22,代码来源:RequestHeadersFixture.cs


示例17: Should_allow_accept_charset_headers_to_be_overwritten

        public void Should_allow_accept_charset_headers_to_be_overwritten()
        {
            // Given
            var expectedValues = new[] {
                new Tuple<string, decimal>("utf-8", 0.7m),
                new Tuple<string, decimal>("iso-8859-5", 0.3m),
            };

            var rawHeaders =
                new Dictionary<string, IEnumerable<string>> { { "Accept-Charset", new[] { "utf-7" } } };

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

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

            // Then
            values[0].Item1.ShouldEqual("utf-8");
            values[0].Item2.ShouldEqual(0.7m);
            values[1].Item1.ShouldEqual("iso-8859-5");
            values[1].Item2.ShouldEqual(0.3m);
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:23,代码来源:RequestHeadersFixture.cs


示例18: SpecialEmbeddedFileResponse

        public SpecialEmbeddedFileResponse(Assembly assembly, string zipFilePath, string resourcePath, RequestHeaders requestHeaders = null, bool disableRequestCompression = false)
        {
            _disableRequestCompression = disableRequestCompression;

            // Generate the etag for the zip file and use it for optionally returning HTTP Not-Modified
            var zipFileEtag = "zip" + File.GetLastWriteTime(zipFilePath).Ticks.ToString("G");
            if (requestHeaders != null && (requestHeaders.IfMatch.Any(x => x == zipFileEtag) || requestHeaders.IfNoneMatch.Any(x => x == zipFileEtag)))
            {
                StatusCode = HttpStatusCode.NotModified;
                this.WithHeader("ETag", zipFileEtag);
                return;
            }

            var content = GetFileFromZip(zipFilePath, resourcePath);
            if (content != null)
            {
                Contents = content;
                if (_disableRequestCompression == false)
                    Headers["Content-Encoding"] = "gzip";
                this.WithHeader("ETag", zipFileEtag);
            }
            else
            {
                // Potentially fall back to loading the requested file if it was embedded as a resource
                var fileContent = assembly.GetManifestResourceStream(resourcePath);
                if (fileContent == null)
                {
                    StatusCode = HttpStatusCode.NotFound;
                    return;
                }
                Contents = GetFileContent(fileContent);
            }
            
            ContentType = MimeTypes.GetMimeType(Path.GetFileName(resourcePath));
            StatusCode = HttpStatusCode.OK;
        }
开发者ID:synhershko,项目名称:RavenDB.ElasticsearchReplication,代码行数:36,代码来源:SpecialEmbeddedFileResponse.cs


示例19: Should_return_referer_headers_when_available

        public void Should_return_referer_headers_when_available()
        {
            // Given
            var expectedValues = new[] { "http://nancyfx.org" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Referer", expectedValues } };

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

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


示例20: Should_return_min_date_when_ifunmodifiedsince_headers_are_not_available

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

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

            // Then
            headers.IfUnmodifiedSince.ShouldEqual(DateTime.MinValue);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:11,代码来源:RequestHeadersFixture.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RequestInfo类代码示例发布时间:2022-05-24
下一篇:
C# RequestHeader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap