develooper Front page | perl.libwww | Postings from March 2001

Emulating POST !!!

Thread Next
Paulo Castro
March 7, 2001 12:11
Emulating POST !!!
Message ID:
The code above emulates a Post operation.
I've tested it and it works fine, it does the post except for the "print
$response->content" where i get the error of malformed header from
script. Bad header=<html>:
/home/facultis/facultis-www/cgi-bin/postform.cgi. I can't return
Initially i thought that it coul be my mistake, the script i was calling
could be returning wrong html. But i tested it with the url above and it
just guives me the same error.
What i'm i missing here...?

#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

my $url = '';

#open (Z,">/tmp/t3.txt");

# Create new UserAgent object (browser)
my $ua = LWP::UserAgent->new();

# Give the browser a name

# Create HTTP POST request
my $request = HTTP::Request->new(POST => $url);

# Execute HTTP request
my $response = $ua->request($request);

# Check success
if ($response->is_success) {
print $response->content;
#print Z $response->as_string;
} else {
print "Error getting document: ", $response->status_line,"\n";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About