Browse Source

Remove extra semi-column when Fetch Replacement parsing FormData #288

Remove extra semi-column when Fetch Replacement parsing FormData #288

This is non-standard behavior which may cause server side incompatible.
Ben Hsieh 7 years ago
parent
commit
785fd0e861
2 changed files with 7 additions and 8 deletions
  1. 4
    3
      polyfill/Blob.js
  2. 3
    5
      polyfill/Fetch.js

+ 4
- 3
polyfill/Blob.js View File

11
 const log = new Log('Blob')
11
 const log = new Log('Blob')
12
 const blobCacheDir = fs.dirs.DocumentDir + '/RNFetchBlob-blobs/'
12
 const blobCacheDir = fs.dirs.DocumentDir + '/RNFetchBlob-blobs/'
13
 
13
 
14
-log.disable()
15
-// log.level(3)
14
+// log.disable()
15
+log.level(3)
16
 
16
 
17
 /**
17
 /**
18
  * A RNFetchBlob style Blob polyfill class, this is a Blob which compatible to
18
  * A RNFetchBlob style Blob polyfill class, this is a Blob which compatible to
113
           formArray.push('\r\n--'+boundary+'\r\n')
113
           formArray.push('\r\n--'+boundary+'\r\n')
114
           let part = parts[i]
114
           let part = parts[i]
115
           for(let j in part.headers) {
115
           for(let j in part.headers) {
116
-            formArray.push(j + ': ' +part.headers[j] + ';\r\n')
116
+            formArray.push(j + ': ' +part.headers[j] + '\r\n')
117
           }
117
           }
118
           formArray.push('\r\n')
118
           formArray.push('\r\n')
119
           if(part.isRNFetchBlobPolyfill)
119
           if(part.isRNFetchBlobPolyfill)
342
       return fs.appendFile(...arg)
342
       return fs.appendFile(...arg)
343
     }.bind(args[i]))
343
     }.bind(args[i]))
344
   }
344
   }
345
+  console.log('###ref', ref)
345
   return p.then(() => Promise.resolve(size))
346
   return p.then(() => Promise.resolve(size))
346
 }
347
 }

+ 3
- 5
polyfill/Fetch.js View File

6
 
6
 
7
 const log = new Log('FetchPolyfill')
7
 const log = new Log('FetchPolyfill')
8
 
8
 
9
-log.disable()
10
-// log.level(3)
9
+// log.disable()
10
+log.level(3)
11
 
11
 
12
 export default class Fetch {
12
 export default class Fetch {
13
 
13
 
32
       options.headers['Content-Type'] = ctype || ctypeH
32
       options.headers['Content-Type'] = ctype || ctypeH
33
       options.headers['content-type'] = ctype || ctypeH
33
       options.headers['content-type'] = ctype || ctypeH
34
       options.method = options.method || 'GET'
34
       options.method = options.method || 'GET'
35
-
36
       if(body) {
35
       if(body) {
37
         // When the request body is an instance of FormData, create a Blob cache
36
         // When the request body is an instance of FormData, create a Blob cache
38
         // to upload the body.
37
         // to upload the body.
55
         else
54
         else
56
           promise = Promise.resolve(body)
55
           promise = Promise.resolve(body)
57
       }
56
       }
58
-
59
       // task is a progress reportable and cancellable Promise, however,
57
       // task is a progress reportable and cancellable Promise, however,
60
       // task.then is not, so we have to extend task.then with progress and
58
       // task.then is not, so we have to extend task.then with progress and
61
       // cancel function
59
       // cancel function
69
         log.verbose('response', resp)
67
         log.verbose('response', resp)
70
         // release blob cache created when sending request
68
         // release blob cache created when sending request
71
         if(blobCache !== null && blobCache instanceof Blob)
69
         if(blobCache !== null && blobCache instanceof Blob)
72
-          blobCache.close()
70
+          // blobCache.close()
73
         return Promise.resolve(new RNFetchBlobFetchRepsonse(resp))
71
         return Promise.resolve(new RNFetchBlobFetchRepsonse(resp))
74
       })
72
       })
75
 
73