post request with content length 0

Ulrich Wisser <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi,

I have a small script trying to login into a website. Of course they use 
forms and cookies for that. Unfortunately does my code not work. If 
tried many approaches but without success. One thing I recognized is, 
that $ua->post() sends "Content-length: 0" header with the request. 
Which I find quite strange. Please see my script and sample output below.

What do I do wrong?

Running on Linux, Perl 5.8.3, LWP 5.76.

Thanks

Ulrich


use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
my $res = $ua->post('http://search.cpan.org/search', (perl test2 
query=>'libwww-perl',mode=>'dist'));
print $res->request->as_string;
print;


Sample output:
POST http://search.cpan.org/search
User-Agent: MyApp/0.1 libwww-perl/5.76
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
Mode: dist
Query: libwww-perl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.