Skip to content

Commit a338cbe

Browse files
committed
feat: custom http methods for chunk test and upload
1 parent b818175 commit a338cbe

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/flow.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @param {bool} [opts.withCredentials]
2020
* @param {Function} [opts.preprocess]
2121
* @param {string} [opts.method]
22+
* @param {string|Function} [opts.testMethod]
23+
* @param {string|Function} [opts.uploadMethod]
2224
* @param {bool} [opts.prioritizeFirstAndLastChunk]
2325
* @param {string|Function} [opts.target]
2426
* @param {number} [opts.maxChunkRetries]
@@ -76,7 +78,8 @@
7678
withCredentials: false,
7779
preprocess: null,
7880
method: 'multipart',
79-
81+
testMethod: 'GET',
82+
uploadMethod: 'POST',
8083
prioritizeFirstAndLastChunk: false,
8184
target: '/',
8285
testChunks: true,
@@ -1238,7 +1241,8 @@
12381241
this.xhr = new XMLHttpRequest();
12391242
this.xhr.addEventListener("load", this.testHandler, false);
12401243
this.xhr.addEventListener("error", this.testHandler, false);
1241-
var data = this.prepareXhrRequest('GET', true);
1244+
var testMethod = evalOpts(this.flowObj.opts.testMethod, this.fileObj, this);
1245+
var data = this.prepareXhrRequest(testMethod, true);
12421246
this.xhr.send(data);
12431247
},
12441248

@@ -1288,7 +1292,8 @@
12881292
this.xhr.addEventListener("load", this.doneHandler, false);
12891293
this.xhr.addEventListener("error", this.doneHandler, false);
12901294

1291-
var data = this.prepareXhrRequest('POST', false, this.flowObj.opts.method, bytes);
1295+
var uploadMethod = evalOpts(this.flowObj.opts.uploadMethod, this.fileObj, this);
1296+
var data = this.prepareXhrRequest(uploadMethod, false, this.flowObj.opts.method, bytes);
12921297
this.xhr.send(data);
12931298
},
12941299

0 commit comments

Comments
 (0)