pub trait HttpHook:
Send
+ Sync
+ 'static {
// Provided methods
fn before_send(&self, request: &mut HttpRequest) { ... }
fn on_reply(&self, request: &HttpRequest, response: &HttpResponse) { ... }
}Expand description
Something that takes part in every HTTP exchange a script starts, whichever client and dispatcher carry it.
A plugin registers one on HttpHooks to add
what a request should carry and to read what a reply says, without the
runtime knowing what it is for: a cookie jar reads Set-Cookie and sends
Cookie, and a signing hook adds an authorization header. Hooks run in the
order they were registered.
Provided Methods§
Sourcefn before_send(&self, request: &mut HttpRequest)
fn before_send(&self, request: &mut HttpRequest)
Called on the world thread just before request is dispatched. The
request goes out as this leaves it.
Sourcefn on_reply(&self, request: &HttpRequest, response: &HttpResponse)
fn on_reply(&self, request: &HttpRequest, response: &HttpResponse)
Called with the reply to request, on whichever thread completed it,
before the script sees it. Not called for a transport failure.