Skip to main content

Http1Parser

Struct Http1Parser 

Source
pub struct Http1Parser { /* private fields */ }
Expand description

HTTP/1.1 请求解析器

Implementations§

Source§

impl Http1Parser

Source

pub fn new(config: Http1Config) -> Self

创建解析器

Source

pub fn reset(&mut self)

重置解析器

Source

pub fn state(&self) -> ParserState

当前状态

Source

pub fn check_idle_timeout(&mut self, now_ms: u64) -> Result<(), Http1Error>

检查空闲超时(Slowloris 防护)

由连接管理层在每个事件循环周期调用。 计时基准为最近一次收到字节的时间(last_activity_ms, 未记录时回退首字节时间):头部阶段自首字节起计时, body/chunked 阶段自最近一次活跃起计时——任何阶段超时一律 fail-closed,杜绝 body 中途 Slowloris 盲区(M-9)。

§参数
  • now_ms - 当前时间戳(毫秒)
Source

pub fn note_first_byte(&mut self, now_ms: u64)

通知首字节到达(由连接层在收到首个数据时调用)

仅记录首字节时间;增量数据的活跃刷新请使用 Self::note_activity(每次收到数据都应调用)。

Source

pub fn note_activity(&mut self, now_ms: u64)

通知活动时间(由连接层在每次收到数据时调用)

刷新最近一次活跃时间戳,并兼具首字节记录语义。 body/chunked 阶段的 Slowloris 防护依赖本时间戳(M-9)。

Source

pub fn feed( &mut self, input: &[u8], ) -> Result<(Option<HttpRequest>, usize), Http1Error>

解析输入数据

Trait Implementations§

Source§

impl Clone for Http1Parser

Source§

fn clone(&self) -> Http1Parser

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Http1Parser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.