Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

LWP::UserAgent Questions

by Martin A (Beadle)
on Dec 08, 2000 at 17:53 UTC ( #45736=perlquestion: print w/ replies, xml ) Need Help??
Martin A has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

Im currently working om a script that will act as an HTTP Client and make a request from a server. Now the thing is that I need to set the HTTP_REFERER (and probably some other) field to the server, to fake that I have clicked on some link to get there.

// Martin

Comment on LWP::UserAgent Questions
Re: LWP::UserAgent Questions
by dchetlin (Friar) on Dec 08, 2000 at 19:09 UTC
    You'll want to mess with the HTTP::Request object that you pass to UserAgent when making your request.

    For example,

    [~] $ cat > tmp/referer.pl require LWP::UserAgent; my $r = HTTP::Request::->new('GET','http://web2/cgi-bin/printenv'); $r->header("REFERER", "foo"); my $ua = LWP::UserAgent::->new; print $ua->request($r)->content; [~] $ perl !$ perl tmp/referer.pl DOCUMENT_ROOT="/usr/local/apache/htdocs" GATEWAY_INTERFACE="CGI/1.1" HTTP_HOST="web2" HTTP_REFERER="foo" HTTP_USER_AGENT="libwww-perl/5.48" PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin" QUERY_STRING="" REMOTE_ADDR="192.168.0.1" REMOTE_PORT="2524" REQUEST_METHOD="GET" REQUEST_URI="/cgi-bin/printenv" [snip remainder of environment]

    -dlc

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://45736]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-11-27 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (179 votes), past polls