#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
#[non_exhaustive]
pub enum HttpPoison {
HeadOverflow,
ChunkLineOverflow,
TrailerOverflow,
PipelineOverflow,
InvalidChunkSize,
MalformedChunkTerminator,
MalformedHead,
ContentLengthWithTransferEncoding,
ConflictingContentLength,
InvalidContentLength,
NonFinalChunked,
UnknownTransferCoding,
DuplicateTransferEncoding,
ObsFold,
BareCr,
DuplicateHost,
NonAsciiAuthority,
UnexpectedResponse,
}
impl HttpPoison {
pub const fn as_str(self) -> &'static str {
match self {
Self::HeadOverflow => "head-overflow",
Self::ChunkLineOverflow => "chunk-line-overflow",
Self::TrailerOverflow => "trailer-overflow",
Self::PipelineOverflow => "pipeline-overflow",
Self::InvalidChunkSize => "invalid-chunk-size",
Self::MalformedChunkTerminator => "malformed-chunk-terminator",
Self::MalformedHead => "malformed-head",
Self::ContentLengthWithTransferEncoding => "content-length-with-transfer-encoding",
Self::ConflictingContentLength => "conflicting-content-length",
Self::InvalidContentLength => "invalid-content-length",
Self::NonFinalChunked => "non-final-chunked",
Self::UnknownTransferCoding => "unknown-transfer-coding",
Self::DuplicateTransferEncoding => "duplicate-transfer-encoding",
Self::ObsFold => "obs-fold",
Self::BareCr => "bare-cr",
Self::DuplicateHost => "duplicate-host",
Self::NonAsciiAuthority => "non-ascii-authority",
Self::UnexpectedResponse => "unexpected-response",
}
}
pub const fn implies_client_fault(self) -> Option<bool> {
match self {
Self::DuplicateHost | Self::NonAsciiAuthority => Some(true),
Self::UnexpectedResponse => Some(false),
_ => None,
}
}
}
impl std::fmt::Display for HttpPoison {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}