Java – appengine gzip compression

I'm trying to gzip response from gae server, but I received 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 have read that the gae server will compress automatically What could be the problem?

Solution

The App Engine front-end server relies on many factors, including accept encoding and user agent headers, to determine whether they should compress the response They do this because many user agents claim to accept gzip compressed responses, but they actually can't understand them

Try to set your user agent to reasonable (not 'gzip', which is not a real user agent) and see if there is any difference

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>