开发者

appengine, iphone and gzip

开发者 https://www.devze.com 2023-01-20 08:34 出处:网络
I have some google appengine java servlet that I access f开发者_Go百科rom some iphone 4 app. The servlet writes the response as XML. I have set the content type of the servlet response to \"text/plai

I have some google appengine java servlet that I access f开发者_Go百科rom 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


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.


I don't think you should set User-Agent

0

精彩评论

暂无评论...
验证码 换一张
取 消