swift-toolkit icon indicating copy to clipboard operation
swift-toolkit copied to clipboard

Replacing the HTTP server with WKURLSchemeHandler?

Open mickael-menu opened this issue 5 years ago • 2 comments

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

mickael-menu avatar Nov 17 '20 09:11 mickael-menu

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.

mickael-menu avatar Oct 04 '22 15:10 mickael-menu

Note that the Range HTTP header seems to be filled in on iOS 15.0+.

mickael-menu avatar Mar 06 '23 16:03 mickael-menu