]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAltId.pm
www: drop --subject from "git send-email" instructions
[public-inbox.git] / lib / PublicInbox / WwwAltId.pm
index e5476d1f50aeedf467feac6c0af56e57ce4baba7..e107dfe06eafb3cbcc3183b73399210c36ea4781 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # dumps using the ".dump" command of sqlite3(1)
@@ -11,22 +11,11 @@ use PublicInbox::Spawn qw(which);
 use PublicInbox::GzipFilter;
 our $sqlite3 = $ENV{SQLITE3};
 
-sub sqlite3_missing ($) {
-       html_oneshot($_[0], 501, \<<EOF);
-<pre>sqlite3 not available
-
-The administrator needs to install the sqlite3(1) binary
-to support gzipped sqlite3 dumps.</pre>
-</pre>
-EOF
-}
-
 sub check_output {
        my ($r, $bref, $ctx) = @_;
        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");
+               warn 'unexpected EOF from sqlite3';
                return html_oneshot($ctx, 501);
        }
        [200, [ qw(Content-Type application/gzip), 'Content-Disposition',
@@ -40,7 +29,7 @@ sub check_output {
 sub sqldump ($$) {
        my ($ctx, $altid_pfx) = @_;
        my $env = $ctx->{env};
-       my $ibx = $ctx->{-inbox};
+       my $ibx = $ctx->{ibx};
        my $altid_map = $ibx->altid_map;
        my $fn = $altid_map->{$altid_pfx};
        unless (defined $fn) {
@@ -52,29 +41,25 @@ EOF
        if ($env->{REQUEST_METHOD} ne 'POST') {
                my $url = $ibx->base_url($ctx->{env}) . "$altid_pfx.sql.gz";
                return html_oneshot($ctx, 405, \<<EOF);
-<pre>A POST request required to retrieve $altid_pfx.sql.gz
+<pre>A POST request is required to retrieve $altid_pfx.sql.gz
 
-       curl -XPOST -O $url
+       curl -d '' -O $url
 
 or
 
-       curl -XPOST $url | \\
+       curl -d '' $url | \\
                gzip -dc | \\
                sqlite3 /path/to/$altid_pfx.sqlite3
 </pre>
 EOF
        }
 
-       $sqlite3 //= which('sqlite3');
-       if (!defined($sqlite3)) {
-               return html_oneshot($ctx, 501, \<<EOF);
+       $sqlite3 //= which('sqlite3') // return html_oneshot($ctx, 501, \<<EOF);
 <pre>sqlite3 not available
 
 The administrator needs to install the sqlite3(1) binary
 to support gzipped sqlite3 dumps.</pre>
-</pre>
 EOF
-       }
 
        # setup stdin, POSIX requires writes <= 512 bytes to succeed so
        # we can close the pipe right away.