+sub set_last_modified {
+ my ($res, $mtime) = @_;
+
+ my $str = POSIX::strftime("%a, %d %b %Y %H:%M:%S %Z", localtime($mtime));
+ $res->headers({ 'Last-Modified' => $str });
+}
+
+sub get_server_name {
+ my $r = shift;
+ my $host = $r->env->{'HTTP_HOST'};
+ $host =~ s/:.*//;
+ return $host;
+}
+
+sub log_info {
+ my ($r, $msg) = @_;
+ if (defined($r->logger)) {
+ $r->logger->({ level => 'info', message => $msg });
+ } else {
+ print STDERR "[INFO] $msg\n";
+ }
+}
+
+sub log_warn {
+ my ($r, $msg) = @_;
+ if (defined($r->logger)) {
+ $r->logger->({ level => 'warn', message => $msg });
+ } else {
+ print STDERR "[WARN] $msg\n";
+ }
+}
+
+sub log_error {
+ my ($r, $msg) = @_;
+ if (defined($r->logger)) {
+ $r->logger->({ level => 'error', message => $msg });
+ } else {
+ print STDERR "[ERROR] $msg\n";
+ }
+}
+