fix: #372 [Bug] Android: malformed empty multipart requests

This commit is contained in:
Sefa Ilkimen
2020-10-19 04:11:49 +02:00
parent e44def06a5
commit 25a0a9a7ae
4 changed files with 26 additions and 3 deletions
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## 3.1.1
- Fixed #372: malformed empty multipart request on Android
## 3.1.0
- Feature #272: add support for aborting requests (thanks russaa)
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-advanced-http",
"version": "3.1.0",
"version": "3.1.1",
"description": "Cordova / Phonegap plugin for communicating with HTTP servers using SSL pinning",
"scripts": {
"updatecert": "node ./scripts/update-e2e-server-cert.js && node ./scripts/update-e2e-client-cert.js",
@@ -66,4 +66,4 @@
"wd": "1.12.1",
"xml2js": "0.4.23"
}
}
}
@@ -154,7 +154,7 @@ abstract class CordovaHttpBase implements Runnable {
} else if ("urlencoded".equals(this.serializer)) {
// intentionally left blank, because content type is set in HttpRequest.form()
} else if ("multipart".equals(this.serializer)) {
request.contentType("multipart/form-data");
// intentionally left blank, because content type is set in HttpRequest.part()
}
}
+19
View File
@@ -1109,6 +1109,25 @@ const tests = [
result.data.status.should.be.equal(-8);
}
},
{
description: 'should not send malformed request when FormData is empty #372',
expected: 'resolved: {"status":200, ...',
before: helpers.setMultipartSerializer,
func: function (resolve, reject) {
var ponyfills = cordova.plugin.http.ponyfills;
var formData = new ponyfills.FormData();
var url = 'http://httpbin.org/anything';
var options = { method: 'post', data: formData };
cordova.plugin.http.sendRequest(url, options, resolve, reject);
},
validationFunc: function (driver, result) {
helpers.checkResult(result, 'resolved');
var parsed = JSON.parse(result.data.data);
parsed.headers['Content-Type'].should.be.equal('application/x-www-form-urlencoded');
}
},
];
if (typeof module !== 'undefined' && module.exports) {