Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Redirect to relative url doesn't work with AndroidClientHandler #1923
Steps to Reproduce
The initial request returns a 302 redirect to relative url: /httpbin/get. This endpoint returns a JSON string.
Instead of following the redirect, an exception is thrown:
Microsoft Visual Studio Enterprise 2017
Installed Version: Enterprise
Xamarin 220.127.116.11 (35a01d8dc)
Xamarin Designer 4.12.1 (f3257e429)
Xamarin.Android SDK 18.104.22.168 (HEAD/dffc59120)
Xamarin.iOS and Xamarin.Mac SDK 22.214.171.124 (64fece5)
Based on our testing, the issue seems to be caused by the handling of the redirect uri here: https://github.com/xamarin/xamarin-android/blob/master/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs#L570
Please note that according to the mentioned rfc https://tools.ietf.org/html/rfc3986#section-5 (example in section 5.4) relative uris (starting with
Please see this reference source here: https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs#L110
Please also note that this issue causes real world problems with the following links not being able to load:
Dropbox share links:
Sharepoint online links:
+1, The issue appeared recently when working with services that redirects Json responses in my case. Issue seems to be related to
The issue persists on the latest preview release as well.
For anyone else who is experiencing the issue, changing the HttpClientHandler to Managed is a workaround. Not ideal, but a workaround until the issue is resolved.
If you are using the default constructor for HttpClient, you can change the behaviour throughout:
Alternatively, you may switch to Managed handler explicitly, and only when required, instead of setting it project-wide: