When using the PHP curl functions, is there anyway to see the exact raw headers that curl is sending to the server?
+5
A:
You can use curl_getinfo:
$headers = curl_getinfo($c, CURLINFO_HEADER_OUT);
Greg
2009-12-01 21:09:53
No, that's not how it works and that code doesn't work
Daniel Stenberg
2009-12-01 22:01:11
Uuuh, I've not kept up. That _is_ how it works... sorry!
Daniel Stenberg
2009-12-01 22:04:05
+2
A:
be sure to set the CURLINFO_HEADER_OUT option before making the curl_getinfo call
curl_setopt($c, CURLINFO_HEADER_OUT, true);
Janek
2009-12-01 21:24:37
@JanekIt should be read as follows: curl_setopt($c, CURLOPT_HEADER, true);
pcdinh
2010-01-05 08:46:05
Janek is correct, CURLINFO_HEADER_OUT is the option to set if you want to view the header using curl_getinfo() it is documented here http://php.net/manual/en/function.curl-setopt.php
gawpertron
2010-06-23 17:58:34
+1
A:
AFAIK, the PHP/CURL binding still lacks proper support for CURLOPT_DEBUGFUNCTION which is a callback from libcurl that can provide all those details.
That's the primary reason why I recommend people to work out HTTP scripting things with the curl command line tool and its --trace-ascii option FIRST, then translate that into a PHP function.
Daniel Stenberg
2009-12-01 21:59:40
It looks like you're right, I poked around the latest stable PHP source a bit, and it looks like they **use** CURLOPT_DEBUGFUNCTION to implement their CURLINFO_HEADER_OUT options, but they don't expose a fully featured CURLOPT_DEBUGFUNCTION of their own. Side note: I remember your emails from the php curl mailing list. I'm amazed you still have the patience to do any kind of PHP related libcurl support :)
Alan Storm
2009-12-01 22:34:50