develooper Front page | perl.vmsperl | Postings from January 2002

LWP/HTTP Content-Length Calculation Error

Thread Next
Kokosa, Chris
January 14, 2002 19:54
LWP/HTTP Content-Length Calculation Error
Message ID:
I'm trying to run a script that does a file upload via POST on a VMS node.
I've download and successfully compiled a version of VMS Perl from "Craig
Berry's 5.6.1 easy-to-install release".  When I run the script on Win32 it
runs fine.  When I run the app on VMS the web server replies with a "500
length of data sent did not match calculated Content-Length header..."

Is the content-length calculation wrong or is it a difference between OSs?
I noticed that when I don't use the dynamic_file_upload that the
content-length in the file field is at 4096 for a 3705K file.  4096 is a
very familiar number ;-)  The $^O variable says that I'm running VMS.

I've tried everything.  If this is a bug I'll code the thing in C via
sockets (yuck).

Here's the script:
use strict;

use LWP::Debug qw(+);
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use MIME::Base64;


my $ua = new LWP::UserAgent;

my $proxy_server = "";
my $proxy_userid = "uid";
my $proxy_password = "pass";

my $url = "";
my $filename = "test.txt";

my $req = POST ($url,
               Content_Type => 'form-data',
               Content => [ The_UserID => 'form_uid',
                            The_Password => 'form_pass',
                            Dir => 'destdir/',                         
                            File => [$filename,$filename]

$ua->proxy(http => $proxy_server);
$req->proxy_authorization_basic( $proxy_userid, $proxy_password );

my $res = $ua->request($req);

print $res->status_line."\n";
print $res->content;


Chris Kokosa
EDS Embedded Systems

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About