Selaa lähdekoodia

Add Android HTTP Close body

Ben Hsieh 8 vuotta sitten
vanhempi
commit
dbb53f9061

+ 4
- 5
src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Näytä tiedosto

@@ -456,9 +456,7 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
456 456
                     // It uses customized response body which is able to report download progress
457 457
                     // and write response data to destination path.
458 458
                     resp.body().bytes();
459
-                } catch (Exception ignored) {
460
-                    ignored.printStackTrace();
461
-                }
459
+                } catch (Exception ignored) {  }
462 460
                 callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
463 461
                 break;
464 462
             default:
@@ -469,8 +467,9 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
469 467
                 }
470 468
                 break;
471 469
         }
472
-        if(!resp.isSuccessful())
473
-            resp.body().close();
470
+//        if(!resp.isSuccessful())
471
+//            resp.body().close();
472
+        resp.body().close();
474 473
         releaseTaskResource();
475 474
     }
476 475
 

+ 2
- 1
test/test-0.9.4.js Näytä tiedosto

@@ -35,7 +35,8 @@ describe('issue #105', (report, done) => {
35 35
     .then((res) => {
36 36
       tmp = res.path()
37 37
       return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
38
-        'Content-Type' : 'multipart/form-data'
38
+        'Content-Type' : 'multipart/form-data',
39
+        'Expect' : '100-continue'
39 40
       }, [
40 41
         { name : 'data', data : 'issue#105 test' },
41 42
         { name : 'file', filename : 'github.png', data : RNFetchBlob.wrap(tmp) }