mozilla / libdweb

Extension containing an experimental libdweb APIs
MIT License
442 stars 32 forks source link

Allow webRequest.onBeforeRequest to redirect to libdweb protocol handler #74

Closed lidel closed 5 years ago

lidel commented 6 years ago

Summary

Thanks to webRequest.onBeforeRequest API WebExtensions are able to inspect HTTP request before it is sent and redirect it to a different URL.

It would be neat if we could use this WebExtension API for uplifting protocol-specific HTTP requests by cancelling and redirecting them to native protocol handler.

Example: IPFS Gateway on HTTP

In context of IPFS we want to redirect requests made to HTTP gateways:

  1. detect HTTP gateways: https://ipfs.io/ipfs/<cid> and https://<cid>.ipfs.foo.tld
  2. redirect to ipfs://<cid>

Problem

Right now cross-protocol redirect via webRequest.onBeforeRequest is not possible. PoC redirect from https:// to ipfs:// gets blocked:

screenshot_12

It feels related to discussion in https://github.com/mozilla/libdweb/issues/52, but here we talk about redirecting from http:// to foo:// via webextension API, not loading content embedded in HTML page.

Let me know if more data or MVP demo is needed.

Gozala commented 5 years ago

Moving to https://bugzilla.mozilla.org/show_bug.cgi?id=1572200 as it can't be addressed here