title: PHP Post | HTTP Error 411. The request must be chunked or have a content length
body: <p>I am posting from a <strong>linux server to an IIS server.</strong> 
  Using the code below - </p>
  
  <pre><code>public function PostToPage($target, $data) {
  
      $opts = array('http' =&gt;
          array(
              'method'  =&gt; 'POST',
              'header'  =&gt; ["'Authorization: Basic ' . base64_encode('MYPOOLIN:znfbPLR261E=')",
                          "Content-type: application/x-www-form-urlencoded",
                          "Transfer-Encoding: chunked",
                          "Content-Encoding: chunked"
                              ],
              'content' =&gt; $data,
              'ignore_errors' =&gt; 1
          )
      );
  
      $context  = stream_context_create($opts);
      $response = file_get_contents($target, false, $context);
  
  
      return $response;
  }
  </code></pre>
  
  <p>When I try posting the data via POSTman, it works perfectly fine. However, when using the above function, it gives an error - <strong><em>HTTP Error 411. The request must be chunked or have a content length.</em></strong></p>
  
  <p>When I add 'Content-Length:1024' in the header (after checking the content length via POSTman example), the POST goes on for a long time like 2-3 minutes (and possibly <strong>times out</strong> giving an error of 500 response code) </p>
  
  <p>Any ideas? </p>