| 1 | # HTTP If-Modified-Since line; Section 14.28 of RFC 2616 | ||
| 2 | # | ||
| 3 | # subclass of HTTP:Part; see that for interface requirements | ||
| 4 | # | ||
| 5 | package IDS::DataSource::HTTP::IfModifiedSince; | ||
| 6 | use base qw(IDS::DataSource::HTTP::Part); | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | use Carp qw(carp confess); | ||
| 11 | use IDS::DataSource::HTTP::Date; | ||
| 12 | use IDS::DataSource::HTTP::Int; | ||
| 13 | |||
| 14 | $IDS::DataSource::HTTP::IfModifiedSince::VERSION = "1.0"; | ||
| 15 | |||
| 16 | sub empty { | ||
| 17 | my $self = shift; | ||
| 18 | undef $self->{"data"}, $self->{"tokens"}; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub parse { | ||
| 22 | my $self = shift; | ||
| 23 | my $data = $self->{"data"}; # convenience | ||
| 24 | my @tokens; | ||
| 25 | |||
| 26 | $self->mesg(1, *parse{PACKAGE} . "::parse: data '$data'"); | ||
| 27 | |||
| 28 | if ($data =~ /^(.*); (length=(\d+))$/) { | ||
| 29 | push @tokens, "Non-standard If-Modified-Since"; | ||
| 30 | my $date = new IDS::DataSource::HTTP::Date($self->{"params"}, $1); | ||
| 31 | push @tokens, $date->tokens(); | ||
| 32 | my $int = new IDS::DataSource::HTTP::Int($self->{"params"}, $3); | ||
| 33 | push @tokens, $int->tokens(); | ||
| 34 | } else { | ||
| 35 | my $date = new IDS::DataSource::HTTP::Date($self->{"params"}, $data); | ||
| 36 | push @tokens, $date->tokens(); | ||
| 37 | } | ||
| 38 | |||
| 39 | $self->mesg(2, *parse{PACKAGE} . "::parse: tokens\n ", | ||
| 40 | "\n ", \@tokens); | ||
| 41 | $self->{"tokens"} = \@tokens; | ||
| 42 | } | ||
| 43 | |||
| 44 | # accessor functions not provided by the superclass | ||
| 45 | |||
| 46 | =head1 AUTHOR INFORMATION | ||
| 47 | |||
| 48 | Copyright 2005-2007, Kenneth Ingham. All rights reserved. | ||
| 49 | |||
| 50 | This library is free software; you can redistribute it and/or modify | ||
| 51 | it under the same terms as Perl itself. | ||
| 52 | |||
| 53 | Address bug reports and comments to: ids_test at i-pi.com. When sending | ||
| 54 | bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, | ||
| 55 | IDS::DataSource.pm, the version of Perl, and the name and version of the | ||
| 56 | operating system you are using. Since Kenneth is a PhD student, the | ||
| 57 | speed of the reponse depends on how the research is proceeding. | ||
| 58 | |||
| 59 | =head1 BUGS | ||
| 60 | |||
| 61 | Please report them. | ||
| 62 | |||
| 63 | =head1 SEE ALSO | ||
| 64 | |||
| 65 | L<IDS::Algorithm>, L<IDS::DataSource> | ||
| 66 | |||
| 67 | =cut | ||
| 68 | |||
| 69 | 1; |