Bug 50788 - Overriding AndroidHttpClientHandlerType does not work in csproj
Summary: Overriding AndroidHttpClientHandlerType does not work in csproj
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2016-12-25 12:45 UTC by Akash Kava
Modified: 2017-08-23 21:16 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Akash Kava 2016-12-25 12:45:29 UTC
I had plans to use ModernHttpClient which uses OKHttp. However, it turns out that default HttpClient still continue to use AndroidHttpClient.

I have an project, "MyProject.Droid" , and I open .csproj file in text editor and added following line.

MyProject.csproj
<AndroidHttpClientHandlerType>MyProject.Droid.Services.ProxyHandler, MyProject.Droid</AndroidHttpClientHandlerType>

ProxyHandler.cs
namespace MyProject.Droid.Services{

    public class ProxyHandler : NativeMessageHandler {
        public ProxyHandler()
        {

        }

        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, 
            CancellationToken cancellationToken)
        {
            System.Diagnostics.Debug.WriteLine($"Proxy Request: {request.RequestUri}");
            return base.SendAsync(request, cancellationToken);
        }
    }
}



Ideally, I should see every request logged in debugger, but I don't see any.
Comment 1 Akash Kava 2016-12-25 12:58:05 UTC
I also created Environment.txt file, changed it's build type to AndroidEnvironment and added following line, still I don't see anything in debugger. 

Environment.txt
XA_HTTP_CLIENT_HANDLER_TYPE=MyProject.Droid.Services.ProxyHandler, MyProject.Droid
Comment 2 Akash Kava 2016-12-25 13:03:36 UTC
 var v  = System.Environment.GetEnvironmentVariable("XA_HTTP_CLIENT_HANDLER_TYPE");
            System.Diagnostics.Debug.WriteLine($"XA_HTTP_CLIENT_HANDLER_TYPE = {v}");

In Debugger, I do see correct, 
MyProject.Droid.Services.ProxyHandler, MyProject.Droid
Comment 3 Prashant [MSFT] 2017-07-05 06:07:14 UTC
Thank you for taking the time to submit the bug. We are unable to reproduce this issue. Please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue
Comment 4 Cody Beyer (MSFT) 2017-08-23 21:16:57 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!