Xamarin-android: AndroidClientHandler doesn't support proxy servers

Created on 31 Aug 2018  路  5Comments  路  Source: xamarin/xamarin-android

Please add support for HTTP proxy server configuration in AndroidClientHandler :)

enhancement feature-request

Most helpful comment

I know I'm a bit late here, but shouldn't the default behavior (if you just call new AndroidClientHandler() without modifying any properties) be to use the system default proxy? Currently these settings are ignored.
@grendello I think support for using the default proxy could be implemented fairly easily by adding something like this to the GetJavaProxy method:

            URI java_uri = new URI(EncodeUrl(destination));
            proxy = ProxySelector.Default?.Select(java_uri).FirstOrDefault();

All 5 comments

This is the related line of code.

https://github.com/xamarin/xamarin-android/blob/3f743678d3e7c19fc6f6e8f6928bfe4ae7d55ff0/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs#L258

This should probably check whether Proxy was set on the HttpClientHandler and use that, then fallback to empty call to OpenConnection() if no proxy was set.

I know I'm a bit late here, but shouldn't the default behavior (if you just call new AndroidClientHandler() without modifying any properties) be to use the system default proxy? Currently these settings are ignored.
@grendello I think support for using the default proxy could be implemented fairly easily by adding something like this to the GetJavaProxy method:

            URI java_uri = new URI(EncodeUrl(destination));
            proxy = ProxySelector.Default?.Select(java_uri).FirstOrDefault();

I totally agree with @dominik-weber and this is what we have implemented in our project in order to be able to debug network calls with Charles Proxy.

Any update on this guys ? I find it extremely strange that something as basic and 'core' to any network layer implementation is missing and it has been almost 8 years since Xamarin started !

The proxy should be used only if the Proxy property is not null (and configured for the specified URL) and the UseProxy property is true - which is what we implement.

Was this page helpful?
0 / 5 - 0 ratings