【发布时间】:2012-03-10 09:07:55
【问题描述】:
我在 iOS 应用程序中使用 Google Geocoding API v3[1],但无法让它返回 gzip 响应。 v2 更轻量级,但在 v3 中,我得到了大约 20kb 的 JSON 响应 .. 在 GPRS 连接不佳时可能需要一些时间来检索,所以我真的很想得到一个 gzip 压缩的结果。
我想知道我在调用中是否做错了什么,或者他们的 API 是否真的不支持 gzip 或 deflate。这对我来说听起来很奇怪。
这是我在代码中所做的:
NSURL *url = [NSURL URLWithString:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=55,12&sensor=true"];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:url];
[req setValue:@"gzip,deflate" forHTTPHeaderField:@"Accept-Encoding"];
NSURLConnection *c = [[NSURLConnection alloc]
initWithRequest:req delegate:self startImmediately:YES];
我也尝试过只使用“gzip”和“deflate”。结果一样。
[1]http://code.google.com/apis/maps/documentation/geocoding/
【问题讨论】: