- Timestamp:
- 2015-12-26T23:41:54+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/Compression.java
r8929 r9169 50 50 ? ZIP 51 51 : NONE; 52 } 53 54 /** 55 * Determines the compression type based on the content type (MIME type). 56 * @param contentType the content type 57 * @return the compression type 58 */ 59 public static Compression forContentType(String contentType) { 60 switch (contentType) { 61 case "application/zip": 62 return ZIP; 63 case "application/x-gzip": 64 return GZIP; 65 case "application/x-bzip2": 66 return BZIP2; 67 default: 68 return NONE; 69 } 52 70 } 53 71 -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r9168 r9169 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.data.Version; 21 import org.openstreetmap.josm.io.Compression; 21 22 22 23 /** … … 115 116 private final HttpURLConnection connection; 116 117 private final int responseCode; 118 private boolean uncompress; 117 119 118 120 private Response(HttpURLConnection connection) throws IOException { 119 121 this.connection = connection; 120 122 this.responseCode = connection.getResponseCode(); 123 } 124 125 /** 126 * Sets whether {@link #getContent()} should uncompress the input stream if necessary. 127 * 128 * @param uncompress whether the input stream should be uncompressed if necessary 129 * @return {@code this} 130 */ 131 public Response uncompress(boolean uncompress) { 132 this.uncompress = uncompress; 133 return this; 121 134 } 122 135 … … 135 148 in = connection.getErrorStream(); 136 149 } 137 return "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in; 150 in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in; 151 if (uncompress) { 152 return Compression.forContentType(getContentType()).getUncompressedInputStream(in); 153 } else { 154 return in; 155 } 138 156 } 139 157
Note:
See TracChangeset
for help on using the changeset viewer.