-This will automatically give you C<add>, C<edit>, C<list>, C<view> and
-C<delete> commands; for instance, a list of breweries, go to
+=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($_));
+ }
+
+ $MODPERL2 || $r->ar->send_http_header;
+ $r->ar->print( $r->output );
+}
+
+=item get_template_root
+
+=cut
+
+sub get_template_root {
+ my $r = shift;
+ $r->ar->document_root . "/" . $r->ar->location;
+}
+
+=back
+
+=cut
+
+#########################################################
+# private / internal methods and subs
+
+
+sub _mod_perl_args {
+ my ( $self, $apr ) = @_;
+ my %args;
+ if ($apr->isa('Apache::Request')) {
+ foreach my $key ( $apr->param ) {
+ my @values = $apr->param($key);
+ $args{$key} = @values == 1 ? $values[0] : \@values;
+ }
+ } else {
+ my $body = $self->_prepare_body($apr);
+ %args = %{$body->param};
+ }
+ return %args;
+}
+
+sub _prepare_body {
+ my ( $self, $r ) = @_;
+
+ unless ($self->{__http_body}) {
+ my $content_type = $r->headers_in->get('Content-Type');
+ my $content_length = $r->headers_in->get('Content-Length');
+ my $body = HTTP::Body->new( $content_type, $content_length );
+ my $length = $content_length;
+ while ( $length ) {
+ $r->read( my $buffer, ( $length < 8192 ) ? $length : 8192 );
+ $length -= length($buffer);
+ $body->add($buffer);
+ }
+ $self->{__http_body} = $body;
+ }
+ return $self->{__http_body};
+}