title: cURL header problems when posting JSON
body: <p>I'm in the process of building an API, but ran into some problems when testing with cURL.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>$people = array( array('name' =&gt; urlencode('casper'),
                         'shoesize' =&gt; urlencode(41)
                        ),
                   array('name' =&gt; urlencode('charlotte'),
                         'activated' =&gt; urlencode(1)
                        )
            );
  
  $data = http_build_query(array('data' =&gt; json_encode($people)));
  $url = '...';
  
  $ch = curl_init($url);
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Accept: application/json',
      'Content-Type: application/json',
      'Connection: Keep-Alive'
  ));
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  $result = curl_exec($ch);
  
  curl_close($ch);
  
  return $result; 
  </code></pre>
  
  <p>The method at the URL endpoint just returns the $_POST['data'].</p>
  
  <p>This works all the way until i set my headers in cURL. Without them set, the data is passed through with no problems. </p>