Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-05-17 01:39:41 +0000
committerDoug Schaefer2017-05-17 01:39:41 +0000
commit822e0d0505804964a79fb5241df33505de604a61 (patch)
tree8d9d15f809138357a3a03a6397f6d8d2731a7612 /toolchains
parent43e62924a1b24840057e9d0af5ed4e79fd5305a7 (diff)
downloadorg.eclipse.cdt-822e0d0505804964a79fb5241df33505de604a61.tar.gz
org.eclipse.cdt-822e0d0505804964a79fb5241df33505de604a61.tar.xz
org.eclipse.cdt-822e0d0505804964a79fb5241df33505de604a61.zip
Bug 516407 Set Agent and make package.json downloads more robust
The ESP8266 URL started reject connections. Turns out setting the User-Agent property on the connection fixes that. I also made this more robust from download failures so that at least other packages can be downloaded. Finally, I removed the ESP8266 URL from the defaults. Change-Id: Ib2ea5667ba490ae660883a30b3049c3d736cfdb7
Diffstat (limited to 'toolchains')
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java1
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java8
2 files changed, 6 insertions, 3 deletions
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
index d67b831ac73..0bd021416b3 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/ArduinoPreferences.java
@@ -26,7 +26,6 @@ public class ArduinoPreferences {
private static final String defaultHome = Paths.get(System.getProperty("user.home"), ".arduinocdt").toString(); //$NON-NLS-1$ //$NON-NLS-2$
private static final String defaultBoardUrls = "http://downloads.arduino.cc/packages/package_index.json" //$NON-NLS-1$
- + "\nhttp://arduino.esp8266.com/stable/package_esp8266com_index.json" //$NON-NLS-1$
+ "\nhttps://adafruit.github.io/arduino-board-index/package_adafruit_index.json"; //$NON-NLS-1$
private static IEclipsePreferences getPrefs() {
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
index 3f43f9c2de9..2e4e07d2d00 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/board/ArduinoManager.java
@@ -200,11 +200,15 @@ public class ArduinoManager {
Path packagePath = ArduinoPreferences.getArduinoHome().resolve(Paths.get(url.getPath()).getFileName());
try {
Files.createDirectories(ArduinoPreferences.getArduinoHome());
- try (InputStream in = url.openStream()) {
+ URLConnection connection = url.openConnection();
+ connection.setRequestProperty("User-Agent", //$NON-NLS-1$
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); //$NON-NLS-1$
+ try (InputStream in = connection.getInputStream()) {
Files.copy(in, packagePath, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
- throw Activator.coreException(String.format("Error loading %s", url.toString()), e); //$NON-NLS-1$
+ // Log and continue, URLs sometimes come and go
+ Activator.log(e);
}
sub.worked(1);
}

Back to the top