Emulyator / open-webkit-sharp

Automatically exported from code.google.com/p/open-webkit-sharp
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Cookies get expired after first request cycle. #144

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
We have the following code:

List<Header> headers = new List<Header>();
headers.Add(new Header("Cookie", "Param1=Val1;Param2=Val2"));
webKitBrowser.Navigate("http://SampleUrl.com/Page1.aspx", headers);

What is the expected output? What do you see instead?
Cookies present during first request. If user clicks any link(For page2.aspx) 
in the "SampleUrl.com/Page1.aspx" page then during this request what ever 
headers we have set during the initial navigate method call are not present.

What version of the product are you using? On what operating system?
OpenWebkitSharp Version:OpenWebKitSharp 2.9 stable.
VS: 2010,
WPF,
Operating System: Windows 7 Enterprise SP1.

Please provide any additional information below.
Do we need to set headers for every navigation? If so, How to do that?
How to set cookies to webkitbrowser document?

Original issue reported on code.google.com by srinu.ka...@gmail.com on 9 Oct 2012 at 2:18

GoogleCodeExporter commented 9 years ago
You can do this probably only by modifying the source of OpenWebKitSharp. Look 
inside the frameLoadDelegate events and find the one that corresponds to the 
time just before the request is sent. Then, use request.setHeader to add the 
header you want. Alternatively, you can look inside WebResourceLoadDelegate.cs 
and find the willSendRequest method. Inside it, before the lines return req; 
and return request; modify the request according to your own needs. This will 
change the headers of all request sent for all resources though.

Original comment by tsumalis96@gmail.com on 9 Oct 2012 at 3:52

GoogleCodeExporter commented 9 years ago
Hi. i am in the same situation. Also, how do you get the cookies to be inserted 
in subsecuent requests?

Original comment by labo...@gmail.com on 21 Oct 2012 at 6:50

GoogleCodeExporter commented 9 years ago
Fixed, it was simple. You have to tell the request to handle the cookies. You 
have a WebKit.Interop.IWebURLRequest, convert it to its mutable version so you 
can use the proper method:

WebKit.Interop.WebMutableURLRequest mutableRequest = request.mutableCopy();
mutableRequest.setHTTPShouldHandleCookies(1);
request = mutableRequest;

Original comment by labo...@gmail.com on 21 Oct 2012 at 10:54