user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 9/9] www_text: fix /$INBOX/_/text/help/raw endpoint
  2024-05-19 21:55  6% [PATCH 0/9] fixes noticed while working on indexheader Eric Wong
@ 2024-05-19 21:55  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2024-05-19 21:55 UTC (permalink / raw)
  To: meta

It wasn't ever documented, but since config/raw exists, it makes
sense for help/raw to exist, too.
---
 lib/PublicInbox/WwwText.pm |  2 +-
 t/psgi_text.t              | 21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index 5e23005e..8279591a 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -37,7 +37,7 @@ sub get_text {
 	}
 	my $env = $ctx->{env};
 	if ($raw) {
-		my $h = delete $ctx->{-res_hdr};
+		my $h = delete $ctx->{-res_hdr} // [];
 		$txt = gzf_maybe($h, $env)->zflush($txt) if $code == 200;
 		push @$h, 'Content-Type', 'text/plain',
 			'Content-Length', length($txt);
diff --git a/t/psgi_text.t b/t/psgi_text.t
index 25599dd9..b8b1bc48 100644
--- a/t/psgi_text.t
+++ b/t/psgi_text.t
@@ -3,12 +3,12 @@
 use v5.12;
 use PublicInbox::Eml;
 use PublicInbox::TestCommon;
+use IO::Uncompress::Gunzip qw(gunzip);
 my ($tmpdir, $for_destroy) = tmpdir();
 my $maindir = "$tmpdir/main.git";
 my $addr = 'test-public@example.com';
 my $cfgpfx = "publicinbox.test";
 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
-require_mods(@mods, 'IO::Uncompress::Gunzip');
 use_ok $_ foreach @mods;
 use PublicInbox::Import;
 use_ok 'PublicInbox::WWW';
@@ -33,9 +33,24 @@ test_psgi(sub { $www->call(@_) }, sub {
 	is($res->header('Content-Encoding'), 'gzip', 'got gzip encoding');
 	is($res->header('Content-Type'), 'text/html; charset=UTF-8',
 		'got gzipped HTML');
-	IO::Uncompress::Gunzip::gunzip(\($res->content) => \$gunzipped);
+	gunzip(\($res->content) => \$gunzipped);
 	is($gunzipped, $content, 'gzipped content is correct');
 
+	$req = GET('/test/_/text/help/raw');
+	$res = $cb->($req);
+	like $res->header('Content-Type'), qr!\Atext/plain\b!,
+		'got text/plain Content-Type';
+	$content = $res->content;
+	like $content, qr!public-inbox help!, 'default help';
+
+	$req->header('Accept-Encoding' => 'gzip');
+	$res = $cb->($req);
+	is($res->header('Content-Encoding'), 'gzip', 'got gzip encoding');
+	like $res->header('Content-Type'), qr!\Atext/plain\b!,
+		'got text/plain Content-Type w/ gzip';
+	gunzip(\($res->content) => \$gunzipped);
+	is $gunzipped, $content, 'gzipped content is correct';
+
 	$req = GET('/test/_/text/config/raw');
 	$res = $cb->($req);
 	$content = $res->content;
@@ -47,7 +62,7 @@ test_psgi(sub { $www->call(@_) }, sub {
 	$res = $cb->($req);
 	is($res->header('Content-Encoding'), 'gzip', 'got gzip encoding');
 	ok($res->header('Content-Length') < $olen, 'gzipped help is smaller');
-	IO::Uncompress::Gunzip::gunzip(\($res->content) => \$gunzipped);
+	gunzip(\($res->content) => \$gunzipped);
 	is($gunzipped, $content);
 });
 

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/9] fixes noticed while working on indexheader
@ 2024-05-19 21:55  6% Eric Wong
  2024-05-19 21:55  7% ` [PATCH 9/9] www_text: fix /$INBOX/_/text/help/raw endpoint Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2024-05-19 21:55 UTC (permalink / raw)
  To: meta

Still trying to figure out how to go about indexheader+altid
across -extindex, multiple inboxes, and lei.  But a bunch of
improvements were found to existing behavior and we shouldn't
have to worry about running out of FDs in xap_helper, anymore.

Introducing khashl.h seems like a big code import atm; but
hsearch(3) really sucks and std::map is too much alien-looking
C++ (and chained hash tables have poor locality).  The FUSE shim
will certainly be C (and not C++) and perhaps URCU (for
rculfhash) is too rare a dependency to count on, so having
khashl available would help there.

Eric Wong (9):
  config: dedupe ibx->{newsgroup}
  xap_helper: key search instances by -Q params, too
  xap_helper.h: use khashl.h instead of hsearch(3)
  xap_helper.h: use xcalloc to simplify error checking
  xap_helper.h: memoize Xapian handles with khashl
  xap_helper: expire DB handles when FD table is near full
  xap_helper: drop DB handles on EMFILE/ENFILE/etc...
  lei_saved_search: drop ->altid_map method
  www_text: fix /$INBOX/_/text/help/raw endpoint

 MANIFEST                          |   1 +
 lib/PublicInbox/Config.pm         |   4 +-
 lib/PublicInbox/ExtSearchIdx.pm   |   8 +-
 lib/PublicInbox/LeiSavedSearch.pm |   2 -
 lib/PublicInbox/Search.pm         |  16 +
 lib/PublicInbox/WwwText.pm        |   2 +-
 lib/PublicInbox/XapHelper.pm      |  48 ++-
 lib/PublicInbox/XapHelperCxx.pm   |   1 +
 lib/PublicInbox/khashl.h          | 502 ++++++++++++++++++++++++++++++
 lib/PublicInbox/xap_helper.h      | 273 +++++++++-------
 lib/PublicInbox/xh_cidx.h         |  79 +++--
 t/psgi_text.t                     |  21 +-
 t/xap_helper.t                    |  23 ++
 13 files changed, 818 insertions(+), 162 deletions(-)
 create mode 100644 lib/PublicInbox/khashl.h


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2024-05-19 21:55  6% [PATCH 0/9] fixes noticed while working on indexheader Eric Wong
2024-05-19 21:55  7% ` [PATCH 9/9] www_text: fix /$INBOX/_/text/help/raw endpoint Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).