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