title: PHP curl_exec returns both HTTP/1.1 100 Continue and HTTP/1.1 200 OK separated by space
body: <p>I'm calling a service from PHP using cURL, like this:</p>
  
  <pre><code>$response = curl_exec($ch);
  </code></pre>
  
  <p>and the request/response headers look something like this:</p>
  
  <p>Request:</p>
  
  <pre><code>POST /item/save HTTP/1.1
  Host: services.mydomain.com
  Accept: */*
  Content-Length: 429
  Expect: 100-continue
  Content-Type: multipart/form-data
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>HTTP/1.1 100 Continue
  
  HTTP/1.1 200 OK
  Date: Fri, 06 Jul 2012 08:37:01 GMT
  Server: Apache
  Vary: Accept-Encoding,User-Agent
  Content-Length: 256
  Content-Type: application/json; charset=utf-8
  </code></pre>
  
  <p>followed by the body (json encoded data).</p>
  
  <p>The problem is that the common thing is to split headers and body in the response by the first empty line encountered, except in this case, the empty line is after the <code>100 Continue</code> and therefore everything else gets pushed into the body–and that is not valid json anymore :-)</p>
  
  <p>So my question is this: What's the common way to deal with this?
  I have 3 options lined up:</p>
  
  <ol>
  <li>Specify that curl should not expect <code>100-continue</code>? (How?)</li>
  <li>Specify that curl should only send back the headers of the last response? (How?)</li>
  <li>Manually check for <code>100 Continue</code> headers and disregard them and their following empty line? (In that case, are there other similar things that could happen, that I should manually check for?)</li>
  </ol>
  
  <p>Unless I'm missing something obvious, I'm sure people have stumbled upon this and solved it many times!</p>