]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: fix ARTICLE/HEAD/BODY/STAT
authorEric Wong <e@80x24.org>
Sat, 19 Sep 2015 02:03:38 +0000 (02:03 +0000)
committerEric Wong <e@80x24.org>
Sat, 19 Sep 2015 04:18:43 +0000 (04:18 +0000)
Article number is optional, but we need to update the
article number of the client connection if it was specified
(but not if it was given a Message-ID) as stipulated by
RFC 977

lib/PublicInbox/NNTP.pm

index 3ded0de44a60bb9b998c5c352f7b2e2aca4e9f1d..01039ba1c95942af996687c7c0b808b1e53b27b3 100644 (file)
@@ -388,41 +388,50 @@ sub header_str ($) {
        $h->as_string
 }
 
-sub cmd_article ($$) {
+sub set_art {
+       my ($self, $art) = @_;
+       $self->{article} = $art if defined $art && $art =~ /\A\d+\z/;
+}
+
+sub cmd_article ($;$) {
        my ($self, $art) = @_;
        my $r = $self->art_lookup($art, 1);
        return $r unless ref $r;
        my ($n, $mid, $s) = @$r;
+       set_art($self, $art);
        more($self, "220 $n <$mid> article retrieved - head and body follow");
        do_more($self, header_str($s));
        do_more($self, "\r\n");
        simple_body_write($self, $s);
 }
 
-sub cmd_head ($$) {
+sub cmd_head ($;$) {
        my ($self, $art) = @_;
        my $r = $self->art_lookup($art, 2);
        return $r unless ref $r;
        my ($n, $mid, $s) = @$r;
+       set_art($self, $art);
        more($self, "221 $n <$mid> article retrieved - head follows");
        do_more($self, header_str($s));
        '.'
 }
 
-sub cmd_body ($$) {
+sub cmd_body ($;$) {
        my ($self, $art) = @_;
        my $r = $self->art_lookup($art, 0);
        return $r unless ref $r;
        my ($n, $mid, $s) = @$r;
+       set_art($self, $art);
        more($self, "222 $n <$mid> article retrieved - body follows");
        simple_body_write($self, $s);
 }
 
-sub cmd_stat ($$) {
+sub cmd_stat ($;$) {
        my ($self, $art) = @_;
        my $r = $self->art_lookup($art, 0);
        return $r unless ref $r;
        my ($n, $mid, undef) = @$r;
+       set_art($self, $art);
        "223 $n <$mid> article retrieved - request text separately";
 }