1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
|
<pre>Network Working Group A. Melnikov
Request for Comments: 4551 Isode Ltd.
Updates: <a href="./rfc3501">3501</a> S. Hole
Category: Standards Track ACI WorldWide/MessagingDirect
June 2006
<span class="h1">IMAP Extension for Conditional STORE Operation</span>
<span class="h1">or Quick Flag Changes Resynchronization</span>
Status of This Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2006).
Abstract
Often, multiple IMAP (<a href="./rfc3501">RFC 3501</a>) clients need to coordinate changes to
a common IMAP mailbox. Examples include different clients working on
behalf of the same user, and multiple users accessing shared
mailboxes. These clients need a mechanism to synchronize state
changes for messages within the mailbox. They must be able to
guarantee that only one client can change message state (e.g.,
message flags) at any time. An example of such an application is use
of an IMAP mailbox as a message queue with multiple dequeueing
clients.
The Conditional Store facility provides a protected update mechanism
for message state information that can detect and resolve conflicts
between multiple writing mail clients.
The Conditional Store facility also allows a client to quickly
resynchronize mailbox flag changes.
This document defines an extension to IMAP (<a href="./rfc3501">RFC 3501</a>).
<span class="grey">Melnikov & Hole Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Table of Contents
<a href="#section-1">1</a>. Introduction and Overview ................................. <a href="#page-3">3</a>
<a href="#section-2">2</a>. Conventions Used in This Document ......................... <a href="#page-5">5</a>
<a href="#section-3">3</a>. IMAP Protocol Changes ..................................... <a href="#page-6">6</a>
<a href="#section-3.1">3.1</a>. New OK untagged responses for SELECT and EXAMINE ......... <a href="#page-6">6</a>
<a href="#section-3.1.1">3.1.1</a>. HIGHESTMODSEQ response code ............................ <a href="#page-6">6</a>
<a href="#section-3.1.2">3.1.2</a>. NOMODSEQ response code ................................. <a href="#page-7">7</a>
<a href="#section-3.2">3.2</a>. STORE and UID STORE Commands ............................. <a href="#page-7">7</a>
<a href="#section-3.3">3.3</a> FETCH and UID FETCH Commands ..............................<a href="#page-13">13</a>
<a href="#section-3.3.1">3.3.1</a>. CHANGEDSINCE FETCH modifier ............................<a href="#page-13">13</a>
<a href="#section-3.3.2">3.3.2</a>. MODSEQ message data item in FETCH Command ..............<a href="#page-14">14</a>
<a href="#section-3.4">3.4</a>. MODSEQ search criterion in SEARCH ........................<a href="#page-16">16</a>
<a href="#section-3.5">3.5</a>. Modified SEARCH untagged response ........................<a href="#page-17">17</a>
<a href="#section-3.6">3.6</a>. HIGHESTMODSEQ status data items ..........................<a href="#page-17">17</a>
<a href="#section-3.7">3.7</a>. CONDSTORE parameter to SELECT and EXAMINE ................<a href="#page-18">18</a>
<a href="#section-3.8">3.8</a>. Additional quality of implementation issues ..............<a href="#page-18">18</a>
<a href="#section-4">4</a>. Formal Syntax .............................................<a href="#page-19">19</a>
<a href="#section-5">5</a>. Server implementation considerations ......................<a href="#page-21">21</a>
<a href="#section-6">6</a>. Security Considerations ...................................<a href="#page-22">22</a>
<a href="#section-7">7</a>. IANA Considerations .......................................<a href="#page-22">22</a>
<a href="#section-8">8</a>. References ................................................<a href="#page-23">23</a>
<a href="#section-8.1">8.1</a>. Normative References .....................................<a href="#page-23">23</a>
<a href="#section-8.2">8.2</a>. Informative References ...................................<a href="#page-23">23</a>
<a href="#section-9">9</a>. Acknowledgements ..........................................<a href="#page-23">23</a>
<span class="grey">Melnikov & Hole Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction and Overview</span>
The Conditional STORE extension is present in any IMAP4
implementation that returns "CONDSTORE" as one of the supported
capabilities in the CAPABILITY command response.
An IMAP server that supports this extension MUST associate a positive
unsigned 64-bit value called a modification sequence (mod-sequence)
with every IMAP message. This is an opaque value updated by the
server whenever a metadata item is modified. The server MUST
guarantee that each STORE command performed on the same mailbox
(including simultaneous stores to different metadata items from
different connections) will get a different mod-sequence value.
Also, for any two successful STORE operations performed in the same
session on the same mailbox, the mod-sequence of the second completed
operation MUST be greater than the mod-sequence of the first
completed. Note that the latter rule disallows the use of the system
clock as a mod-sequence, because if system time changes (e.g., an NTP
[<a href="#ref-NTP" title=""Network Time Protocol (Version 3) Specification, Implementation and Analysis"">NTP</a>] client adjusting the time), the next generated value might be
less than the previous one.
Mod-sequences allow a client that supports the CONDSTORE extension to
determine if a message metadata has changed since some known moment.
Whenever the state of a flag changes (i.e., the flag is added where
previously it wasn't set, or the flag is removed and before it was
set) the value of the modification sequence for the message MUST be
updated. Adding the flag when it is already present or removing when
it is not present SHOULD NOT change the mod-sequence.
When a message is appended to a mailbox (via the IMAP APPEND command,
COPY to the mailbox, or using an external mechanism) the server
generates a new modification sequence that is higher than the highest
modification sequence of all messages in the mailbox and assigns it
to the appended message.
The server MAY store separate (per-message) modification sequence
values for different metadata items. If the server does so, per-
message mod-sequence is the highest mod-sequence of all metadata
items for the specified message.
The server that supports this extension is not required to be able to
store mod-sequences for every available mailbox. <a href="#section-3.1.2">Section 3.1.2</a>
describes how the server may act if a particular mailbox doesn't
support the persistent storage of mod-sequences.
<span class="grey">Melnikov & Hole Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
This extension makes the following changes to the IMAP4 protocol:
a) adds UNCHANGEDSINCE STORE modifier.
b) adds the MODIFIED response code which should be used with an OK
response to the STORE command. (It can also be used in a NO
response.)
c) adds a new MODSEQ message data item for use with the FETCH
command.
d) adds CHANGEDSINCE FETCH modifier.
e) adds a new MODSEQ search criterion.
f) extends the syntax of untagged SEARCH responses to include
mod-sequence.
g) adds new OK untagged responses for the SELECT and EXAMINE
commands.
h) defines an additional parameter to SELECT/EXAMINE commands.
i) adds the HIGHESTMODSEQ status data item to the STATUS command.
A client supporting CONDSTORE extension indicates its willingness to
receive mod-sequence updates in all untagged FETCH responses by
issuing:
- a SELECT or EXAMINE command with the CONDSTORE parameter,
- a STATUS (HIGHESTMODSEQ) command,
- a FETCH or SEARCH command that includes the MODSEQ message data
item,
- a FETCH command with the CHANGEDSINCE modifier, or
- a STORE command with the UNCHANGEDSINCE modifier.
The server MUST include mod-sequence data in all subsequent untagged
FETCH responses (until the connection is closed), whether they were
caused by a regular STORE, a STORE with UNCHANGEDSINCE modifier, or
an external agent.
This document uses the term "CONDSTORE-aware client" to refer to a
client that announces its willingness to receive mod-sequence updates
as described above. The term "CONDSTORE enabling command" will refer
any of the commands listed above. A future extension to this
document may extend the list of CONDSTORE enabling commands. A first
CONDSTORE enabling command executed in the session MUST cause the
<span class="grey">Melnikov & Hole Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
server to return HIGHESTMODSEQ (<a href="#section-3.1.1">Section 3.1.1</a>) unless the server has
sent NOMODSEQ (<a href="#section-3.1.2">Section 3.1.2</a>) response code when the currently
selected mailbox was selected.
The rest of this document describes the protocol changes more
rigorously.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Conventions Used in This Document</span>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <a href="./rfc2119">RFC 2119</a> [<a href="#ref-KEYWORDS" title=""Key words for use in RFCs to Indicate Requirement Levels"">KEYWORDS</a>].
In examples, lines beginning with "S:" are sent by the IMAP server,
and lines beginning with "C:" are sent by the client. Line breaks
may appear in example commands solely for editorial clarity; when
present in the actual message, they are represented by "CRLF".
Formal syntax is defined using ABNF [<a href="#ref-ABNF" title=""Augmented BNF for Syntax Specifications: ABNF"">ABNF</a>].
The term "metadata" or "metadata item" is used throughout this
document. It refers to any system or user-defined keyword. Future
documents may extend "metadata" to include other dynamic message
data.
Some IMAP mailboxes are private, accessible only to the owning user.
Other mailboxes are not, either because the owner has set an Access
Control List [<a href="#ref-ACL" title=""IMAP4 Access Control List (ACL) Extension"">ACL</a>] that permits access by other users, or because it
is a shared mailbox. Let's call a metadata item "shared" for the
mailbox if any changes to the metadata items are persistent and
visible to all other users accessing the mailbox. Otherwise, the
metadata item is called "private". Note that private metadata items
are still visible to all sessions accessing the mailbox as the same
user. Also note that different mailboxes may have different metadata
items as shared.
See <a href="#section-1">Section 1</a> for the definition of a "CONDSTORE-aware client" and a
"CONDSTORE enabling command".
<span class="grey">Melnikov & Hole Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. IMAP Protocol Changes</span>
<span class="h3"><a class="selflink" id="section-3.1" href="#section-3.1">3.1</a>. New OK Untagged Responses for SELECT and EXAMINE</span>
This document adds two new response codes, HIGHESTMODSEQ and
NOMODSEQ. One of those response codes MUST be returned in the OK
untagged response for a successful SELECT/EXAMINE command.
When opening a mailbox, the server must check if the mailbox supports
the persistent storage of mod-sequences. If the mailbox supports the
persistent storage of mod-sequences and the mailbox open operation
succeeds, the server MUST send the OK untagged response including
HIGHESTMODSEQ response code. If the persistent storage for the
mailbox is not supported, the server MUST send the OK untagged
response including NOMODSEQ response code instead.
<span class="h4"><a class="selflink" id="section-3.1.1" href="#section-3.1.1">3.1.1</a>. HIGHESTMODSEQ Response Code</span>
This document adds a new response code that is returned in the OK
untagged response for the SELECT and EXAMINE commands. A server
supporting the persistent storage of mod-sequences for the mailbox
MUST send the OK untagged response including HIGHESTMODSEQ response
code with every successful SELECT or EXAMINE command:
OK [HIGHESTMODSEQ <mod-sequence-value>]
where <mod-sequence-value> is the highest mod-sequence value of
all messages in the mailbox. When the server changes UIDVALIDITY
for a mailbox, it doesn't have to keep the same HIGHESTMODSEQ for
the mailbox.
A disconnected client can use the value of HIGHESTMODSEQ to check if
it has to refetch metadata from the server. If the UIDVALIDITY value
has changed for the selected mailbox, the client MUST delete the
cached value of HIGHESTMODSEQ. If UIDVALIDITY for the mailbox is the
same, and if the HIGHESTMODSEQ value stored in the client's cache is
less than the value returned by the server, then some metadata items
on the server have changed since the last synchronization, and the
client needs to update its cache. The client MAY use SEARCH MODSEQ
(<a href="#section-3.4">Section 3.4</a>) to find out exactly which metadata items have changed.
Alternatively, the client MAY issue FETCH with the CHANGEDSINCE
modifier (<a href="#section-3.3.1">Section 3.3.1</a>) in order to fetch data for all messages that
have metadata items changed since some known modification sequence.
Example 1:
C: A142 SELECT INBOX
S: * 172 EXISTS
<span class="grey">Melnikov & Hole Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [HIGHESTMODSEQ 715194045007]
S: A142 OK [READ-WRITE] SELECT completed
<span class="h4"><a class="selflink" id="section-3.1.2" href="#section-3.1.2">3.1.2</a>. NOMODSEQ Response Code</span>
A server that doesn't support the persistent storage of mod-sequences
for the mailbox MUST send the OK untagged response including NOMODSEQ
response code with every successful SELECT or EXAMINE command. A
server that returned NOMODSEQ response code for a mailbox, which
subsequently receives one of the following commands while the mailbox
is selected:
- a FETCH command with the CHANGEDSINCE modifier,
- a FETCH or SEARCH command that includes the MODSEQ message data
item, or
- a STORE command with the UNCHANGEDSINCE modifier
MUST reject any such command with the tagged BAD response.
Example 2:
C: A142 SELECT INBOX
S: * 172 EXISTS
S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support
modsequences
S: A142 OK [READ-WRITE] SELECT completed
<span class="h3"><a class="selflink" id="section-3.2" href="#section-3.2">3.2</a>. STORE and UID STORE Commands</span>
This document defines the following STORE modifier (see Section 2.5
of [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>]):
UNCHANGEDSINCE <mod-sequence>
For each message specified in the message set, the server performs
the following. If the mod-sequence of any metadata item of the
<span class="grey">Melnikov & Hole Standards Track [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
message is equal or less than the specified UNCHANGEDSINCE value,
then the requested operation (as described by the message data
item) is performed. If the operation is successful, the server
MUST update the mod-sequence attribute of the message. An
untagged FETCH response MUST be sent, even if the .SILENT suffix
is specified, and the response MUST include the MODSEQ message
data item. This is required to update the client's cache with the
correct mod-sequence values. See <a href="#section-3.3.2">Section 3.3.2</a> for more details.
However, if the mod-sequence of any metadata item of the message
is greater than the specified UNCHANGEDSINCE value, then the
requested operation MUST NOT be performed. In this case, the
mod-sequence attribute of the message is not updated, and the
message number (or unique identifier in the case of the UID STORE
command) is added to the list of messages that failed the
UNCHANGESINCE test.
When the server finished performing the operation on all the
messages in the message set, it checks for a non-empty list of
messages that failed the UNCHANGESINCE test. If this list is
non-empty, the server MUST return in the tagged response a
MODIFIED response code. The MODIFIED response code includes the
message set (for STORE) or set of UIDs (for UID STORE) of all
messages that failed the UNCHANGESINCE test.
Example 3:
All messages pass the UNCHANGESINCE test.
C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 12121230045)
+FLAGS.SILENT (\Deleted)
S: * 1 FETCH (UID 4 MODSEQ (12121231000))
S: * 2 FETCH (UID 6 MODSEQ (12121230852))
S: * 4 FETCH (UID 8 MODSEQ (12121130956))
S: a103 OK Conditional Store completed
Example 4:
C: a104 STORE * (UNCHANGEDSINCE 12121230045) +FLAGS.SILENT
(\Deleted $Processed)
S: * 50 FETCH (MODSEQ (12111230047))
S: a104 OK Store (conditional) completed
Example 5:
C: c101 STORE 1 (UNCHANGEDSINCE 12121230045) -FLAGS.SILENT
(\Deleted)
S: * OK [HIGHESTMODSEQ 12111230047]
<span class="grey">Melnikov & Hole Standards Track [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
S: * 50 FETCH (MODSEQ (12111230048))
S: c101 OK Store (conditional) completed
HIGHESTMODSEQ response code was sent by the server presumably
because this was the first CONDSTORE enabling command.
Example 6:
In spite of the failure of the conditional STORE operation for
message 7, the server continues to process the conditional STORE
in order to find all messages that fail the test.
C: d105 STORE 7,5,9 (UNCHANGEDSINCE 320162338)
+FLAGS.SILENT (\Deleted)
S: * 5 FETCH (MODSEQ (320162350))
S: d105 OK [MODIFIED 7,9] Conditional STORE failed
Example 7:
Same as above, but the server follows the SHOULD recommendation in
Section 6.4.6 of [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>].
C: d105 STORE 7,5,9 (UNCHANGEDSINCE 320162338)
+FLAGS.SILENT (\Deleted)
S: * 7 FETCH (MODSEQ (320162342) FLAGS (\Seen \Deleted))
S: * 5 FETCH (MODSEQ (320162350))
S: * 9 FETCH (MODSEQ (320162349) FLAGS (\Answered))
S: d105 OK [MODIFIED 7,9] Conditional STORE failed
Use of UNCHANGEDSINCE with a modification sequence of 0 always
fails if the metadata item exists. A system flag MUST always be
considered existent, whether it was set or not.
Example 8:
C: a102 STORE 12 (UNCHANGEDSINCE 0)
+FLAGS.SILENT ($MDNSent)
S: a102 OK [MODIFIED 12] Conditional STORE failed
The client has tested the presence of the $MDNSent user-defined
keyword.
Note: A client trying to make an atomic change to the state of a
particular metadata item (or a set of metadata items) should be
prepared to deal with the case when the server returns the MODIFIED
response code if the state of the metadata item being watched hasn't
changed (but the state of some other metadata item has). This is
necessary, because some servers don't store separate mod-sequences
<span class="grey">Melnikov & Hole Standards Track [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
for different metadata items. However, a server implementation
SHOULD avoid generating spurious MODIFIED responses for +FLAGS/-FLAGS
STORE operations, even when the server stores a single mod-sequence
per message. <a href="#section-5">Section 5</a> describes how this can be achieved.
Unless the server has included an unsolicited FETCH to update
client's knowledge about messages that have failed the UNCHANGEDSINCE
test, upon receipt of the MODIFIED response code, the client SHOULD
try to figure out if the required metadata items have indeed changed
by issuing FETCH or NOOP command. It is RECOMMENDED that the server
avoids the need for the client to do that by sending an unsolicited
FETCH response (Examples 9 and 10).
If the required metadata items haven't changed, the client SHOULD
retry the command with the new mod-sequence. The client SHOULD allow
for a configurable but reasonable number of retries (at least 2).
Example 9:
In the example below, the server returns the MODIFIED response
code without sending information describing why the STORE
UNCHANGEDSINCE operation has failed.
C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000)
+FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (303181230852))
S: * 102 FETCH (MODSEQ (303181230852))
...
S: * 150 FETCH (MODSEQ (303181230852))
S: a106 OK [MODIFIED 101] Conditional STORE failed
The flag $Processed was set on the message 101...
C: a107 NOOP
S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed))
S: a107 OK
Or the flag hasn't changed, but another has (note that this server
behaviour is discouraged. Server implementers should also see
<a href="#section-5">Section 5</a>)...
C: b107 NOOP
S: * 101 FETCH (MODSEQ (303011130956) FLAGS (\Deleted \Answered))
S: b107 OK
...and the client retries the operation for the message 101 with
the updated UNCHANGEDSINCE value
<span class="grey">Melnikov & Hole Standards Track [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
C: b108 STORE 101 (UNCHANGEDSINCE 303011130956)
+FLAGS.SILENT ($Processed)
S: * 101 FETCH (MODSEQ (303181230852))
S: b108 OK Conditional Store completed
Example 10:
Same as above, but the server avoids the need for the client to
poll for changes.
The flag $Processed was set on the message 101 by another
client...
C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000)
+FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (303181230852))
S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed))
S: * 102 FETCH (MODSEQ (303181230852))
...
S: * 150 FETCH (MODSEQ (303181230852))
S: a106 OK [MODIFIED 101] Conditional STORE failed
Or the flag hasn't changed, but another has (note that this server
behaviour is discouraged. Server implementers should also see
<a href="#section-5">Section 5</a>)...
C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000)
+FLAGS.SILENT ($Processed)
S: * 100 FETCH (MODSEQ (303181230852))
S: * 101 FETCH (MODSEQ (303011130956) FLAGS (\Deleted \Answered))
S: * 102 FETCH (MODSEQ (303181230852))
...
S: * 150 FETCH (MODSEQ (303181230852))
S: a106 OK [MODIFIED 101] Conditional STORE failed
...and the client retries the operation for the message 101 with
the updated UNCHANGEDSINCE value
C: b108 STORE 101 (UNCHANGEDSINCE 303011130956)
+FLAGS.SILENT ($Processed)
S: * 101 FETCH (MODSEQ (303181230852))
S: b108 OK Conditional Store completed
Or the flag hasn't changed, but another has (nice server
behaviour. Server implementers should also see <a href="#section-5">Section 5</a>)...
C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000)
+FLAGS.SILENT ($Processed)
<span class="grey">Melnikov & Hole Standards Track [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
S: * 100 FETCH (MODSEQ (303181230852))
S: * 101 FETCH (MODSEQ (303011130956) FLAGS ($Processed \Deleted
\Answered))
S: * 102 FETCH (MODSEQ (303181230852))
...
S: * 150 FETCH (MODSEQ (303181230852))
S: a106 OK Conditional STORE completed
Example 11:
The following example is based on the example from the <a href="./rfc2180#section-4.2.3">Section</a>
<a href="./rfc2180#section-4.2.3">4.2.3 of [RFC-2180]</a> and demonstrates that the MODIFIED response
code may be also returned in the tagged NO response.
Client tries to conditionally STORE flags on a mixture of expunged
and non-expunged messages; one message fails the UNCHANGEDSINCE
test.
C: B001 STORE 1:7 (UNCHANGEDSINCE 320172338) +FLAGS (\SEEN)
S: * 1 FETCH (MODSEQ (320172342) FLAGS (\SEEN))
S: * 3 FETCH (MODSEQ (320172342) FLAGS (\SEEN))
S: B001 NO [MODIFIED 2] Some of the messages no longer exist.
C: B002 NOOP
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 4 EXPUNGE
S: * 2 FETCH (MODSEQ (320172340) FLAGS (\Deleted \Answered))
S: B002 OK NOOP Completed.
By receiving FETCH responses for messages 1 and 3, and EXPUNGE
responses that indicate that messages 4 through 7 have been
expunged, the client retries the operation only for the message 2.
The updated UNCHANGEDSINCE value is used.
C: b003 STORE 2 (UNCHANGEDSINCE 320172340) +FLAGS (\Seen)
S: * 2 FETCH (MODSEQ (320180050))
S: b003 OK Conditional Store completed
Note: If a message is specified multiple times in the message set,
and the server doesn't internally eliminate duplicates from the
message set, it MUST NOT fail the conditional STORE operation for the
second (or subsequent) occurrence of the message if the operation
completed successfully for the first occurrence. For example, if the
client specifies:
<span class="grey">Melnikov & Hole Standards Track [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
e105 STORE 7,3:9 (UNCHANGEDSINCE 12121230045)
+FLAGS.SILENT (\Deleted)
the server must not fail the operation for message 7 as part of
processing "3:9" if it succeeded when message 7 was processed the
first time.
Once the client specified the UNCHANGEDSINCE modifier in a STORE
command, the server MUST include the MODSEQ fetch response data items
in all subsequent unsolicited FETCH responses.
This document also changes the behaviour of the server when it has
performed a STORE or UID STORE command and the UNCHANGEDSINCE
modifier is not specified. If the operation is successful for a
message, the server MUST update the mod-sequence attribute of the
message. The server is REQUIRED to include the mod-sequence value
whenever it decides to send the unsolicited FETCH response to all
CONDSTORE-aware clients that have opened the mailbox containing the
message.
Server implementers should also see <a href="#section-3.8">Section 3.8</a> for additional
quality of implementation issues related to the STORE command.
<span class="h3"><a class="selflink" id="section-3.3" href="#section-3.3">3.3</a>. FETCH and UID FETCH Commands</span>
<span class="h4"><a class="selflink" id="section-3.3.1" href="#section-3.3.1">3.3.1</a>. CHANGEDSINCE FETCH Modifier</span>
This document defines the following FETCH modifier (see Section 2.4
of [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>]):
CHANGEDSINCE <mod-sequence>
CHANGEDSINCE FETCH modifier allows to create a further subset of
the list of messages described by sequence set. The information
described by message data items is only returned for messages that
have mod-sequence bigger than <mod-sequence>.
When CHANGEDSINCE FETCH modifier is specified, it implicitly adds
MODSEQ FETCH message data item (<a href="#section-3.3.2">Section 3.3.2</a>).
Example 12:
C: s100 UID FETCH 1:* (FLAGS) (CHANGEDSINCE 12345)
S: * 1 FETCH (UID 4 MODSEQ (65402) FLAGS (\Seen))
S: * 2 FETCH (UID 6 MODSEQ (75403) FLAGS (\Deleted))
S: * 4 FETCH (UID 8 MODSEQ (29738) FLAGS ($NoJunk $AutoJunk
$MDNSent))
S: s100 OK FETCH completed
<span class="grey">Melnikov & Hole Standards Track [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
<span class="h4"><a class="selflink" id="section-3.3.2" href="#section-3.3.2">3.3.2</a>. MODSEQ Message Data Item in FETCH Command</span>
This extension adds a MODSEQ message data item to the FETCH command.
The MODSEQ message data item allows clients to retrieve mod-sequence
values for a range of messages in the currently selected mailbox.
Once the client specified the MODSEQ message data item in a FETCH
request, the server MUST include the MODSEQ fetch response data items
in all subsequent unsolicited FETCH responses.
Syntax: MODSEQ
The MODSEQ message data item causes the server to return MODSEQ
fetch response data items.
Syntax: MODSEQ ( <permsg-modsequence> )
MODSEQ response data items contain per-message mod-sequences.
The MODSEQ response data item is returned if the client issued
FETCH with MODSEQ message data item. It also allows the server to
notify the client about mod-sequence changes caused by conditional
STOREs (<a href="#section-3.2">Section 3.2</a>) and/or changes caused by external sources.
Example 13:
C: a FETCH 1:3 (MODSEQ)
S: * 1 FETCH (MODSEQ (624140003))
S: * 2 FETCH (MODSEQ (624140007))
S: * 3 FETCH (MODSEQ (624140005))
S: a OK Fetch complete
In this example, the client requests per-message mod-sequences for
a set of messages.
When a flag for a message is modified in a different session, the
server sends an unsolicited FETCH response containing the mod-
sequence for the message.
Example 14:
(Session 1, authenticated as a user "alex"). The user adds a
shared flag \Deleted:
C: A142 SELECT INBOX
...
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Answered \Deleted \Seen \*)] Limited
<span class="grey">Melnikov & Hole Standards Track [Page 14]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
...
C: A160 STORE 7 +FLAGS.SILENT (\Deleted)
S: * 7 FETCH (MODSEQ (2121231000))
S: A160 OK Store completed
(Session 2, also authenticated as the user "alex"). Any changes
to flags are always reported to all sessions authenticated as the
same user as in the session 1.
C: C180 NOOP
S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (12121231000))
S: C180 OK Noop completed
(Session 3, authenticated as a user "andrew"). As \Deleted is a
shared flag, changes in session 1 are also reported in session 3:
C: D210 NOOP
S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (12121231000))
S: D210 OK Noop completed
The user modifies a private flag \Seen in session 1...
C: A240 STORE 7 +FLAGS.SILENT (\Seen)
S: * 7 FETCH (MODSEQ (12121231777))
S: A240 OK Store completed
...which is only reported in session 2...
C: C270 NOOP
S: * 7 FETCH (FLAGS (\Deleted \Answered \Seen) MODSEQ
(12121231777))
S: C270 OK Noop completed
...but not in session 3.
C: D300 NOOP
S: D300 OK Noop completed
And finally, the user removes flags \Answered (shared) and \Seen
(private) in session 1.
C: A330 STORE 7 -FLAGS.SILENT (\Answered \Seen)
S: * 7 FETCH (MODSEQ (12121245160))
S: A330 OK Store completed
<span class="grey">Melnikov & Hole Standards Track [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Both changes are reported in the session 2...
C: C360 NOOP
S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (12121245160))
S: C360 OK Noop completed
...and only changes to shared flags are reported in session 3.
C: D390 NOOP
S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (12121245160))
S: D390 OK Noop completed
Server implementers should also see <a href="#section-3.8">Section 3.8</a> for additional
quality of implementation issues related to the FETCH command.
<span class="h3"><a class="selflink" id="section-3.4" href="#section-3.4">3.4</a>. MODSEQ Search Criterion in SEARCH</span>
The MODSEQ criterion for the SEARCH command allows a client to search
for the metadata items that were modified since a specified moment.
Syntax: MODSEQ [<entry-name> <entry-type-req>] <mod-sequence-valzer>
Messages that have modification values that are equal to or
greater than <mod-sequence-valzer>. This allows a client, for
example, to find out which messages contain metadata items that
have changed since the last time it updated its disconnected
cache. The client may also specify <entry-name> (name of metadata
item) and <entry-type-req> (type of metadata item) before
<mod-sequence-valzer>. <entry-type-req> can be one of "shared",
"priv" (private), or "all". The latter means that the server
should use the biggest value among "priv" and "shared" mod-
sequences for the metadata item. If the server doesn't store
internally separate mod-sequences for different metadata items, it
MUST ignore <entry-name> and <entry-type-req>. Otherwise, the
server should use them to narrow down the search.
For a flag <flagname>, the corresponding <entry-name> has a form
"/flags/<flagname>" as defined in [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>]. Note that the
leading "\" character that denotes a system flag has to be escaped
as per Section 4.3 of [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>], as the <entry-name> uses syntax for
quoted strings.
If client specifies a MODSEQ criterion in a SEARCH command and the
server returns a non-empty SEARCH result, the server MUST also append
(to the end of the untagged SEARCH response) the highest mod-sequence
for all messages being returned. See also <a href="#section-3.5">Section 3.5</a>.
<span class="grey">Melnikov & Hole Standards Track [Page 16]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Example 15:
C: a SEARCH MODSEQ "/flags/\\draft" all 620162338
S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500)
S: a OK Search complete
In the above example, the message numbers of any messages
containing the string "IMAP4" in the "value" attribute of the
"/comment" entry and having a mod-sequence equal to or greater
than 620162338 for the "\Draft" flag are returned in the search
results.
Example 16:
C: t SEARCH OR NOT MODSEQ 720162338 LARGER 50000
S: * SEARCH
S: t OK Search complete, nothing found
<span class="h3"><a class="selflink" id="section-3.5" href="#section-3.5">3.5</a>. Modified SEARCH Untagged Response</span>
Data: zero or more numbers
mod-sequence value (omitted if no match)
This document extends syntax of the untagged SEARCH response to
include the highest mod-sequence for all messages being returned.
If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH)
command and the server returns a non-empty SEARCH result, the server
MUST also append (to the end of the untagged SEARCH response) the
highest mod-sequence for all messages being returned. See <a href="#section-3.4">Section</a>
<a href="#section-3.4">3.4</a> for examples.
<span class="h3"><a class="selflink" id="section-3.6" href="#section-3.6">3.6</a>. HIGHESTMODSEQ Status Data Items</span>
This document defines a new status data item:
HIGHESTMODSEQ
The highest mod-sequence value of all messages in the mailbox.
This is the same value that is returned by the server in the
HIGHESTMODSEQ response code in an OK untagged response (see
<a href="#section-3.1.1">Section 3.1.1</a>). If the server doesn't support the persistent
storage of mod-sequences for the mailbox (see <a href="#section-3.1.2">Section 3.1.2</a>), the
server MUST return 0 as the value of HIGHESTMODSEQ status data
item.
<span class="grey">Melnikov & Hole Standards Track [Page 17]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Example 17:
C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ)
S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292
HIGHESTMODSEQ 7011231777)
S: A042 OK STATUS completed
<span class="h3"><a class="selflink" id="section-3.7" href="#section-3.7">3.7</a>. CONDSTORE Parameter to SELECT and EXAMINE</span>
The CONDSTORE extension defines a single optional select parameter,
"CONDSTORE", which tells the server that it MUST include the MODSEQ
fetch response data items in all subsequent unsolicited FETCH
responses.
The CONDSTORE parameter to SELECT/EXAMINE helps avoid a race
condition that might arise when one or more metadata items are
modified in another session after the server has sent the
HIGHESTMODSEQ response code and before the client was able to issue a
CONDSTORE enabling command.
Example 18:
C: A142 SELECT INBOX (CONDSTORE)
S: * 172 EXISTS
S: * 1 RECENT
S: * OK [UNSEEN 12] Message 12 is first unseen
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: * OK [UIDNEXT 4392] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
S: * OK [HIGHESTMODSEQ 715194045007]
S: A142 OK [READ-WRITE] SELECT completed, CONDSTORE is now enabled
<span class="h3"><a class="selflink" id="section-3.8" href="#section-3.8">3.8</a>. Additional Quality-of-Implementation Issues</span>
Server implementations should follow the following rule, which
applies to any successfully completed STORE/UID STORE (with and
without UNCHANGEDSINCE modifier), as well as to a FETCH command that
implicitly sets \Seen flag:
Adding the flag when it is already present or removing when it is
not present SHOULD NOT change the mod-sequence.
This will prevent spurious client synchronization requests.
<span class="grey">Melnikov & Hole Standards Track [Page 18]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-19" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
However, note that client implementers MUST NOT rely on this server
behavior. A client can't distinguish between the case when a server
has violated the SHOULD mentioned above, and that when one or more
clients set and unset (or unset and set) the flag in another session.
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Formal Syntax</span>
The following syntax specification uses the Augmented Backus-Naur
Form (ABNF) [<a href="#ref-ABNF" title=""Augmented BNF for Syntax Specifications: ABNF"">ABNF</a>] notation. Elements not defined here can be found
in the formal syntax of the ABNF [<a href="#ref-ABNF" title=""Augmented BNF for Syntax Specifications: ABNF"">ABNF</a>], IMAP [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>], and IMAP ABNF
extensions [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>] specifications.
Except as noted otherwise, all alphabetic characters are case-
insensitive. The use of upper- or lowercase characters to define
token strings is for editorial clarity only. Implementations MUST
accept these strings in a case-insensitive fashion.
capability =/ "CONDSTORE"
status-att =/ "HIGHESTMODSEQ"
;; extends non-terminal defined in <a href="./rfc3501">RFC 3501</a>.
status-att-val =/ "HIGHESTMODSEQ" SP mod-sequence-valzer
;; extends non-terminal defined in [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>].
;; Value 0 denotes that the mailbox doesn't
;; support persistent mod-sequences
;; as described in <a href="#section-3.1.2">Section 3.1.2</a>
store-modifier =/ "UNCHANGEDSINCE" SP mod-sequence-valzer
;; Only a single "UNCHANGEDSINCE" may be
;; specified in a STORE operation
fetch-modifier =/ chgsince-fetch-mod
;; conforms to the generic "fetch-modifier"
;; syntax defined in [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>].
chgsince-fetch-mod = "CHANGEDSINCE" SP mod-sequence-value
;; CHANGEDSINCE FETCH modifier conforms to
;; the fetch-modifier syntax
fetch-att =/ fetch-mod-sequence
;; modifies original IMAP4 fetch-att
fetch-mod-sequence = "MODSEQ"
fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")"
msg-att-dynamic =/ fetch-mod-resp
<span class="grey">Melnikov & Hole Standards Track [Page 19]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-20" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
search-key =/ search-modsequence
;; modifies original IMAP4 search-key
;;
;; This change applies to all commands
;; referencing this non-terminal, in
;; particular SEARCH.
search-modsequence = "MODSEQ" [search-modseq-ext] SP
mod-sequence-valzer
search-modseq-ext = SP entry-name SP entry-type-req
resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value /
"NOMODSEQ" /
"MODIFIED" SP set
entry-name = entry-flag-name
entry-flag-name = DQUOTE "/flags/" attr-flag DQUOTE
;; each system or user defined flag <flag>
;; is mapped to "/flags/<flag>".
;;
;; <entry-flag-name> follows the escape rules
;; used by "quoted" string as described in
;; Section 4.3 of [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>], e.g., for the flag
;; \Seen the corresponding <entry-name> is
;; "/flags/\\seen", and for the flag
;; $MDNSent, the corresponding <entry-name>
;; is "/flags/$mdnsent".
entry-type-resp = "priv" / "shared"
;; metadata item type
entry-type-req = entry-type-resp / "all"
;; perform SEARCH operation on private
;; metadata item, shared metadata item or both
permsg-modsequence = mod-sequence-value
;; per message mod-sequence
mod-sequence-value = 1*DIGIT
;; Positive unsigned 64-bit integer
;; (mod-sequence)
;; (1 <= n < 18,446,744,073,709,551,615)
mod-sequence-valzer = "0" / mod-sequence-value
search-sort-mod-seq = "(" "MODSEQ" SP mod-sequence-value ")"
<span class="grey">Melnikov & Hole Standards Track [Page 20]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-21" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
select-param =/ condstore-param
;; conforms to the generic "select-param"
;; non-terminal syntax defined in [<a href="#ref-IMAPABNF" title=""Collected Extensions to IMAP4 ABNF"">IMAPABNF</a>].
condstore-param = "CONDSTORE"
mailbox-data =/ "SEARCH" [1*(SP nz-number) SP
search-sort-mod-seq]
attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" /
"\\Seen" / "\\Draft" / attr-flag-keyword /
attr-flag-extension
;; Does not include "\\Recent"
attr-flag-extension = "\\" atom
;; Future expansion. Client implementations
;; MUST accept flag-extension flags. Server
;; implementations MUST NOT generate
;; flag-extension flags except as defined by
;; future standard or standards-track
;; revisions of [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>].
attr-flag-keyword = atom
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Server Implementation Considerations</span>
This section describes how a server implementation that doesn't store
separate per-metadata mod-sequences for different metadata items can
avoid sending the MODIFIED response to any of the following
conditional STORE operations:
+FLAGS
-FLAGS
+FLAGS.SILENT
-FLAGS.SILENT
Note that the optimization described in this section can't be
performed in case of a conditional STORE FLAGS operation.
Let's use the following example. The client has issued
C: a106 STORE 100:150 (UNCHANGEDSINCE 212030000000)
+FLAGS.SILENT ($Processed)
When the server receives the command and parses it successfully, it
iterates through the message set and tries to execute the conditional
STORE command for each message.
<span class="grey">Melnikov & Hole Standards Track [Page 21]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-22" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Each server internally works as a client, i.e., it has to cache the
current state of all IMAP flags as it is known to the client. In
order to report flag changes to the client, the server compares the
cached values with the values in its database for IMAP flags.
Imagine that another client has changed the state of a flag \Deleted
on the message 101 and that the change updated the mod-sequence for
the message. The server knows that the mod-sequence for the mailbox
has changed; however, it also knows that:
a) the client is not interested in \Deleted flag, as it hasn't
included it in +FLAGS.SILENT operation; and
b) the state of the flag $Processed hasn't changed (the server can
determine this by comparing cached flag state with the state of
the flag in the database).
Therefore, the server doesn't have to report MODIFIED to the client.
Instead, the server may set $Processed flag, update the mod-sequence
for the message 101 once again and send an untagged FETCH response
with new mod-sequence and flags:
S: * 101 FETCH (MODSEQ (303011130956)
FLAGS ($Processed \Deleted \Answered))
See also <a href="#section-3.8">Section 3.8</a> for additional quality-of-implementation issues.
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Security Considerations</span>
It is believed that the Conditional STORE extension doesn't raise any
new security concerns that are not already discussed in [<a href="#ref-IMAP4" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">IMAP4</a>].
However, the availability of this extension may make it possible for
IMAP4 to be used in critical applications it could not be used for
previously, making correct IMAP server implementation and operation
even more important.
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. IANA Considerations</span>
IMAP4 capabilities are registered by publishing a standards track or
IESG approved experimental RFC. The registry is currently located
at:
<a href="http://www.iana.org/assignments/imap4-capabilities">http://www.iana.org/assignments/imap4-capabilities</a>
This document defines the CONDSTORE IMAP capability. IANA has added
it to the registry accordingly.
<span class="grey">Melnikov & Hole Standards Track [Page 22]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-23" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. References</span>
<span class="h3"><a class="selflink" id="section-8.1" href="#section-8.1">8.1</a>. Normative References</span>
[<a id="ref-KEYWORDS">KEYWORDS</a>] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997.
[<a id="ref-ABNF">ABNF</a>] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", <a href="./rfc4234">RFC 4234</a>, October 2005.
[<a id="ref-IMAP4">IMAP4</a>] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
4rev1", <a href="./rfc3501">RFC 3501</a>, March 2003.
[<a id="ref-IMAPABNF">IMAPABNF</a>] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4
ABNF", <a href="./rfc4466">RFC 4466</a>, April 2006.
<span class="h3"><a class="selflink" id="section-8.2" href="#section-8.2">8.2</a>. Informative References</span>
[<a id="ref-ACAP">ACAP</a>] Newman, C. and J. Myers, "ACAP -- Application
Configuration Access Protocol", <a href="./rfc2244">RFC 2244</a>, November 1997.
[<a id="ref-ACL">ACL</a>] Melnikov, A., "IMAP4 Access Control List (ACL) Extension",
<a href="./rfc4314">RFC 4314</a>, December 2005.
[<a id="ref-ANN">ANN</a>] Daboo, C. and R. Gellens, <a style="text-decoration: none" href='https://www.google.com/search?sitesearch=datatracker.ietf.org%2Fdoc%2Fhtml%2F&q=inurl:draft-+%22IMAP+ANNOTATE+Extension%22'>"IMAP ANNOTATE Extension"</a>, Work
in Progress, March 2006.
[<a id="ref-NTP">NTP</a>] Mills, D., "Network Time Protocol (Version 3)
Specification, Implementation and Analysis", <a href="./rfc1305">RFC 1305</a>,
March 1992.
[<a id="ref-RFC-2180">RFC-2180</a>] Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", <a href="./rfc2180">RFC</a>
<a href="./rfc2180">2180</a>, July 1997.
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Acknowledgements</span>
Some text was borrowed from "IMAP ANNOTATE Extension" [<a href="#ref-ANN" title=""IMAP ANNOTATE Extension"">ANN</a>] by
Randall Gellens and Cyrus Daboo and from "ACAP -- Application
Configuration Access Protocol" [<a href="#ref-ACAP" title=""ACAP -- Application Configuration Access Protocol"">ACAP</a>] by Chris Newman and John Myers.
Many thanks to Randall Gellens for his thorough review of the
document.
The authors also acknowledge the feedback provided by Cyrus Daboo,
Larry Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen,
Timo Sirainen, Mark Crispin, Ned Freed, Ken Murchison, and Dave
Cridland.
<span class="grey">Melnikov & Hole Standards Track [Page 23]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-24" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Authors' Addresses
Alexey Melnikov
Isode Limited
5 Castle Business Village
36 Station Road
Hampton, Middlesex
TW12 2BX,
United Kingdom
EMail: Alexey.Melnikov@isode.com
Steve Hole
ACI WorldWide/MessagingDirect
#1807, 10088 102 Ave
Edmonton, AB
T5J 2Z1
Canada
EMail: Steve.Hole@messagingdirect.com
<span class="grey">Melnikov & Hole Standards Track [Page 24]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-25" ></span>
<span class="grey"><a href="./rfc4551">RFC 4551</a> IMAP Extension for Conditional STORE June 2006</span>
Full Copyright Statement
Copyright (C) The Internet Society (2006).
This document is subject to the rights, licenses and restrictions
contained in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a>, and except as set forth therein, the authors
retain all their rights.
This document and the information contained herein are provided on an
"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property
The IETF takes no position regarding the validity or scope of any
Intellectual Property Rights or other rights that might be claimed to
pertain to the implementation or use of the technology described in
this document or the extent to which any license under such rights
might or might not be available; nor does it represent that it has
made any independent effort to identify any such rights. Information
on the procedures with respect to rights in RFC documents can be
found in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and <a href="https://www.rfc-editor.org/bcp/bcp79">BCP 79</a>.
Copies of IPR disclosures made to the IETF Secretariat and any
assurances of licenses to be made available, or the result of an
attempt made to obtain a general license or permission for the use of
such proprietary rights by implementers or users of this
specification can be obtained from the IETF on-line IPR repository at
<a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>.
The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary
rights that may cover technology that may be required to implement
this standard. Please address the information to the IETF at
ietf-ipr@ietf.org.
Acknowledgement
Funding for the RFC Editor function is provided by the IETF
Administrative Support Activity (IASA).
Melnikov & Hole Standards Track [Page 25]
</pre>
|