Changeset 9227 in josm for trunk/src/org/openstreetmap/josm/tools/HttpClient.java
- Timestamp:
- 2015-12-31T03:24:56+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r9200 r9227 231 231 * @see HttpURLConnection#getErrorStream() 232 232 */ 233 @SuppressWarnings("resource") 233 234 public InputStream getContent() throws IOException { 234 235 InputStream in; … … 238 239 in = connection.getErrorStream(); 239 240 } 240 in = new ProgressInputStream(in, getContentLength(), monitor); 241 in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in; 242 Compression compression = Compression.NONE; 243 if (uncompress) { 244 final String contentType = getContentType(); 245 Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType); 246 compression = Compression.forContentType(contentType); 247 } 248 if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) { 249 final String contentDisposition = getHeaderField("Content-Disposition"); 250 final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition); 251 if (matcher.find()) { 252 Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition); 253 compression = Compression.byExtension(matcher.group(1)); 241 if (in != null) { 242 in = new ProgressInputStream(in, getContentLength(), monitor); 243 in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in; 244 Compression compression = Compression.NONE; 245 if (uncompress) { 246 final String contentType = getContentType(); 247 Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType); 248 compression = Compression.forContentType(contentType); 254 249 } 255 } 256 in = compression.getUncompressedInputStream(in); 250 if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) { 251 final String contentDisposition = getHeaderField("Content-Disposition"); 252 final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition); 253 if (matcher.find()) { 254 Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition); 255 compression = Compression.byExtension(matcher.group(1)); 256 } 257 } 258 in = compression.getUncompressedInputStream(in); 259 } 257 260 return in; 258 261 }
Note:
See TracChangeset
for help on using the changeset viewer.