Skip to content

Conversation

@frederikbosch
Copy link

Since Capacitor 8.0 data: requests throw because NSURLResponse is not a HTTPURLRepsonse

data: request throw because NSURLResponse is not a HTTPURLRepsonse
@theproducer
Copy link
Contributor

Thanks @frederikbosch! Do you have a reproduction for this issue, or can it be seen in basically any minimal project that uses CapacitorHttp?

@frederikbosch
Copy link
Author

frederikbosch commented Jan 12, 2026

@theproducer I don't at the moment. I have upgraded my app from 7 to 8 and I got crashes because of the forced casts. It might very well be that because of some other upgrades that I only now started with data: URI requests.

That data URIs fail can be proven quite easily by this SwiftFiddle.

Moreover, it is kind of documented behavior. The URLSession.dataTask method documentation says:

If you are making an HTTP or HTTPS request, the returned object is actually an HTTPURLResponse object.

And a data: URI request is not a HTTP request. But documentation is not clear what the response is if the request is not a HTTP(S) request, but apparently it is a NSURLResponse.

@theproducer theproducer self-assigned this Jan 12, 2026
riderx pushed a commit to Cap-go/capacitor-plus that referenced this pull request Jan 13, 2026
@frederikbosch
Copy link
Author

@markemer Much better to unpack the response optional, I have updated the PR.

riderx pushed a commit to Cap-go/capacitor-plus that referenced this pull request Jan 14, 2026
riderx pushed a commit to Cap-go/capacitor-plus that referenced this pull request Jan 15, 2026
riderx pushed a commit to Cap-go/capacitor-plus that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants