gpt4 book ai didi

ios - RKRequestDelegate TotalBytesExpectedToReceive 始终返回 -1

转载 作者:行者123 更新时间:2023-11-29 04:53:49 24 4
gpt4 key购买 nike

我正在实现

-(void)request:(RKRequest *)request didReceivedData:(NSInteger)bytesReceived totalBytesReceived:(NSInteger)totalBytesReceived totalBytesExpectedToReceive:(NSInteger)totalBytesExpectedToReceive {
NSLog(@"totalBytesExpectedToReceive = [%i] : totalBytesReceived = [%i]", totalBytesExpectedToReceive, totalBytesReceived);
}

但是我只正确地得到了totalBytesReceivedtotalBytesExpectedToReceive 始终返回 -1。

可能是什么问题?

谢谢

沙尼

最佳答案

RestKit 使用响应中发送的 Content-Length HTTP header 来确定预期长度。我建议您在 AppDelegate 中将日志级别设置为 Trace:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com