cURL and redirects - returning multiple headers? cURL and redirects - returning multiple headers? curl curl

cURL and redirects - returning multiple headers?


You can get the information of the total header size, and split the string up like this:

$buffer = curl_exec($ch);$curl_info = curl_getinfo($ch);curl_close($ch);$header_size = $curl_info["header_size"];$header = substr($buffer, 0, $header_size);$body = substr($buffer, $header_size)

Information taken from the helpful post by "grandpa".


use curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).


$header_size = $curl_info["header_size"];$header = substr($buffer, 0, $header_size-1);$body = substr($buffer, $header_size);