本文整理汇总了C#中HttpCookie.ToHeaderString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpCookie.ToHeaderString方法的具体用法?C# HttpCookie.ToHeaderString怎么用?C# HttpCookie.ToHeaderString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpCookie
的用法示例。
在下文中一共展示了HttpCookie.ToHeaderString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToHeaderString_SingleValueWithWhiteSpace_Formatting
public void ToHeaderString_SingleValueWithWhiteSpace_Formatting()
{
string name = "foobar";
string value = "the value";
var cookie = new HttpCookie(name, value);
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=\"the value\"\r\n", header);
}
示例2: ToHeaderString_NameWithComma_Formatting
public void ToHeaderString_NameWithComma_Formatting()
{
string name = "foo,bar";
string value = "value";
var cookie = new HttpCookie(name, value);
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: \"foo,bar\"=value\r\n", header);
}
示例3: ToHeaderString_SingleValueWithSemiColon_Formatting
public void ToHeaderString_SingleValueWithSemiColon_Formatting()
{
string name = "foobar";
string value = "value;";
var cookie = new HttpCookie(name, value);
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=\"value;\"\r\n", header);
}
示例4: ToHeaderString_NameValueAndPath_Formatting
public void ToHeaderString_NameValueAndPath_Formatting()
{
string name = "foobar";
string value = "value";
var cookie = new HttpCookie(name, value);
cookie.Path = "/foobar/";
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=value; path=/foobar/\r\n", header);
}
示例5: ToHeaderString_NameValueAndSecure_Formatting
public void ToHeaderString_NameValueAndSecure_Formatting()
{
string name = "foobar";
string value = "value";
var cookie = new HttpCookie(name, value);
cookie.Secure = true;
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=value; secure\r\n", header);
}
示例6: ToHeaderString_NameValueAndExpires_Formatting
public void ToHeaderString_NameValueAndExpires_Formatting()
{
string name = "foobar";
string value = "value";
var cookie = new HttpCookie(name, value);
cookie.Expires = new DateTime(2010, 8, 4, 10, 11, 12, DateTimeKind.Utc);
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=value; expires=Wed, 04 Aug 2010 10:11:12 GMT\r\n", header);
}
示例7: ToHeaderString_NameValueAndDomain_Formatting
public void ToHeaderString_NameValueAndDomain_Formatting()
{
string name = "foobar";
string value = "value";
var cookie = new HttpCookie(name, value);
cookie.Domain = "http://manos-de-mono.com";
string header = cookie.ToHeaderString();
Assert.AreEqual("Set-Cookie: foobar=value; domain=http://manos-de-mono.com\r\n", header);
}
示例8: ToHeaderString_SingleValueWithComma_Formatting
public void ToHeaderString_SingleValueWithComma_Formatting()
{
var name = "foobar";
var value = "val,ue";
var cookie = new HttpCookie (name, value);
var header = cookie.ToHeaderString ();
Assert.AreEqual ("Set-Cookie: foobar=\"val,ue\"\r\n", header);
}
示例9: ToHeaderString_SingleValueNoWhiteSpace_Formatting
public void ToHeaderString_SingleValueNoWhiteSpace_Formatting()
{
var name = "foobar";
var value = "value";
var cookie = new HttpCookie (name, value);
var header = cookie.ToHeaderString ();
Assert.AreEqual ("Set-Cookie: foobar=value\r\n", header);
}
示例10: ToHeaderString_NameValueAndHttpOnly_Formatting
public void ToHeaderString_NameValueAndHttpOnly_Formatting()
{
var name = "foobar";
var value = "value";
var cookie = new HttpCookie (name, value);
cookie.HttpOnly = true;
var header = cookie.ToHeaderString ();
Assert.AreEqual ("Set-Cookie: foobar=value; HttpOnly\r\n", header);
}