title: What would cause HTTP to send back "400 OK"
body: <p>I'm receiving an error sometimes for what should be a valid request as "400 OK" when I PUT some arguments to a URL.</p>
  
  <p>The same URL and arguments will work 99% of the time, but I'm seeing errors crop up in our logs.</p>
  
  <p>Is that an obscure thing that can happen due to some factors or is something specific to my app causing the mish-mash of strange headers? I'm guessing it's the latter if there's no answers to the former :)</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>For the comments, "it" is a relatively simple RESTful API that was written. Now it's almost always giving back the right headers like 400 and body of error or 200 with body of ok. When a bad header makes it to the web client, the web client is pinging a reporting URL with the message it got so we can differentiate API errors between our web app and mobile apps. As far as we know there is no combintation of code that would make this "400 OK" hell. But seeing as it seems impossible for that to happen outside of our code messing up, I'm going to take a deeper look.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Okay I've delved deeper into our framework than I have in a long time and spoke with some devs. </p>
  
  <p>It returns the information via the AJAX call to the API to the browser.</p>
  
  <p>The browser detects a "400 OK" and sends it back to our server, where we are getting this strange report. No one has seen this happen with their eyes, but the logs say it's happening.</p>
  
  <p>There is literally zero code in our codebase that would return 400 OK since the only 400 in our HTTP header handlers are "400 bad request"</p>
  
  <p>I'm wondering now if there's some browser/jquery/ajax bug I've stumbled into.</p>
  
  <p><strong>UPDATE 3 (because you can't have too much information)</strong></p>
  
  <p>I checked how the browser sees what's wrong. A callback is fired on failure as reported by jQuery $.ajax. We then have code like this:</p>
  
  <pre><code>xhr.always(function() {
    var request = [ this.type, this.url, this.data ].join(' '),
        response = [ xhr.status, xhr.statusText, xhr.responseText ].join(' ');
  
    $.ajax({ 
      url   : REPORTING_URL,
      type  : 'POST', 
      data : { request : request, response : response }
    });
  });
  </code></pre>
  
  <p>And we know this works "most" of the time because we also received "400 error" responses from these ajax calls</p>
  
  <p><strong>UPDATE 4</strong></p>
  
  <p>I just noticed that literally all the errors came from user agent:</p>
  
  <p><code>Mozilla webkit etc...... AdobeAIR/1.5.3</code> which is a very old version</p>
  
  <p>Our AIR app just has an iframe of our web app. I can only imagine what's happening there.</p>