Thursday, June 4, 2015

Android HttpUrlConnection Disable default content encoding in gzip

At present i have came across a scenario that our ESB is not responding to gzip format content encoded requests. Though ESB successfully call back end service after decoding these gzip requests originated from android apps which use HttpUrlConnection, ESB is not capable of respond the request after backend service successfully hand the response to ESB

Neither web nor Google helped me to understand how the default gzip encoding stops.

And then it came to my mind. Just set “Content-Encoding” to “identity” and you are done.

HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setRequestProperty(“Content-Encoding”, “identity”);

con.setRequestProperty(“Accept-Encoding”, “identity”);

http://ift.tt/eA8V8J June 04, 2015 at 12:18PM