" $"美元字符前缀名称饼干 [英] "$" dollar character prefixing cookies names
问题描述
我有这个功能中检索响应cookie中的CookieContainer(this.cookies)
I have this function to retreive response cookies in a CookieContainer (this.cookies)
private void getCookies(string url)
{
// request
HttpWebRequest request = CreateWebRequestObject(url);
request.CookieContainer = this.cookies;
request.Headers.Add("Accept-Encoding", "gzip, deflate");
request.Headers.Add("Accept-Language", " es-MX,es;q=0.8,en-us;q=0.5,en;q=0.3");
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Method = "GET";
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2";
// response
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
foreach (Cookie c in response.Cookies)
{
this.cookies.Add(new Cookie(c.Name, c.Value, c.Path, c.Domain));
}
}
}
但是,当我在调试小提琴手的要求,我得到这样的:
But, when I debug the request in Fiddler, I get this:
为什么有一个$,在饼干?
Why there is a "$" in cookies?
据 MSDN
公共曲奇(字符串名称,字符串值,路径字符串,字符串
区)
public Cookie( string name, string value, string path, string domain )
名称
类型:System
A Cookie的名称。等号,分号,逗号,换行符(\\\
),回报(\r),
选项卡(\t),以及空格字符:下列字符不能内部名称中使用。美元符号的($)不能
是第一个字符。
name Type: System.String The name of a Cookie. The following characters must not be used inside name: equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character.
如何?我可以删除这个角色
How can I remove this character?
推荐答案
您看到的$不是的名称的cookie的;这是一个的属性的与Cookie相关联。
The $ you see is not the name of the cookie; it is an attribute associated with a cookie.
的 RFC 2109 与HTTP状态管理协议; 4.4节与美元符号前缀专门处理。希望帮助...
RFC 2109 deals with HTTP state management; section 4.4 specifically deals with the dollar sign prefix. Hope that helps...
这篇关于" $"美元字符前缀名称饼干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!