Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Passing POST parameters

by btrott (Parson)
on Apr 04, 2000 at 03:09 UTC ( [id://6776]=note: print w/replies, xml ) Need Help??


in reply to Passing POST parameters

Sure. You should take a look at the source of lwp-request, an app that uses LWP::UserAgent to make requests. It does exactly what you're looking for, so you could either use it directly or incorporate its relevant bits into your code.

Essentially, you just do:

# create a new LWP::UserAgent my $ua = new LWP::UserAgent; # create a new HTTP::Request, specifying # the POST method my $request = new HTTP::Request; # read in the content from STDIN; print "Enter in your content:\n"; my $content = join '', <STDIN>; # attach the content to the request # (change content-type to the appropriate type) $request->header('Content-Type' => 'text/plain'); $request->header('Content-Length' => length $content); $request->content($content); # send request and get a response my $response = $ua->request($request);
And that's that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6776]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-20 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found