viewing requests sent by curl
How can I see requests that are sent out by curl? For example;
I'm getting a page and print out the contents, 开发者_开发问答but this page also requests another page that I would like the contents of.
How would I do this?
If it's header information you're after...
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1);
and
curl_setopt($curl_handle, CURLOPT_HEADER,1);
will return the header information in the results which you will then have to process with either string functions or regular expressions.
eg
preg_match_all('#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims', $curl_result, $header_matches);
$headers = split("\r\n", str_replace("\r\n\r\n", '', array_pop($header_matches[0])));
$curl_result = preg_replace('#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims', '',$curl_result);
From there you can locate any offending header entries in the array $headers
精彩评论