Skip to main content

HttpConfig

Struct HttpConfig 

Source
pub struct HttpConfig {
Show 13 fields pub listen: SocketAddr, pub max_connections: usize, pub max_connections_per_ip: usize, pub read_timeout: Duration, pub header_timeout: Duration, pub body_timeout: Duration, pub shutdown_timeout: Duration, pub max_header_bytes: usize, pub max_body_bytes: usize, pub route_body_limits: Vec<(String, usize)>, pub response_timeout: Duration, pub security: SecurityConfig, pub metrics: Option<Arc<MetricsRegistry>>,
}

Fields§

§listen: SocketAddr§max_connections: usize§max_connections_per_ip: usize

单 IP 的 HTTP 并发连接上限(0 = 不限制;默认 24,与 C 版一致)。

§read_timeout: Duration§header_timeout: Duration

Total budget for receiving one request’s headers (slowloris guard, aligned with the C implementation): a peer that drips one byte per second is disconnected after this instead of holding a slot forever.

§body_timeout: Duration

Total budget for receiving one request’s body.

§shutdown_timeout: Duration§max_header_bytes: usize§max_body_bytes: usize§route_body_limits: Vec<(String, usize)>

按路径前缀覆盖 max_body_bytes(第一个匹配生效,未匹配用全局值)。

固件/配置导入这类本来就要上传大包的接口才需要大额度;其余接口保持 小额度,未认证的请求在读完头之后就被挡掉,不会先把整个包读进内存。

§response_timeout: Duration

Per-write deadline for response bodies. A peer that stops reading (slow/frozen client) is disconnected after this, instead of pinning a connection slot forever (R22).

§security: SecurityConfig§metrics: Option<Arc<MetricsRegistry>>

Optional global metrics registry for request counting.

Implementations§

Source§

impl HttpConfig

Source

pub fn new(listen: SocketAddr) -> Self

Source

pub fn validate(&self) -> Result<()>

Source

pub fn with_metrics(self, metrics: Arc<MetricsRegistry>) -> Self

Attach a global metrics registry (request/segment counters).

Trait Implementations§

Source§

impl Clone for HttpConfig

Source§

fn clone(&self) -> Self

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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more