Re: Patch to LWP::Protocol::ftp to return last modified time
Charles C. Fu (ccwf@bacchus.com)
Mon, 6 Jul 1998 02:02:33 -0700 (PDT)
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.
-ccwf
===============================================================================
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)) {