--- Common.pm.orig Thu May 20 16:14:48 2004
+++ Common.pm Thu May 20 16:19:37 2004
@@ -3,14 +3,15 @@
package HTTP::Request::Common;
use strict;
-use vars qw(@EXPORT @EXPORT_OK $VERSION $DYNAMIC_FILE_UPLOAD);
+use vars qw(@EXPORT @EXPORT_OK $VERSION $DYNAMIC_FILE_UPLOAD $NO_LENGTH_FILE_UPLOAD);
$DYNAMIC_FILE_UPLOAD ||= 0; # make it defined (don't know why)
+$NO_LENGTH_FILE_UPLOAD ||= 0;
require Exporter;
*import = \&Exporter::import;
@EXPORT =qw(GET HEAD PUT POST);
[EMAIL PROTECTED] = qw($DYNAMIC_FILE_UPLOAD);
[EMAIL PROTECTED] = qw($DYNAMIC_FILE_UPLOAD $NO_LENGTH_FILE_UPLOAD);
require HTTP::Request;
use Carp();
@@ -87,12 +88,16 @@
$req->header('Content-Type' => $ct); # might be redundant
if (defined($content)) {
- $req->header('Content-Length' =>
- length($content)) unless ref($content);
+ unless ($NO_LENGTH_FILE_UPLOAD) {
+ $req->header('Content-Length' =>
+ length($content)) unless ref($content);
+ }
$req->content($content);
}
else {
- $req->header('Content-Length' => 0);
+ unless ($NO_LENGTH_FILE_UPLOAD) {
+ $req->header('Content-Length' => 0);
+ }
}
$req;
}
@@ -152,7 +157,10 @@
local($/) = undef; # slurp files
$content = <$fh>;
close($fh);
- $h->header("Content-Length" => length($content));
+
+ unless ($NO_LENGTH_FILE_UPLOAD) {
+ $h->header("Content-Length" => length($content));
+ }
}
unless ($ct) {
require LWP::MediaTypes;
@@ -438,6 +446,12 @@
applications) like this. Also, if the file(s) change in size between
the time the Content-Length is calculated and the time that the last
chunk is delivered, the subroutine will C<Croak>.
+
+Alternatively, if you set the $NO_LENGTH_FILE_UPLOAD variable
+(exportable) to some TRUE value, then the Content-Length header will
+NOT be set for the file upload MIME chunk. This allow you to
+upload files to old/broken web servers that cannot handle
+Content-Length headers.
=back
Please consider applying this patch to the development version of
libwww-perl and including it in future versions of libwww-perl.
Thanks,
- Matt
--
Matt Christian [EMAIL PROTECTED] Learn to love and love to learn.
http://www.visi.com/~mattc/ 0111 ftp://ftp.visi.com/users/mattc/
5468652073656372657420697320131b331b2e1b311b341b311b351b39110d0a