File Coverage

blib/lib/HTTP/Throwable/Role/Status/NotModified.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 16 18 88.8


line stmt bran cond sub pod time code
1             package HTTP::Throwable::Role::Status::NotModified;
2             our $AUTHORITY = 'cpan:STEVAN';
3             $HTTP::Throwable::Role::Status::NotModified::VERSION = '0.026';
4 1     1   870 use Moo::Role;
  1         1  
  1         11  
5              
6 1     1   331 use Plack::Util ();
  1         2  
  1         157  
7              
8             with(
9             'HTTP::Throwable',
10             'HTTP::Throwable::Role::BoringText',
11             );
12              
13 2     2 0 102 sub default_status_code { 304 }
14 2     2 0 9633 sub default_reason { 'Not Modified' }
15              
16             around 'as_psgi' => sub {
17             my $next = shift;
18             my $self = shift;
19             my $psgi = $self->$next();
20              
21             # MUST NOT have a message body, see below
22             Plack::Util::header_set( $psgi->[1], 'Content-Length' => 0 );
23             Plack::Util::header_remove( $psgi->[1], 'Content-Type');
24              
25             $psgi->[2] = [];
26              
27             $psgi;
28             };
29              
30 1     1   5 no Moo::Role; 1;
  1         2  
  1         4  
31              
32             =pod
33              
34             =encoding UTF-8
35              
36             =head1 NAME
37              
38             HTTP::Throwable::Role::Status::NotModified - 304 Not Modified
39              
40             =head1 VERSION
41              
42             version 0.026
43              
44             =head1 DESCRIPTION
45              
46             If the client has performed a conditional GET request and access
47             is allowed, but the document has not been modified, the server
48             SHOULD respond with this status code. The 304 response MUST NOT
49             contain a message-body, and thus is always terminated by the
50             first empty line after the header fields.
51              
52             The response MUST include the following header fields:
53              
54             =over 4
55              
56             =item Date, unless its omission is required by section 14.18.1
57              
58             If a clockless origin server obeys these rules, and proxies and
59             clients add their own Date to any response received without one
60             (as already specified by [RFC 2068], section 14.19), caches will
61             operate correctly.
62              
63             =item ETag and/or Content-Location, if the header would have been sent in a 200 response to the same request
64              
65             =item Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous response for the same variant
66              
67             =back
68              
69             If the conditional GET used a strong cache validator, the response
70             SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional
71             GET used a weak validator), the response MUST NOT include other
72             entity-headers; this prevents inconsistencies between cached
73             entity-bodies and updated headers.
74              
75             If a 304 response indicates an entity not currently cached, then
76             the cache MUST disregard the response and repeat the request without
77             the conditional.
78              
79             If a cache uses a received 304 response to update a cache entry,
80             the cache MUST update the entry to reflect any new field values
81             given in the response.
82              
83             =head1 AUTHORS
84              
85             =over 4
86              
87             =item *
88              
89             Stevan Little
90              
91             =item *
92              
93             Ricardo Signes
94              
95             =back
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2011 by Infinity Interactive, Inc..
100              
101             This is free software; you can redistribute it and/or modify it under
102             the same terms as the Perl 5 programming language system itself.
103              
104             =cut
105              
106             __END__