本文整理汇总了C#中HttpHeaders.SetContentLength方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHeaders.SetContentLength方法的具体用法?C# HttpHeaders.SetContentLength怎么用?C# HttpHeaders.SetContentLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.SetContentLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSetContentLengthNullClearsValue
public void TestSetContentLengthNullClearsValue()
{
HttpHeaders headers = new HttpHeaders ();
headers.SetContentLength ("100");
Assert.AreEqual (100, headers.ContentLength, "a1");
headers.SetContentLength (null);
Assert.IsNull (headers.ContentLength, "a2");
}
示例2: TestSetContentLengthInvalid
public void TestSetContentLengthInvalid()
{
HttpHeaders headers = new HttpHeaders ();
Should.Throw<ArgumentException> (() => headers.SetContentLength ("foobar"));
Should.Throw<ArgumentException> (() => headers.SetContentLength ("-1 foobar"));
Should.Throw<ArgumentException> (() => headers.SetContentLength ("1foo"));
Should.Throw<ArgumentException> (() => headers.SetContentLength ("1FA"));
Should.Throw<ArgumentException> (() => headers.SetContentLength ("1."));
Should.Throw<ArgumentException> (() => headers.SetContentLength ("1.0"));
}
示例3: TestSetContentLengthNegative
public void TestSetContentLengthNegative()
{
HttpHeaders headers = new HttpHeaders ();
Should.Throw<ArgumentException> (() => headers.SetContentLength ("-1"));
}
示例4: TestSetContentLength
public void TestSetContentLength()
{
HttpHeaders headers = new HttpHeaders ();
headers.SetContentLength ("100");
Assert.AreEqual (100, headers.ContentLength, "a1");
headers.SetContentLength ("1");
Assert.AreEqual (1, headers.ContentLength, "a2");
headers.SetContentLength ("0");
Assert.AreEqual (0, headers.ContentLength, "a3");
}