Seeing the example config linkified, some users may inevitably
try to following it in a browser with a GET request. Provide
a helpful message to inform users to use POST instead of
attempting to treat /$INBOX/$ALTID.sql.gz as a Message-Id.
get_vcs_object($ctx, $1, $2, $3);
} elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s\z!o) {
r301($ctx, $1, $2, 's/');
get_vcs_object($ctx, $1, $2, $3);
} elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s\z!o) {
r301($ctx, $1, $2, 's/');
+ } elsif ($path_info =~ m!$INBOX_RE/(\w+)\.sql\.gz\z!o) {
+ get_altid_dump($ctx, $1, $2);
# convenience redirects order matters
} elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
r301($ctx, $1, $2);
# convenience redirects order matters
} elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
r301($ctx, $1, $2);
# and thus not usable from DBD::SQLite.
sub sqldump ($$) {
my ($ctx, $altid_pfx) = @_;
# and thus not usable from DBD::SQLite.
sub sqldump ($$) {
my ($ctx, $altid_pfx) = @_;
my $ibx = $ctx->{-inbox};
my $altid_map = $ibx->altid_map;
my $fn = $altid_map->{$altid_pfx};
my $ibx = $ctx->{-inbox};
my $altid_map = $ibx->altid_map;
my $fn = $altid_map->{$altid_pfx};
+ if ($env->{REQUEST_METHOD} ne 'POST') {
+ my $url = $ibx->base_url($ctx->{env}) . "$altid_pfx.sql.gz";
+ return PublicInbox::WwwStream::oneshot($ctx, 405, \<<EOF);
+<pre>A POST request required to retrieve $altid_pfx.sql.gz
+
+ curl -XPOST -O $url
+
+or
+
+ curl -XPOST $url | \\
+ gzip -dc | \\
+ sqlite3 /path/to/$altid_pfx.sqlite3
+</pre>
+EOF
+ }
+
eval { require PublicInbox::GzipFilter } or
return PublicInbox::WwwStream::oneshot($ctx, 501, \<<EOF);
<pre>gzip output not available
eval { require PublicInbox::GzipFilter } or
return PublicInbox::WwwStream::oneshot($ctx, 501, \<<EOF);
<pre>gzip output not available
# TODO: use -readonly if available with newer sqlite3(1)
my $qsp = PublicInbox::Qspawn->new([$sqlite3, $fn], undef, { 0 => $r });
# TODO: use -readonly if available with newer sqlite3(1)
my $qsp = PublicInbox::Qspawn->new([$sqlite3, $fn], undef, { 0 => $r });
$ctx->{altid_pfx} = $altid_pfx;
$env->{'qspawn.filter'} = PublicInbox::GzipFilter->new;
$qsp->psgi_return($env, undef, \&check_output, $ctx);
$ctx->{altid_pfx} = $altid_pfx;
$env->{'qspawn.filter'} = PublicInbox::GzipFilter->new;
$qsp->psgi_return($env, undef, \&check_output, $ctx);