W3C home > Mailing lists > Public > xml-dist-app@w3.org > July 2002

Simulating an http post

From: Jon Leigh <jon_leigh@msn.com>
Date: Wed, 24 Jul 2002 16:19:02 -0400 (EDT)
To: <xml-dist-app@w3.org>
Message-ID: <000801c2334f$92864060$65081f3e@007776020343>




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
Received on Wednesday, 24 July 2002 17:17:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:10 GMT