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).hash: The fragment identifier of the request (e.g., #section).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 Cow<'a, str>, allowing for efficient handling of both owned and borrowed string data.
§Parameters
key: The header key, which will be converted into aCow<'a, str>.value: The value of the header, which will be converted into aCow<'a, str>.
§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 set_method(&mut self, val: RequestMethod) -> &mut Self
pub fn get_host(&self) -> &RequestHost
pub fn set_host(&mut self, val: RequestHost) -> &mut Self
pub fn get_path(&self) -> &RequestPath
pub fn set_path(&mut self, val: RequestPath) -> &mut Self
pub fn get_query(&self) -> &RequestQuery
pub fn set_query(&mut self, val: RequestQuery) -> &mut Self
pub fn get_hash(&self) -> &RequestHash
pub fn set_hash(&mut self, val: RequestHash) -> &mut Self
pub fn get_headers(&self) -> &RequestHeaders
pub fn set_headers(&mut self, val: RequestHeaders) -> &mut Self
pub fn get_body(&self) -> &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