Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/index.php(1) : eval()'d code on line 1

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/index.php(1) : eval()'d code on line 1

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/index.php(1) : eval()'d code on line 14

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/index.php(1) : eval()'d code on line 14

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/index.php(1) : eval()'d code on line 18

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/index.php(1) : eval()'d code on line 18

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-config.php(1) : eval()'d code on line 1

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-config.php(1) : eval()'d code on line 1

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-config.php(1) : eval()'d code on line 14

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-config.php(1) : eval()'d code on line 14

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-config.php(1) : eval()'d code on line 18

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-config.php(1) : eval()'d code on line 18

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 1

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 1

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 14

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 14

Notice: Use of undefined constant HTTP_REFERER - assumed 'HTTP_REFERER' in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 18

Notice: Undefined index: HTTP_REFERER in /home/me/public_html/wp-settings.php(1) : eval()'d code on line 18
Georgie Casey

February 13, 2010

php curl debugging - seeing the exact http request headers sent by curl

In my many of years of php/curl use, I’ve hammered my head off my table countless times trying to debug scripts that weren’t emulating the browser like it was supposed to. This was pretty hard without seeing the exact HTTP request header sent by cURL each session, but this is possible now from PHP 5.1.3

Use the curl_getinfo php function with the CURLINFO_HEADER_OUT option but make sure to set option CURLINFO_HEADER_OUT to true as a curl option.

$ch = curl_init("http://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$get = curl_exec($ch);
$info=curl_getinfo($ch,CURLINFO_HEADER_OUT);
var_dump($info);