Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting 411 error on POST with LWP

Status
Not open for further replies.

philsy

Technical User
Mar 12, 2008
4
US
Can someone help me resolve this error. I have a short script that is connecting to a web site and submitting a form. I am getting an "411 Length required" message back. Here is the code I have in place. Any ideas how I can get around this?

Thanks In advance.

Phil

#!usr/bin/perl

use strict;
use warnings;
use LWP;



my $browser = LWP::UserAgent->new;
$browser->agent("Mozilla/4.76 [en] (Windows NT 5.0; U)");
$browser->proxy('http', '
my $response = $browser->post(
' 'cPageId' => '7920',
,
);



die "Hmm, eror \"", $response->status_line( ), "\" when getting " unless $response->is_success( );

my $content_type = $response->content_type( );
die "Hm, unexpected content type $content_type from "
unless $content_type eq 'text/html';

my $content = $response->content( );
die "Odd, the content from is awefully short!"
if length($content) < 3000;

print "\n";
print $content;
print "\n";
print $response->status_line();
print "\n";
 
This seems to be an issue with only certain webservers, what are you posting to, IIS 6 perchance?

Appears there's no real solution using LWP::UserAgent, (why aren't you use-ing LWP::UserAgent?)
from LWP on CPAN said:
For a POST request you should add the "Content-Type" header. When you try to emulate HTML <FORM> handling you should usually let the value of the "Content-Type" header be "application/x- See lwpcook for examples of this.

This seems to indicate that this should be set before the content is sent

Try that and see what happens ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top