pub trait HandleRequestBody: Sync + Send {
// Required methods
fn handle(
&mut self,
body: Option<&Bytes>,
end_of_stream: bool,
) -> Result<()>;
fn restart(&mut self);
}Expand description
What a plugin does with the body of the request as it is passed on to the upstream: looks at it (a digest to check) or keeps a copy of it (a mirror). It does not change it.
Set by the plugin at its request step
(Ctx::add_request_body_handler) and called by the proxy for each
chunk. A request the upstream is never asked for - answered by a later
plugin, or from the cache - has its body passed to nobody, and the
handler is not called.
Required Methods§
Sourcefn handle(&mut self, body: Option<&Bytes>, end_of_stream: bool) -> Result<()>
fn handle(&mut self, body: Option<&Bytes>, end_of_stream: bool) -> Result<()>
A chunk of the body, None where there is none, and whether it is
the last. An error ends the request, and the upstream is not sent
this chunk.
The end is not always said. A request that turns out to have no
body may get one call with end_of_stream or none at all (pingora
sends the header of such a request to an HTTP/2 upstream as its
end, and passes nothing through the filter). And a body with a
Content-Length is complete for the upstream once that many bytes
are out, which may be well before a client over HTTP/2 ends its
stream. Whoever has to act when the body is complete goes by the
length the request declares, not by this flag alone.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".