Skip to main content

HttpDispatch

Trait HttpDispatch 

Source
pub trait HttpDispatch:
    Send
    + Sync
    + 'static {
    // Required method
    fn dispatch(
        &self,
        label: &str,
        request: HttpRequest,
        body_limit: u64,
        done: HttpDone,
    );
}
Expand description

How a request leaves the calling thread and how its reply comes back.

HttpClient says how to perform a request; this says who performs it and when the answer arrives. They are separate because the answer is not always a blocked thread waiting on a socket: a browser has no thread to block and resolves the request from a promise instead.

Required Methods§

Source

fn dispatch( &self, label: &str, request: HttpRequest, body_limit: u64, done: HttpDone, )

Start request and hand its outcome to done exactly once.

This call returns immediately; it must never block on the request. The dispatcher forwards body_limit to the client unchanged - the cap is the caller’s policy, not the transport’s. label names the work for diagnostics (it becomes the worker thread’s name) and carries no meaning a dispatcher may act on.

Implementors§