Skip to content

Redirect to relative url doesn't work with AndroidClientHandler #1923

Closed
@dominik-weber

Description

@dominik-weber

Steps to Reproduce

  1. Execute this code:
var client = new HttpClient(new AndroidClientHandler());
var res = await client.GetStringAsync("https://nghttp2.org/httpbin/redirect-to?url=/httpbin/get");

Expected Behavior

The initial request returns a 302 redirect to relative url: /httpbin/get. This endpoint returns a JSON string.

Actual Behavior

Instead of following the redirect, an exception is thrown:
System.InvalidCastException: Unable to convert instance of type 'Java.Net.URLConnectionInvoker' to type 'Java.Net.HttpURLConnection'.
Please note that the code above works fine when using HttpClientHandler instead of AndroidClientHandler

Version Information

Microsoft Visual Studio Enterprise 2017
Version 15.7.4
VisualStudio.15.Release/15.7.4+27703.2035
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

Xamarin 4.10.10.2 (35a01d8dc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 4.12.1 (f3257e429)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.3.3.2 (HEAD/dffc59120)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.12.0.4 (64fece5)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

VS bug #742257

Metadata

Metadata

Assignees

Labels

bugComponent does not function as intended.vs-syncFor internal use only; creates a VSTS "mirror" issue.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions