pub struct SmugglingDetector;Expand description
请求走私检测器
在请求解析阶段对头部进行检测,识别不一致或恶意构造。
Implementations§
Source§impl SmugglingDetector
impl SmugglingDetector
Sourcepub fn detect<N, V>(
&self,
headers: &[(N, V)],
) -> Result<(), (SmugglingKind, String)>
pub fn detect<N, V>( &self, headers: &[(N, V)], ) -> Result<(), (SmugglingKind, String)>
检测头部序列中的走私攻击
§参数
headers: [(name, value)] 头部列表(名称未规范化也可,内部会小写化)
§返回
- Ok(()) : 通过检测
- Err((SmugglingKind, String)) : 检测到的走私类型与说明
§性能
头部名称已小写化的调用方(如 crate::parser::Http1Parser 经
parse_header_line 规范化后)应优先使用 Self::detect_already_lowercased,
跳过每头一次的 to_ascii_lowercase 分配。
Sourcepub fn detect_already_lowercased<N, V>(
&self,
headers: &[(N, V)],
) -> Result<(), (SmugglingKind, String)>
pub fn detect_already_lowercased<N, V>( &self, headers: &[(N, V)], ) -> Result<(), (SmugglingKind, String)>
检测头部序列中的走私攻击(假设头部名称已小写化)
与 Self::detect 语义一致,但假设调用方已将头部名称小写化
(如 crate::parser::Http1Parser 的 parse_header_line 已执行
to_ascii_lowercase),跳过每头一次的 to_ascii_lowercase 分配。
§安全性
若传入未小写化的头部名称,匹配将失败(如 Content-Length 不会匹配
"content-length"),可能导致漏检。调用方必须保证名称已小写。
Sourcepub fn detect_err<N, V>(&self, headers: &[(N, V)]) -> Result<(), Http1Error>
pub fn detect_err<N, V>(&self, headers: &[(N, V)]) -> Result<(), Http1Error>
便捷:直接返回 Http1Error
Sourcepub fn detect_err_already_lowercased<N, V>(
&self,
headers: &[(N, V)],
) -> Result<(), Http1Error>
pub fn detect_err_already_lowercased<N, V>( &self, headers: &[(N, V)], ) -> Result<(), Http1Error>
便捷:直接返回 Http1Error(假设头部名称已小写化)
与 Self::detect_err 语义一致,但委托 Self::detect_already_lowercased,
跳过 to_ascii_lowercase 分配。调用方必须保证头部名称已小写化。
Trait Implementations§
Source§impl Clone for SmugglingDetector
impl Clone for SmugglingDetector
Source§fn clone(&self) -> SmugglingDetector
fn clone(&self) -> SmugglingDetector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SmugglingDetector
impl Debug for SmugglingDetector
Source§impl Default for SmugglingDetector
impl Default for SmugglingDetector
Source§fn default() -> SmugglingDetector
fn default() -> SmugglingDetector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SmugglingDetector
impl RefUnwindSafe for SmugglingDetector
impl Send for SmugglingDetector
impl Sync for SmugglingDetector
impl Unpin for SmugglingDetector
impl UnsafeUnpin for SmugglingDetector
impl UnwindSafe for SmugglingDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more