@@ -193,7 +193,7 @@ - (void) sendRequest:(__weak NSDictionary * _Nullable )options
193
193
- (void ) URLSession : (NSURLSession *)session dataTask : (NSURLSessionDataTask *)dataTask didReceiveResponse : (NSURLResponse *)response completionHandler : (void (^)(NSURLSessionResponseDisposition ))completionHandler
194
194
{
195
195
expectedBytes = [response expectedContentLength ];
196
-
196
+
197
197
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
198
198
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode ];
199
199
NSString * respType = @" " ;
@@ -246,7 +246,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
246
246
@" timeout" : @NO ,
247
247
@" status" : [NSString stringWithFormat: @" %d " , statusCode ]
248
248
};
249
-
249
+
250
250
[self .bridge.eventDispatcher
251
251
sendDeviceEventWithName: EVENT_STATE_CHANGE
252
252
body: respInfo
@@ -275,7 +275,7 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
275
275
NSLog (@" write file error" );
276
276
}
277
277
}
278
-
278
+
279
279
completionHandler (NSURLSessionResponseAllow );
280
280
}
281
281
@@ -292,11 +292,11 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
292
292
{
293
293
[writeStream write :[data bytes ] maxLength: [data length ]];
294
294
}
295
-
295
+
296
296
if ([progressTable valueForKey: taskId] == @YES )
297
297
{
298
298
[self .bridge.eventDispatcher
299
- sendDeviceEventWithName: EVENT_PROGRESS
299
+ sendDeviceEventWithName: EVENT_PROGRESS
300
300
body: @{
301
301
@" taskId" : taskId,
302
302
@" written" : [NSString stringWithFormat: @" %d " , receivedBytes],
@@ -316,19 +316,19 @@ - (void) URLSession:(NSURLSession *)session didBecomeInvalidWithError:(nullable
316
316
317
317
- (void ) URLSession : (NSURLSession *)session task : (NSURLSessionTask *)task didCompleteWithError : (NSError *)error
318
318
{
319
-
319
+
320
320
self.error = error;
321
321
NSString * errMsg = [NSNull null ];
322
322
NSString * respStr = [NSNull null ];
323
323
NSString * rnfbRespType = @" " ;
324
-
324
+
325
325
[[UIApplication sharedApplication ] setNetworkActivityIndicatorVisible: NO ];
326
-
326
+
327
327
if (respInfo == nil )
328
328
{
329
329
respInfo = [NSNull null ];
330
330
}
331
-
331
+
332
332
if (error != nil )
333
333
{
334
334
errMsg = [error localizedDescription ];
@@ -353,7 +353,7 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCom
353
353
// if it turns out not to be `nil` that means the response data contains valid UTF8 string,
354
354
// in order to properly encode the UTF8 string, use URL encoding before BASE64 encoding.
355
355
NSString * utf8 = [[NSString alloc ] initWithData: respData encoding: NSUTF8StringEncoding];
356
-
356
+
357
357
if (utf8 != nil )
358
358
{
359
359
rnfbRespType = RESP_TYPE_UTF8;
@@ -364,12 +364,12 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCom
364
364
rnfbRespType = RESP_TYPE_BASE64;
365
365
respStr = [respData base64EncodedStringWithOptions: 0 ];
366
366
}
367
-
367
+
368
368
}
369
369
}
370
-
370
+
371
371
callback (@[ errMsg, rnfbRespType, respStr]);
372
-
372
+
373
373
@synchronized (taskTable, uploadProgressTable, progressTable)
374
374
{
375
375
if ([taskTable objectForKey: taskId] == nil )
@@ -379,7 +379,7 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCom
379
379
[uploadProgressTable removeObjectForKey: taskId];
380
380
[progressTable removeObjectForKey: taskId];
381
381
}
382
-
382
+
383
383
respData = nil ;
384
384
receivedBytes = 0 ;
385
385
[session finishTasksAndInvalidate ];
0 commit comments