diff --git a/builds/Makefile b/builds/Makefile index 95e4d1532dd6..a34b888fbb0a 100644 --- a/builds/Makefile +++ b/builds/Makefile @@ -109,6 +109,9 @@ $(SDK_CONFIG): echo "DISABLE_ANDROID=1" > $@ echo "DISABLE_DESKTOP=1" >> $@ echo "DISABLE_WASM=1" >> $@ + echo "ENABLE_IOS=1" >> $@ + echo "ENABLE_MAC=1" >> $@ + ifdef DISABLE_BUILDS_MAKEFILE_DEP BUILDS_MAKEFILE_DEP = diff --git a/mk/mono.mk b/mk/mono.mk index 3417893ae3ab..0165bc1fc6f4 100644 --- a/mk/mono.mk +++ b/mk/mono.mk @@ -3,4 +3,4 @@ NEEDED_MONO_BRANCH := 2019-10 MONO_DIRECTORY := mono -MONO_MODULE := https://github.com/mono/mono +MONO_MODULE := https://github.com/monojenkins/mono diff --git a/src/Foundation/NSUrlSessionHandler.cs b/src/Foundation/NSUrlSessionHandler.cs index f98b6ef62b96..059b1ead0f12 100644 --- a/src/Foundation/NSUrlSessionHandler.cs +++ b/src/Foundation/NSUrlSessionHandler.cs @@ -831,11 +831,7 @@ protected override void Dispose (bool disposing) base.Dispose (disposing); } -#if __WATCHOS__ protected override Task SerializeToStreamAsync (Stream stream, TransportContext context) -#else - protected internal override Task SerializeToStreamAsync (Stream stream, TransportContext context) -#endif { if (contentCopied) { if (!content.CanSeek) { diff --git a/src/System.Net.Http/CFContentStream.cs b/src/System.Net.Http/CFContentStream.cs index 42f0142ed564..bdd3518ad57b 100644 --- a/src/System.Net.Http/CFContentStream.cs +++ b/src/System.Net.Http/CFContentStream.cs @@ -125,7 +125,7 @@ public void Close () data_event.Set (); } - protected internal override async Task SerializeToStreamAsync (Stream stream, TransportContext context) + protected override async Task SerializeToStreamAsync (Stream stream, TransportContext context) { while (data_event.WaitOne ()) { data_mutex.WaitOne (); diff --git a/src/System.Net.Http/CFNetworkHandler.cs b/src/System.Net.Http/CFNetworkHandler.cs index 7af25c9628fc..edca57709388 100644 --- a/src/System.Net.Http/CFNetworkHandler.cs +++ b/src/System.Net.Http/CFNetworkHandler.cs @@ -358,7 +358,7 @@ void HandleHasBytesAvailableEvent (object sender, CFStream.StreamEventArgs e) var key = entry.Key.ToString (); var value = entry.Value == null ? string.Empty : entry.Value.ToString (); HttpHeaders item_headers; - if (HttpHeaders.GetKnownHeaderKind (key) == Headers.HttpHeaderKind.Content) { + if (HeaderDescriptor.TryGet (key, out var descriptor) && descriptor.HeaderType == HttpHeaderType.Content) { item_headers = response_msg.Content.Headers; } else { item_headers = response_msg.Headers; diff --git a/tests/linker/ios/link sdk/HttpClientHandlerTest.cs b/tests/linker/ios/link sdk/HttpClientHandlerTest.cs index e9f2e68461d0..6a347f65ed4e 100644 --- a/tests/linker/ios/link sdk/HttpClientHandlerTest.cs +++ b/tests/linker/ios/link sdk/HttpClientHandlerTest.cs @@ -30,7 +30,6 @@ public void HttpClient () Assert.That (handler.AutomaticDecompression, Is.EqualTo (DecompressionMethods.None), "AutomaticDecompression"); Assert.That (handler.ClientCertificateOptions, Is.EqualTo (ClientCertificateOption.Manual), "ClientCertificateOptions"); Assert.That (handler.MaxAutomaticRedirections, Is.EqualTo (50), "MaxAutomaticRedirections"); - Assert.That (handler.MaxRequestContentBufferSize, Is.EqualTo (Int32.MaxValue), "MaxRequestContentBufferSize"); Assert.Null (handler.Proxy, "Proxy"); Assert.True (handler.SupportsAutomaticDecompression, "SupportsAutomaticDecompression"); Assert.True (handler.SupportsProxy, "SupportsProxy"); diff --git a/tests/mmptest/src/MMPTest.cs b/tests/mmptest/src/MMPTest.cs index c1e3d03c6389..ac7907feb299 100644 --- a/tests/mmptest/src/MMPTest.cs +++ b/tests/mmptest/src/MMPTest.cs @@ -474,9 +474,9 @@ public void HttpClientHandler (string mmpHandler, string expectedHandler) References = " ", TestCode = $@" var client = new System.Net.Http.HttpClient (); - var field = client.GetType ().BaseType.GetField (""handler"", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + var field = client.GetType ().BaseType.GetField (""_handler"", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (field == null) - throw new System.Exception (""Could not find the field 'handler' in HttpClient's base type (which should be 'HttpMessageInvoker').""); + throw new System.Exception (""Could not find the field '_handler' in HttpClient's base type (which should be 'HttpMessageInvoker').""); var fieldValue = field.GetValue (client); if (fieldValue == null) throw new System.Exception (""Unexpected null value found in 'HttpMessageInvoker.handler' field.""); diff --git a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs index 206e3a4ee36f..63c33eba6cb3 100644 --- a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs +++ b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs @@ -14,6 +14,7 @@ using NUnit.Framework; using System.Net.Http.Headers; +using System.Security.Authentication; using System.Text; using Foundation; #if MONOMAC @@ -169,29 +170,35 @@ public void RejectSslCertificatesServicePointManager (Type handlerType) TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 9, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion (PlatformName.iOS, 7, 0, throwIfOtherPlatform: false); -#if __MACOS__ - if (handlerType == typeof (NSUrlSessionHandler) && TestRuntime.CheckSystemVersion (PlatformName.MacOSX, 10, 10, 0) && !TestRuntime.CheckSystemVersion (PlatformName.MacOSX, 10, 11, 0)) - Assert.Ignore ("Fails on macOS 10.10: https://github.com/xamarin/maccore/issues/1645"); -#endif - - bool servicePointManagerCbWasExcuted = false; + bool validationCbWasExecuted = false; + bool customValidationCbWasExecuted = false; + bool invalidServicePointManagerCbWasExcuted = false; bool done = false; Exception ex = null; + Type expectedExceptionType = null; HttpResponseMessage result = null; var handler = GetHandler (handlerType); - if (handler is NSUrlSessionHandler ns) { - ns.TrustOverride += (a,b) => { - servicePointManagerCbWasExcuted = true; + if (handler is HttpClientHandler ch) { + expectedExceptionType = typeof (AuthenticationException); + ch.ServerCertificateCustomValidationCallback = (sender, certificate, chain, errors) => { + validationCbWasExecuted = true; // return false, since we want to test that the exception is raised return false; }; - } else { ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => { - servicePointManagerCbWasExcuted = true; + invalidServicePointManagerCbWasExcuted = true; + return false; + }; + } else if (handler is NSUrlSessionHandler ns) { + expectedExceptionType = typeof (WebException); + ns.TrustOverride += (a,b) => { + validationCbWasExecuted = true; // return false, since we want to test that the exception is raised return false; }; + } else { + Assert.Fail ($"Invalid HttpMessageHandler: '{handler.GetType ()}'."); } TestRuntime.RunAsync (DateTime.Now.AddSeconds (30), async () => @@ -213,11 +220,14 @@ public void RejectSslCertificatesServicePointManager (Type handlerType) if (!done) { // timeouts happen in the bots due to dns issues, connection issues etc.. we do not want to fail Assert.Inconclusive ("Request timedout."); } else { + // the ServicePointManager.ServerCertificateValidationCallback will never be executed. + Assert.False(invalidServicePointManagerCbWasExcuted); + Assert.True(validationCbWasExecuted); // assert the exception type Assert.IsNotNull (ex, (result == null)? "Expected exception is missing and got no result" : $"Expected exception but got {result.Content.ReadAsStringAsync ().Result}"); Assert.IsInstanceOfType (typeof (HttpRequestException), ex); Assert.IsNotNull (ex.InnerException); - Assert.IsInstanceOfType (typeof (WebException), ex.InnerException); + Assert.IsInstanceOfType (expectedExceptionType, ex.InnerException); } } diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 1a740988c5f3..5af0880017ba 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -3940,9 +3940,9 @@ public class HandlerTest public void Test () {{ var client = new System.Net.Http.HttpClient (); - var field = client.GetType ().BaseType.GetField (""handler"", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + var field = client.GetType ().BaseType.GetField (""_handler"", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (field == null) - throw new System.Exception (""Could not find the field 'handler' in HttpClient's base type (which should be 'HttpMessageInvoker').""); + throw new System.Exception (""Could not find the field '_handler' in HttpClient's base type (which should be 'HttpMessageInvoker').""); var fieldValue = field.GetValue (client); if (fieldValue == null) throw new System.Exception (""Unexpected null value found in 'HttpMessageInvoker.handler' field."");