diff options
author | Eric Wong <e@80x24.org> | 2015-09-19 02:03:38 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-09-19 04:18:43 +0000 |
commit | 2e8669171f148ecfd410cca543f8794d0f3d69a5 (patch) | |
tree | 0953f60d716047119fc3c9576d3f88e4eea62e44 /lib/PublicInbox/NNTP.pm | |
parent | 56bb0c9ce4ddbb953ff68b667b220cf6eacc0b20 (diff) | |
download | public-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/PublicInbox/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 17 |
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"; } |