title: Can PHP curl return an object with body and headers in a single request?
body: <p>Can curl return an object that has the headers and body as separate properties? </p>
  
  <p>Here is what I'm doing now. This returns a String(?) with the header first and then body after:  </p>
  
  <pre><code>$session = curl_init($url);
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($session, CURLOPT_HEADER, true);
  $response = curl_exec($session);
  echo $response; // string
  </code></pre>
  
  <p>What I want is: </p>
  
  <pre><code>...
  $response = curl_exec($session);
  $header = $response-&gt;headers;
  $body = $response-&gt;body;
  </code></pre>
  
  <p>I've seen a similar question that suggests requesting both the headers and body and then parsing the results. I'm not asking about that. </p>
  
  <p>I'm specifically asking about returning an <code>object</code> with the body and headers as separate properties. </p>
  
  <p>If the answer is "No, that's not possible" then I'll accept that answer. I'll also accept "No <code>curl</code> doesn't do that but here is another called <code>swurl</code> (or whatever) that does return an object..."</p>