Skip to content

Commit 3744b02

Browse files
committed
📚 Document ResponseCode: compatibility, codes, etc
* Document backwards-compatibility for unparsed response code data. * Document Net::IMAP#responses behavior. * Document RFC3501 codes. * List RFC5530 codes.
1 parent 39f3b8c commit 3744b02

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

lib/net/imap/response_data.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,76 @@ class ResponseText < Struct.new(:code, :text)
126126
# response: any TaggedResponse and UntaggedResponse when the response type
127127
# is a "condition" ("OK", "NO", "BAD", "PREAUTH", or "BYE").
128128
#
129+
# Some response codes come with additional data which will be parsed by
130+
# Net::IMAP. Others return +nil+ for #data, but are used as a
131+
# machine-readable annotation for the human-readable ResponseText#text in
132+
# the same response. When Net::IMAP does not know how to parse response
133+
# code text, #data returns the unparsed string.
134+
#
135+
# Untagged response code #data is pushed directly onto Net::IMAP#responses,
136+
# keyed by #name, unless it is removed by the command that generated it.
137+
# Use Net::IMAP#add_response_handler to view tagged response codes for
138+
# command methods that do not return their TaggedResponse.
139+
#
140+
# \IMAP extensions may define new codes and the data that comes with them.
141+
# The IANA {IMAP Response
142+
# Codes}[https://www.iana.org/assignments/imap-response-codes/imap-response-codes.xhtml]
143+
# registry has links to specifications for all standard response codes.
144+
# Response codes are backwards compatible: Servers are allowed to send new
145+
# response codes even if the client has not enabled the extension that
146+
# defines them. When unknown response code data is encountered, #data
147+
# will return an unparsed string.
148+
#
149+
# See [IMAP4rev1[https://www.rfc-editor.org/rfc/rfc3501]] {§7.1, "Server
150+
# Responses - Status
151+
# Responses"}[https://www.rfc-editor.org/rfc/rfc3501#section-7.1] for full
152+
# definitions of the basic set of IMAP4rev1 response codes:
153+
# * +ALERT+, the ResponseText#text contains a special alert that MUST be
154+
# brought to the user's attention.
155+
# * +BADCHARSET+, #data will be an array of charset strings, or +nil+.
156+
# * +CAPABILITY+, #data will be an array of capability strings.
157+
# * +PARSE+, the ResponseText#text presents an error parsing a message's
158+
# \[RFC5322] or [MIME-IMB] headers.
159+
# * +PERMANENTFLAGS+, followed by an array of flags. System flags will be
160+
# symbols, and keyword flags will be strings. See
161+
# rdoc-ref:Net::IMAP@System+flags
162+
# * +READ-ONLY+, the mailbox was selected read-only, or changed to read-only
163+
# * +READ-WRITE+, the mailbox was selected read-write, or changed to
164+
# read-write
165+
# * +TRYCREATE+, when #append or #copy fail because the target mailbox
166+
# doesn't exist.
167+
# * +UIDNEXT+, #data is an Integer, the next UID value of the mailbox. See
168+
# [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501]],
169+
# {§2.3.1.1, "Unique Identifier (UID) Message
170+
# Attribute}[https://www.rfc-editor.org/rfc/rfc3501#section-2.3.1.1].
171+
# * +UIDVALIDITY+, #data is an Integer, the UID validity value of the
172+
# mailbox See [{IMAP4rev1}[https://www.rfc-editor.org/rfc/rfc3501]],
173+
# {§2.3.1.1, "Unique Identifier (UID) Message
174+
# Attribute}[https://www.rfc-editor.org/rfc/rfc3501#section-2.3.1.1].
175+
# * +UNSEEN+, #data is an Integer, the number of messages which do not have
176+
# the <tt>\Seen</tt> flag set.
177+
#
178+
# See RFC5530[https://www.rfc-editor.org/rfc/rfc5530], "IMAP Response
179+
# Codes" for the definition of the following response codes, which are all
180+
# machine-readable annotations for the human-readable ResponseText#text, and
181+
# have +nil+ #data of their own:
182+
# * +UNAVAILABLE+
183+
# * +AUTHENTICATIONFAILED+
184+
# * +AUTHORIZATIONFAILED+
185+
# * +EXPIRED+
186+
# * +PRIVACYREQUIRED+
187+
# * +CONTACTADMIN+
188+
# * +NOPERM+
189+
# * +INUSE+
190+
# * +EXPUNGEISSUED+
191+
# * +CORRUPTION+
192+
# * +SERVERBUG+
193+
# * +CLIENTBUG+
194+
# * +CANNOT+
195+
# * +LIMIT+
196+
# * +OVERQUOTA+
197+
# * +ALREADYEXISTS+
198+
# * +NONEXISTENT+
129199
#
130200
class ResponseCode < Struct.new(:name, :data)
131201
##

0 commit comments

Comments
 (0)