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

RE: LWP/HTTP Content-Length Calculation Error

Thread Previous | Thread Next
Bohan, Larry
January 14, 2002 21:31
RE: LWP/HTTP Content-Length Calculation Error
Message ID:
poor man's guess:  older version of libwww ?  
(I vaguely recall bumping into the content-length issue noted below)

2001-01-12   Gisle Aas <>
Release 5.50

    Fix for test cases that failed because of URI-1.10 now encode
    space as '+' instead of '%20. Patch by Christian Gilmore

    Makefile.PL: Require URI-1.10.

    HTTP::Daemon now accepts any non-space character as method name
    on the request line.  It used to fail on methods like "M-POST"
    because it only allowed \w-chars.

    HTTP::Date now allow fractional seconds in ISO date formats.
    Based on patch from Mark D. Anderson <>

    HTTP::Request::Common will now calculate Content-length
    even if $DYNAMIC_FILE_UPLOAD is set.  Patch provided by
    Lindley, Lee T <>.

-----Original Message-----
From: Kokosa, Chris []
Sent: Monday, January 14, 2002 8:25 PM
To: 'winston@SLAC.Stanford.EDU'
Cc: ''
Subject: RE: LWP/HTTP Content-Length Calculation Error

Sorry for confusion.  The webserver is running on a Win32/IIS machine (a
second server is running UNIX/Netscape).  The script below runs on VMS.  To
make things more difficult the web server is managed by a third party and
they aren't too helpful.

The proxy setting is necessary for now.  Eventually they're going to punch a
hole in the firewall between the Alpha and the web server.  Until then I'm
stuck with the proxy server.  The other GETS, PUTS and POSTS appear to work
fine other than this file upload.

-----Original Message-----
From: Alan Winston - SSRL Central Computing
Sent: Monday, January 14, 2002 10:02 PM
To: Kokosa, Chris
Cc: ''
Subject: Re: LWP/HTTP Content-Length Calculation Error

Chris wrote:

> 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'm confused.  Is the webserver that you're trying to reach on VMS, or are
you on VMS running the script?  If the webserver is on VMS, the following
questions may be relevant:

What webserver are you using on VMS?  I've just been looking at the WASD
docs, and I see WASD has a default buffer-size of 4096 for communicating
CGIs.  I don't think that would necessarily cut the file short, but it
(This is a settable parameter in WASD.)

Also, it looks like you've got a proxy server between you and the system
trying to get to.  What's the proxy server running?  Can you get around it
and use the end-node directly?

> 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 = "";
> 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

 Disclaimer: I speak only for myself, not SLAC or SSRL   Phone:
 Paper mail to: SSRL -- SLAC BIN 99, 2575 Sand Hill Rd, Menlo Park CA

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