Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix proxy script use
When using a proxy configuration script (aka wpad pac script), the actual
proxy settings you get depend on the url you target.
It's used for load balancing / web proxy routing in enterprises.

If you were unlikely enough (like me) to have a split between google urls
and the rest of the www, the current code would use the google proxy
to target github urls, which was failing (405 in my case but I guess
that could depend on the actual setup).
  • Loading branch information
gluck committed Jan 15, 2015
commit 23631fc1a1b5d1228a94107e273432a99b35aac6
17 changes: 8 additions & 9 deletions src/Paket.Bootstrapper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Paket.Bootstrapper
{
class Program
{
static IWebProxy GetDefaultWebProxy()
static IWebProxy GetDefaultWebProxyFor(String url)
{
IWebProxy result = WebRequest.GetSystemWebProxy();
Uri irrelevantDestination = new Uri(@"http://google.com");
Uri address = result.GetProxy(irrelevantDestination);
Uri relevantDestination = new Uri(url);
Uri address = result.GetProxy(relevantDestination);

if (address == irrelevantDestination)
if (address == relevantDestination)
return null;

return new WebProxy(address) {
Expand Down Expand Up @@ -61,17 +61,16 @@ static void Main(string[] args)
}
}

var proxy = GetDefaultWebProxy();

if (latestVersion == "")
{
using (WebClient client = new WebClient())
{
var releasesUrl = "https://github.com/fsprojects/Paket/releases";

client.Headers.Add("user-agent", "Paket.Bootstrapper");
client.UseDefaultCredentials = true;
client.Proxy = proxy;
client.Proxy = GetDefaultWebProxyFor(releasesUrl);

var releasesUrl = "https://github.com/fsprojects/Paket/releases";
var data = client.DownloadString(releasesUrl);
var start = 0;
while (latestVersion == "")
Expand All @@ -94,7 +93,7 @@ static void Main(string[] args)
var request = (HttpWebRequest)HttpWebRequest.Create(url);

request.UseDefaultCredentials = true;
request.Proxy = proxy;
request.Proxy = GetDefaultWebProxyFor(url);

request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse())
Expand Down