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

Commit 6a4cb4a

Browse files
committed
Merge branch '0.9.4' into 0.10.0
2 parents 305bda6 + dbb53f9 commit 6a4cb4a

File tree

6 files changed

+72
-16
lines changed

6 files changed

+72
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fetchblob-dev",
3-
"version": "0.9.3",
3+
"version": "0.9.4",
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start",

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ private void done(Response resp) {
458458
// It uses customized response body which is able to report download progress
459459
// and write response data to destination path.
460460
resp.body().bytes();
461-
} catch (Exception ignored) {
462-
ignored.printStackTrace();
463-
}
461+
} catch (Exception ignored) { }
464462
callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_PATH, this.destPath);
465463
break;
466464
default:
@@ -471,8 +469,9 @@ private void done(Response resp) {
471469
}
472470
break;
473471
}
474-
if(!resp.isSuccessful())
475-
resp.body().close();
472+
// if(!resp.isSuccessful())
473+
// resp.body().close();
474+
resp.body().close();
476475
releaseTaskResource();
477476
}
478477

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-fetch-blob",
3-
"version": "0.9.3",
3+
"version": "0.9.4-beta.1",
44
"description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
55
"main": "index.js",
66
"scripts": {

src/polyfill/XMLHttpRequest.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget{
321321
log.debug('XMLHttpRequest done', this._url, resp, this)
322322
this._statusText = this._status
323323
let responseDataReady = () => {
324+
log.debug('request done state = 4')
324325
this.dispatchEvent('load')
325326
this.dispatchEvent('loadend')
326327
this._dispatchReadStateChange(XMLHttpRequest.DONE)
@@ -330,14 +331,6 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget{
330331
let info = resp.respInfo || {}
331332
log.debug(this._url, info, info.respType)
332333
switch(info.respType) {
333-
case 'json' :
334-
try{
335-
this._responseText = resp.text()
336-
this._response = resp.json()
337-
responseDataReady()
338-
} catch(err) {
339-
}
340-
break;
341334
case 'blob' :
342335
resp.blob().then((b) => {
343336
this._responseText = resp.text()

src/polyfill/XMLHttpRequestEventTarget.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class XMLHttpRequestEventTarget extends EventTarget {
2626
}
2727

2828
dispatchEvent(event:string, e:Event) {
29+
log.debug('dispatch event', event, e)
2930
super.dispatchEvent(event, e)
3031
switch(event) {
3132
case 'abort' :
@@ -70,7 +71,7 @@ export default class XMLHttpRequestEventTarget extends EventTarget {
7071
}
7172

7273
set onload(fn:(e:Event) => void) {
73-
log.info('set onload')
74+
log.info('set onload', fn)
7475
this._onload = fn
7576
}
7677

test/test-0.9.4.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import RNTest from './react-native-testkit/'
2+
import React from 'react'
3+
import RNFetchBlob from 'react-native-fetch-blob'
4+
import {
5+
StyleSheet,
6+
Text,
7+
View,
8+
ScrollView,
9+
Platform,
10+
Dimensions,
11+
Image,
12+
} from 'react-native';
13+
14+
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
15+
window.Blob = RNFetchBlob.polyfill.Blob
16+
17+
const fs = RNFetchBlob.fs
18+
const { Assert, Comparer, Info, prop } = RNTest
19+
const describe = RNTest.config({
20+
group : '0.9.4',
21+
run : true,
22+
expand : true,
23+
timeout : 20000,
24+
})
25+
const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
26+
const dirs = RNFetchBlob.fs.dirs
27+
28+
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
29+
30+
describe('issue #105', (report, done) => {
31+
let tmp = null
32+
RNFetchBlob
33+
.config({ fileCache : true })
34+
.fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
35+
.then((res) => {
36+
tmp = res.path()
37+
return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
38+
'Content-Type' : 'multipart/form-data',
39+
'Expect' : '100-continue'
40+
}, [
41+
{ name : 'data', data : 'issue#105 test' },
42+
{ name : 'file', filename : 'github.png', data : RNFetchBlob.wrap(tmp) }
43+
])
44+
})
45+
.then((res) => {
46+
done()
47+
})
48+
})
49+
50+
describe('issue #106', (report, done) => {
51+
52+
fetch('https://rnfb-test-app.firebaseapp.com/6m-json.json')
53+
.then((res) => {
54+
console.log('## converted')
55+
return res.json()
56+
})
57+
.then((data) => {
58+
// console.log(data)
59+
report(<Assert key="fetch request success" expect={20000} actual={data.total}/>)
60+
done()
61+
})
62+
63+
})

0 commit comments

Comments
 (0)