Skip to content

Commit

Permalink
Merge pull request #552 from gluck/proxy_pac
Browse files Browse the repository at this point in the history
Fix proxy script use
  • Loading branch information
forki committed Jan 15, 2015
2 parents e336cfb + 23631fc commit 4d641c5
Showing 1 changed file with 8 additions and 9 deletions.
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

0 comments on commit 4d641c5

Please sign in to comment.