Struct tk_http::websocket::client::Encoder [] [src]

pub struct Encoder<S> { /* fields omitted */ }

This a request writer that you receive in Codec

Methods of this structure ensure that everything you write into a buffer is consistent and valid protocol

Methods

impl<S> Encoder<S>
[src]

Write request line.

This puts request line into a buffer immediately. If you don't continue with request it will be sent to the network shortly.

Panics

When request line is already written. It's expected that your request handler state machine will never call the method twice.

Add a header to the websocket authenticatin data

Header is written into the output buffer immediately. And is sent as soon as the next loop iteration

Content-Length header must be send using the add_length method and Transfer-Encoding: chunked must be set with the add_chunked method. These two headers are important for the security of HTTP.

Note that there is currently no way to use a transfer encoding other than chunked.

We return Result here to make implementing proxies easier. In the application handler it's okay to unwrap the result and to get a meaningful panic (that is basically an assertion).

Panics

Panics when add_header is called in the wrong state.

When you add a special header Connection, Upgrade, Sec-Websocket-*, because they must be set with special methods

Same as add_header but allows value to be formatted directly into the buffer

Useful for dates and numeric headers, as well as some strongly typed wrappers

Finish writing headers and return EncoderDone which can be moved to

Panics

Panics when the request is in a wrong state.