From 45ee8b01df5dc8975c2a95f1250bc15dbaf238cf Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 22 Dec 2021 00:14:19 -0800 Subject: [PATCH] HTTP reader: Keep track of task suspend/resume so we don't stall trying to resume an already running stream --- Plugins/HTTPSource/HTTPSource.h | 1 + Plugins/HTTPSource/HTTPSource.m | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Plugins/HTTPSource/HTTPSource.h b/Plugins/HTTPSource/HTTPSource.h index 95e77c9c1..155fba32e 100644 --- a/Plugins/HTTPSource/HTTPSource.h +++ b/Plugins/HTTPSource/HTTPSource.h @@ -31,6 +31,7 @@ long _bytesBuffered; long _byteCount; + BOOL taskSuspended; NSString *_mimeType; } diff --git a/Plugins/HTTPSource/HTTPSource.m b/Plugins/HTTPSource/HTTPSource.m index 79688afbe..c9da7aac0 100644 --- a/Plugins/HTTPSource/HTTPSource.m +++ b/Plugins/HTTPSource/HTTPSource.m @@ -104,6 +104,7 @@ } if (bytesBuffered >= BUFFER_SIZE) { [task suspend]; + taskSuspended = YES; } } @@ -182,6 +183,7 @@ didCompleteWithError:(NSError *)error{ didReceiveResponse = NO; didReceiveRandomData = NO; redirected = NO; + taskSuspended = NO; redirectURLs = [[NSMutableArray alloc] init]; bufferedData = [[NSMutableData alloc] init]; @@ -262,8 +264,9 @@ didCompleteWithError:(NSError *)error{ bytesBuffered = _bytesBuffered; } - if (!didComplete && bytesBuffered <= (BUFFER_SIZE * 3 / 4)) { + if (!didComplete && taskSuspended && bytesBuffered <= (BUFFER_SIZE * 3 / 4)) { [task resume]; + taskSuspended = NO; } totalRead += amountReceived;