[Mono-bugs] [Bug 691291] Incomplete proxy support/ system wide proxy bypass list is ignored
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Sep 30 03:39:58 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=691291
https://bugzilla.novell.com/show_bug.cgi?id=691291#c3
--- Comment #3 from QuickJack . <test051102 at hotmail.com> 2011-09-30 07:39:56 UTC ---
By debugging the class library I found a solution which provides full support
for proxy bypassing in Linux. I have tested the scenario in Ubuntu Maverick.
Problem
####################
IWebProxy WebRequest.GetSysteWebProxy() creates an object of class WebProxy.
However, the current implementation is always using the default constructor. As
a result, the proxy bypass list is always null. Following is the original code
located in WebProxy.cs:
[MonoTODO("Look in other places for proxy config info")]
public static IWebProxy GetSystemWebProxy ()
{
string address = Environment.GetEnvironmentVariable ("http_proxy");
if (address == null)
address = Environment.GetEnvironmentVariable ("HTTP_PROXY");
if (address != null) {
try {
if (!address.StartsWith ("http://"))
address = "http://" + address;
Uri uri = new Uri (address);
IPAddress ip;
if (IPAddress.TryParse (uri.Host, out ip)) {
if (IPAddress.Any.Equals (ip)) {
UriBuilder builder = new UriBuilder (uri);
builder.Host = "127.0.0.1";
uri = builder.Uri;
} else if (IPAddress.IPv6Any.Equals (ip)) {
UriBuilder builder = new UriBuilder (uri);
builder.Host = "[::1]";
uri = builder.Uri;
}
}
return new WebProxy (uri);
} catch (UriFormatException) { }
}
if (cfGetDefaultProxy != null)
return (IWebProxy) cfGetDefaultProxy.Invoke (null, null);
return new WebProxy ();
}
if (cfGetDefaultProxy != null)
return (IWebProxy) cfGetDefaultProxy.Invoke (null, null);
return new WebProxy ();
}
Solution
####################
(1) IWebProxy WebRequest.GetSystemWebProxy() must use the full constructor the
create a complete proxy object. This constructor contains a parameter called
"string [] bypassList"
(2) Within GetSystemeWideProxy() the bypassList must be determined depending on
the no_proxy environment variable.
I have modified WebRequest.cs as follows:
[MonoTODO("Look in other places for proxy config info")]
public static IWebProxy GetSystemWebProxy ()
{
string address = Environment.GetEnvironmentVariable ("http_proxy");
if (address == null)
address = Environment.GetEnvironmentVariable ("HTTP_PROXY");
if (address != null) {
try {
if (!address.StartsWith ("http://"))
address = "http://" + address;
Uri uri = new Uri (address);
IPAddress ip;
if (IPAddress.TryParse (uri.Host, out ip)) {
if (IPAddress.Any.Equals (ip)) {
UriBuilder builder = new UriBuilder (uri);
builder.Host = "127.0.0.1";
uri = builder.Uri;
} else if (IPAddress.IPv6Any.Equals (ip)) {
UriBuilder builder = new UriBuilder (uri);
builder.Host = "[::1]";
uri = builder.Uri;
}
}
string[] bypassList=null;
string bypass = Environment.GetEnvironmentVariable ("no_proxy");
if (bypass == null)
bypass = Environment.GetEnvironmentVariable ("NO_PROXY");
if (bypass != null) {
bypass = bypass.Remove (bypass.IndexOf("*.local"), 7);//remove
Ubuntu's standard "*.local" entry to prevent exception
bypassList = bypass.Split (new char[]{','},
StringSplitOptions.RemoveEmptyEntries);
}
return new WebProxy (uri, false, bypassList);
} catch (UriFormatException) { }
}
if (cfGetDefaultProxy != null)
return (IWebProxy) cfGetDefaultProxy.Invoke (null, null);
return new WebProxy ();
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list