views/mdc/assets/js/components/events/posts.js in coprl-3.0.0.beta.4 vs views/mdc/assets/js/components/events/posts.js in coprl-3.0.0.beta.5
- old
+ new
@@ -57,17 +57,14 @@
for (const [name, value] of Object.entries(expandedParams)) {
formData.append(name, encode(value));
}
- const paramCount = Array.from(formData).length;
-
- if (paramCount < 1) {
+ if (this.paramCount(formData) < 1) {
console.warn(
'Creating request with no data!'
- + ' Are you sure you\'ve hooked everything up correctly?',
- );
+ + ' Are you sure you\'ve hooked everything up correctly?');
}
let errors = this.validate(formData);
if (errors.length > 0) {
return new Promise(function(_, reject) {
@@ -183,11 +180,18 @@
httpRequest.setRequestHeader(key, value);
}
}
// Send our FormData object; HTTP headers are set automatically
- httpRequest.send(formData);
+ // Rack 2.2 will throw an exception https://github.com/rack/rack/issues/1603
+ // if we set the header as multi-part form data with no data in the body
+ // So we set the body to null in this case.
+ httpRequest.send(this.paramCount(formData) < 1 ? null : formData);
});
+ }
+
+ paramCount(formData){
+ return Array.from(formData).length;
}
isForm() {
var parentElement = this.parentElement();
return parentElement && parentElement.elements;