From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 28DFE63386D for ; Sat, 19 Sep 2015 02:03:47 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/12] nntp: fix ARTICLE/HEAD/BODY/STAT Date: Sat, 19 Sep 2015 02:03:38 +0000 Message-Id: <20150919020340.6484-11-e@80x24.org> In-Reply-To: <20150919020340.6484-1-e@80x24.org> References: <20150919020340.6484-1-e@80x24.org> List-Id: 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 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 3ded0de..01039ba 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -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"; } -- EW