title: Ajax POST requests to Heroku loses post data
body: <p>My ajax post requests to my Heroku app loses its post data in approximately 90% of the calls. </p>
  
  <p>I was using GET and changed to POST for security reasons. The GET requests have been working for months. The POST requests work like a charm locally in the IDE and using foreman. But when moving it to my Heroku app the POST data is lost in 90% of the calls. </p>
  
  <p>I am pretty sure that the data is sent correctly as:</p>
  
  <ol>
  <li>It works when running my application locally</li>
  <li>Using Chrome dev tools I verify that the data is part of the call</li>
  </ol>
  
  <p>I dump detailed incoming request data to the Papertrail logs. Here I can see that the data is gone. The content-length indicates that the request data should be there, but it is just gone. </p>
  
  <p>The Ajax call I am using. I have tried with $.post request and non-jquery ajax request. I have tried with JSON.stringify on the data and many many different combinations of request headers. </p>
  
  <pre><code> function doPostRequestWithDataV2(method, data) {
      var methodName = "/call/echo";
      var jqxhr = $.ajax({
          type: "POST",
          contentType: "application/json;charset=utf-8",
          url: methodName,
          data: {uuuuu: "ppppp"},
      })
              .done(function () {
                  var jsonString = jqxhr.responseText;
                  alert("All went well: " + jsonString);
              })
              .error(function () {
                  alert("Problem: " + jqxhr.responseText);
              });
  }
  </code></pre>
  
  <p>Full output successful call. The important differences in bold. </p>
  
  <pre>
  Mar 07 07:29:18 my-fine-app app/web.1: FIRST TOUCH: <b>Number of bytes 945</b>
  Mar 07 07:29:18 my-fine-app app/web.1: FIRST TOUCH: ##########
  Mar 07 07:29:18 my-fine-app app/web.1: POST /call/echo HTTP/1.1
  Mar 07 07:29:18 my-fine-app app/web.1: Host: staging.kollektivafondval.se
  Mar 07 07:29:18 my-fine-app app/web.1: Connection: close
  Mar 07 07:29:18 my-fine-app app/web.1: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0
  Mar 07 07:29:18 my-fine-app app/web.1: Accept: */*
  Mar 07 07:29:18 my-fine-app app/web.1: Accept-Language: en-US,en;q=0.5
  Mar 07 07:29:18 my-fine-app app/web.1: Accept-Encoding: gzip, deflate
  Mar 07 07:29:18 my-fine-app app/web.1: Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Mar 07 07:29:18 my-fine-app app/web.1: X-Requested-With: XMLHttpRequest
  Mar 07 07:29:18 my-fine-app app/web.1: Referer: http://staging.kollektivafondval.se/debug/index.html
  Mar 07 07:29:18 my-fine-app app/web.1: Cookie: _ga=GA1.2.492366677.1421911589; __utma=33200548.492366677.1421911589.1425495130.1425495130.1; __utmc=33200548; __utmz=33200548.1425495130.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); cp=0; undefined=0; ptl=0; _gat=1
  Mar 07 07:29:18 my-fine-app app/web.1: Pragma: no-cache
  Mar 07 07:29:18 my-fine-app app/web.1: Cache-Control: no-cache
  Mar 07 07:29:18 my-fine-app app/web.1: X-Request-Id: 17981145-acce-49bf-a5dd-e212a2a184ef
  Mar 07 07:29:18 my-fine-app app/web.1: X-Forwarded-For: 83.227.55.31
  Mar 07 07:29:18 my-fine-app app/web.1: X-Forwarded-Proto: http
  Mar 07 07:29:18 my-fine-app app/web.1: X-Forwarded-Port: 80
  Mar 07 07:29:18 my-fine-app app/web.1: Via: 1.1 vegur
  Mar 07 07:29:18 my-fine-app app/web.1: Connect-Time: 0
  Mar 07 07:29:18 my-fine-app app/web.1: X-Request-Start: 1425709758119
  Mar 07 07:29:18 my-fine-app app/web.1: Total-Route-Time: 0<b>
  Mar 07 07:29:18 my-fine-app app/web.1: Content-Length: 17
  Mar 07 07:29:18 my-fine-app app/web.1: String=any+string</b>
  Mar 07 07:29:18 my-fine-app app/web.1: ##########
  </pre>
  
  <p>Full output when data is missing. The important differences in bold. </p>
  
  <pre>
  Mar 07 07:29:15 my-fine-app app/web.1: ************************************************************
  Mar 07 07:29:16 my-fine-app app/web.1: <b>FIRST TOUCH: Number of bytes 928</b>
  Mar 07 07:29:16 my-fine-app app/web.1: FIRST TOUCH: ##########
  Mar 07 07:29:16 my-fine-app app/web.1: POST /call/echo HTTP/1.1
  Mar 07 07:29:16 my-fine-app app/web.1: Host: staging.kollektivafondval.se
  Mar 07 07:29:16 my-fine-app app/web.1: Connection: close
  Mar 07 07:29:16 my-fine-app app/web.1: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0
  Mar 07 07:29:16 my-fine-app app/web.1: Accept: */*
  Mar 07 07:29:16 my-fine-app app/web.1: Accept-Language: en-US,en;q=0.5
  Mar 07 07:29:16 my-fine-app app/web.1: Accept-Encoding: gzip, deflate
  Mar 07 07:29:16 my-fine-app app/web.1: Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Mar 07 07:29:16 my-fine-app app/web.1: X-Requested-With: XMLHttpRequest
  Mar 07 07:29:16 my-fine-app app/web.1: Referer: http://staging.kollektivafondval.se/debug/index.html
  Mar 07 07:29:16 my-fine-app app/web.1: Cookie: _ga=GA1.2.492366677.1421911589; __utma=33200548.492366677.1421911589.1425495130.1425495130.1; __utmc=33200548; __utmz=33200548.1425495130.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); cp=0; undefined=0; ptl=0; _gat=1
  Mar 07 07:29:16 my-fine-app app/web.1: Pragma: no-cache
  Mar 07 07:29:16 my-fine-app app/web.1: Cache-Control: no-cache
  Mar 07 07:29:16 my-fine-app app/web.1: X-Request-Id: 16caf2b0-88a6-455b-ac03-71581920e1e5
  Mar 07 07:29:16 my-fine-app app/web.1: X-Forwarded-For: 83.227.55.31
  Mar 07 07:29:16 my-fine-app app/web.1: X-Forwarded-Proto: http
  Mar 07 07:29:16 my-fine-app app/web.1: X-Forwarded-Port: 80
  Mar 07 07:29:16 my-fine-app app/web.1: Via: 1.1 vegur
  Mar 07 07:29:16 my-fine-app app/web.1: Connect-Time: 0
  Mar 07 07:29:16 my-fine-app app/web.1: X-Request-Start: 1425709756264
  Mar 07 07:29:16 my-fine-app app/web.1: Total-Route-Time: 0<b>
  Mar 07 07:29:16 my-fine-app app/web.1: Content-Length: 17</b>
  Mar 07 07:29:16 my-fine-app app/web.1: ##########
  </pre>