Change:
print $ua->request($req)->as_string;
To:
print $ua->request($req)->content;

And see if that does what you want.  as_string prints all the headers and
such.

Chris

On Wed, Jul 24, 2002 at 09:29:17PM +0100, Jon Leigh wrote:
> I am trying to simulate an http POST in Perl. The following code works
> (with a big BUT - see below) :-
> 
> #!/usr/bin/perl --
> 
> use HTTP::Request::Common qw(POST);
> use HTTP::Request::Common;
> require LWP::UserAgent;
> $ua = LWP::UserAgent->new;
> 
> my $req = POST
> 'http://www.10minutewill.co.uk/cgi-bin/test-receive-post.cgi',
> Content_Type => 'form-data', Content => [parm1 => 'parm1value', parm2 =>
> 'parm2value', parm3 => 'parm3value', parm4 => 'parm4value', parm5 =>
> 'parm5value', parm6 => 'parm6value', parm7 => 'parm7value'];
> 
> print "Content-type: application/x-www-form-urlencoded\n\n";
> print $ua->request($req)->as_string;
> 
> #########
> 
> The 'BUT' is that whatever the target perl program tries to do, I cannot
> prevent a load of rubbish being printed at the top of the screen eg:-
> 
> HTTP/1.1 200 OK Connection: close Date: Wed, 24 Jul 2002 20:15:14 GMT
> Server: Apache/1.3.20 (Unix) mod_gzip/1.3.19.1a FrontPage/5.0.2.2510
> PHP/4.1.1 mod_fastcgi/2.2.12 mod_ssl/2.8.4 OpenSSL/0.9.5a rus/PL30.5
> Content-Type: text/html Client-Date: Wed, 24 Jul 2002 20:15:14 GMT
> Client-Peer: 62.115.255.83:80 Title: Data 
> 
> If you want to see what I mean, try the following URL which runs the
> above perl code:- http://www.10minutewill.co.uk/cgi-bin/test-post.cgi
> 
> Can anybody tell me how to re-code so as to remove this unsightly stuff?
> 
> Cheers
> 
> Jon

Reply via email to