I'm trying to gzip responses from GAE server, but receive null in Content-Encoding.
I have the following code:
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/json; charset=utf-8"); //"application/json; charset=utf-8"
connection.setRequestProperty("Accept-Encoding", "gzip");
connection.setRequestProperty("User-Agent", "gzip");
connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);
//write
//read
System.out.println("Content-Encoding " + connection.getContentEncoding());
I've read that on GAE servers do compressing automatically. So what can be the problem?
The App Engine frontend servers rely on a number of factors, including the Accept-Encoding
and User-Agent
headers to determine if they should compress responses. They do this because there are a number of user agents out there that claim to accept gzipped responses, but actually can't understand them.
Try setting your user agent to something sensible (and not 'gzip', which isn't a real user agent), and see if that makes any difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With