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


C# HttpHeaders.Parse方法代码示例

本文整理汇总了C#中HttpHeaders.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHeaders.Parse方法的具体用法?C# HttpHeaders.Parse怎么用?C# HttpHeaders.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpHeaders的用法示例。


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

示例1: TestMultilineParse

        public void TestMultilineParse()
        {
            //
            // multiline values are acceptable if the next
            // line starts with spaces
            //
            string header = @"HeaderName: Some multiline
              								value";

            HttpHeaders headers = new HttpHeaders ();

            headers.Parse (new StringReader (header));

            Assert.AreEqual ("Some multiline value", headers ["HeaderName"], "a1");

            header = @"HeaderName: Some multiline
              								value
            that spans
            a bunch of lines";

            headers = new HttpHeaders ();
            headers.Parse (new StringReader (header));

            Assert.AreEqual ("Some multiline value that spans a bunch of lines", headers ["HeaderName"], "a2");
        }
开发者ID:KevinT,项目名称:manos,代码行数:25,代码来源:HttpHeadersTest.cs

示例2: TestWhiteSpaceStartsFirstLine

        public void TestWhiteSpaceStartsFirstLine()
        {
            HttpHeaders headers = new HttpHeaders ();

            string str = " Key: Value";

            Should.Throw<HttpException> (() => headers.Parse (new StringReader (str)));
            Assert.AreEqual (0, headers.Count, "a2");
        }
开发者ID:KevinT,项目名称:manos,代码行数:9,代码来源:HttpHeadersTest.cs

示例3: TestSingleValueParseTrailingWhiteSpace

        public void TestSingleValueParseTrailingWhiteSpace()
        {
            HttpHeaders headers = new HttpHeaders ();

            string str = "Key: Value      ";
            headers.Parse (new StringReader (str));
            Assert.AreEqual ("Value", headers ["Key"], "a1");
            Assert.AreEqual (1, headers.Count, "a2");

            str = "Key: Value\t";
            headers.Parse (new StringReader (str));
            Assert.AreEqual ("Value", headers ["Key"], "a1");
            Assert.AreEqual (1, headers.Count, "a2");

            str = "Key: Value ";
            headers.Parse (new StringReader (str));
            Assert.AreEqual ("Value", headers ["Key"], "a1");
            Assert.AreEqual (1, headers.Count, "a2");
        }
开发者ID:KevinT,项目名称:manos,代码行数:19,代码来源:HttpHeadersTest.cs

示例4: TestParseNoValue

        public void TestParseNoValue()
        {
            HttpHeaders headers = new HttpHeaders ();

            string str = "Key:\n";

            Should.Throw<HttpException> (() => headers.Parse (new StringReader (str)));
            Assert.AreEqual (0, headers.Count, "a2");
            Assert.IsNull (headers.ContentLength, "a3");
        }
开发者ID:KevinT,项目名称:manos,代码行数:10,代码来源:HttpHeadersTest.cs

示例5: TestValueIsJustWhiteSpace

        public void TestValueIsJustWhiteSpace()
        {
            var headers = new HttpHeaders();

            string str = "Key: ";

            Should.Throw<HttpException>(() => headers.Parse(new StringReader(str)));
            Assert.AreEqual(0, headers.Count, "a2");
        }
开发者ID:nuxleus,项目名称:manos,代码行数:9,代码来源:HttpHeadersTest.cs

示例6: TestMultipleValueParse

        public void TestMultipleValueParse()
        {
            HttpHeaders headers = new HttpHeaders ();

            string str = "Key1: Value1\nKey2: Value2\nKey3: Value3";

            headers.Parse (new StringReader (str));

            Assert.AreEqual ("Value1", headers ["Key1"], "a1");
            Assert.AreEqual ("Value2", headers ["Key2"], "a2");
            Assert.AreEqual ("Value3", headers ["Key3"], "a3");
            Assert.AreEqual (3, headers.Count, "a4");
        }
开发者ID:KevinT,项目名称:manos,代码行数:13,代码来源:HttpHeadersTest.cs


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