From 43da7400e44da0f8e6093fa25dbe87c9c4120554 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 15 Jun 2020 18:14:07 +0200 Subject: [PATCH] Fixed invalid http accept header This patch overrides the default JDK accept header that happens to be invalid, as per RFC 7231. Real issue: https://bugs.openjdk.java.net/browse/JDK-8163921 Fix https://github.com/arduino/Arduino/issues/10264 --- .../src/cc/arduino/utils/network/HttpConnectionManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java b/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java index 25577e0dcd2..b067e8faaa9 100644 --- a/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java +++ b/arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java @@ -128,6 +128,11 @@ private HttpURLConnection makeConnection(URL requestURL, int movedTimes, .toUpperCase().replace("-", "").substring(0, 16); HttpURLConnection connection = (HttpURLConnection) requestURL .openConnection(proxy); + + // see https://github.com/arduino/Arduino/issues/10264 + // Workaround for https://bugs.openjdk.java.net/browse/JDK-8163921 + connection.setRequestProperty("Accept", "*/*"); + connection.setRequestProperty("User-agent", userAgent); connection.setRequestProperty("X-Request-ID", requestId); if (id != null) {