Probably the best approach would be to subclass ASIHTTPRequest, and override handleBytesAvailable with something like this:
- (void)handleBytesAvailable
{
[super handleBytesAvailable];
if ([self totalBytesRead] >= 65535) {
[self cancelLoad];
[self handleStreamComplete];
}
}
Untested, but let me know if you get stuck.
Best
Ben
>> Probably the best approach would be to subclass ASIHTTPRequest, and override handleBytesAvailable with something like this:
>>
>> - (void)handleBytesAvailable
>> {
>> [super handleBytesAvailable];
>> if ([self totalBytesRead] >= 65535) {
>> [self cancelLoad];
>> [self handleStreamComplete];
>> }
>>
>> }
>>
>> Untested, but let me know if you get stuck.
> Thanks so much for the detailed reply.
>
> One thing, however the [self handleStreamComplete] throws an
> EXC_BAD_ACCESS. I can't see where exactly, but it's something to do
> with reading the response headers.
>
> Stack trace:
>
> CFReadStreamCopyProperty + 33
> -[ASIHTTPRequest readResponseHeaders] + 133 (ASIHTTPRequest.m:2045)
> -[ASIHTTPRequest handleStreamComplete] + 157 (ASIHTTPRequest.m:3136)
Ah, ok, looks like it's trying to get to the CFNetwork request object after we've released it.
Possibly just doing this instead:
- (void)handleBytesAvailable
{
[super handleBytesAvailable];
if ([self totalBytesRead] >= 65535) {
[self handleStreamComplete];
}
}
I think handleStreamComplete should handle cancelling the load for you, and I would guess this will prevent the problem above - this seemed to work in a quick test for me, but I haven't really tested properly.
Best
Ben