From 1d236e649df10515bf042fa2283eef509648d9c9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Sep 2015 21:00:25 +0000 Subject: nntp: implement OVER/XOVER summary in search document The document data of a search message already contains a good chunk of the information needed to respond to OVER/XOVER commands quickly. Expand on that and use the document data to implement OVER/XOVER quickly. This adds a dependency on Xapian being available for nntpd usage, but is probably alright since nntpd is esoteric enough that anybody willing to run nntpd will also want search functionality offered by Xapian. This also speeds up XHDR/HDR with the To: and Cc: headers and :bytes/:lines article metadata used by some clients for header displays and marking messages as read/unread. --- t/nntpd.t | 25 ++++++++++++++++++++++++- t/search.t | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/nntpd.t b/t/nntpd.t index ea2c3df8..e4c0244d 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -151,7 +151,30 @@ EOF '', '', '202', - '1' ] }, "XOVER works"); + '1' ] }, "XOVER range works"); + + is_deeply($n->xover('1'), { + '1' => ['hihi', + 'Me ', + 'Thu, 01 Jan 1970 06:06:06 +0000', + '', + '', + '202', + '1' ] }, "XOVER by article works"); + + { + syswrite($s, "OVER $mid\r\n"); + $buf = ''; + do { + sysread($s, $buf, 4096, length($buf)); + } until ($buf =~ /^[^2]../ || $buf =~ /\r\n\.\r\n\z/); + my @r = split("\r\n", $buf); + like($r[0], qr/^224 /, 'got 224 response for OVER'); + is($r[1], "0\thihi\tMe \t" . + "Thu, 01 Jan 1970 06:06:06 +0000\t" . + "$mid\t\t202\t1", 'OVER by Message-ID works'); + is($r[2], '.', 'correctly terminated response'); + } ok(kill('TERM', $pid), 'killed nntpd'); $pid = undef; diff --git a/t/search.t b/t/search.t index b1c77289..cd7048fd 100644 --- a/t/search.t +++ b/t/search.t @@ -285,7 +285,7 @@ sub filter_mids { ok($doc_id > 0, "doc_id defined with circular reference"); my $smsg = $rw->lookup_message('circle@a'); $smsg->ensure_metadata; - is($smsg->references_sorted, '', "no references created"); + is($smsg->references, '', "no references created"); } done_testing(); -- cgit v1.2.3-24-ge0c7