user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
			download mbox.gz: |
* [PATCH 10/43] mbox: remove html_oneshot import
  @ 2020-07-05 23:27  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-07-05 23:27 UTC (permalink / raw)
  To: meta

It's no longer needed, we no longer show a runtime error
for zlib being missing, as zlib is a hard requirement.

Fixes: a318e758129d616b ("make zlib-related modules a hard dependency")
---
 lib/PublicInbox/Mbox.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index b46dacfdc..4c0b01edf 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -13,7 +13,6 @@ use warnings;
 use PublicInbox::MID qw/mid_escape/;
 use PublicInbox::Hval qw/to_filename/;
 use PublicInbox::Smsg;
-use PublicInbox::WwwStream qw(html_oneshot);
 use PublicInbox::Eml;
 
 sub subject_fn ($) {

^ permalink raw reply	[relevance 7%]

* [PATCH] make zlib-related modules a hard dependency
@ 2020-04-21  6:57  6% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-04-21  6:57 UTC (permalink / raw)
  To: meta

This allows us to simplify some of our existing code and make
future changes easier.

I doubt anybody goes through the trouble to have a Perl
installation without zlib support.  The zlib source code is even
bundled with Perl since 5.9.3 for systems without existing zlib
development headers and libraries.

Of course, zlib is also a requirement of git, too; and we're not
going to stop using git :)
---
 Makefile.PL                   |  5 +++++
 ci/deps.perl                  |  2 +-
 lib/PublicInbox/Mbox.pm       | 17 ++---------------
 lib/PublicInbox/NNTP.pm       | 11 ++---------
 lib/PublicInbox/WwwListing.pm | 13 ++++++-------
 script/public-inbox-nntpd     |  2 +-
 6 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/Makefile.PL b/Makefile.PL
index ab24b9cf..27bb112c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -132,6 +132,11 @@ WriteMakefile(
 		# `perl5' on FreeBSD
 		'Encode' => 0,
 
+		# libperl$PERL_VERSION + perl-modules-$PERL_VERSION
+		'Compress::Raw::Zlib' => 0,
+		'Compress::Zlib' => 0,
+		'IO::Compress::Gzip' => 0,
+
 		# Plack is needed for public-inbox-httpd and PublicInbox::WWW
 		# 'Plack' => 0,
 
diff --git a/ci/deps.perl b/ci/deps.perl
index b960089f..06b4fbe0 100755
--- a/ci/deps.perl
+++ b/ci/deps.perl
@@ -25,6 +25,7 @@ my $profiles = {
 		Email::MIME::ContentType
 		Encode
 		ExtUtils::MakeMaker
+		IO::Compress::Gzip
 		URI::Escape
 		), @test_essential ],
 
