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: DurationTotal 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: DurationTotal 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: DurationPer-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
impl HttpConfig
pub fn new(listen: SocketAddr) -> Self
pub fn validate(&self) -> Result<()>
Sourcepub fn with_metrics(self, metrics: Arc<MetricsRegistry>) -> Self
pub fn with_metrics(self, metrics: Arc<MetricsRegistry>) -> Self
Attach a global metrics registry (request/segment counters).
Trait Implementations§
Auto Trait Implementations§
impl Forget for HttpConfig
impl Freeze for HttpConfigwhere
*const u8 is !null: Freeze,
PhantomData<(String, usize)>: Freeze,
PhantomData<IpCidr>: Freeze,
*const ArcInner<MetricsRegistry> is !null: Freeze,
PhantomData<ArcInner<MetricsRegistry>>: Freeze,
impl Move for HttpConfig
impl RefUnwindSafe for HttpConfig
impl Send for HttpConfig
impl Sync for HttpConfig
impl Unpin for HttpConfig
impl UnsafeUnpin for HttpConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, usize)>: UnsafeUnpin,
PhantomData<IpCidr>: UnsafeUnpin,
*const ArcInner<MetricsRegistry> is !null: UnsafeUnpin,
PhantomData<ArcInner<MetricsRegistry>>: UnsafeUnpin,
impl UnwindSafe for HttpConfig
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