* [PATCH 1/3] examples/public-inbox.psgi: update with middlewares
@ 2015-09-03 8:32 Eric Wong
2015-09-03 8:32 ` [PATCH 2/3] feed: use application/atom+xml for Content-Type Eric Wong
2015-09-03 8:32 ` [PATCH 3/3] www: move fallback after legacy matches Eric Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2015-09-03 8:32 UTC (permalink / raw)
To: meta
HTML, text, and probably Atom feeds should be compressed.
---
examples/public-inbox.psgi | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/examples/public-inbox.psgi b/examples/public-inbox.psgi
index 8eb67eb..04f3329 100644
--- a/examples/public-inbox.psgi
+++ b/examples/public-inbox.psgi
@@ -5,9 +5,17 @@
# Usage: plackup [OPTIONS] /path/to/this/file
use strict;
use warnings;
-require PublicInbox::WWW;
-require Plack::Request;
-sub {
- my $req = Plack::Request->new(@_);
- PublicInbox::WWW::run($req, $req->method);
-};
+use PublicInbox::WWW;
+PublicInbox::WWW->preload;
+use Plack::Request;
+use Plack::Builder;
+builder {
+ enable "Deflater",
+ content_type => [ 'text/html', 'text/plain',
+ 'application/atom+xml' ];
+ enable "Head";
+ sub {
+ my $req = Plack::Request->new(@_);
+ PublicInbox::WWW::run($req, $req->method);
+ }
+}
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] feed: use application/atom+xml for Content-Type
2015-09-03 8:32 [PATCH 1/3] examples/public-inbox.psgi: update with middlewares Eric Wong
@ 2015-09-03 8:32 ` Eric Wong
2015-09-03 8:32 ` [PATCH 3/3] www: move fallback after legacy matches Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2015-09-03 8:32 UTC (permalink / raw)
To: meta
This is the correct Content-Type for Atom feeds, especially
since we updated to use ".atom" as the suffix.
---
lib/PublicInbox/Feed.pm | 4 ++--
t/cgi.t | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 2284f23..75fecf5 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -60,7 +60,7 @@ sub atom_header {
sub emit_atom {
my ($cb, $ctx) = @_;
- my $fh = $cb->([ 200, ['Content-Type' => 'application/xml']]);
+ my $fh = $cb->([ 200, ['Content-Type' => 'application/atom+xml']]);
my $max = $ctx->{max} || MAX_PER_PAGE;
my $feed_opts = get_feedopts($ctx);
my $x = atom_header($feed_opts);
@@ -97,7 +97,7 @@ sub emit_atom_thread {
my ($cb, $ctx) = @_;
my $res = $ctx->{srch}->get_thread($ctx->{mid});
return _no_thread($cb) unless $res->{total};
- my $fh = $cb->([200, ['Content-Type' => 'application/xml']]);
+ my $fh = $cb->([200, ['Content-Type' => 'application/atom+xml']]);
my $feed_opts = get_feedopts($ctx);
my $html_url = $feed_opts->{atomurl} = $ctx->{self_url};
diff --git a/t/cgi.t b/t/cgi.t
index b0af8ae..7f72eaa 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -206,7 +206,7 @@ EOF
$path = "/test/blahblah%40example.com/t.atom";
$res = cgi_run($path);
like($res->{head}, qr/^Status: 200 /, "atom returned 200");
- like($res->{head}, qr!^Content-Type: application/xml!m,
+ like($res->{head}, qr!^Content-Type: application/atom\+xml!m,
"search returned atom");
my $p = XML::Feed->parse(\($res->{body}));
is($p->format, "Atom", "parsed atom feed");
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] www: move fallback after legacy matches
2015-09-03 8:32 [PATCH 1/3] examples/public-inbox.psgi: update with middlewares Eric Wong
2015-09-03 8:32 ` [PATCH 2/3] feed: use application/atom+xml for Content-Type Eric Wong
@ 2015-09-03 8:32 ` Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2015-09-03 8:32 UTC (permalink / raw)
To: meta
We do not want to get legacy URLs swallowed up by our workaround
for weird and wonky servers that attempt to unescape PATH_INFO
before the app sees it.
---
lib/PublicInbox/WWW.pm | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 6eebf62..e8b35cb 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -42,11 +42,6 @@ sub run {
} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/$END_RE\z!o) {
msg_page($ctx, $1, $2, $3);
- # some Message-IDs have slashes in them and the HTTP server
- # may try to be clever and unescape them :<
- } elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/$END_RE\z!o) {
- msg_page($ctx, $1, $2, $3);
-
# convenience redirects order matters
} elsif ($path_info =~ m!$LISTNAME_RE/([^/]{2,})\z!o) {
r301($ctx, $1, $2);
@@ -354,6 +349,11 @@ sub legacy_redirects {
} elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\z!o) {
r301($ctx, $1, $2, 'f/');
+ # some Message-IDs have slashes in them and the HTTP server
+ # may try to be clever and unescape them :<
+ } elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/$END_RE\z!o) {
+ msg_page($ctx, $1, $2, $3);
+
} else {
r404();
}
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-03 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-03 8:32 [PATCH 1/3] examples/public-inbox.psgi: update with middlewares Eric Wong
2015-09-03 8:32 ` [PATCH 2/3] feed: use application/atom+xml for Content-Type Eric Wong
2015-09-03 8:32 ` [PATCH 3/3] www: move fallback after legacy matches Eric Wong
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).