@@ -35,7 +36,6 @@ my $profiles = {
 		DBD::SQLite
 		DBI
 		Filesys::Notify::Simple
-		IO::Compress::Gzip
 		Inline::C
 		Net::Server
 		Plack
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index 9995140c..97bec5e7 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -152,8 +152,7 @@ sub thread_cb {
 
 sub thread_mbox {
 	my ($ctx, $over, $sfx) = @_;
-	eval { require PublicInbox::MboxGz };
-	return need_gzip($ctx) if $@;
+	require PublicInbox::MboxGz;
 	my $msgs = $ctx->{msgs} = $over->get_thread($ctx->{mid}, {});
 	return [404, [qw(Content-Type text/plain)], []] if !@$msgs;
 	$ctx->{prev} = $msgs->[-1];
@@ -221,8 +220,7 @@ sub results_cb {
 sub mbox_all {
 	my ($ctx, $query) = @_;
 
-	eval { require PublicInbox::MboxGz };
-	return need_gzip($ctx) if $@;
+	require PublicInbox::MboxGz;
 	return mbox_all_ids($ctx) if $query eq '';
 	my $qopts = $ctx->{qopts} = { mset => 2 };
 	my $srch = $ctx->{srch} = $ctx->{-inbox}->search or
@@ -236,15 +234,4 @@ sub mbox_all {
 	PublicInbox::MboxGz->response($ctx, \&results_cb, 'results-'.$query);
 }
 
-sub need_gzip {
-	html_oneshot($_[0], 501, \<<EOF);
-<pre>gzipped mbox not available
-
-The administrator needs to install the Compress::Raw::Zlib Perl module
-to support gzipped mboxes.
-
-<a href="../">Return to index</a></pre>
-EOF
-}
-
 1;
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index c79f198b..e9c66cd1 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -38,8 +38,7 @@ NEWNEWS\r
 LIST ACTIVE ACTIVE.TIMES NEWSGROUPS OVERVIEW.FMT\r
 HDR\r
 OVER\r
-
-my $have_deflate;
+COMPRESS DEFLATE\r
 
 sub greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
 
@@ -903,7 +902,7 @@ sub cmd_starttls ($) {
 sub cmd_compress ($$) {
 	my ($self, $alg) = @_;
 	return '503 Only DEFLATE is supported' if uc($alg) ne 'DEFLATE';
-	return r502 if $self->compressed || !$have_deflate;
+	return r502 if $self->compressed;
 	PublicInbox::NNTPdeflate->enable($self);
 	$self->requeue;
 	undef
@@ -990,10 +989,4 @@ sub busy {
 	($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now));
 }
 
-# this is an import to prevent "perl -c" from complaining about fields
-sub import {
-	$have_deflate = eval { require PublicInbox::NNTPdeflate } and
-		$CAPABILITIES .= "COMPRESS DEFLATE\r\n";
-}
-
 1;
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 42a0c0d8..38a37dda 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -14,14 +14,13 @@ use bytes (); # bytes::length
 use HTTP::Date qw(time2str);
 use Digest::SHA ();
 use File::Spec ();
+use IO::Compress::Gzip qw(gzip);
 *try_cat = \&PublicInbox::Inbox::try_cat;
 our $json;
-if (eval { require IO::Compress::Gzip }) {
-	for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) {
-		eval "require $mod" or next;
-		# ->ascii encodes non-ASCII to "\uXXXX"
-		$json = $mod->new->ascii(1) and last;
-	}
+for my $mod (qw(JSON::MaybeXS JSON JSON::PP)) {
+	eval "require $mod" or next;
+	# ->ascii encodes non-ASCII to "\uXXXX"
+	$json = $mod->new->ascii(1) and last;
 }
 
 sub list_all_i {
@@ -220,7 +219,7 @@ sub js ($$) {
 		$repo->{reference} = $abs2urlpath->{$abs};
 	}
 	my $out;
-	IO::Compress::Gzip::gzip(\($json->encode($manifest)) => \$out);
+	gzip(\($json->encode($manifest)) => \$out);
 	$manifest = undef;
 	[ 200, [ qw(Content-Type application/gzip),
 		 'Last-Modified', time2str($mtime),
diff --git a/script/public-inbox-nntpd b/script/public-inbox-nntpd
index ce42de2d..f42db6fe 100755
--- a/script/public-inbox-nntpd
+++ b/script/public-inbox-nntpd
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 use PublicInbox::Daemon;
-use PublicInbox::NNTP; # need to call import
+use PublicInbox::NNTPdeflate; # loads PublicInbox::NNTP
 use PublicInbox::NNTPD;
 my $nntpd = PublicInbox::NNTPD->new;
 PublicInbox::Daemon::run('0.0.0.0:119',

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse
2020-04-21  6:57  6% [PATCH] make zlib-related modules a hard dependency Eric Wong
2020-07-05 23:27     [PATCH 00/43] www: async git cat-file w/ -httpd Eric Wong
2020-07-05 23:27  7% ` [PATCH 10/43] mbox: remove html_oneshot import Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git