Copy link to clipboard
Copied
We have an ajax request that got a "400 bad request" response from our server. The weird thing is, the request got fully processed by CF. How is that possible?
Is it possible for the server to see the request as "bad", yet it still allows it to be processed?
CF definitely did manage to receive and processe the request, because there are a bunch of cfhttp requests that would only be run if the CF code in question are executed, and we know the cfhttp requests definitely did run because our custom logging routine logged all the relevant details.
Yes it's a weird one, and I've found the culprit - I forgot to encode the xml string before sending it with the ajax request. And for some reason, if you do that, the server would still process the request (alb
...Copy link to clipboard
Copied
A 400 status indicates that the server (your web server, more likely than cf) had some problem with the client request. As such, no, that should not have somehow been passed to cf.
But there are at least a couple possible explanations:
Or maybe others will have better ideas.
Copy link to clipboard
Copied
CF definitely did manage to receive and processe the request, because there are a bunch of cfhttp requests that would only be run if the CF code in question are executed, and we know the cfhttp requests definitely did run because our custom logging routine logged all the relevant details.
Yes it's a weird one, and I've found the culprit - I forgot to encode the xml string before sending it with the ajax request. And for some reason, if you do that, the server would still process the request (albeit with the form being completely blank), but respond with a 400 error at the end of it.
Here's a simple test to replicate this behavior:
var url = "http://localhost/test.cfm";
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
var data = "blah=1&xml=<company><![CDATA[blah & blah]]></company>";
xhr.send(data);
Copy link to clipboard
Copied
Interesting, indeed. Thanks for the update.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more