cURL / Mailing Lists / curl-library / Single Mail

curl-library

modify the REMOTE_ADDR part of the http header

From: Sangeetha Naik <sangeetha_at_poornam.com>
Date: Wed, 19 Dec 2001 11:45:47 +0530

Hi all,
I am trying to modify the REMOTE_ADDR part of the http header for an http
post. This is the script I used. Its written in perl with the Curl::easy
module

$url = "http://someurl.com";

# Init the curl session
 my $curl= Curl::easy::init();
 if(!$curl) {
    die "curl init failed!\n";
 }

# Add some additional headers to the http-request:
my @myheaders;
$myheaders[0] = "REMOTE_ADDR: yahoo.com";
Curl::easy::setopt($curl, Curl::easy::CURLOPT_HTTPHEADER, \@myheaders);

# Set the url, and parameters and send HTTP Post to $url
 Curl::easy::setopt($curl, CURLOPT_URL, $url);
 Curl::easy::setopt($curl, CURLOPT_POST, 1);
 Curl::easy::setopt($curl, CURLOPT_POSTFIELDS,
"postvar1=value1&postvar2=value2&postvar3=value3");
 
 if (Curl::easy::perform($curl) != 0) {
    print "Failed: $errbuf\n";
 };
 
# Cleanup
 Curl::easy::cleanup($curl);

As you can see I am using CURLOPT_HTTPHEADER to modify the REMOTE_ADDR
variable. But it does not really change that variable on the other side.
However I am have been successful in changing the HTTP_REFERER and
HTTP_USER_AGENT variables using CURLOPT_REFERER and CURLOPT_USERAGENT

What am I doing wrong :-(

sangeetha
Received on 2001-12-19