NSURLSession: implement missing body data for data completion handlers

Now using the previously unused "in-memory" body data drain if a task has a completion handler, which requires the full body to be passed on completion.

Also consolidated private NSURLSessionTask methods, some of which were previously implemented twice in separate categories with the same name, leading to possible undefined runtime behavior.
This commit is contained in:
Frederik Seiffert 2023-01-16 15:40:43 +01:00 committed by Frederik Seiffert
parent 153482ea94
commit 82d9917c2c
5 changed files with 138 additions and 131 deletions

View file

@ -13,44 +13,8 @@
#import "Foundation/NSStream.h"
#import "Foundation/NSURL.h"
#import "Foundation/NSURLError.h"
#import "Foundation/NSURLSession.h"
#import "Foundation/NSValue.h"
@interface NSURLSessionTask (Internal)
- (void) setCountOfBytesExpectedToReceive: (int64_t)count;
- (void) setCountOfBytesExpectedToSend: (int64_t)count;
- (dispatch_queue_t) workQueue;
@end
@implementation NSURLSessionTask (Internal)
- (void) setCountOfBytesExpectedToReceive: (int64_t)count
{
_countOfBytesExpectedToReceive = count;
}
- (void) setCountOfBytesExpectedToSend: (int64_t)count
{
_countOfBytesExpectedToSend = count;
}
- (GSURLSessionTaskBody*) knownBody
{
return _knownBody;
}
- (dispatch_queue_t) workQueue
{
return _workQueue;
}
@end
@interface GSURLCacherHelper : NSObject
+ (BOOL) canCacheResponse: (NSCachedURLResponse*)response