1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Preferences: added proxy settings

This commit is contained in:
Federico Fissore
2015-03-17 11:40:58 +01:00
parent 9add5f74e7
commit 4db6c737be
3 changed files with 193 additions and 87 deletions

View File

@ -96,7 +96,7 @@ public class DownloadableContributionsDownloader {
});
downloader.download();
if (!downloader.isCompleted()) {
throw new Exception(format(_("Error dowloading {0}"), url), downloader.getError());
throw new Exception(format(_("Error downloading {0}"), url), downloader.getError());
}
}

View File

@ -29,6 +29,8 @@
package cc.arduino.utils.network;
import org.apache.commons.codec.binary.Base64;
import processing.app.PreferencesData;
import processing.app.helpers.StringUtils;
import java.io.File;
import java.io.IOException;
@ -120,6 +122,19 @@ public class FileDownloader extends Observable {
setStatus(Status.CONNECTING);
if (PreferencesData.has("proxy.server") && PreferencesData.get("proxy.server") != null && !PreferencesData.get("proxy.server").equals("")) {
System.getProperties().put("http.proxyHost", PreferencesData.get("proxy.server"));
System.getProperties().put("http.proxyPort", PreferencesData.get("proxy.port"));
if (PreferencesData.has("proxy.user")) {
System.getProperties().put("http.proxyUser", PreferencesData.get("proxy.user"));
System.getProperties().put("http.proxyPassword", PreferencesData.get("proxy.password"));
}
} else {
System.getProperties().remove("http.proxyHost");
System.getProperties().remove("http.proxyPort");
System.getProperties().remove("http.proxyUser");
System.getProperties().remove("http.proxyPassword");
}
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
if (downloadUrl.getUserInfo() != null) {