-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Android HttpClientHandler throws wrong exception type #56089
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionCode such as this should throw a new HttpClientHandler().MaxAutomaticRedirections = 0; We have some tests checking this, and they throw
We might need exception handling here to throw the inner exception if it hits a runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs Lines 417 to 428 in 0733681
Configuration
I believe this also happens in Preview 7. Regression?I believe this was working in Preview 6, because the Android http handler implementation was not complete yet. /cc @steveisok
|
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsDescriptionCode such as this should throw a new HttpClientHandler().MaxAutomaticRedirections = 0; We have some tests checking this, and they throw
We might need exception handling here to throw the inner exception if it hits a runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs Lines 417 to 428 in 0733681
Configuration
I believe this also happens in Preview 7. Regression?I believe this was working in Preview 6, because the Android http handler implementation was not complete yet. /cc @steveisok
|
* MaxAutomaticRedirections should throw if <= 0 * UseCookies defaults to true * CookieContainer creates a new instance on first call * Catch TargetInvocationException, see: dotnet/runtime#56089 * Catch PlatformNotSupportedException for ClientCertificateOptions
* MaxAutomaticRedirections should throw if <= 0 * UseCookies defaults to true * CookieContainer creates a new instance on first call * Catch TargetInvocationException, see: dotnet/runtime#56089 * Catch PlatformNotSupportedException for ClientCertificateOptions
…nvocationException Originally on mobile workloads when UseNativeHttpHandler is set to true, all reflection method invokes bubbled up a TargetInvocationException. To make the details a bit more readable, we will instead rethrow the InnerException. Fixes dotnet#56089
Changes: dotnet/installer@78a1bc3...7cfb26e Changes: dotnet/linker@5b2391c...5851f6d Changes: dotnet/runtime@14b34eb...fe6bd2d Context: https://github.com/dotnet/runtime/blob/0f5b75344d5858d76da403735ee34c71d9d69d54/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs#L776 Context: dotnet/runtime@57dd919 Context: dotnet/runtime#56089 Context: dotnet/runtime#57800 Updates: * Microsoft.Dotnet.Sdk.Internal: from 6.0.100-rc.1.21418.8 to 6.0.100-rc.1.21420.5 * Microsoft.NET.ILLink.Tasks: from 6.0.100-preview.6.21416.1 to 6.0.100-preview.6.21419.1 * Microsoft.NETCore.App.Ref: from 6.0.0-rc.1.21417.1 to 6.0.0-rc.1.21419.17 Update `Xamarin.Android.Net.AndroidMessageHandler` so that additional properties are specified. Commit dotnet/runtime@57dd919a updated `HttpMessageHandler` so that additional properties were no longer "unsupported" on Android, meaning they needed to exist. As they didn't yet exist, the linker emitted warnings: ILLink : warning IL2037: System.Net.Http.HttpClientHandler.GetClientCertificateOptions(): No members were resolved for 'get_ClientCertificateOptions'. ILLink : warning IL2037: System.Net.Http.HttpClientHandler.GetClientCertificates(): No members were resolved for 'get_ClientCertificates'. ILLink : warning IL2037: System.Net.Http.HttpClientHandler.SetClientCertificateOptions(ClientCertificateOption): No members were resolved for 'set_ClientCertificateOptions'. We need to add the missing members that are now expected: partial class AndroidMessageHandler { public ClientCertificateOption ClientCertificateOptions { get; set; } public X509CertificateCollection ClientCertificates { get; set; } // … } Note that these new properties *must* be public, as `Type.GetMethod(string)` is used, which only finds public members. We can also update `AndroidClientHandlerTests.cs` and remove the `catch(TargetInvocationException)` blocks added in 1e5bfa3, as dotnet/runtime#56089 has been fixed. Begin ignoring `AotTests.NoSymbolsArgShouldReduceAppSize()`, as it started failing. See dotnet/runtime#57800. Finally, `SslProtocols.Tls13` is only valid on API-29+. Update `AndroidMessageHandler.SslProtocols` so that `SslProtocols.Tls13` is only used on appropriate platforms. Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Changes: dotnet/installer@78a1bc3...5c2d8ef Changes: dotnet/linker@5b2391c...5b2391c Changes: dotnet/runtime@14b34eb...5a5d7f0 Context: https://github.com/dotnet/runtime/blob/0f5b75344d5858d76da403735ee34c71d9d69d54/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs#L776 Context: dotnet/runtime@57dd919 Context: dotnet/runtime#56089 Context: dotnet/runtime#57800 Updates: * Microsoft.Dotnet.Sdk.Internal: from 6.0.100-rc.1.21418.8 to 6.0.100-rc.2.21418.44 * Microsoft.NET.ILLink.Tasks: from 6.0.100-preview.6.21416.1 to 6.0.100-preview.6.21418.3 * Microsoft.NETCore.App.Ref: from 6.0.0-rc.1.21417.1 to 6.0.0-rc.2.21417.16 Update `Xamarin.Android.Net.AndroidMessageHandler` so that additional properties are specified. Commit dotnet/runtime@57dd919a updated `HttpMessageHandler` so that additional properties were no longer "unsupported" on Android, meaning they needed to exist. As they didn't yet exist, the linker emitted warnings: ILLink : warning IL2037: System.Net.Http.HttpClientHandler.GetClientCertificateOptions(): No members were resolved for 'get_ClientCertificateOptions'. ILLink : warning IL2037: System.Net.Http.HttpClientHandler.GetClientCertificates(): No members were resolved for 'get_ClientCertificates'. ILLink : warning IL2037: System.Net.Http.HttpClientHandler.SetClientCertificateOptions(ClientCertificateOption): No members were resolved for 'set_ClientCertificateOptions'. We need to add the missing members that are now expected: partial class AndroidMessageHandler { public ClientCertificateOption ClientCertificateOptions { get; set; } public X509CertificateCollection ClientCertificates { get; set; } // … } Note that these new properties *must* be public, as `Type.GetMethod(string)` is used, which only finds public members. We can also update `AndroidClientHandlerTests.cs` and remove the `catch(TargetInvocationException)` blocks added in 1e5bfa3, as dotnet/runtime#56089 has been fixed. Begin ignoring `AotTests.NoSymbolsArgShouldReduceAppSize()`, as it started failing. See dotnet/runtime#57800. Finally, `SslProtocols.Tls13` is only valid on API-29+. Update `AndroidMessageHandler.SslProtocols` so that `SslProtocols.Tls13` is only used on appropriate platforms. Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Description
Code such as this should throw a
ArgumentOutOfRangeException
:We have some tests checking this, and they throw
TargetInvocationException
instead:We might need exception handling here to throw the inner exception if it hits a
TargetInvocationException
:runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs
Lines 417 to 428 in 0733681
Configuration
I believe this also happens in Preview 7.
Regression?
I believe this was working in Preview 6, because the Android http handler implementation was not complete yet.
/cc @steveisok
The text was updated successfully, but these errors were encountered: