Open valentingrigorean opened 3 years ago
The issue is here I think.
Current Impl:
if (session.Configuration.HttpCookieStorage != null) {
var cookies = cookieContainer?.GetCookieHeader (request.RequestUri); // as per docs: An HTTP cookie header, with strings representing Cookie instances delimited by semicolons.
if (!string.IsNullOrEmpty (cookies)) {
var cookiePtr = NSString.CreateNative (Cookie);
var cookiesPtr = NSString.CreateNative (cookies);
nativeHeaders.LowlevelSetObject (cookiesPtr, cookiePtr);
NSString.ReleaseNative (cookiePtr);
NSString.ReleaseNative (cookiesPtr);
}
}
Possible fix:
if (session.Configuration.HttpCookieStorage != null)
{
var cookieHeader =
cookieContainer?.GetCookieHeader(request
.RequestUri); // as per docs: An HTTP cookie header, with strings representing Cookie instances delimited by semicolons.
if (!string.IsNullOrEmpty(cookies))
{
var cookiePtr = NSString.CreateNative(Cookie);
var cookiesPtr = NSString.CreateNative(cookieHeader);
nativeHeaders.LowlevelSetObject(cookiesPtr, cookiePtr);
NSString.ReleaseNative(cookiePtr);
NSString.ReleaseNative(cookiesPtr);
}
else
{
var cookies = session.Configuration.HttpCookieStorage.CookiesForUrl(request.RequestUri);
foreach (var cookie in cookies)
{
_configuration.HttpCookieStorage.DeleteCookie(cookie);
}
}
}
cc @mandel-macaque thoughts?
We need to test. I believe what happens is that the cookier container is used, provides the cookies for the native one, native one is not invalidated and reuses the cookies. So I don't think the propose fix is correct but this is certainly an issue.
we need to link somehow the update of the managed container to the native one.
Steps to Reproduce
Expected Behavior
The next request should have no cookies set.
Actual Behavior
Cookies are still set from previous requests.
Environment
Build Logs
Example Project (If Possible)