… | |
… | |
27 | |
27 | |
28 | sub fatal { |
28 | sub fatal { |
29 | my ($self) = @_; |
29 | my ($self) = @_; |
30 | |
30 | |
31 | $self->send ("HTTP/1.1 500 internal error\015\012"); |
31 | $self->send ("HTTP/1.1 500 internal error\015\012"); |
|
|
32 | } |
|
|
33 | |
|
|
34 | sub respond_304 { |
|
|
35 | $_[0]->send ("HTTP/1.1 304 cache\015\012" |
|
|
36 | . $_[0]{ohdr} |
|
|
37 | . "\015\012"); |
32 | } |
38 | } |
33 | |
39 | |
34 | sub respond { |
40 | sub respond { |
35 | $_[0]->send ("HTTP/1.1 $_[1]\015\012" |
41 | $_[0]->send ("HTTP/1.1 $_[1]\015\012" |
36 | . "content-length: " . (0 + length $_[2]) . "\015\012" |
42 | . "content-length: " . (0 + length $_[2]) . "\015\012" |
… | |
… | |
127 | |
133 | |
128 | $idx |
134 | $idx |
129 | or do { $self->respond ("404 illegal face name"), next }; |
135 | or do { $self->respond ("404 illegal face name"), next }; |
130 | |
136 | |
131 | if ($req =~ /if-none-match/i) { # dirtiest hack evar |
137 | if ($req =~ /if-none-match/i) { # dirtiest hack evar |
132 | $self->respond ("304 not modified", "", $cache_headers); |
138 | $self->respond_304; |
133 | next; |
139 | next; |
134 | } |
140 | } |
135 | |
141 | |
136 | my $type = cf::face::get_type $idx; |
142 | my $type = cf::face::get_type $idx; |
137 | my $data = cf::face::get_data $idx; |
143 | my $data = cf::face::get_data $idx; |
… | |
… | |
153 | my $data = cf::face::get_data $idx; |
159 | my $data = cf::face::get_data $idx; |
154 | my $csum = unpack "H*", cf::face::get_csum $idx; |
160 | my $csum = unpack "H*", cf::face::get_csum $idx; |
155 | my $hdr = "etag: \"$csum\"\015\012" . $revalidate_headers; |
161 | my $hdr = "etag: \"$csum\"\015\012" . $revalidate_headers; |
156 | |
162 | |
157 | if ($req =~ /if-none-match: "$csum"/i) { # dirtiest hack evar |
163 | if ($req =~ /if-none-match: "$csum"/i) { # dirtiest hack evar |
158 | $self->respond ("304 not modified", "", $hdr); |
164 | $self->respond_304; |
159 | next; |
165 | next; |
160 | } |
166 | } |
161 | |
167 | |
162 | $self->respond ("200 OK", $data, (content_type $uri, $data) . $hdr); |
168 | $self->respond ("200 OK", $data, (content_type $uri, $data) . $hdr); |
163 | |
169 | |