Trait tk_http::websocket::client::Authorizer [] [src]

pub trait Authorizer<S> {
    type Result: Sized;
    fn write_headers(&mut self, e: Encoder<S>) -> EncoderDone<S>;
    fn headers_received(
        &mut self,
        headers: &Head
    ) -> Result<Self::Result, Error>; }

Authorizer sends all the necessary headers and checks response headers to establish websocket connection

The SimpleAuthorizer implementation is good enough for most cases, but custom authorizer may be helpful for Cookie or Authorization header.

Associated Types

The type that may be returned from a header_received. It should encompass everything parsed from input headers.

Required Methods

Write request headers

Websocket-specific headers like Connection, Upgrade, and Sec-Websocket-Key are written automatically. But other important things like Host, Origin, User-Agent must be written by this method, as well as path encoded in request-line.

A handler of response headers

It's called when websocket has been sucessfully connected or when server returned error, check that response code equals 101 to make sure response is established.

Anyway, handler may be skipped in case of invalid response headers.

Implementors