about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-19 02:03:38 +0000
committerEric Wong <e@80x24.org>2015-09-19 04:18:43 +0000
commit2e8669171f148ecfd410cca543f8794d0f3d69a5 (patch)
tree0953f60d716047119fc3c9576d3f88e4eea62e44 /lib
parent56bb0c9ce4ddbb953ff68b667b220cf6eacc0b20 (diff)
downloadpublic-inbox-2e8669171f148ecfd410cca543f8794d0f3d69a5.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/NNTP.pm17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 3ded0de4..01039ba1 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";
 }