don't set Content-Type in the presence of hx-encoding

This commit is contained in:
carson 2020-09-29 11:28:21 -06:00
parent b401f54c54
commit 6900ab8278
2 changed files with 3 additions and 8 deletions

View File

@ -1637,12 +1637,8 @@ return (function () {
addExpressionVars(elt, rawParameters);
var filteredParameters = filterValues(rawParameters, elt);
if (verb !== 'get') {
var encoding = getClosestAttributeValue(elt, "hx-encoding");
if (encoding == null) {
encoding = 'application/x-www-form-urlencoded; charset=UTF-8';
}
headers['Content-Type'] = encoding;
if (verb !== 'get' && getClosestAttributeValue(elt, "hx-encoding") == null) {
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
// behavior of anchors w/ empty href is to use the current URL

View File

@ -630,8 +630,7 @@ describe("Core htmx AJAX Tests", function(){
it('multipart/form-data encoding works', function()
{
this.server.respondWith("POST", "/test", function(xhr){
console.log(xhr);
xhr.requestHeaders['Content-Type'].startsWith("multipart/form-data");
should.equal(xhr.requestHeaders['Content-Type'], undefined);
xhr.requestBody.get("i1").should.equal('foo');
xhr.respond(200, {}, "body: " + xhr.requestBody);
});