File: 304.pl

package info (click to toggle)
libapache2-mod-perl2 2.0.4-5%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,868 kB
  • ctags: 3,820
  • sloc: perl: 56,663; ansic: 14,001; makefile: 91; sh: 38
file content (49 lines) | stat: -rwxr-xr-x 1,263 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings FATAL => 'all';

# manually handle 'If-Modified-Since' requests

use APR::Date ();
use Apache2::Util ();
use Apache2::RequestRec ();

use constant FMT => '%a, %d %b %Y %H:%M:%S %Z';
use constant GMT => 1;
use Apache2::Const -compile => qw(HTTP_NOT_MODIFIED);

my $last_modified = "Sun, 29 Oct 2000 15:43:29 GMT";

my $r = shift;

my $if_modified_since = $r->headers_in->{'If-Modified-Since'};

my $status = 200;
my $body   = '<html><head></head><body>Test</body></html>';

#APR::Date::parse_http may fail
my $if_modified_since_secs =
    ($if_modified_since && APR::Date::parse_http($if_modified_since)) || 0;
my $last_modified_secs = APR::Date::parse_http($last_modified);

#warn "If-Modified-Since      $if_modified_since\n";
#warn "last_modified_secs     $last_modified_secs\n";
#warn "if_modified_since_secs $if_modified_since_secs\n\n";

if ($last_modified_secs < $if_modified_since_secs) {
    $status = Apache2::Const::HTTP_NOT_MODIFIED;
    $body   = '';
}

my $date = Apache2::Util::ht_time($r->pool, $r->request_time, FMT, GMT);

print <<HEADERS;
Status: $status
Date: $date
Server: Apache/2.0.47
Connection: close
Last-Modified: $last_modified
Content-Type: text/html; charset=iso-8859-1

HEADERS

print $body if length $body;