swift-toolkit
swift-toolkit copied to clipboard
Replacing the HTTP server with WKURLSchemeHandler?
Using an HTTP server has many downsides:
- error-prone
- more complicated to setup
- third-party dependencies
- unsafe (any other app on the device can access the publication resources)
WKURLSchemeHandler could be a solution to serve EPUB resources directly. Looking at the API, it seems promising even for byte range requests.
However, it is available only on iOS 11+. So we still need to support HTTP servers as an alternative until we drop support for iOS 10.
Related issue for Kotlin: https://github.com/readium/r2-testapp-kotlin/issues/297
https://github.com/readium/r2-navigator-swift/pull/160 contains a first stab at this using WKURLSchemeHandler. Unfortunately, there are some blocking issues, including the lack of support of byte range requests for media resources.
It seems to have been addressed in WKWebView recently: https://commits.webkit.org/237270@main But since WKWebView is upgraded with each new iOS version, we won't be able to use this any time soon.
Note that the Range HTTP header seems to be filled in on iOS 15.0+.