我正在实施
-(void)request:(RKRequest *)request didReceivedData:(NSInteger)bytesReceived totalBytesReceived:(NSInteger)totalBytesReceived totalBytesExpectedToReceive:(NSInteger)totalBytesExpectedToReceive {
NSLog(@"totalBytesExpectedToReceive = [%i] : totalBytesReceived = [%i]", totalBytesExpectedToReceive, totalBytesReceived);
}
但是我只能正确得到
totalBytesReceived
。 totalBytesExpectedToReceive
始终返回-1。可能是什么问题?
谢谢
香妮
最佳答案
RestKit使用响应中发送的Content-Length
HTTP标头确定预期的长度。我建议您在AppDelegate中将日志级别设置为“跟踪”:
RKLogConfigureByName("RestKit/*", RKLogLevelTrace);
并在日志中找到标题。寻找这样的声明
2011-12-04 17:00:36.564 XXXXXX[56816:15803] D restkit.network:RKResponse.m:197 Headers: {
Connection = "Keep-Alive";
"Content-Disposition" = "inline; filename=xxxx.xml";
"Content-Encoding" = gzip;
"Content-Length" = 391;
"Content-Type" = "application/xml";
Date = "Sun, 04 Dec 2011 16:00:36 GMT";
"Keep-Alive" = "timeout=15, max=100";
Server = "Apache/2.2.14 (Ubuntu)";
Vary = "Accept-Encoding";
}
如果输出中缺少
"Content-Length"
,则RestKit无法告诉您需要多少数据。关于ios - RKRequestDelegate TotalBytesExpectedToReceive始终返回-1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8376360/