HTTP/ETag.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 4 SCAR 23.0
CC
4
Cov
0%
parse
20.0
empty
2.0
BEGIN
2.0
CRAP 10.0
1 # HTTP ETag; Section 14.19 and 3.11 of RFC 2616. A draft I saw of
2 # another RFC (un-identified) has the trailing /W, so it is supported
3 # here as well.
4 #
5 # subclass of HTTP:Part; see that for interface requirements
6 #
7  
8 package IDS::DataSource::HTTP::ETag;
9  
10 use strict;
11 use warnings;
12 use Carp qw(carp confess);
13 use base qw(IDS::DataSource::HTTP::Part);
14  
15 $IDS::DataSource::HTTP::ETag::VERSION = "1.0";
16  
17 sub empty {
18 my $self = shift;
19 undef $self->{"data"}, $self->{"tokens"};
20 }
21  
22 sub parse {
23 my $self = shift;
24 my $data = $self->{"data"}; # convenience
25 my @tokens;
26  
27 $self->mesg(1, *parse{PACKAGE} . "::parse: data '$data'");
28  
29 # Some lines with entity tags may contain multiple, separated by ,
30 my $etagpat = qr'(W/)?"([^"]+)"(/W)?(,\s*)?';
31 while ($data =~ m!$etagpat!g) {
32 my $etag = $2;
33 my $token = (defined($1) || defined($3) ? "Weak " : "") . "Entity Tag";
34 unless (${$self->{"params"}}{"handle_EntityTag"}) {
35 $token .= ": $etag";
36 }
37 push @tokens, $token;
38 }
39 if ($data !~ m!$etagpat!g) {
40 my $pmsg = *parse{PACKAGE} . "::parse: In " .
41 ${$self->{"params"}}{"source"} .
42 " invalid etag in '$data'\n";
43 $self->warn($pmsg, \@tokens, "!Invalid etag value");
44 }
45  
46 $self->mesg(2, *parse{PACKAGE} . "::parse: tokens\n ",
47 "\n ", \@tokens);
48 $self->{"tokens"} = \@tokens;
49 }
50  
51 # accessor functions not provided by the superclass
52  
53 =head1 AUTHOR INFORMATION
54  
55 Copyright 2005-2007, Kenneth Ingham. All rights reserved.
56  
57 This library is free software; you can redistribute it and/or modify
58 it under the same terms as Perl itself.
59  
60 Address bug reports and comments to: ids_test at i-pi.com. When sending
61 bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm,
62 IDS::DataSource.pm, the version of Perl, and the name and version of the
63 operating system you are using. Since Kenneth is a PhD student, the
64 speed of the reponse depends on how the research is proceeding.
65  
66 =head1 BUGS
67  
68 Please report them.
69  
70 =head1 SEE ALSO
71  
72 L<IDS::Algorithm>, L<IDS::DataSource>
73  
74 =cut
75  
76 1;