Reasons for the previous failure of network connectivity issues

Source: Internet
Author: User

the initial failure was due to the fact that the login sent the post instruction without any code for access, after studying the OC code of the seniors,found that he acquired the server cookie at Init and extracted it from the cookie Csrftoken, and added it to the access header at login, asthe token for the permission. After I tried, I finally got the cookie and added Csrftoken to HttpURLConnection's head, and returned403, we have been here for a long time lag. after the help of the learning elder sister, finally understand that Csrftoken is not the only authority identifier, but the need to add all the cookies obtained by the init login Access to the server's httpclient header to complete the access. The difference between the two popular point is equivalent to two people to access a server, two people with aand b indicate that a is responsible for INIT,B login. The first method is like a first initialization of a cookie that has access rights, and then the token given to B,then B takes the token obtained from a to access it, so the server is recognized as insufficient authority. The second method is equivalent to the first initialization of a given access rightsCookie, and then give all of the resulting cookie including token to B, at which point B is equivalent to a copy, which is equivalent to a once again to access the servicewhen the service considers that B has access rights. (PS: Originally thought HttpURLConnection and httpclient send the data format is different, therefore beganis to send the post instructions with HttpURLConnection, and later found that the implementation of the effect is equivalent, so after swapping with httpclient to implement the POST request).

Reasons for the previous failure of network connectivity issues

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.