Struct tk_http::server::RecvMode
[−]
[src]
pub struct RecvMode { /* fields omitted */ }
This type is returned from headers_received
handler of either
client client or server protocol handler
The marker is used to denote whether you want to have the whole response buffered for you or read chunk by chunk.
The Progressive
(chunk by chunk) mode is mostly useful for proxy servers.
Or it may be useful if your handler is able to parse data without holding
everything in the memory.
Otherwise, it's best to use Buffered
mode (for example, comparing with
using your own buffering). We do our best to optimize it for you.
Methods
impl RecvMode
[src]
fn buffered_upfront(max_body_size: usize) -> RecvMode
Download whole message body (request or response) into the memory before starting response
The argument is maximum size of the body. The Buffered variant works equally well for Chunked encoding and for read-util-end-of-stream mode of HTTP/1.0, so sometimes you can't know the size of the request in advance. Note this is just an upper limit it's neither buffer size nor minimum size of the body.
fn progressive(min_chunk_size_hint: usize) -> RecvMode
Fetch data chunk-by-chunk.
Note, your response handler can start either before or after progressive body has started or ended to read. I mean they are completely independent, and actual sequence of events depends on other requests coming in and performance of a client.
The parameter denotes minimum number of bytes that may be passed
to the protocol handler. This is for performance tuning (i.e. less
wake-ups of protocol parser). But it's not an input buffer size. The
use of Progressive(1)
is perfectly okay (for example if you use http
request body as a persistent connection for sending multiple messages
on-demand)
fn hijack() -> RecvMode
Don't read request body and hijack connection after response headers are sent. Useful for connection upgrades, including websockets and for CONNECT method.
Note: data_received
method of Codec is never called for Hijack
d
connection.
fn body_read_timeout(self, duration: Duration) -> RecvMode
Change timeout for reading the whole request body to this value instead of configured default
This might be useful if you have some specific slow routes and you can authenticate that request is valid enough. This is also useful for streaming large bodies and similar things.
Or vice versa if you what shorter timeouts for suspicious host.
Trait Implementations
impl Debug for RecvMode
[src]
impl Clone for RecvMode
[src]
fn clone(&self) -> RecvMode
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more