For my current contract, I have a posthttp routine written by the lead
programmer. It was originally written to assume the data CONTENT_TYPE was
application/x-www-form-urlencoded
and it works fine for that.
However, there is a form I need to process that uses
multipart/form-data
The data all comes in through STDIN and I'm gathering it up and saving it
in $formdata and then pushing that into the content.
$doc (below) is the incoming URL (the remote CGI).
my $ua=new LWP::UserAgent;
my $req = new HTTP::Request 'POST', "http://$host$doc";
# $req->content_type('application/x-www-form-urlencoded');
$req->content_type('multipart/form-data');
$req->content_length($length);
$req->content( $formdata );
my $res = $ua->request($req);
my $resp=$res->as_string;
I have debugging traces that print the values as
posthttp: host=10.0.0.4, port=80, length=858
posthttp: doc=/cgi-bin/WebX?[EMAIL PROTECTED]^[email protected]
posthttp: formdata=-----------------------------069095586212880
Content-Disposition: form-data; name="name"
-----------------------------069095586212880
Content-Disposition: form-data; name="email"
-----------------------------069095586212880
Content-Disposition: form-data; name="title"
Why did Poe use a Raven?
-----------------------------069095586212880
Content-Disposition: form-data; name="header"
Discussion of the poem, The Raven, by Poe.
-----------------------------069095586212880
Content-Disposition: form-data; name="enclosures"; filename=""
-----------------------------069095586212880
Content-Disposition: form-data; name="showauthor"
false
-----------------------------069095586212880
Content-Disposition: form-data; name="showauthor"
true
-----------------------------069095586212880--
posthttp: result=HTTP/1.1 200 OK
But the final page that comes back says "Post with no data" so the remote CGI
is not liking what I am sending it.
Suggestions? I'm pretty sure I'm probably missing something small and
stupid...
--
- Vicki
Vicki Brown ZZZ Journeyman Sourceror:
P.O. Box 1269 zz |\ _,,,---,,_ Scripts & Philtres
San Bruno, CA zz /,`.-'`' -. ;-;;,_ Perl, Unix, MacOS
94066 USA |,4- ) )-,_. ,\ ( `'-'
mailto:[EMAIL PROTECTED] '---''(_/--' `-'\_) http://www.cfcl.com/~vlb