views:

58

answers:

1

Hi,

I have some google appengine java servlet that I access from some iphone 4 app.

The servlet writes the response as XML. I have set the content type of the servlet response to "text/plain". If I fetch the servlet page using Chrome, the response is gzipped (1 Kb). But, if I fetch the servlet using my iphone app, the response is 19 Kb sized...

Either the iphone app fetches data with [NSData dataWithContentOfURL:url] or with some NSMutableURLRequest with HTTP header field "Accept-Encoding" set to "gzip", the response is still not gzipped.

Moreover, I can see in Google AppEngine logs that my iphone app accepts gzip : CFNetwork/485.10.2 Darwin/10.4.0,gzip(gfe)

What can I do?

Thanks. François

A: 

Ok, I found a way: you have to add "gzip" to the User-Agent.

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:myURL]];
[request addValue:@"gzip" forHTTPHeaderField:@"User-Agent"];

If you do it this way, you will lost default values set by the framework (appName/Version CFNetwork/blah blah blah), but GAE returns a gzipped response.

Francois B.