pub struct Request { /* private fields */ }Expand description
Represents an HTTP request.
§Fields
method: The HTTP method of the request (e.g., GET, POST).host: The host of the request (e.g., example.com).path: The path of the request (e.g., /api/v1/resource).query: The query string of the request (e.g., ?key=value).headers: A collection of HTTP headers as key-value pairs.body: The binary body of the request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(stream: &TcpStream) -> RequestNewResult
pub fn new(stream: &TcpStream) -> RequestNewResult
Sourcepub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self
pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self
Adds a header to the request.
This function inserts a key-value pair into the request headers.
The key and value are converted into String, allowing for efficient handling of both owned and borrowed string data.
§Parameters
key: The header key, which will be converted into aString.value: The value of the header, which will be converted into aString.
§Returns
- Returns a mutable reference to the current instance (
&mut Self), allowing for method chaining.
Source§impl Request
impl Request
pub fn get_method(&self) -> &RequestMethod
pub fn get_mut_method(&mut self) -> &mut RequestMethod
pub fn set_method(&mut self, val: RequestMethod) -> &mut Self
pub fn get_host(&self) -> &RequestHost
pub fn get_mut_host(&mut self) -> &mut RequestHost
pub fn set_host(&mut self, val: RequestHost) -> &mut Self
pub fn get_path(&self) -> &RequestPath
pub fn get_mut_path(&mut self) -> &mut RequestPath
pub fn set_path(&mut self, val: RequestPath) -> &mut Self
pub fn get_query(&self) -> &RequestQuery
pub fn get_mut_query(&mut self) -> &mut RequestQuery
pub fn set_query(&mut self, val: RequestQuery) -> &mut Self
pub fn get_headers(&self) -> &RequestHeaders
pub fn get_mut_headers(&mut self) -> &mut RequestHeaders
pub fn set_headers(&mut self, val: RequestHeaders) -> &mut Self
pub fn get_body(&self) -> &RequestBody
pub fn get_mut_body(&mut self) -> &mut RequestBody
pub fn set_body(&mut self, val: RequestBody) -> &mut Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
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