/// Takes the length as a content-length without other checks. /// /// Should only be called if previously confirmed this isn't /// CLOSE_DELIMITED or CHUNKED. #[inline] #[cfg(feature = "http1")] pub(crate) fn danger_len(self) -> u64 {
debug_assert!(self.0 < Self::CHUNKED.0); self.0
}
/// Converts to an Option<u64> representing a Known or Unknown length. pub(crate) fn into_opt(self) -> Option<u64> { matchself {
DecodedLength::CHUNKED | DecodedLength::CLOSE_DELIMITED => None,
DecodedLength(known) => Some(known),
}
}
/// Checks the `u64` is within the maximum allowed for content-length. #[cfg(any(feature = "http1", feature = "http2"))] pub(crate) fn checked_new(len: u64) -> Result<Self, crate::error::Parse> { use tracing::warn;
if len <= MAX_LEN {
Ok(DecodedLength(len))
} else {
warn!("content-length bigger than maximum: {} > {}", len, MAX_LEN);
Err(crate::error::Parse::TooLarge)
}
}
/// Returns whether this represents an exact length. /// /// This includes 0, which of course is an exact known length. /// /// It would return false if "chunked" or otherwise size-unknown. #[cfg(feature = "http2")] pub(crate) fn is_exact(&self) -> bool { self.0 <= MAX_LEN
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.