本文整理汇总了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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}