From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 233FF1FBDD for ; Wed, 10 Jun 2020 07:05:23 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 21/82] imap: support the CLOSE command Date: Wed, 10 Jun 2020 07:04:18 +0000 Message-Id: <20200610070519.18252-22-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It seems worthless to support CLOSE for read-only inboxes, but mutt sends it, so don't return a BAD error with proper use. --- lib/PublicInbox/IMAP.pm | 6 ++++++ t/imapd.t | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 54c616eee2f..0852ffab868 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -121,6 +121,12 @@ sub cmd_login ($$$$) { login_success($self, $tag); } +sub cmd_close ($$) { + my ($self, $tag) = @_; + delete $self->{ibx} ? "$tag OK Close done\r\n" + : "$tag BAD No mailbox\r\n"; +} + sub cmd_logout ($$) { my ($self, $tag) = @_; delete $self->{logged_in}; diff --git a/t/imapd.t b/t/imapd.t index 1ec0d5c370f..8172a91923d 100644 --- a/t/imapd.t +++ b/t/imapd.t @@ -327,7 +327,8 @@ $r2 = $mic->fetch_hash(2, 'BODY.PEEK[HEADER.FIELDS (message-id)]') is($r2->{2}->{'BODY[HEADER.FIELDS (MESSAGE-ID)]'}, 'Message-ID: <20200418222508.GA13918@dcvr>'."\r\n\r\n", 'BODY.PEEK[HEADER.FIELDS ...] drops .PEEK'); - +ok($mic->close, 'CLOSE works'); +ok(!$mic->close, 'CLOSE not idempotent'); ok($mic->logout, 'logged out'); $td->kill;