Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit fabbd5e

Browse files
committed
Change link script and related file
When install in RN > 0.30 the link script will automatically add a statement to Android HTTP response callback (in RNFetchBlobReq.java) so that response body does not leaking.
1 parent a74e071 commit fabbd5e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private void done(Response resp) {
451451
break;
452452
}
453453
removeTaskInfo();
454-
// resp.close();
454+
resp.close();
455455
}
456456

457457
/**

src/scripts/prelink.js

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ if(VERSION < 0.28) {
4545
console.log('adding OkHttp3 dependency to pre 0.28 project .. ok')
4646
}
4747

48+
if(VERSION > 0.30) {
49+
let dest = process.cwd() + '/node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java'
50+
var main = fs.readFileSync(dest);
51+
console.log('patching OkHttp3 3.4.1 API ..')
52+
main = String(main).replace('// ${OKHTTP 3.4.1 ONLY STATEMENT}', "resp.close();");
53+
fs.writeFileSync(dest, main);
54+
console.log('patching OkHttp3 3.4.1 API .. ok')
55+
}
56+
4857
// set file access permission for Android < 6.0
4958
fs.readFile(MANIFEST_PATH, function(err, data) {
5059

0 commit comments

Comments
 (0)