-
Notifications
You must be signed in to change notification settings - Fork 549
[Foundation] Add support to ignore the cookies in the NSUrlSessionHandler. #7677
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
Conversation
…dler. This change allows to ignore the use of cookies and cookie containers in the NSUrlSessionHandler. There are two different cookie containers to consider: 1. The native NSHttoCookieStorage. 2. The managed CookieContainer. If the native one is set to null, the native code will not use a cookie storage, which is used as a flag to ignore the managed one. There is an interesting situation, we allow different types of sessions. From the cookie storage point of view, Default and Background sessions are the same, but Ephemeral is not, since we only want to store in ram the cookies and do not share them. This supposes a problem because Apple does not provide any API that will allow to determine the session type use in the configuration. The workaround has been to hide the direct native call for the configuration and add an enum value that can later be accessed in the NSUrlSessionHandler. Of course things cannot be that easy. When a session is created with the configuration, it creates a copy, and the internal session configuration does not longer have the flag, therefore, we need to store the session type in the handler. Fixes: dotnet#7659
chamons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not qualified to say if the PR is good or not, but some comments to fix until someone else can.
| public SessionConfigurationType SessiontType { | ||
| get => configurationType; | ||
| private set => configurationType = value; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is the same as:
public SessionConfigurationType SessiontType { get; private set; } = SessionConfigurationType.Default;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that is a lot shorter :)
Co-Authored-By: Chris Hamons <[email protected]>
|
Build failure ✅ Build succeeded |
|
Build failure Test results2 tests failed, 85 tests passed.Failed tests
|
|
Build success |
dalexsoto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
| public void TestNSUrlSessionEphemeralDisabledCookies () | ||
| { | ||
| // assert we do throw an exception with ephemeral configs. | ||
| var config = NSUrlSessionConfiguration.EphemeralSessionConfiguration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
| #if XAMCORE_2_0 | ||
| using Foundation; | ||
| #else | ||
| using MonoTouch.Foundation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the !XAMCORE_2_0 code, we never build in that mode anymore.
…cios into ignore-cookies
|
Build failure Test results16 tests failed, 71 tests passed.Failed tests
|
|
Build failure Test results1 tests failed, 86 tests passed.Failed tests
|
This change allows to ignore the use of cookies and cookie containers in
the NSUrlSessionHandler. There are two different cookie containers to
consider:
If the native one is set to null, the native code will not use a cookie
storage, which is used as a flag to ignore the managed one.
There is an interesting situation, we allow different types of sessions.
From the cookie storage point of view, Default and Background sessions
are the same, but Ephemeral is not, since we only want to store in ram
the cookies and do not share them.
This supposes a problem because Apple does not provide any API that will
allow to determine the session type use in the configuration. The
workaround has been to hide the direct native call for the configuration
and add an enum value that can later be accessed in the
NSUrlSessionHandler. Of course things cannot be that easy. When a
session is created with the configuration, it creates a copy, and the
internal session configuration does not longer have the flag, therefore,
we need to store the session type in the handler.
Fixes: #7659