[swift] support content type application json variants (#18539)

* [swift] support content type application json variants

* [swift] support content type application json variants
This commit is contained in:
Bruno Coelho 2024-04-30 11:16:28 +01:00 committed by GitHub
parent a4cf255dce
commit 0768ddcd7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 19 additions and 19 deletions

View File

@ -96,7 +96,7 @@ private var managerStore = SynchronizedDictionary<String, Alamofire.Session>()
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = nil

View File

@ -134,7 +134,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -96,7 +96,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = nil

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))

View File

@ -134,7 +134,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
case .options, .post, .put, .patch, .delete, .trace, .connect:
let contentType = headers["Content-Type"] ?? "application/json"
if contentType.hasPrefix("application/json") {
if contentType.hasPrefix("application/") && contentType.contains("json") {
encoding = JSONDataEncoding()
} else if contentType.hasPrefix("multipart/form-data") {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))