java - Android HttpURLConnection: gzip compression -


i can't understand documentation says that.

by default, implementation of httpurlconnection requests servers use gzip compression. since getcontentlength() returns number of bytes transmitted, cannot use method predict how many bytes can read getinputstream(). instead, read stream until exhausted: when read() returns -1. gzip compression can disabled setting acceptable encodings in request header:

urlconnection.setrequestproperty("accept-encoding", "identity"); 

i know if current implementation decompress stream before returning (using conn.getinputstream()) or if says connection automatically sends header gzip encoding , need manage that.

thanks.

you dont need handle this. use conn.getinputstream()

from this blogpost:

in gingerbread, added transparent response compression. httpurlconnection automatically add header outgoing requests, , handle corresponding response:

accept-encoding: gzip


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -