Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proxy script use #552

Merged
merged 1 commit into from
Jan 15, 2015
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
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