|
@@ -69,7 +69,7 @@ static void initialize_tables() {
|
69
|
69
|
return _sharedInstance;
|
70
|
70
|
}
|
71
|
71
|
|
72
|
|
-+ (void) sendRequest:(__weak NSDictionary * _Nullable )options
|
|
72
|
+- (void) sendRequest:(__weak NSDictionary * _Nullable )options
|
73
|
73
|
contentLength:(long) contentLength
|
74
|
74
|
bridge:(RCTBridge * _Nullable)bridgeRef
|
75
|
75
|
taskId:(NSString * _Nullable)taskId
|
|
@@ -82,32 +82,45 @@ static void initialize_tables() {
|
82
|
82
|
bridge:bridgeRef
|
83
|
83
|
taskId:taskId
|
84
|
84
|
withRequest:req
|
85
|
|
- taskOperationQueue:[self sharedInstance].taskQueue
|
|
85
|
+ taskOperationQueue:self.taskQueue
|
86
|
86
|
callback:callback];
|
87
|
87
|
|
88
|
88
|
@synchronized([RNFetchBlobNetwork class]) {
|
89
|
|
- [[self sharedInstance].requestsTable setObject:request forKey:taskId];
|
|
89
|
+ [self.requestsTable setObject:request forKey:taskId];
|
90
|
90
|
}
|
91
|
91
|
}
|
92
|
92
|
|
93
|
|
-+ (void) enableProgressReport:(NSString *) taskId config:(RNFetchBlobProgress *)config
|
|
93
|
+- (void) enableProgressReport:(NSString *) taskId config:(RNFetchBlobProgress *)config
|
94
|
94
|
{
|
95
|
95
|
if (config) {
|
96
|
96
|
@synchronized ([RNFetchBlobNetwork class]) {
|
97
|
|
- [[self sharedInstance].requestsTable objectForKey:taskId].progressConfig = config;
|
|
97
|
+ [self.requestsTable objectForKey:taskId].progressConfig = config;
|
98
|
98
|
}
|
99
|
99
|
}
|
100
|
100
|
}
|
101
|
101
|
|
102
|
|
-+ (void) enableUploadProgress:(NSString *) taskId config:(RNFetchBlobProgress *)config
|
|
102
|
+- (void) enableUploadProgress:(NSString *) taskId config:(RNFetchBlobProgress *)config
|
103
|
103
|
{
|
104
|
104
|
if (config) {
|
105
|
105
|
@synchronized ([RNFetchBlobNetwork class]) {
|
106
|
|
- [[self sharedInstance].requestsTable objectForKey:taskId].uploadProgressConfig = config;
|
|
106
|
+ [self.requestsTable objectForKey:taskId].uploadProgressConfig = config;
|
107
|
107
|
}
|
108
|
108
|
}
|
109
|
109
|
}
|
110
|
110
|
|
|
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
|
+
|
111
|
124
|
// removing case from headers
|
112
|
125
|
+ (NSMutableDictionary *) normalizeHeaders:(NSDictionary *)headers
|
113
|
126
|
{
|
|
@@ -115,7 +128,7 @@ static void initialize_tables() {
|
115
|
128
|
for(NSString * key in headers) {
|
116
|
129
|
[mheaders setValue:[headers valueForKey:key] forKey:[key lowercaseString]];
|
117
|
130
|
}
|
118
|
|
-
|
|
131
|
+
|
119
|
132
|
return mheaders;
|
120
|
133
|
}
|
121
|
134
|
|
|
@@ -140,17 +153,4 @@ static void initialize_tables() {
|
140
|
153
|
}
|
141
|
154
|
}
|
142
|
155
|
|
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
|
|
-
|
156
|
156
|
@end
|