Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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:


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

Replies are listed 'Best First'.
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/ 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/ 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="" REMOTE_PORT="2524" REQUEST_METHOD="GET" REQUEST_URI="/cgi-bin/printenv" [snip remainder of environment]


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2016-10-21 16:20 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.