| 
				
			 | 
			
			
				@@ -57,24 +57,38 @@ class RNFetchBlobFetchPolyfill { 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				57
			 | 
			
			
				       // task is a progress reportable and cancellable Promise, however, 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				58
			 | 
			
			
				       // task.then is not, so we have to extend task.then with progress and 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				59
			 | 
			
			
				       // cancel function 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-      let task = promise 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+      let progressHandler, uploadHandler, cancelHandler 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+      let statefulPromise = promise 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				62
			 | 
			
			
				           .then((body) => { 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-            return RNFetchBlob.config(config) 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-            .fetch(options.method, url, options.headers, body) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+            let task = RNFetchBlob.config(config) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+              .fetch(options.method, url, options.headers, body) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+            if(progressHandler) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+              task.progress(progressHandler) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+            if(uploadHandler) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+              task.uploadProgress(uploadHandler) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+            if(cancelHandler) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+              task.cancel() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+            return task.then((resp) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+              log.verbose('response', resp) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+              // release blob cache created when sending request 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+              if(blobCache !== null && blobCache instanceof Blob) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+                blobCache.close() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+              return Promise.resolve(new RNFetchBlobFetchRepsonse(resp)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+            }) 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				78
			 | 
			
			
				           }) 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				79
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-      let statefulPromise = task.then((resp) => { 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-        log.verbose('response', resp) 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-        // release blob cache created when sending request 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-        if(blobCache !== null && blobCache instanceof Blob) 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-          blobCache.close() 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-        return Promise.resolve(new RNFetchBlobFetchRepsonse(resp)) 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-      }) 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				80
			 | 
			
			
				       // extend task.then progress with report and cancelling functions 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-      statefulPromise.cancel = task.cancel 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-      statefulPromise.progress = task.progress 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				-      statefulPromise.uploadProgress = task.uploadProgress 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+      statefulPromise.progress = (fn) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+        progressHandler = fn 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+      statefulPromise.uploadProgress = (fn) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+        uploadHandler = fn 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+      statefulPromise.cancel = () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+        cancelHandler = true 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+        if(task.cancel) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+          task.cancel() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				92
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				79
			 | 
			
				93
			 | 
			
			
				       return statefulPromise 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				94
			 | 
			
			
				  
			 |