|
发表于 2013-8-16 11:56:43
|
显示全部楼层
然后说cookie和cookiecollection只有一个生效的问题
在loginItem.CookieCollection添加一个名为test1的cookie测试- private void button1_Click(object sender, EventArgs e)
- {
- HttpItem loginItem= new HttpItem();
- loginItem.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
- loginItem.Method = "post";
- loginItem.URL = "https://account.xiaomi.com/pass/serviceLoginAuth";
- loginItem.Postdata = "user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile";
- loginItem.ContentType = "application/x-www-form-urlencoded";
- loginItem.Allowautoredirect = false;
- loginItem.SecurityProtocolType = SecurityProtocolType.Ssl3;
- loginItem.CookieCollection = new CookieCollection();//添加test1 的cookie
- loginItem.CookieCollection.Add(new Cookie("test1", "test1", "/", ".xiaomi.com"));
- HttpHelper httphelper = new HttpHelper();
- HttpResult result = httphelper.GetHtml(loginItem);
- }
复制代码 请求数据包如下
POST /pass/serviceLoginAuth HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
Host: account.xiaomi.com
Cookie: test1=test1
Content-Length: 300
Expect: 100-continue
user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile
在loginItem.Cookie添加一个名为test2的cookie测试
- private void button1_Click(object sender, EventArgs e)
- {
- HttpItem loginItem= new HttpItem();
- loginItem.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
- loginItem.Method = "post";
- loginItem.URL = "https://account.xiaomi.com/pass/serviceLoginAuth";
- loginItem.Postdata = "user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile";
- loginItem.ContentType = "application/x-www-form-urlencoded";
- loginItem.Allowautoredirect = false;
- loginItem.SecurityProtocolType = SecurityProtocolType.Ssl3;
- loginItem.Cookie = "test2=test2";
- HttpHelper httphelper = new HttpHelper();
- HttpResult result = httphelper.GetHtml(loginItem);
- }
复制代码 请求数据包如下:
POST /pass/serviceLoginAuth HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
Cookie: test2=test2
Host: account.xiaomi.com
Content-Length: 300
Expect: 100-continue
Connection: Keep-Alive
user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile
同时添加test1和test2,代码如下- private void button1_Click(object sender, EventArgs e)
- {
- HttpItem loginItem= new HttpItem();
- loginItem.UserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
- loginItem.Method = "post";
- loginItem.URL = "https://account.xiaomi.com/pass/serviceLoginAuth";
- loginItem.Postdata = "user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile";
- loginItem.ContentType = "application/x-www-form-urlencoded";
- loginItem.Allowautoredirect = false;
- loginItem.SecurityProtocolType = SecurityProtocolType.Ssl3;
- loginItem.CookieCollection = new CookieCollection();
- loginItem.CookieCollection.Add(new Cookie("test1", "test1", "/", ".xiaomi.com"));
- loginItem.Cookie = "test2=test2";
- HttpHelper httphelper = new HttpHelper();
- HttpResult result = httphelper.GetHtml(loginItem);
- }
复制代码 请求数据包如下,可以看到请求数据包里面只有test1,而test2则没有生效:
POST /pass/serviceLoginAuth HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
Host: account.xiaomi.com
Cookie: test1=test1
Content-Length: 300
Expect: 100-continue
Connection: Keep-Alive
user=axiaomi007%40163.com&pwd=xiaomi8513&callback=http%3A%2F%2Fm.xiaomi.com%2Fmshopapi%2Fv1%2Fauthorize%2Fsso_callback%3Ffollowup%3Dhttp%253A%252F%252Fm.xiaomi.com%252F%2523ac%253Daccount%2526op%253Dindex%26sign%3DNGNmM2VmZDlkZTQ5MGMzMmNjN2Y2MjBmNjc0MGNiMWQxZjg0MzAxNQ%2C%2C&sid=eshopm&display=mobile
|
|