fix HTTP 403 error for some URLs
authorGregory.Shrago <gregory.shrago@jetbrains.com>
Thu, 14 Apr 2016 20:44:08 +0000 (23:44 +0300)
committerGregory.Shrago <gregory.shrago@jetbrains.com>
Thu, 14 Apr 2016 20:45:06 +0000 (23:45 +0300)
platform/util/src/com/intellij/util/ImageLoader.java

index 36dbce28de3479e991ebec2ef82dd2277f375968..e4ea9845090190ff826cd827cf3f17174f7f747f 100644 (file)
@@ -36,7 +36,9 @@ import java.awt.image.ImageFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
+import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -84,7 +86,11 @@ public class ImageLoader implements Serializable {
       }
       if (stream == null) {
         url = new URL(path);
-        stream = url.openStream();
+        URLConnection connection = url.openConnection();
+        if (connection instanceof HttpURLConnection) {
+          connection.addRequestProperty("User-Agent", "IntelliJ");
+        }
+        stream = connection.getInputStream();
       }
       return type.load(url, stream, scale);
     }