Skip to content
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

[Bug]: http fetch/get of media file produces http status 0 when it should be 200 #7794

Open
1 of 3 tasks
leotohill opened this issue Dec 5, 2024 · 3 comments
Open
1 of 3 tasks
Labels

Comments

@leotohill
Copy link

leotohill commented Dec 5, 2024

Capacitor Version

Latest Dependencies:

@capacitor/cli: 6.2.0
@capacitor/core: 6.2.0
@capacitor/android: 6.2.0
@capacitor/ios: 6.2.0

Installed Dependencies:

@capacitor/android: not installed
@capacitor/cli: 6.2.0
@capacitor/ios: 6.2.0
@capacitor/core: 6.2.0

[success] iOS looking great! 👌

Other API Details

npm 10.8.2
node v22.8.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

On ios, a http fetch of an .mp3 file, or certain other media files, produces a result with http status 0, when it should be 200.

Expected Behavior

a successful fetch of an http resource should produce http result 200 (excepting certain other operations, like range requests that return status 206. But never 0.)

Project Reproduction

https://github.com/leotohill/TestFetchMedia.git

Additional Information

It appears to me that the problem was introduced with commit 348c08d to WebViewAssetHandler.swift. WIth that change, a request for a mp3 (or other known media types) produces the result from class URLResponse instead of its subclass HTTPURLResponse. URLResponse does not include the "statusCode" property.

@leotohill
Copy link
Author

A repro project is provided, but in short the repro is
response = await fetch("test.mp3", { method: "GET" });

@VityaSchel
Copy link

Running into the same issue, but in my case it works with .webm files on ios, but not with mp3 files

@leotohill
Copy link
Author

@VityaSchel , right, it only fails for files with these extensions:

let mediaExtensions = ["m4v", "mov", "mp4", "aac", "ac3", "aiff", "au", "flac", "m4a", "mp3", "wav"]

That's in WebViewAssetHandler.swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants