Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies get expired after first request cycle. #144

Open
GoogleCodeExporter opened this issue Apr 15, 2015 · 3 comments
Open

Cookies get expired after first request cycle. #144

GoogleCodeExporter opened this issue Apr 15, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 9 Oct 2012 at 2:18

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 9 Oct 2012 at 3:52

@GoogleCodeExporter
Copy link
Author

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

Original comment by [email protected] on 21 Oct 2012 at 6:50

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 21 Oct 2012 at 10:54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant