<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc private="Dovecot" ?>

<rfc category="std" docName="draft-bettini-imap-inprogress-00"
     ipr="trust200902" consensus="true" submissionType="IETF"
     xml:lang="en" version="3" xmlns:xi="http://www.w3.org/2001/XInclude">

<front><!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<title abbrev="IMAP4 Response Code for Command Progress">
IMAP4 Response Code for Command Progress Notifications.
</title>
<seriesInfo name="Internet-Draft" value="draft-spec-bettini-imap-inprogress"/>

<author fullname="Marco Bettini" initials="M." surname="Bettini">
	<organization>Open-Xchange Oy</organization>
  <address>
    <postal>
      <street>Lars Sonckin Kaari 12</street>
      <code>02600</code>
      <city>Espoo</city>
      <country>Finland</country>
    </postal>
    <email>marco.bettini@open-xchange.com</email>
  </address>
</author>

<date/>

<area>General</area>
<keyword>IMAP</keyword>
<keyword>response code</keyword>

<abstract>
<t>
This document defines a new IMAP untagged response code, "INPROGRESS",
that serves as a keepalive for the client and, optionally, provides
numeric progress status indication.
</t>
</abstract>

</front><!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<middle><!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<section title="Introduction">
<t>
Internet Message Access Protocol (IMAP) <xref target="RFC9051"/> commands
can require a considerable amount of time to be completed by the server.
In these cases, the client has no information about the progress of the
commands. Also, some clients may trigger timeouts if the server doesn't
communicate within a certain time interval. While this is already possible
with a generic untagged response, like "* OK Still working", this does
not provide a standardized way to provide command status completion
information to the client, which could be used to inform the client user
of long-running actions.
</t>
<t>
This document extends the Internet Message Access Protocol (IMAP)
<xref target="RFC9051"/> with a new "INPROGRESS" response code
<xref target="RFC5530"/>. The new response code provides consistent
means for a client to receive progress updates on command completion
status.
</t>
</section>

<section title="Conventions Used in This Document">
<t>
"Conventions" are basic principles or procedures. Document conventions are
noted in this section.
</t>
<t>
The key words
"<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>",
"<bcp14>REQUIRED</bcp14>",
"<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>",
"<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>",
"<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>"
in this document are to be interpreted as described in BCP 14
<xref target="RFC2119"/> <xref target="RFC8174"/>
when, and only when, they appear in all capitals, as shown here.
</t>
<t>
The word "can" (not "may") is used to refer to a possible
circumstance or situation, as opposed to an optional facility of the
protocol.
</t>
<t>
Conventions for notations are as in <xref target="RFC9051"/> and
<xref target="RFC5530"/>.
</t>
<t>
In examples, "C:" and "S:" indicate lines sent by the client and
server, respectively. Note that each line includes the terminating CRLF.
</t>
</section>

<section title="The &quot;INPROGRESS&quot; Response Code">
<t>
The "INPROGRESS" Response Code <bcp14>MAY</bcp14> be sent by the server
to update the client on the progress of the execution of client's commands,
or simply to prevent the client from timing out and terminating the
connection. If the server elects to send updates, it <bcp14>SHOULD</bcp14>
do every 10-15 seconds.
</t>
<t>
The response code is meant to appear embedded inside an
untagged OK reply. The response code <bcp14>MUST NOT</bcp14> appear in a
tagged response (as that implies the command has completed and no further
progress update is needed).
</t>

<t>
The response code <bcp14>MAY</bcp14> embed a list of details, composed
in order of:
</t>
<ol>
<li><bcp14>OPTIONAL</bcp14> the cmd-tag <xref target="RFC9051"/> that
    originated the long running command,</li>
<li><bcp14>OPTIONAL</bcp14> a number indicating the PROGRESS,</li>
<li><bcp14>OPTIONAL</bcp14> a number indicating the GOAL. This is the
    number that PROGRESS is expected to reach at the completion of the
    command (if known).</li>
