Question

I am implementing

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

But I only get the totalBytesReceived correctly. The totalBytesExpectedToReceive always returns -1.

What can be the problem ?

Thanks

Shani

Was it helpful?

Solution

RestKit use Content-Length HTTP header sent in the response to determine the expected length. I recommend you to set log level to Trace in your AppDelegate:

RKLogConfigureByName("RestKit/*", RKLogLevelTrace);

and find the headers in your log. Look for a statement like this

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";
}

if the "Content-Length" is missing from your output there is no way for RestKit to tell you how much data is expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top