我正在连接到我自己的 Web 服务,我认为它正在发回一个 gzipped 响应,该响应由 AF Networking 库在后台解压缩。当存在接受编码 gzip header 时,我已验证我的服务器正在发送压缩数据,并且我已验证库正在发送此 header 。
但是_totalBytesRead的值是解压后的总字节数。这是因为这个值是在解压缩之后还是我实际上没有得到压缩数据?如果是前者,在 iOS 端确认我正在压缩数据的最可靠方法是什么?
代码如下:
NSString *absolutePath = @"http://example.com/webservice";
NSMutableURLRequest * request = [self requestWithMethod:@"GET" path:absolutePath parameters:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:tempFilePath append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
//_totalBytesRead here equals size of uncompressed file/data
}
最佳答案
尝试安装 Charles 并按照代理 iOS 设备上的说明进行操作
http://www.charlesproxy.com/documentation/faqs/using-charles-from-an-iphone/
您将获得所需的信息以及更多信息。
关于ios - AFHTTPRequestOperation _totalBytesRead 是在放气之前还是之后?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27496395/