@@ -870,6 +870,37 @@ class ThreadMember < Struct.new(:seqno, :children)
870
870
# children of this in the thread.
871
871
end
872
872
873
+ # Net::IMAP::BodyStructure is included by all of the structs that can be
874
+ # returned from a <tt>"BODYSTRUCTURE"</tt> or <tt>"BODY"</tt>
875
+ # FetchData#attr value. Although these classes don't share a base class,
876
+ # this module can be used to pattern match all of them.
877
+ #
878
+ # See {[IMAP4rev1] §7.4.2}[https://www.rfc-editor.org/rfc/rfc3501.html#section-7.4.2]
879
+ # and {[IMAP4rev2] §7.5.2}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.5.2-4.9]
880
+ # for full description of all +BODYSTRUCTURE+ fields, and also
881
+ # Net::IMAP@Message+envelope+and+body+structure for other relevant RFCs.
882
+ #
883
+ # === Classes that include BodyStructure
884
+ # BodyTypeBasic:: Represents any message parts that are not handled by
885
+ # BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
886
+ # BodyTypeText:: Used by <tt>text/*</tt> parts. Contains all of the
887
+ # BodyTypeBasic fields.
888
+ # BodyTypeMessage:: Used by <tt>message/rfc822</tt> and
889
+ # <tt>message/global</tt> parts. Contains all of the
890
+ # BodyTypeBasic fields. Other <tt>message/*</tt> types
891
+ # should use BodyTypeBasic.
892
+ # BodyTypeMultipart:: for <tt>multipart/*</tt> parts
893
+ #
894
+ # ==== Deprecated BodyStructure classes
895
+ # The following classes represent invalid server responses or parser bugs:
896
+ # BodyTypeExtension:: parser bug: used for <tt>message/*</tt> where
897
+ # BodyTypeBasic should have been used.
898
+ # BodyTypeAttachment:: server bug: some servers sometimes return the
899
+ # "Content-Disposition: attachment" data where the
900
+ # entire body structure for a message part is expected.
901
+ module BodyStructure
902
+ end
903
+
873
904
# Net::IMAP::BodyTypeBasic represents basic body structures of messages and
874
905
# message parts, unless they have a <tt>Content-Type</tt> that is handled by
875
906
# BodyTypeText, BodyTypeMessage, or BodyTypeMultipart.
@@ -884,6 +915,7 @@ class BodyTypeBasic < Struct.new(:media_type, :subtype,
884
915
:description , :encoding , :size ,
885
916
:md5 , :disposition , :language ,
886
917
:extension )
918
+ include BodyStructure
887
919
888
920
##
889
921
# method: media_type
@@ -1018,6 +1050,7 @@ class BodyTypeText < Struct.new(:media_type, :subtype,
1018
1050
:lines ,
1019
1051
:md5 , :disposition , :language ,
1020
1052
:extension )
1053
+ include BodyStructure
1021
1054
1022
1055
##
1023
1056
# method: lines
@@ -1062,6 +1095,7 @@ class BodyTypeMessage < Struct.new(:media_type, :subtype,
1062
1095
:envelope , :body , :lines ,
1063
1096
:md5 , :disposition , :language ,
1064
1097
:extension )
1098
+ include BodyStructure
1065
1099
1066
1100
##
1067
1101
# method: envelope
@@ -1120,6 +1154,7 @@ def media_subtype
1120
1154
# structure.
1121
1155
#
1122
1156
class BodyTypeAttachment < Struct . new ( :dsp_type , :_unused_ , :param )
1157
+ include BodyStructure
1123
1158
1124
1159
# *invalid for BodyTypeAttachment*
1125
1160
def media_type
@@ -1161,6 +1196,7 @@ class BodyTypeMultipart < Struct.new(:media_type, :subtype,
1161
1196
:parts ,
1162
1197
:param , :disposition , :language ,
1163
1198
:extension )
1199
+ include BodyStructure
1164
1200
1165
1201
##
1166
1202
# method: media_type
@@ -1240,6 +1276,8 @@ def media_subtype
1240
1276
class BodyTypeExtension < Struct . new ( :media_type , :subtype ,
1241
1277
:params , :content_id ,
1242
1278
:description , :encoding , :size )
1279
+ include BodyStructure
1280
+
1243
1281
def multipart?
1244
1282
return false
1245
1283
end
0 commit comments