About the assignment of a simulated HTTP request cookie

Source: Internet
Author: User

Recent work has been about simulating HTTP request knowledge.

Originally thought very simple, is simply simulates the HTTP request. Use Fiddler to simulate the request, verify that the interface is available, and then go directly to the code.

But in the simulation of a Unicom HTTP request, I encountered difficulties, the first to enter the other people's website, must be registered account login.

So the previous simple login at all does not involve what the cookie parameter, there is also a very simple single key value pairs assignment.

I cut a request for Unicom:

You can see the cookie for this request is quite long; my first show was 艹 so long. Those that are useful are useless, do not want me to try one by one, it is better to be assigned to the value on the back,

So I'll put all the cookies

Req. Cookiecontainer.add (New Cookie ("Sid", "WERWERQW", "/", "iservice.10010"));
This form plus finally since the error.
I wonder if this interface is encrypted, or is not connected at all. If I put all the requests into the fiddler to try, the result is still not,
Is the interface really not available, should not AH!
I have tried to use postman to request, there is a result (it seems that the analog HTTP request postman is better than fiddler)
So why is my code not working?
Thought for a while, I know the problem must be on the cookie;
It is best to use reflection to assign a value to the cookie so that it is simple and practical, the code is as follows:
1    Public Static voidSetheadervalue (webheadercollection header,stringNamestringvalue)2         {3             varproperty =typeof(webheadercollection). GetProperty ("innercollection", BindingFlags.Instance |bindingflags.nonpublic);4             if(Property! =NULL)5             {6                 varCollection = property. GetValue (header,NULL) asNameValueCollection;7Collection[name] =value;8             }9}
Setheadervalue (req. Headers, "Cookie", "value of the Cookie");
It's OK!

About the assignment of a simulated HTTP request cookie

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.