[Foundation] Ensure that we allow celullar data by default until the user says otherwise. #6762 (#6916)
* [Foundation] Ensure that we allow celullar data by default until the user says otherwise. #6762 The default value in the NSUrlSession is to allow cellular data. This small change closes the issue, since users will not have an unexpected result. Later we need to provide a proper fix to allow the property to be exposed AND used the value of the session. Fixes: https://github.com/xamarin/xamarin-macios/issues/6762
This commit is contained in:
Родитель
8a4c85863a
Коммит
4a08c6c7b2
|
@ -158,7 +158,7 @@ namespace Foundation {
|
|||
// therefore, we do not have to listen to the notifications.
|
||||
isBackgroundSession = !string.IsNullOrEmpty (configuration.Identifier);
|
||||
#endif
|
||||
|
||||
allowsCellularAccess = configuration.AllowsCellularAccess;
|
||||
AllowAutoRedirect = true;
|
||||
|
||||
// we cannot do a bitmask but we can set the minimum based on ServicePointManager.SecurityProtocol minimum
|
||||
|
@ -280,7 +280,7 @@ namespace Foundation {
|
|||
}
|
||||
}
|
||||
|
||||
bool allowsCellularAccess;
|
||||
bool allowsCellularAccess = true;
|
||||
|
||||
public bool AllowsCellularAccess {
|
||||
get {
|
||||
|
|
|
@ -15,6 +15,7 @@ using System.IO;
|
|||
using NUnit.Framework;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Foundation;
|
||||
#if MONOMAC
|
||||
using Foundation;
|
||||
#endif
|
||||
|
@ -272,5 +273,20 @@ namespace MonoTests.System.Net.Http
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertDefaultValuesNSUrlSessionHandler ()
|
||||
{
|
||||
using (var handler = new NSUrlSessionHandler ()) {
|
||||
Assert.True (handler.AllowAutoRedirect, "Default redirects value");
|
||||
Assert.True (handler.AllowsCellularAccess, "Default cellular data value.");
|
||||
}
|
||||
using (var config = NSUrlSessionConfiguration.DefaultSessionConfiguration) {
|
||||
config.AllowsCellularAccess = false;
|
||||
using (var handler = new NSUrlSessionHandler (config)) {
|
||||
Assert.False (handler.AllowsCellularAccess, "Configuration cellular data value.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче