Trait ProtocolHandler

Source
pub trait ProtocolHandler: Send + Sync {
    // Required method
    fn load(
        &self,
        request: &mut Request,
        done_chan: &mut DoneChannel,
        context: &FetchContext,
    ) -> Pin<Box<dyn Future<Output = Response> + Send>>;

    // Provided methods
    fn privileged_paths(&self) -> &'static [&'static str] { ... }
    fn is_fetchable(&self) -> bool { ... }
    fn is_secure(&self) -> bool { ... }
}

Required Methods§

Source

fn load( &self, request: &mut Request, done_chan: &mut DoneChannel, context: &FetchContext, ) -> Pin<Box<dyn Future<Output = Response> + Send>>

Triggers the load of a resource for this protocol and returns a future that will produce a Response. Even if the protocol is not backed by a http endpoint, it is recommended to a least provide:

  • A relevant status code.
  • A Content Type.

Provided Methods§

Source

fn privileged_paths(&self) -> &'static [&'static str]

A list of schema-less URLs that can be resolved against this handler’s scheme. These URLs will be granted access to the navigator.servo interface to perform privileged operations that manipulate Servo internals.

Source

fn is_fetchable(&self) -> bool

Specify if resources served by that protocol can be retrieved with fetch() without no-cors mode to allow the caller direct access to the resource content.

Source

fn is_secure(&self) -> bool

Specify if this custom protocol can be used in a secure context

Note: this only works for bypassing mixed content checks right now

Implementors§