curl-library
RE: Getting the outgoing request header
Date: Fri, 27 Jan 2006 14:37:46 +0530
Perhaps put a tcp monitor kind of thing in between application and web
server. See what exactly are the header values being sent and compare
with ones sent from firefox directly.
Thanks
Dinesh
-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Kenneth Andresen
Sent: Friday, January 27, 2006 2:29 PM
To: libcurl development
Subject: Getting the outgoing request header
Using libcurl with php, and am on a particular page getting odd results
when using the following code:
<?php
function url_get($domain, $uri, $referer)
{
$header = array();
$header[] = 'GET '.$uri.' HTTP/1.1';
$header[] = 'Host: '.$domain;
$header[] = 'User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.8) Gecko/20051111 Firefox/1.5';
$header[] = 'Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,image/png,*/*;q=0.5
';
$header[] = 'Accept-Language: en-us,en;q=0.5';
$header[] = 'Accept-Encoding: gzip,deflate';
$header[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$header[] = 'Keep-Alive: 300';
$header[] = 'Connection: keep-alive';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domain.$uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, ""); #"gzip,deflate,compress"
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$result['exec'] = curl_exec ($ch);
$result['info'] = curl_getinfo($ch);
# echo curlinfo_content_type($ch);
# foreach ($result['info'] as $key=>$value ) { echo "$key $value <br
/>"; }
//use this line to get more info
//return $result;
return $result['exec'];
curl_close ($ch);
}
echo url_get('www.site.com', '/', '-');
?>
--------
When commenting out the CURLOPT_HTTPHEADER line the result is ok, but I
am not getting the expected return from the script with my custom
headers. In Firefox which I try to mimic, the result however is ok, so I
assume some headers are not sent as expected. How can I trouble shoot
what my requested headers really where?
Received on 2006-01-27