Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppEngine gzip compressing

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?

like image 821
Sergey Avatar asked Dec 12 '11 08:12

Sergey


1 Answers

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.

like image 180
Nick Johnson Avatar answered Sep 27 '22 23:09

Nick Johnson