MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / content_length

Method content_length

src/http/body.rs:192–198  ·  view source on GitHub ↗

Get a value for the length of this `Body`'s content, in bytes, if known. This value can come from either the Content-Length header received in the incoming request or response assocated with the body, or be provided by an exact `http_body::Body::size_hint` if the `Body` is constructed from an `http_body::Body` impl.

(&self)

Source from the content-addressed store, hash-verified

190 /// or be provided by an exact `http_body::Body::size_hint` if the `Body`
191 /// is constructed from an `http_body::Body` impl.
192 pub fn content_length(&self) -> Option<u64> {
193 match &self.0 {
194 BodyInner::Boxed(b) => b.size_hint().exact(),
195 BodyInner::Complete { data, .. } => Some(data.len() as u64),
196 BodyInner::Incoming(i) => i.size_hint.content_length(),
197 }
198 }
199
200 /// Construct an empty Body
201 pub fn empty() -> Self {

Callers 2

respondMethod · 0.80
mainFunction · 0.80

Calls 1

size_hintMethod · 0.80

Tested by

no test coverage detected