[swift] [urlsession] Fixes crash for uploads with content-type "image/" (#21544)

* Fix image upload for content-type image

* update samples

* add test case in spec and update samples

* update bitrise stack so we get xcpretty 0.4.1

* Revert "add test case in spec and update samples"

This reverts commit 92202dd850.
This commit is contained in:
Jonas Reichert
2025-07-15 10:25:34 +02:00
committed by GitHub
parent ca8c6d2f5d
commit f9098d5a89
24 changed files with 24 additions and 24 deletions

View File

@@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendable {
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))
} else if contentType.hasPrefix("application/x-www-form-urlencoded") {
encoding = FormURLEncoding()
} else if contentType.hasPrefix("application/octet-stream"){
} else if contentType.hasPrefix("application/octet-stream") || contentType.hasPrefix("image/") {
encoding = OctetStreamEncoding()
} else {
fatalError("Unsupported Media Type - \(contentType)")