diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-09-10 20:10:05 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-09-10 20:10:05 -0700 |
commit | 51daaa5023774fece5ea31d117f82a82cc66d7d9 (patch) | |
tree | 8754e0a89818e7df8ddaf125b62282ee66fa757e /src/github/daneren2005 | |
parent | 880033f291d265e3d656c8fb315857ceb9bb1d99 (diff) | |
download | dsub-51daaa5023774fece5ea31d117f82a82cc66d7d9.tar.gz dsub-51daaa5023774fece5ea31d117f82a82cc66d7d9.tar.bz2 dsub-51daaa5023774fece5ea31d117f82a82cc66d7d9.zip |
Decompress any gzip compressed streams we come across
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r-- | src/github/daneren2005/dsub/service/RESTMusicService.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 3e59abe3..9509b41a 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -620,7 +620,12 @@ public class RESTMusicService implements MusicService { List<String> parameterNames = Arrays.asList("id"); List<Object> parameterValues = Arrays.<Object>asList(entry.getCoverArt()); HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener); - in = entity.getContent(); + + in = entity.getContent(); + Header contentEncoding = entity.getContentEncoding(); + if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) { + in = new GZIPInputStream(in); + } // If content type is XML, an error occured. Get it. String contentType = Util.getContentType(entity); @@ -698,6 +703,10 @@ public class RESTMusicService implements MusicService { String contentType = Util.getContentType(response.getEntity()); if (contentType != null && contentType.startsWith("text/xml")) { InputStream in = response.getEntity().getContent(); + Header contentEncoding = response.getEntity().getContentEncoding(); + if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) { + in = new GZIPInputStream(in); + } try { new ErrorParser(context, getInstance(context)).parse(new InputStreamReader(in, Constants.UTF_8)); } finally { @@ -1309,6 +1318,10 @@ public class RESTMusicService implements MusicService { HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener); in = entity.getContent(); + Header contentEncoding = entity.getContentEncoding(); + if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) { + in = new GZIPInputStream(in); + } // If content type is XML, an error occurred. Get it. String contentType = Util.getContentType(entity); |