From a31b4292d856f2fc4ca5ecc5fa9493774fd8f7be Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 4 Jan 2014 09:36:08 -0800 Subject: #239 Allow GZip encoding where supported --- src/github/daneren2005/dsub/service/RESTMusicService.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/github') diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 6d55cbd3..951a182d 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -98,6 +98,7 @@ import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.Util; import java.io.*; +import java.util.zip.GZIPInputStream; /** * @author Sindre Mehus @@ -1269,6 +1270,10 @@ public class RESTMusicService implements MusicService { } InputStream in = entity.getContent(); + Header contentEncoding = entity.getContentEncoding(); + if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) { + in = new GZIPInputStream(in); + } return new InputStreamReader(in, Constants.UTF_8); } @@ -1356,6 +1361,7 @@ public class RESTMusicService implements MusicService { request.addHeader(header); } } + request.addHeader("Accept-Encoding", "gzip"); // Set credentials to get through apache proxies that require authentication. int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); -- cgit v1.2.3