flixz has asked for the wisdom of the Perl Monks concerning the following question:

Hi there Perlmonks, I can't seem to figure out how to create a proper POST HTTP::Request in order to send files. When I use:
$res = $ua->request(POST $server, Content_Type => 'form-data', Content => [ login => $ICT_login, filenaamOriginal => $test_file, test=>'JA', filenaam => [$test_filename, $test_file], ]);
The files are transmitted to the webserver without any problems. I need to send files using a different method for creating a HTTP::Request object because I need to use the $req->proxy_authorization_basic method, which I can't access using the previous method. When I use the following code:
$req = HTTP::Request->new (POST => $server, Content_Type => 'form-data', Content => [login => $ICT_login, filenaamOriginal => $test_file, test => 'JA', filenaam => [$test_filename,$test_file], ]);
I get the following error message: Bad header argument at eclient.pl line 2035 My guts say this a very trivial problem but I can't seem to figure out what I'm doing wrong ;-)

Thanks!

Felix

Replies are listed 'Best First'.
Re: Problems creating a proper HTTP::Request object for sending files
by Abigail-II (Bishop) on Jun 06, 2002 at 11:37 UTC
    According the manual page of HTTP::Request, HTTP::Request -> new takes up to four arguments. If there is a third argument, it should be a reference to an HTTP::Headers object.

    Grepping through the source reveals that the error message is generated by HTTP::Message, while it's testing if a certain argument is indeed a reference...

    I suggest consulting the documentation of HTTP::Request and sticking to its API.

    Abigail