|
25 | 25 | import java.io.IOException; |
26 | 26 | import java.io.InputStream; |
27 | 27 | import java.lang.ref.SoftReference; |
| 28 | +import java.net.InetSocketAddress; |
| 29 | +import java.net.Proxy; |
28 | 30 | import java.net.URI; |
29 | 31 | import java.util.*; |
30 | 32 | import java.util.concurrent.TimeUnit; |
@@ -314,6 +316,18 @@ protected boolean load(URI itemToLoad, boolean fallbackLoad) { |
314 | 316 | try { |
315 | 317 | OkHttpClient.Builder builder = new OkHttpClient.Builder(); |
316 | 318 |
|
| 319 | + String proxyPort = this.properties.get("proxy.port"); |
| 320 | + String proxyHost = this.properties.get("proxy.host"); |
| 321 | + String proxyType = this.properties.get("proxy.type"); |
| 322 | + if(proxyPort != null && proxyHost != null) { |
| 323 | + if (proxyType == null) { |
| 324 | + proxyType = Proxy.Type.HTTP.name(); |
| 325 | + } |
| 326 | + Proxy proxy = new Proxy(Proxy.Type.valueOf(proxyType.toUpperCase()), |
| 327 | + InetSocketAddress.createUnresolved(proxyHost, Integer.parseInt(proxyPort))); |
| 328 | + builder = builder.proxy(proxy); |
| 329 | + } |
| 330 | + |
317 | 331 | String connectTimeout = this.properties.get("connection.connect.timeout"); |
318 | 332 | if(connectTimeout != null) { |
319 | 333 | int seconds = Integer.parseInt(connectTimeout); |
@@ -346,23 +360,11 @@ protected boolean load(URI itemToLoad, boolean fallbackLoad) { |
346 | 360 | final Request request = requestBuilder |
347 | 361 | .url(itemToLoad.toString()) |
348 | 362 | .build(); |
349 | | - |
350 | | -// String proxyPort = this.properties.get("proxy.port"); |
351 | | -// String proxyHost = this.properties.get("proxy.host"); |
352 | | -// String proxyType = this.properties.get("proxy.type"); |
353 | | -// if(proxyType!=null){ |
354 | | -// Proxy proxy = new Proxy(Proxy.Type.valueOf(proxyType.toUpperCase()), |
355 | | -// InetSocketAddress.createUnresolved(proxyHost, Integer.parseInt(proxyPort))); |
356 | | -// conn = itemToLoad.toURL().openConnection(proxy); |
357 | | -// }else{ |
358 | | -// conn = itemToLoad.toURL().openConnection(); |
359 | | -// } |
360 | | -// |
361 | 363 |
|
362 | 364 | // conn.setRequestProperty("Accept", "application/xhtml+xml"); |
363 | 365 | // conn.setRequestProperty("Accept-Encoding", "gzip, deflate, br"); |
364 | 366 | // conn.setRequestProperty("Accept-Language", "en-US,en;q=0.9"); |
365 | | -// |
| 367 | +// TODO check if any of those are necessary? |
366 | 368 |
|
367 | 369 | final Call call = client.newCall(request); |
368 | 370 |
|
|
0 commit comments