Thank you.

I like your /good/ old way and I tried it but got error from return page.
It said "No CONTENT_LENGTH in environment." Below is a part of my code.

# code starting
my $url = CGI_URL;
my $array_ref = [inputName => "test"];
my $request = POST($url,@{$array_ref},);

my $response = $ua->request($request);
die "$url failed: ",$response->error_as_HTML
    unless $response->is_success;
print $response->content;
 
#code end

Have any idea? Thank you very much.

David
-----Original Message-----
From: Sean M. Burke [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 23, 2001 3:07 AM
To: Kuo, David; [EMAIL PROTECTED]
Subject: RE: Newbie help (POSTing)


By the way, I'll be giving a tutorial about LWP at the The Perl Conference
in July in San Diego; the kind of stuff you ask about is exactly what the
talk is about: it's an introduction to LWP.

I'm also working on a book for O'Reilly about things like this, too.  It
should be out sometime before the Robot Holocaust.


At 09:19 PM 2001-05-22 -0400, David Kuo wrote:
>[...]But how about the "POST" method? How do I send out the
>arguments to the web server? If the syntax "$request = new
>HTTP::Request('POST' => $url, [name1 => value1, name2
> => value2, ...,]);" correct? [...]

I call using HTTP::Request->new the bad old way.  (Well, it's not exactly
bad, it's just not especially convenient for most purposes.)

The /good/ old way is:

use LWP;
my $browser = LWP::UserAgent->new();
use HTTP::Request::Common;  # exports POST(...) et al

my $request = POST($url, [name1 => value1, name2 => value2, ...,]);
my $response = $browser->request($request);


And the good /new/ way is:

use LWP 5.5394;   # a devel version, by the way
my $browser = LWP::UserAgent->new();

my $response = $browser->post($url,
  [name1 => value1, name2 => value2, ...,],
);


--
Sean M. Burke  [EMAIL PROTECTED]  http://www.spinn.net/~sburke/

Reply via email to