Pug has asked for the wisdom of the Perl Monks concerning the following question:
I have a program, acting like a browser, that logs into a server. It needs fill out a form (that is done) and then when the program hits submit, upload a file to the server.
I have use HTML::Form to fill out the form and to give the HTML::Form the proper path and file name, which works. But when LWP::UserAgent->request($form->click("submit")) happens I get a 500. The code I wrote is below.
$ERROR has in it your basic 500 error page. At $form->click("submit") I did a# This works fine. Here I get the form. $form=_get_new_form($self,$response->as_string,$response->base); if($form==0) { return 0; } # Here I am filling out the form. foreach $input ($form->inputs) { if($input->name eq "email") { $form->value($input->name,$email); } if($input->name eq "clientCertReq") { $form->value($input->name,$file); } } #Here is where the problem is. $response=$agent->request($form->click("submit")); if(!$response->is_success) { $ERROR=$response->error_as_html; return 0; } return 1; } sub _get_new_form { my ($self,$html,$uri,$form)=@_; $form=HTML::Form->parse($html,$uri); if(!defined ($form)) { return 0; } return $form; } }
Which when you look at the code for LWP::UserAgent It does not do anything special with Content-Disposition. The input that has the name "clientCertReq" is a HTML::Form::TextInput object. But if you look at HTML::Form::TextInput (it is in the HTML::Form file.) The comments below that point sayPOST http://server:8080/Foo/servlet Content-Length: 332 Content-Type multipart/form-data; boundary=xYzZY --xYzZY Content-Disposition: form-data; name="email" this_email@address.com --xYzZY Content-Disposition: form-data; name="clientCertReq" /tmp/CERTS/new.cr.DER --xYzZY Content-Disposition: form-data; name="submit" submit --xYzZY--
So is this a bug or am I doing something wrong?
Edit by dws to add <readmore> tag
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is this a bug in HTML::Form::Input or am I doing something wrong?
by Speedy (Monk) on Mar 01, 2002 at 01:27 UTC | |
by Pug (Monk) on Mar 01, 2002 at 02:59 UTC | |
by gregorovius (Friar) on Mar 01, 2002 at 16:46 UTC | |
by Pug (Monk) on Mar 04, 2002 at 15:30 UTC | |
by Speedy (Monk) on Mar 01, 2002 at 18:54 UTC | |
by gregorovius (Friar) on Mar 01, 2002 at 19:46 UTC |