Przeglądaj źródła

Merge branch 'master' into 0.9.0

Ben Hsieh 8 lat temu
rodzic
commit
ca01361526
1 zmienionych plików z 14 dodań i 14 usunięć
  1. 14
    14
      src/ios/RNFetchBlobNetwork.m

+ 14
- 14
src/ios/RNFetchBlobNetwork.m Wyświetl plik

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