]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAtomStream.pm
run update-copyrights from gnulib for 2019
[public-inbox.git] / lib / PublicInbox / WwwAtomStream.pm
index bb574a7cd0c0270687fc1350c3e51f70a776e3df..fd861d45b549586962aed303760322a2b07887aa 100644 (file)
@@ -1,7 +1,10 @@
-# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Atom body stream for which yields getline+close methods
+# public-inbox-httpd favors "getline" response bodies to take a
+# "pull"-based approach to feeding slow clients (as opposed to a
+# more common "push" model)
 package PublicInbox::WwwAtomStream;
 use strict;
 use warnings;
@@ -33,8 +36,8 @@ sub response {
 sub getline {
        my ($self) = @_;
        if (my $middle = $self->{cb}) {
-               my $mime = $middle->();
-               return feed_entry($self, $mime) if $mime;
+               my $smsg = $middle->();
+               return feed_entry($self, $smsg) if $smsg;
        }
        delete $self->{cb} ? '</feed>' : undef;
 }
@@ -92,10 +95,11 @@ sub mid2uuid ($) {
 
 # returns undef or string
 sub feed_entry {
-       my ($self, $mime) = @_;
+       my ($self, $smsg) = @_;
        my $ctx = $self->{ctx};
+       my $mime = $smsg->{mime};
        my $hdr = $mime->header_obj;
-       my $mid = mid_clean($hdr->header_raw('Message-ID'));
+       my $mid = $smsg->mid;
        my $irt = PublicInbox::View::in_reply_to($hdr);
        my $uuid = mid2uuid($mid);
        my $base = $ctx->{feed_base_url};
@@ -133,7 +137,7 @@ sub feed_entry {
                qq{<content\ntype="xhtml">} .
                qq{<div\nxmlns="http://www.w3.org/1999/xhtml">} .
                qq(<pre\nstyle="white-space:pre-wrap">) .
-               PublicInbox::View::multipart_text_as_html($mime, $href) .
+               PublicInbox::View::multipart_text_as_html($mime, $href, $ctx) .
                '</pre></div></content></entry>';
 }