RequestConfig

Struct RequestConfig 

Source
pub struct RequestConfig(/* private fields */);
Expand description

Thread-safe configuration wrapper for HTTP request parsing.

This struct uses ArcRwLock to provide thread-safe access to RequestConfigData , allowing concurrent reads and exclusive writes. It is the public-facing API for configuring HTTP request parsing limits.

Implementations§

Source§

impl RequestConfig

Source

pub async fn new() -> Self

Creates a new RequestConfig with default secure settings.

This constructor initializes the configuration with standard security limits suitable for most HTTP request parsing scenarios.

§Returns
  • Self - A new RequestConfig instance with default settings.
Source

pub async fn high_security() -> Self

Creates a new RequestConfig with high-security settings.

This constructor initializes the configuration with more restrictive limits to provide maximum protection against various attacks in high-risk environments.

§Returns
  • Self - A new RequestConfig instance with high-security settings.
Source

pub async fn data(&self, data: RequestConfigData) -> &Self

Sets the configuration data.

§Arguments
  • RequestConfigData - The configuration data.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn get_data(&self) -> RequestConfigData

Gets the configuration data.

§Returns
  • RequestConfigData - The inner configuration.
Source

pub async fn buffer_size(&self, buffer_size: usize) -> &Self

Sets the buffer size for reading operations.

§Arguments
  • usize - The buffer size in bytes.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_request_line_length( &self, max_request_line_length: usize, ) -> &Self

Sets the maximum length for HTTP request line in bytes.

§Arguments
  • usize - The maximum request line length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_path_length(&self, max_path_length: usize) -> &Self

Sets the maximum length for URL path in bytes.

§Arguments
  • usize - The maximum path length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_query_length(&self, max_query_length: usize) -> &Self

Sets the maximum length for query string in bytes.

§Arguments
  • usize - The maximum query string length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_header_line_length( &self, max_header_line_length: usize, ) -> &Self

Sets the maximum length for a single header line in bytes.

§Arguments
  • usize - The maximum header line length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_header_count(&self, max_header_count: usize) -> &Self

Sets the maximum number of headers allowed in a request.

§Arguments
  • usize - The maximum header count.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_header_key_length(&self, max_header_key_length: usize) -> &Self

Sets the maximum length for a header key in bytes.

§Arguments
  • usize - The maximum header key length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_header_value_length( &self, max_header_value_length: usize, ) -> &Self

Sets the maximum length for a header value in bytes.

§Arguments
  • usize - The maximum header value length.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_body_size(&self, max_body_size: usize) -> &Self

Sets the maximum size for request body in bytes.

§Arguments
  • usize - The maximum body size.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_ws_frame_size(&self, max_ws_frame_size: usize) -> &Self

Sets the maximum size for WebSocket frame in bytes.

§Arguments
  • usize - The maximum WebSocket frame size.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn max_ws_frames(&self, max_ws_frames: usize) -> &Self

Sets the maximum number of WebSocket frames to process in a single request.

§Arguments
  • usize - The maximum WebSocket frames count.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn http_read_timeout_ms(&self, http_read_timeout_ms: u64) -> &Self

Sets the timeout for reading HTTP request in milliseconds.

§Arguments
  • u64 - The HTTP read timeout in milliseconds.
§Returns
  • &Self - The RequestConfig instance for chaining.
Source

pub async fn ws_read_timeout_ms(&self, ws_read_timeout_ms: u64) -> &Self

Sets the timeout for reading WebSocket frames in milliseconds.

§Arguments
  • u64 - The WebSocket read timeout in milliseconds.
§Returns
  • &Self - The RequestConfig instance for chaining.

Trait Implementations§

Source§

impl Clone for RequestConfig

Source§

fn clone(&self) -> RequestConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for RequestConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<RequestConfigData> for RequestConfig

Implementation of From trait for RequestConfig.

Source§

fn from(ctx: RequestConfigData) -> Self

Converts a RequestConfigData into a RequestConfig.

§Arguments
  • RequestConfigData - The wrapped context data.
§Returns
  • RequestConfig - The newly created context instance.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,