]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/POP3.pm
pop3: advertise STLS in CAPA if appropriate
[public-inbox.git] / lib / PublicInbox / POP3.pm
index 51c2b71a560fd10e041ad8bb949e2b8c3ab6486e..ec73893c5694d6cdda85ad5d3739d4c910c21d69 100644 (file)
@@ -300,12 +300,13 @@ sub retr_cb { # called by git->cat_async via ibx_async_cat
                $hdr .= "\r\n\r\n";
                my @tmp = split(/^/m, $bdy);
                $hdr .= join('', splice(@tmp, 0, $top_nr));
+       } elsif (exists $self->{expire}) {
+               $self->{expire} .= pack('S', $off + 1);
        }
        $$bref =~ s/^\./../gms;
        $$bref .= substr($$bref, -2, 2) eq "\r\n" ? ".\r\n" : "\r\n.\r\n";
        $self->msg_more("+OK message follows\r\n");
        $self->write($bref);
-       $self->{expire} .= pack('S', $off + 1) if exists $self->{expire};
        $self->requeue;
 }
 
@@ -342,15 +343,17 @@ sub cmd_dele {
 # RFC 2449
 sub cmd_capa {
        my ($self) = @_;
+       my $STLS = !$self->{ibx} && !$self->{sock}->can('stop_SSL') &&
+                       $self->{pop3d}->{accept_tls} ? "\nSTLS\r" : '';
        $self->{expire} = ''; # "EXPIRE 0" allows clients to avoid DELE commands
-       \<<EOM;
+       <<EOM;
 +OK Capability list follows\r
 TOP\r
 USER\r
 PIPELINING\r
 UIDL\r
 EXPIRE 0\r
-RESP-CODES\r
+RESP-CODES\r$STLS
 .\r
 EOM
 }