Changeset 15742 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r15741 r15742 23 23 import java.util.regex.Pattern; 24 24 import java.util.zip.GZIPInputStream; 25 import java.util.zip.InflaterInputStream; 25 26 26 27 import org.openstreetmap.josm.data.validation.routines.DomainValidator; … … 112 113 } 113 114 this.requestMethod = requestMethod; 114 this.headers.put("Accept-Encoding", "gzip"); 115 this.headers.put("Accept-Encoding", "gzip, deflate"); 115 116 } 116 117 … … 376 377 InputStream in = getInputStream(); 377 378 in = new ProgressInputStream(in, getContentLength(), monitor); 378 in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in; 379 in = "gzip".equalsIgnoreCase(getContentEncoding()) 380 ? new GZIPInputStream(in) 381 : "deflate".equalsIgnoreCase(getContentEncoding()) 382 ? new InflaterInputStream(in) 383 : in; 379 384 Compression compression = Compression.NONE; 380 385 if (uncompress) { -
trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java
r15741 r15742 316 316 public void testTakesTooLong() throws IOException { 317 317 HttpClient.create(new URL("https://httpbin.org/delay/1")).setReadTimeout(500).connect(progress); 318 } 319 320 /** 321 * Test reading Deflate-encoded data. 322 * @throws IOException if any I/O error occurs 323 */ 324 @Test 325 public void testDeflate() throws IOException { 326 final HttpClient.Response response = HttpClient.create(new URL("https://httpbin.org/deflate")).connect(progress); 327 assertThat(response.getResponseCode(), is(200)); 328 try (InputStream in = response.getContent(); 329 JsonReader json = JsonProvider.provider().createReader(in)) { 330 assertThat(json.readObject().getBoolean("deflated"), is(true)); 331 } 332 } 333 334 /** 335 * Test reading Gzip-encoded data. 336 * @throws IOException if any I/O error occurs 337 */ 338 @Test 339 public void testGzip() throws IOException { 340 final HttpClient.Response response = HttpClient.create(new URL("https://httpbin.org/gzip")).connect(progress); 341 assertThat(response.getResponseCode(), is(200)); 342 try (InputStream in = response.getContent(); 343 JsonReader json = JsonProvider.provider().createReader(in)) { 344 assertThat(json.readObject().getBoolean("gzipped"), is(true)); 345 } 318 346 } 319 347
Note:
See TracChangeset
for help on using the changeset viewer.