|
22 | 22 | import java.util.jar.JarInputStream; |
23 | 23 | import java.util.jar.JarOutputStream; |
24 | 24 | import java.util.jar.Pack200; |
| 25 | +import java.util.zip.GZIPInputStream; |
25 | 26 |
|
26 | 27 | import javax.swing.JOptionPane; |
27 | 28 |
|
@@ -53,8 +54,21 @@ public static void readRemoteList(List<FileEntry> files, List<String> dirs) |
53 | 54 | try |
54 | 55 | { |
55 | 56 | URL resourceUrl = new URL(RemoteInfoReader.instance().getSyncUrl()); |
| 57 | + URLConnection connection = resourceUrl.openConnection(); |
| 58 | + connection.setRequestProperty("Accept-Encoding", "gzip"); |
| 59 | + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:10.0) Gecko/20100101 Firefox/55.0"); |
| 60 | + |
56 | 61 | JdomParser parser = new JdomParser(); |
57 | | - JsonRootNode data = parser.parse(new InputStreamReader(resourceUrl.openStream(), Charsets.UTF_8)); |
| 62 | + InputStreamReader reader = null; |
| 63 | + if("gzip".equals(connection.getContentEncoding())) |
| 64 | + { |
| 65 | + reader = new InputStreamReader(new GZIPInputStream(connection.getInputStream()), Charsets.UTF_8); |
| 66 | + } |
| 67 | + else |
| 68 | + { |
| 69 | + reader = new InputStreamReader(connection.getInputStream(), Charsets.UTF_8); |
| 70 | + } |
| 71 | + JsonRootNode data = parser.parse(reader); |
58 | 72 |
|
59 | 73 | for(int i = 0; i < data.getElements().size(); i++) |
60 | 74 | { |
@@ -103,6 +117,7 @@ public void run() |
103 | 117 | try |
104 | 118 | { |
105 | 119 | URLConnection connection = url.openConnection(); |
| 120 | + connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:10.0) Gecko/20100101 Firefox/55.0"); |
106 | 121 |
|
107 | 122 | final int fileLength = connection.getContentLength(); |
108 | 123 |
|
|
0 commit comments