ios - AFHTTPRequestOperation _totalBytesRead 是在放气之前还是之后?

标签 ios afnetworking afhttprequestoperation afhttpclient

我正在连接到我自己的 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/

相关文章:

ios - NSFetchedResultsController 不诉诸内容更改

objective-c - iOS- AFNETWORKING 2.0 -AFHTTPRequestOperationManager - 后多部分请求

ios - AFNetworking - 上传视频和其他参数

ios - 为什么取消 AFHTTPRequestOperation 有时会遇到成功 block ?

ios - Apple Mach-O Linker Error 主可执行文件的隐式输入/启动

ios - 火力基地。 swift :Retrieve a message after 5 hours of the post

ios - 如何检查(id)对象在ios中是否为空?

ios - 如何让 Mocktail 接受 URL 参数

html - 以编程方式按 NSURLRequest 中的 html 按钮

ios - UILabel 如何垂直居中其文本?