Can curl return an object that has the headers and body as separate properties?
Here is what I'm doing now. This returns a String(?) with the header first and then body after:
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_HEADER, true);
$response = curl_exec($session);
echo $response; // string
What I want is:
...
$response = curl_exec($session);
$header = $response->headers;
$body = $response->body;
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.
I'm specifically asking about returning an object
with the body and headers as separate properties.
If the answer is "No, that's not possible" then I'll accept that answer. I'll also accept "No curl
doesn't do that but here is another called swurl
(or whatever) that does return an object..."