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.