[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:
Manuel de la Pena 2019-09-05 16:03:10 -04:00 коммит произвёл GitHub
Родитель 8a4c85863a
Коммит 4a08c6c7b2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 18 добавлений и 2 удалений

Просмотреть файл

@ -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.");
}
}
}
}
}