@@ -56,9 +56,14 @@ struct ContentType: Hashable {
56
56
/// The type is encoded as an async sequence of parts.
57
57
case multipart
58
58
59
+ /// A content type for XML.
60
+ ///
61
+ /// The bytes are provided to a CustomCoder.
62
+ case xml
63
+
59
64
/// Creates a category from the provided type and subtype.
60
65
///
61
- /// First checks if the provided content type is a JSON, then text,
66
+ /// First checks if the provided content type is a JSON, then XML, then text,
62
67
/// and uses binary if none of the two match.
63
68
/// - Parameters:
64
69
/// - lowercasedType: The first component of the MIME type.
@@ -68,6 +73,10 @@ struct ContentType: Hashable {
68
73
if ( lowercasedType == " application " && lowercasedSubtype == " json " ) || lowercasedSubtype. hasSuffix ( " +json " )
69
74
{
70
75
self = . json
76
+ } else if ( lowercasedType == " application " && lowercasedSubtype == " xml " )
77
+ || lowercasedSubtype. hasSuffix ( " +xml " )
78
+ {
79
+ self = . xml
71
80
} else if lowercasedType == " application " && lowercasedSubtype == " x-www-form-urlencoded " {
72
81
self = . urlEncodedForm
73
82
} else if lowercasedType == " multipart " && lowercasedSubtype == " form-data " {
@@ -84,6 +93,7 @@ struct ContentType: Hashable {
84
93
case . binary: return . binary
85
94
case . urlEncodedForm: return . urlEncodedForm
86
95
case . multipart: return . multipart
96
+ case . xml: return . xml
87
97
}
88
98
}
89
99
}
@@ -214,12 +224,17 @@ struct ContentType: Hashable {
214
224
/// A Boolean value that indicates whether the content type
215
225
/// is a multipart form.
216
226
var isMultipart : Bool { category == . multipart }
227
+ /// A Boolean value that indicates whether the content type
228
+ /// is a type of XML.
229
+ var isXml : Bool { category == . xml }
217
230
218
231
/// The content type `text/plain`.
219
232
static var textPlain : Self { try ! . init( string: " text/plain " ) }
220
233
221
234
/// The content type `application/json`.
222
235
static var applicationJSON : Self { try ! . init( string: " application/json " ) }
236
+ /// The content type `application/xml`.
237
+ static var applicationXML : Self { try ! . init( string: " application/xml " ) }
223
238
224
239
/// The content type `application/octet-stream`.
225
240
static var applicationOctetStream : Self { try ! . init( string: " application/octet-stream " ) }
0 commit comments