X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwAltId.pm;h=2818400eabd17359446d3b72936a245b4f498bcb;hb=7f8e6ba85dd5e41efdfb518e3b86bceda3ee027e;hp=263e884aa445c92b588c1637546166b343205399;hpb=5513e163236d8a64411050ae2e1f87aa8d24f023;p=public-inbox.git diff --git a/lib/PublicInbox/WwwAltId.pm b/lib/PublicInbox/WwwAltId.pm index 263e884a..2818400e 100644 --- a/lib/PublicInbox/WwwAltId.pm +++ b/lib/PublicInbox/WwwAltId.pm @@ -5,28 +5,19 @@ package PublicInbox::WwwAltId; use strict; use PublicInbox::Qspawn; -use PublicInbox::WwwStream; +use PublicInbox::WwwStream qw(html_oneshot); use PublicInbox::AltId; use PublicInbox::Spawn qw(which); +use PublicInbox::GzipFilter; our $sqlite3 = $ENV{SQLITE3}; -sub sqlite3_missing ($) { - PublicInbox::WwwResponse::oneshot($_[0], 501, \<sqlite3 not available - -The administrator needs to install the sqlite3(1) binary -to support gzipped sqlite3 dumps. - -EOF -} - sub check_output { my ($r, $bref, $ctx) = @_; - return PublicInbox::WwwResponse::oneshot($ctx, 500) if !defined($r); + return html_oneshot($ctx, 500) if !defined($r); if ($r == 0) { my $err = eval { $ctx->{env}->{'psgi.errors'} } // \*STDERR; $err->print("unexpected EOF from sqlite3\n"); - return PublicInbox::WwwResponse::oneshot($ctx, 501); + return html_oneshot($ctx, 501); } [200, [ qw(Content-Type application/gzip), 'Content-Disposition', "inline; filename=$ctx->{altid_pfx}.sql.gz" ] ] @@ -43,14 +34,14 @@ sub sqldump ($$) { my $altid_map = $ibx->altid_map; my $fn = $altid_map->{$altid_pfx}; unless (defined $fn) { - return PublicInbox::WwwStream::oneshot($ctx, 404, \<`$altid_pfx' is not a valid altid for this inbox EOF } if ($env->{REQUEST_METHOD} ne 'POST') { my $url = $ibx->base_url($ctx->{env}) . "$altid_pfx.sql.gz"; - return PublicInbox::WwwStream::oneshot($ctx, 405, \<A POST request required to retrieve $altid_pfx.sql.gz curl -XPOST -O $url @@ -64,23 +55,12 @@ or EOF } - eval { require PublicInbox::GzipFilter } or - return PublicInbox::WwwStream::oneshot($ctx, 501, \<gzip output not available - -The administrator needs to install the Compress::Raw::Zlib Perl module -to support gzipped sqlite3 dumps. -EOF - $sqlite3 //= which('sqlite3'); - if (!defined($sqlite3)) { - return PublicInbox::WwwStream::oneshot($ctx, 501, \<sqlite3 not available The administrator needs to install the sqlite3(1) binary to support gzipped sqlite3 dumps. - EOF - } # setup stdin, POSIX requires writes <= 512 bytes to succeed so # we can close the pipe right away.