M
Mark Mykkanen
Can someone tell me why the following code randomly produces a status
code of the following states?
500 Can't read entity body: Unknown error
405 Method not allowed
I'm trying to send a file via HTTP using a web form. I can upload a
file without any problems using a browser, but I haven't been
successful with the code below. Please help.
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
my $req = new HTTP::Request 'GET' => 'http://localhost/';
$req->authorization_basic('user','pass');
my $content=$ua->request($req)->as_string;
=formOutput
<form ACTION="DataCollection.asp"
METHOD="POST"
ENCTYPE="multipart/form-data">
<input TYPE="File" NAME="File">
<input TYPE="Submit" VALUE="Submit">
</form>
=cut
# Everything up to here succeeds
my $res = $ua->post(
'http://localhost/',
Content_Type => 'form-data',
Content => [
file => ['data.txt']
]
);
print $res->content() if($res->is_success);
code of the following states?
500 Can't read entity body: Unknown error
405 Method not allowed
I'm trying to send a file via HTTP using a web form. I can upload a
file without any problems using a browser, but I haven't been
successful with the code below. Please help.
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
my $req = new HTTP::Request 'GET' => 'http://localhost/';
$req->authorization_basic('user','pass');
my $content=$ua->request($req)->as_string;
=formOutput
<form ACTION="DataCollection.asp"
METHOD="POST"
ENCTYPE="multipart/form-data">
<input TYPE="File" NAME="File">
<input TYPE="Submit" VALUE="Submit">
</form>
=cut
# Everything up to here succeeds
my $res = $ua->post(
'http://localhost/',
Content_Type => 'form-data',
Content => [
file => ['data.txt']
]
);
print $res->content() if($res->is_success);