Re: setting referer and host information in requests

Gisle Aas (gisle@aas.no)
01 Jul 1998 14:29:12 +0200


Mark Biango <mab@webstakes.com> writes:

> Using my web browser (i.e., ip 200.200.200.9) , I can retreive an html
> page (htmlpage.html)  from a Web Server (i.e., www.webserver.com)  by
> executing a cgi bin program (cgiprogram.cgi) running on machine, i.e.,
> 200.200.200.10 which uses LWP:
> 
>           my $req = new HTTP::Request GET =>
> "http://www.webserver.com/htmlpage.html";
> 
> However, when I look at the web server access logs for
> www.webserver.com, though I can see the access for htmlpage.html, the
> record lacks information for the referer (HTTP_REFERER).  I know it
> is possible to set the HTTP_USER_AGENT within the program using
> $ua->agent("AnyUserAgent"),
> but is it possible to set the referer information (HTTP_REFERER).

Yes.  $req->referer($some_url);

> More importantly, the web servers access log shows that ip
> 200.200.200.10 made the request (the machine running cgiprogram.cgi) NOT
> 200.200.200.9 (my browser executing cgiprogram.cgi). This is
> understandable, but I would like my program to set this variable (is it
> REMOTE_HOST or REMOTE_ADDR) to the ip of the browser machine executing
> the cgiprogram.cgi (in this case I would like it set to 200.200.200.9
> rather than 10). Is is possible to set this information?

No.

> Do the following lines in Protocol/http.pm have anything to do with
> this:
> 
> # HTTP/1.1 will require us to send the 'Host' header, so we might
>     # as well start now.
>     $request->header('Host', $url->netloc);

No.  The Host header is the name of the server not the client.

-- 
Gisle Aas