Trait fastly::experimental::BodyExt
source · pub trait BodyExt {
// Required methods
fn append_trailer(
&mut self,
name: impl ToHeaderName,
value: impl ToHeaderValue
);
fn get_trailers(&mut self) -> Result<HeaderMap, Error>;
}
Expand description
Extensions to the crate::http::body::Body
type to support trailers.
Required Methods§
sourcefn append_trailer(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue)
fn append_trailer(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue)
Append the given trailer name and value to this body.
Trailers will be sent once the body send is complete. This function will not discard any existing values for the trailer; this value will simply be appended to the set of existing values.
§Stability
This is part of an experimental API that is subject to change or removal even in minor versions of this crate.
sourcefn get_trailers(&mut self) -> Result<HeaderMap, Error>
fn get_trailers(&mut self) -> Result<HeaderMap, Error>
Get the trailers associated with this body.
Note that modifying this HeaderMap
will have no effect on the trailers
for the body; in order to add trailers, you will need to use BodyExt::append_trailer
.
If you need to remove a trailer, the only current mechanism to do so is to
create a fresh body, and then copy over the trailers you wish to maintain.
(If this inconvenient, please contact your Fastly support team, and mention
this shortcoming.)
§Trailers
Trailers can be tricky to access. You must completely read all bytes from the body
before calling this function. The outermost Result
reflects this requirement; if you
receive BodyHandleError::TrailersNotReady
, there are potentially more bytes available
in the body that you must read.
§Stability
This is part of an experimental API that is subject to change or removal even in minor versions of this crate.