- require Apache::Constants;
- Apache::Constants->import(":common");
- my $config = $self->config;
- my %ok = map {$_ => 1} @{$config->{displaying_tables}};
- return DECLINED() unless exists $ok{$self->{table}};
-
- # Does the action method exist?
- my $cv = $self->model_class->can($self->{action});
- return DECLINED() unless $cv;
-
- # Is it exported?
- my $attribs = join " ", attributes::get($cv);
- return DECLINED() unless $attribs =~ /\b(Exported|Class|Single|Multiple)\b/i;
- return OK();
+ $self->params( { $self->_mod_perl_args( $self->ar ) } );
+ $self->query( $self->params );
+}
+
+=item redirect_request
+
+=cut
+
+# FIXME: use headers_in to gather host and other information?
+sub redirect_request
+{
+ my $r = shift;
+ my $redirect_url = $_[0];
+ my $status = "302";
+ if ($_[1]) {
+ my %args = @_;
+ if ($args{url}) {
+ $redirect_url = $args{url};
+ } else {
+ my $path = $args{path} || $r->path;
+ my $host = $args{domain} || $r->ar->hostname;
+ my $protocol = $args{protocol} || $r->get_protocol;
+ $redirect_url = "${protocol}://${host}/${path}";
+ }
+ $status = $args{status} if ($args{status});
+ }
+
+ $r->headers_out->set('Status' => $status);
+ $r->headers_out->set('Location' => $redirect_url);
+ return OK;
+}
+
+=item get_protocol
+
+=cut
+
+sub get_protocol {
+ my $self = shift;
+ my $protocol = ( $self->ar->protocol =~ m/https/i ) ? 'https' : 'http' ;
+ return $protocol;
+}
+
+=item send_output
+
+=cut
+
+sub send_output {
+ my $r = shift;
+ $r->ar->content_type(
+ $r->content_type =~ m/^text/
+ ? $r->content_type . "; charset=" . $r->document_encoding
+ : $r->content_type
+ );
+ $r->ar->headers_out->set(
+ "Content-Length" => do { use bytes; length $r->output }
+ );
+
+ foreach ($r->headers_out->field_names) {
+ next if /^Content-(Type|Length)/;
+ $r->ar->headers_out->set($_ => $r->headers_out->get($_));
+ }
+
+ APACHE2 || $r->ar->send_http_header;
+ $r->ar->print( $r->output );