> -----Original Message-----
> From: Gisle Aas [mailto:[EMAIL PROTECTED]]
> Sent: 07 April 2000 14:18
> To: BAZLEY, Sebastian
> Cc: [EMAIL PROTECTED]
> Subject: Re: How to PUT a large file using ftp protocol ?
>
>
> "BAZLEY, Sebastian" <[EMAIL PROTECTED]> writes:
>
> > Is it possible to upload a large file using LWP methods?
>
> Should be.
It is now ... (see below)
>
> > I have tried HTTP::Request->new( 'PUT', ftp://host/file,
> undef, $content),
> > and that works OK for small files.
> >
> > However, when I try a large file, somewhere between 37,000
> and 80,000 bytes
> > LWP appears to loop doing IO. Note: the $content variable
> contains the
> > entire file contents, which is a ZIP file (as it happens).
> >
> > This is on VMS 7.2 running LWP 5.41, Perl 5.005_2.
>
> The $data->write() calls inside the PUT section of LWP::Protocol::ftp
> should probably loop if $data->write() returns less than expected
> number of bytes. Do you want to try to provide a patch?
Thanks for the pointer, I've now found the problem; it was actually in
Net::FTP::I.
syswrite() does not like a buffer size larger than 65535 - it returns undef.
Your code already deals with no of bytes written being less than the number
requested, but not with undef, which may perhaps be a VMS-specific bug?
One fix is to change Net::FTP::I::write() as follows:
+ my $maxchunk = 65535; # maximum size allowed by syswrite()
while($sent > 0) {
- my $n = syswrite($data, $buf, $sent,$off);
+ my $n = syswrite($data, $buf, $sent > $maxchunk ? $maxchunk :
$sent,$off);
+ croak "Maxchunk ($maxchunk) too large!" unless defined($n);# Just in
case
return $n if $n < 0;
[Above diff generated by hand - sorry, I don't have the correct diff tool]
Syswrite() may need fixing also - I'll try and look into that - but it might
not be a bad idea to make $maxchunk configurable, with a default of 65535?
[Thanks also for patch re Netscape proxy problem; I'm afraid I haven't had a
chance to try it yet - I'm avoiding the problem by using Pragma: no-cache.]
--
Sebastian Bazley <[EMAIL PROTECTED]>
The opinions expressed herein are my own, and are not necessarily endorsed
by my employer ...
___________________________________________________________________________
This email is confidential and intended solely for the use of the
individual to whom it is addressed. Any views or opinions presented are
solely those of the author and do not necessarily represent those of
Sema Group.
If you are not the intended recipient, be advised that you have received this
email in error and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited.
If you have received this email in error please notify the Sema Group
Helpdesk by telephone on +44 (0) 121 627 5600.
___________________________________________________________________________