The reason why the GET request goes through WAP multiple times is 302 related to the cookie.

Source: Internet
Author: User

Packet Capture finds that there are two cookie values in the request header when the access is successful, that is, two set-cookies in the header are returned during the first request. The previous code is httpurlconnection. getheaderfield ("Set-cookie"), only the last set-cookie value can be obtained.

String cookieval = NULL;
String key = NULL;
For (INT I = 1; (Key = httpurlconnection. getheaderfieldkey (I ))! = NULL; I ++ ){
If (key. inclusignorecase ("Set-cookie ")){
Cookieval = httpurlconnection. getheaderfield (I );
Cookieval = cookieval. substring (0,
Cookieval. indexof (";"));
Cookies = cookies + cookieval + ";";
}
}
Cookie = cookies;

Cookie is added for each access, and the page content is obtained. However, the cookie is added to the Request Header for the fourth packet capture information. No matter how many reasons, I hope you will not be informed.

 

There is also a kind of cookie-free, the program processing is infinite Multiple times 302, and it has not been solved yet, depressing ing ...... This connection is still good or bad, and UC can be accessed normally. it's okay that I haven't finished it every time. Now I have to process 302 multiple times in advance and then continue, and write the connection to the file at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.