使用 Fiddler 跟踪 POST 包,结果:
POST http://site1.do HTTP/1.1
Host: data.bls.gov
Connection: keep-alive
Content-Length: 12
Cache-Control: max-age=0
Origin: http://data.bls.gov
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://site1.jsp
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=C6395D730AD166AF76AB4E1CC7ECC694.tc_instance3; WT_FPC=id=2859218d72fe8fdf53b1342567507813:lv=1342569213802:ss=1342567507813; fsr.s={"v":0,"rid":"1342592707969_345732","to":2.7,"f":1342594413334}
type=arg1
我必须保留 cookie 才能获得具有相同会话 ID 的另一个站点。所以,我使用 WebClient 和扩展(CookieAwareWebClient 发布在 StackOverflow 上)。一种方法是:
private void ReadCookies(WebResponse r)
{
var response = r as HttpWebResponse;
if (response != null)
{
CookieCollection cookies = response.Cookies;
container.Add(cookies);
}
}
但
response.Cookies = JSESSIONID=C6395D730AD166AF76AB4E1CC7ECC694.tc_instance3;
丢失有关 WT_FPC 的信息。