Apache-Mojo
view release on metacpan or search on metacpan
lib/Apache/Mojo.pm view on Meta::CPAN
}
sub _response {
my ($r, $res) = @_;
# status
$r->status($res->code);
# headers
my $headers = $res->headers;
foreach my $key (@{$headers->names}) {
my @value = $headers->header($key);
next unless @value;
$r->headers_out->set($key => shift @value);
$r->headers_out->add($key => $_) foreach (@value);
}
# content-type gets ignored in headers_out()
$r->content_type($headers->header('Content-Type'));
# Response body
my $offset = 0;
while (1) {
my $chunk = $res->get_body_chunk($offset);
# No content yet, try again
unless (defined $chunk) {
sleep 1;
next;
}
# End of content
last unless length $chunk;
# Content
my $written = STDOUT->syswrite($chunk);
$offset += $written;
}
}
1;
__END__
=pod
=head1 NAME
Apache::Mojo - mod_perl handler for Mojo
=head1 VERSION
version 0.003
=head1 SYNOPSIS
in httpd.conf:
<Perl>
use lib '...';
use Apache::Mojo;
use TestApp;
</Perl>
<Location />
SetHandler perl-script
PerlSetEnv MOJO_APP TestApp
PerlSetEnv MOJO_PATH /path/to/testapp/
PerlHandler Apache::Mojo
</Location>
=head1 DESCRIPTION
This is a mod_perl handler for L<Mojo>/L<Mojolicious> and Apache. For
mod_perl2, use L<Apache2::Mojo>.
Set the application class with the environment variable C<MOJO_APP>.
If you use relative filesystem paths for templates, etc., set the environment
variable C<MOJO_PATH> to your base application path.
C<MOJO_RELOAD> is also supported (e. g. C<PerlSetEnv MOJO_RELOAD 1>).
=head1 SEE ALSO
L<Apache>, L<Mojo>, L<Mojolicious>.
=head1 AUTHOR
Apache2::Mojo by Uwe Voelker, <uwe.voelker@gmx.de>
Ported to mod_perl 1 by Dave Sherohman, <dave@sherohman.org>
=cut
( run in 2.086 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )