diff -r -C 5 libwww-perl-5.64.orig/lib/LWP/Protocol/http.pm libwww-perl-5.64/lib/LWP/Protocol/http.pm
*** libwww-perl-5.64.orig/lib/LWP/Protocol/http.pm      Fri Dec 14 13:33:52 2001
--- libwww-perl-5.64/lib/LWP/Protocol/http.pm   Mon Apr 29 11:29:05 2002
***************
*** 175,184 ****
--- 175,193 ----
        unless (defined $clen) {
            push(@h, "Transfer-Encoding" => "chunked");
            $has_content++;
            $chunked++;
        }
+     } elsif (ref($$content_ref) eq 'FileHandle') {
+       use FileHandle;
+       my $cur = FileHandle::tell($$content_ref); # remember where we are
+       FileHandle::seek($$content_ref, 0, 2); # jump to the end
+       my $clen = (FileHandle::tell($$content_ref) - $cur); # potential offset
+       FileHandle::seek($$content_ref, $cur, 0); # please be kind, rewind
+       hlist_remove(\@h, 'Content-Length'); # who cares what was there before?
+       push(@h, 'Content-Length' => "$clen"); # it's gonna be this now!
+       $has_content++;
      } else {
        # Set (or override) Content-Length header
        my $clen = $request_headers->header('Content-Length');
        if (defined($$content_ref) && length($$content_ref)) {
            $has_content++;
***************
*** 216,231 ****
--- 225,247 ----
            if ($request_headers->header("Expect") || "") =~ /100-continue/;
  
        my $eof;
        my $wbuf;
        my $woffset = 0;
+ 
        if (ref($content_ref) eq 'CODE') {
            my $buf = &$content_ref();
            $buf = "" unless defined($buf);
            $buf = sprintf "%x%s%s%s", length($buf), $CRLF, $buf, $CRLF
                if $chunked;
            $wbuf = \$buf;
+       } elsif (ref($$content_ref) eq 'FileHandle') {
+           my $buf;
+           my $res = $$content_ref->read($buf, $size);
+           if (! defined $res) { die "can not read from FileHandle $!"; }
+           if ($res == 0) { $eof = 1; }
+           $wbuf = \$buf;
        }
        else {
            $wbuf = $content_ref;
            $eof = 1;
        }
***************
*** 285,302 ****
                    die "syswrite: no bytes written";
                }
                $woffset += $n;
  
                if (!$eof && $woffset >= length($$wbuf)) {
!                   # need to refill buffer from $content_ref code
!                   my $buf = &$content_ref();
!                   $buf = "" unless defined($buf);
!                   $eof++ unless length($buf);
!                   $buf = sprintf "%x%s%s%s", length($buf), $CRLF, $buf, $CRLF
!                       if $chunked;
!                   $wbuf = \$buf;
!                   $woffset = 0;
                }
            }
        }
      }
  
--- 301,327 ----
                    die "syswrite: no bytes written";
                }
                $woffset += $n;
  
                if (!$eof && $woffset >= length($$wbuf)) {
!                   if (ref($$content_ref) eq 'FileHandle') {
!                       my $buf;
!                       my $res = $$content_ref->read($buf, $size);
!                       if (! defined $res) { die "can not read from FileHandle $!"; }
!                       if ($res == 0) { $eof++; }
!                       $wbuf = \$buf;
!                       $woffset = 0;
!                   } else {
!                       # need to refill buffer from $content_ref code
!                       my $buf = &$content_ref();
!                       $buf = "" unless defined($buf);
!                       $eof++ unless length($buf);
!                       $buf = sprintf "%x%s%s%s", length($buf), $CRLF, $buf, $CRLF
!                           if $chunked;
!                       $wbuf = \$buf;
!                       $woffset = 0;
!                   }
                }
            }
        }
      }
  
