gpt4 book ai didi

c# - "$"美元字符前缀 cookie 名称

转载 作者:太空狗 更新时间:2023-10-29 19:39:43 26 4
gpt4 key购买 nike

我有这个功能来检索 CookieContainer (this.cookies) 中的响应 cookie

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));


}
}
}

但是,当我在 Fiddler 中调试请求时,我得到了这个:

enter image description here

为什么cookie里有个“$”?

根据MSDN

public Cookie( string name, string value, string path, string domain )

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.

如何删除这个字符?

最佳答案

您看到的 $ 不是 cookie 的名称;它是与 cookie 关联的属性

RFC 2109处理 HTTP 状态管理; 4.4 节专门讨论了美元符号前缀。希望对您有所帮助...

关于c# - "$"美元字符前缀 cookie 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9508017/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com