stackunderflow
stackunderflow

Reputation: 1774

Curl doesnt return header information

i use curl to get the data (http request) from a website through php. and some of the information of the data is stored inside the header information. i can simply fetch the data using curl_exec, but if i try to fetch the header information using curl_getinfo, the information is missing. it supposed to be worked just like ajax. can somebody help me with this?

Upvotes: 0

Views: 363

Answers (1)

deceze
deceze

Reputation: 521994

curl_getinfo doesn't give you the headers, it just gives meta information about the last request. The CURLOPT_HEADER options makes sure the headers are included in the output:

...
curl_setopt($c, CURLOPT_HEADER, true);
$data = curl_exec($c);

list($headers, $body) = explode("\n\n", $data, 2);

Upvotes: 1

Related Questions