Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ workflows:

meta:
bitrise.io:
stack: osx-xcode-16.0.x
stack: osx-xcode-16.3.x
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fileprivate class URLSessionRequestBuilderConfiguration: @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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T>, @unchecked Sendab
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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Loading