mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-05-31 00:00:07 +08:00
fix: #372 [Bug] Android: malformed empty multipart requests
This commit is contained in:
@@ -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
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user