“$”美元字符前缀cookie名称 [英] "$" dollar character prefixing cookies names

查看:164
本文介绍了“$”美元字符前缀cookie名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个函数来检索CookieContainer中的响应cookie(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));


    }
  }
}

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

But, when I debug the request in Fiddler, I get this:

为什么Cookie中有一个$?

Why there is a "$" in cookies?

根据 MSDN


public Cookie(字符串名称,字符串值,字符串路径,字符串
domain)

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

/ strong>
类型:System.String
Cookie的名称。在名称中不能使用以下字符:等号,分号,逗号,换行符(\\\
),return(\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.

推荐答案

您看到的$不是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...

这篇关于“$”美元字符前缀cookie名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