I have an NSURLConnection that connects to a PHP API I have made. That PHP API responds with data. Since it is a dynamic application, I do this to tell the content length:
ob_start('scAPIHandler');
function scAPIHandler($buffer){
header('Content-Length: '.strlen($buffer));
return $buffer;
}
At the beginning of the API file, which then later outputs whatever is necessary. However, when the
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
function fires, the value of response.expectedContentLength
is -1. When I try connecting not to my PHP API, but some images on the web, the correct expected content length is shown. Is there any way I can make my PHP API tell the NSURLResponse the content length to expect? The content-length header does not seem to work.
Thanks in advance!