Bug 41224 - HttpClientHandler.UseProxy = false setting is ignored.
Summary: HttpClientHandler.UseProxy = false setting is ignored.
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http ()
Version: 4.2.0 (C6)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-05-20 20:42 UTC by Jon Goldberger [MSFT]
Modified: 2016-05-26 21:32 UTC (History)
3 users (show)

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


Attachments
Test Project (12.36 KB, application/zip)
2016-05-20 20:42 UTC, Jon Goldberger [MSFT]
Details


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 GitHub or Developer Community 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 FIXED

Description Jon Goldberger [MSFT] 2016-05-20 20:42:18 UTC
Created attachment 16059 [details]
Test Project

## Description

Using the following code, I wold expect the system proxy setting to be bypassed:
 
>var handler = new HttpClientHandler {UseProxy = false};
>_netHttpClient = new HttpClient (handler);

but the proxy is still used. The same is true using ModernHttpClient with:
>var handler = new ModernHttpClient.NativeMessageHandler(){UseProxy = false};

The only way I found to bypass the system proxy is with:
>var handler = new CFNetworkHandler () { UseSystemProxy = false };


## Steps to reproduce (need to have a proxy server configured and an iOS device set to use that proxy)

1. Open the attached test project and deploy app to your device that is set up to use a proxy.

2. Observe the console output. The response headers should indicate whether your proxy was used in the "Via: " header

Expected result: System proxy is not used.

Actual result: System proxy is used. 

## Notes

I tested this with the current Beta channel as well and got the same results.
Mono 4.4.0.168
Xamarin.iOS 9.8.0.318


## Environment

=== Xamarin Studio Enterprise ===

Version 5.10.3 (build 51)
Installation UUID: ceaba76c-db06-4fbd-b326-f69ea53c3e01
Runtime:
	Mono 4.2.4 (explicit/71b88f3)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402040004

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.4.0 (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 25.1.3
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.Mac ===

Version: 2.4.2.3 (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: 9.6.2.4 (Visual Studio Enterprise)
Hash: d8bedd0
Branch: master
Build date: 2016-05-05 17:43:01-0400

=== Build Information ===

Release ID: 510030051
Git revision: f3c0d982165f785772d125f02668370d929014fb
Build date: 2016-03-24 18:51:31-04
Xamarin addins: ee5cfd3ecb6b20de47c1d25efb9a9abc101e8ce7
Build lane: monodevelop-lion-cycle6-c6sr3

=== Operating System ===

Mac OS X 10.11.5
Darwin Jons-MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
Comment 1 Marek Safar 2016-05-24 16:45:45 UTC
I am testing with http system proxy "81.98.217.31:80" but I don't see any "via" header but I see there is potential issue.

Could you try to change "UseProxy = true" as much as it sounds weird and test again. It should ignore any proxy settings.
Comment 2 Marek Safar 2016-05-24 17:18:38 UTC
Fixed in master
Comment 3 Jeremy Cook 2016-05-24 22:49:59 UTC
I tested today on the Beta channel setting UseProxy = true, and low and behold, it started working on iOS/Android!   Would never have thought to try that :)
Comment 4 Jon Goldberger [MSFT] 2016-05-26 18:27:13 UTC
I confirmed the same behavior on Beta. I assume the "Fixed in Master" in comment 2 means that you will be reversing this so UseProxy = false will bypass the proxy, instead of USeProxy = true bypassing the proxy?
Comment 5 Marek Safar 2016-05-26 21:32:52 UTC
Fixed in master means that UseProxy = false will work as expected