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

LWP/HTTP Content-Length Calculation Error

Thread Next
From:
Kokosa, Chris
Date:
January 14, 2002 19:54
Subject:
LWP/HTTP Content-Length Calculation Error
Message ID:
8CE5617ED444D411BDF800508BDF0BEE09733C24@usahm015.exmi01.exch.eds.com
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;

$HTTP::Request::Common::DYNAMIC_FILE_UPLOAD++;

my $ua = new LWP::UserAgent;
$ua->agent("fris_1.0");

my $proxy_server = "http://myproxy.com";
my $proxy_userid = "uid";
my $proxy_password = "pass";

my $url = "http://uploadserver.com/servlet/UploadFile";
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
chris.kokosa@eds.com


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About