Skip to content

Commit

Permalink
remove userSetContentType
Browse files Browse the repository at this point in the history
  • Loading branch information
gbourant committed Nov 8, 2023
1 parent cfd9729 commit cbc0fdf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -3302,8 +3302,7 @@ return (function () {
});
});
triggerEvent(elt, 'htmx:beforeSend', responseInfo);
var userSetContentType = (etc.headers && etc.headers['Content-Type']);
var params = useUrlParams ? null : !userSetContentType ? encodeParamsForBody(xhr, elt, filteredParameters) : etc.values;
var params = useUrlParams ? null : encodeParamsForBody(xhr, elt, filteredParameters);
xhr.send(params);
return promise;
}
Expand Down
6 changes: 3 additions & 3 deletions test/core/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ describe("Core htmx API test", function(){
it('ajax api Content-Type header override to application/json', function(){

this.server.respondWith("POST", "/test", function (xhr) {
var params = getParameters(xhr);
xhr.requestHeaders['Content-Type'].should.equal('application/json;charset=utf-8');
const requestBody = JSON.parse(xhr.requestBody);
chai.expect(requestBody.grug).to.be.equal("brain");
params['i1'].should.equal("test");
xhr.respond(200, {}, "Clicked!");
});

Expand All @@ -285,7 +285,7 @@ describe("Core htmx API test", function(){
headers: {
'Content-Type': 'application/json'
},
values: '{"grug":"brain"}'
values:{i1: 'test'}
})

this.server.respond();
Expand Down

0 comments on commit cbc0fdf

Please sign in to comment.