PublicInbox::WWW->preload;
my $www = PublicInbox::WWW->new;
$app = eval {
- my $deflate_types = eval {
- require Plack::Middleware::Deflater;
- [ 'text/html', 'text/plain',
- 'application/atom+xml' ]
- };
builder {
enable 'Chunked';
- if ($deflate_types) {
+ eval {
enable 'Deflater',
- content_type => $deflate_types
- }
- enable 'ReverseProxy';
+ content_type => [ qw(
+ text/html
+ text/plain
+ application/atom+xml
+ )]
+ };
+ $@ and warn
+"Plack::Middleware::Deflater missing, bandwidth will be wasted\n";
+
+ eval { enable 'ReverseProxy' };
+ $@ and warn
+"Plack::Middleware::ReverseProxy missing,\n",
+"URL generation for redirects may be wrong if behind a reverse proxy\n";
+
enable 'Head';
sub { $www->call(@_) };
};
1;
+# XXX This is a totally unstable API for public-inbox internal use only
+# This is exposed via the 'pi-httpd.async' key in the PSGI env hash.
+# The name of this key is not even stable!
+# Currently is is intended for use with read-only pipes.
package PublicInbox::HTTPD::Async;
use strict;
use warnings;
sub new {
my ($class, $io, $cb) = @_;
my $self = fields::new($class);
- $io->blocking(0);
+ IO::Handle::blocking($io, 0);
$self->SUPER::new($io);
$self->{cb} = $cb;
$self->watch_read(1);