ravyoli
ravyoli

Reputation: 718

send back compressed JSON in Restlet/GAE

I am writing a Restlet application on GAE similar as described here: First Application

I am sending back a JSON represntation of an entity, and this works. But I am so far unsuccessful in sending the response compressed.

I tried to add to request an accept-encoding header with "gzip". but that didn't help. Here is how i tested it:

URL url = new URL(address);
URLConnection urlConn = url.openConnection();
urlConn.setRequestProperty("Accept-Encoding", "gzip");
InputStream openStream = urlConn.getInputStream();

Any ideas would be very much appreciated!

Upvotes: 2

Views: 703

Answers (1)

Amy U.
Amy U.

Reputation: 2237

I believe you also need to specify the User-Agent header to force the compression. From the docs:

https://developers.google.com/appengine/docs/python/runtime#Responses

If the client sends HTTP headers with the request indicating that the client can accept compressed (gzipped) content, App Engine compresses the response data automatically and attaches the appropriate response headers. It uses both the Accept-Encoding and User-Agent request headers to determine if the client can reliably receive compressed responses. Custom clients can force content to be compressed by specifying both Accept-Encoding and User-Agent headers with a value of "gzip".

Upvotes: 1

Related Questions