Hi,

I can't see what I am doing wrong when I construct a request with
HTTP::Request::Common. I am trying to use the Form-based File-Upload
feature as described at

http://search.cpan.org/~gaas/libwww-perl-5.825/lib/HTTP/Request/Common.pm


Here my code fragment:

use  'Carp';
BEGIN { use_ok( 'LWP::UserAgent' ); }
BEGIN { use_ok( 'HTTP::Request::Common' ); }
...

  $url .= '/cgi-bin/uploadPDF.pl';

  my $req = HTTP::Request->new(POST $url, Content_Type => 'form-data',
Content => [uploaded_file => $file_glob]);

  my $ua = LWP::UserAgent->new;
  my $res = $ua->request($req);
  $ua->timeout(90);
  print STDERR "Send request for $url\n";
  if ($res->is_success) {
       return($res->decoded_content);
  }
  else {
     croak "Error from http request: ".$res->decoded_content." ".$res;
  }


The error is:

Send request for http://server.somedomain/cgi-bin/uploadPDF.pl
Error from http request: 400 URL missing
 HTTP::Response=HASH(0x882e894) at t/05upload_pdf.t line 51
        main::upload_pdf('server.somedomain', '/path/to/mypdf.pdf') called at
t/05upload_pdf.t line 20
# Looks like your test exited with 255 just after 3

The error reads like I LWP does not understand the request object I've
made, or at least the URL part of it. The server at the other end is
not reporting a connection either.

Can anyone spot where I am going wrong?
TIA,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to