@@ -69,7 +69,7 @@ + (RNFetchBlobNetwork* _Nullable)sharedInstance {
6969 return _sharedInstance;
7070}
7171
72- + (void ) sendRequest : (__weak NSDictionary * _Nullable )options
72+ - (void ) sendRequest : (__weak NSDictionary * _Nullable )options
7373 contentLength : (long ) contentLength
7474 bridge : (RCTBridge * _Nullable)bridgeRef
7575 taskId : (NSString * _Nullable)taskId
@@ -82,40 +82,53 @@ + (void) sendRequest:(__weak NSDictionary * _Nullable )options
8282 bridge: bridgeRef
8383 taskId: taskId
8484 withRequest: req
85- taskOperationQueue: [ self sharedInstance ] .taskQueue
85+ taskOperationQueue: self .taskQueue
8686 callback: callback];
8787
8888 @synchronized ([RNFetchBlobNetwork class ]) {
89- [[ self sharedInstance ] .requestsTable setObject: request forKey: taskId];
89+ [self .requestsTable setObject: request forKey: taskId];
9090 }
9191}
9292
93- + (void ) enableProgressReport : (NSString *) taskId config : (RNFetchBlobProgress *)config
93+ - (void ) enableProgressReport : (NSString *) taskId config : (RNFetchBlobProgress *)config
9494{
9595 if (config) {
9696 @synchronized ([RNFetchBlobNetwork class ]) {
97- [[ self sharedInstance ] .requestsTable objectForKey: taskId].progressConfig = config;
97+ [self .requestsTable objectForKey: taskId].progressConfig = config;
9898 }
9999 }
100100}
101101
102- + (void ) enableUploadProgress : (NSString *) taskId config : (RNFetchBlobProgress *)config
102+ - (void ) enableUploadProgress : (NSString *) taskId config : (RNFetchBlobProgress *)config
103103{
104104 if (config) {
105105 @synchronized ([RNFetchBlobNetwork class ]) {
106- [[ self sharedInstance ] .requestsTable objectForKey: taskId].uploadProgressConfig = config;
106+ [self .requestsTable objectForKey: taskId].uploadProgressConfig = config;
107107 }
108108 }
109109}
110110
111+ - (void ) cancelRequest : (NSString *)taskId
112+ {
113+ NSURLSessionDataTask * task;
114+
115+ @synchronized ([RNFetchBlobNetwork class ]) {
116+ task = [self .requestsTable objectForKey: taskId].task ;
117+ }
118+
119+ if (task && task.state == NSURLSessionTaskStateRunning ) {
120+ [task cancel ];
121+ }
122+ }
123+
111124// removing case from headers
112125+ (NSMutableDictionary *) normalizeHeaders : (NSDictionary *)headers
113126{
114127 NSMutableDictionary * mheaders = [[NSMutableDictionary alloc ]init];
115128 for (NSString * key in headers) {
116129 [mheaders setValue: [headers valueForKey: key] forKey: [key lowercaseString ]];
117130 }
118-
131+
119132 return mheaders;
120133}
121134
@@ -140,17 +153,4 @@ + (void) emitExpiredTasks
140153 }
141154}
142155
143- + (void ) cancelRequest : (NSString *)taskId
144- {
145- NSURLSessionDataTask * task;
146-
147- @synchronized ([RNFetchBlobNetwork class ]) {
148- task = [[self sharedInstance ].requestsTable objectForKey: taskId].task ;
149- }
150-
151- if (task && task.state == NSURLSessionTaskStateRunning ) {
152- [task cancel ];
153- }
154- }
155-
156156@end
0 commit comments