</ol>
<t>
If a detail is not available, it <bcp14>MUST</bcp14> be replaced with NIL.
</t>
<t>
The server can provide the progress notifications details with different
degrees of completeness:
</t>
<sourcecode>
- bare keepalive
  * OK [INPROGRESS] Hang in there..
- keepalive with indication of the command tag
  * OK [INPROGRESS ("tag" NIL NIL)] Hang in there..
- progress indication with unknown total (goal)
  * OK [INPROGRESS ("tag" 175 NIL)] Processed 175 items so far
- progress indication with the indication of the goal
  * OK [INPROGRESS ("tag" 175 1000)] Processed 17% of the items
</sourcecode>
<t>
Example:
</t>
<sourcecode>
  C: 001 search text very-long-to-complete
  ... time passes ...
  S: * OK [INPROGRESS ("001" 454 1000)] Processed 45% of the items
  ... time passes ...
  S: * OK [INPROGRESS ("001" 999 1000)] Processed 99% of the items
  ... time passes, but less than the threshold ...
  S: [...] actual results for the command
  S: 001 OK done
</sourcecode>

<t>
If all the details are NIL, the whole details section <bcp14>MAY</bcp14>
be omitted, i.e.:
</t>
<sourcecode>
* OK [INPROGRESS (NIL NIL NIL)] Working on it
</sourcecode>
<t>
can be replaced by:
</t>
<sourcecode>
* OK [INPROGRESS] Working on it
</sourcecode>

<t>
The cmd-tag detail <bcp14>MUST NOT</bcp14> contain "]". If that is the
case, cmd-tag <bcp14>MUST</bcp14> be replaced by NIL.
</t>
<t>
The GOAL number <bcp14>MUST</bcp14> be non-zero when provided, and it
<bcp14>SHOULD NOT</bcp14> change between successive notifications for
the same command (i.e. for the same cmd-tag).
</t>
<t>
PROGRESS and GOAL <bcp14>SHOULD</bcp14> be counts of the kind of item
being processed - in most cases, message counts - OR, if that is not
possible, percentages (progress varies from 0 to 99 and goal stays fixed
at 100).
</t>
<t>
The command is completed when PROGRESS equals GOAL. In this case the the
server <bcp14>SHOULD NOT</bcp14> send a progress notification but just
the proper command completion. If the command isn't completed yet,
PROGRESS <bcp14>MUST</bcp14> be strictly less than GOAL.
</t>
</section>

<section title="Formal Syntax">
<t>
The following syntax specification uses the Augmented Backus-Naur Form
(ABNF) <xref target="RFC5234"/> notation. Elements not defined here can
be found in the formal syntax of the ABNF <xref target="RFC5234"/>, IMAP
<xref target="RFC9051"/> and IMAP ABNF extension <xref target="RFC4466"/>
specifications.
</t>
<t>
Except as noted otherwise, all alphabetic characters are case insensitive.
The use of uppercase or lowercase characters to define token strings is
for editorial clarity only. Implementations <bcp14>MUST</bcp14> accept
these strings in a case-insensitive fashion.
</t>
<sourcecode>
resp-text-code =/ "INPROGRESS" [ SP "(" quoted / nil
                                     SP number / nil
                                     SP number / nil ")" ]
</sourcecode>
</section>

<section title="Security Considerations">
<t>
The details of response code are not expected disclose to the client any
information that isn't already provided at the command completion. Also,
the details are not expected to reveal any significant insight about the
load of the server, which in case could anyway be inferred by the total
completion time of the command.
</t>
</section>

<section title="IANA Considerations">
<t>
   IANA is requested to add "INPROGRESS" to the "IMAP Response Codes" registry
   located at &lt;https://www.iana.org/assignments/imap-response-codes&gt;
   with a reference to this document.
</t>
</section>

</middle><!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<back><!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<references title="Normative References">
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml"/>
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.4466.xml"/>
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5234.xml"/>
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.5530.xml"/>
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml"/>
  <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.9051.xml"/>
</references>

<!--<references title="Informative References">

</references> -->
</back><!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

</rfc>
