Re: Patch to LWP::Protocol::ftp to return last modified time
Gisle Aas (gisle@aas.no)
06 Jul 1998 11:30:25 +0200
"Charles C. Fu" <ccwf@bacchus.com> writes:
> Gisle Aas writes:
> > [an improvement on my patch]
>
> Hmm, I should have looked at the source for the current Net::FTP::mdtm
> and seen that it already does a time format check and conversion. So,
> the patch can be improved further as included below.
Yes, indeed. This patch is in. Thanks!
Regards,
Gisle
> diff -u orig/ftp.pm
> --- orig/ftp.pm Fri Dec 12 07:49:31 1997
> +++ ./ftp.pm Mon Jul 6 01:52:01 1998
> @@ -134,6 +134,19 @@
> }
>
> if ($method eq 'GET' || $method eq 'HEAD') {
> + LWP::Debug::debug("MDTM");
> + if(my $mod_time = $ftp->mdtm($remote_file)) {
> + $response->last_modified($mod_time);
> + if (my $ims = $request->if_modified_since) {
> + LWP::Debug::debug("IMS: $ims");
> + if ($mod_time > $ims) {
> + $response->code(&HTTP::Status::RC_NOT_MODIFIED);
> + $response->message("Not modified");
> + return $response;
> + }
> + }
> + }
> +
> my $data; # the data handle
> LWP::Debug::debug("retrieve file?");
> if (length($remote_file) and $data = $ftp->retr($remote_file)) {
>