pub struct HttpRequest {
pub method: String,
pub path: String,
pub protocol: String,
pub headers: HashMap<String, String>,
pub body: Vec<u8>,
pub ip: Option<String>,
}
Fields§
§method: String
§path: String
§protocol: String
§headers: HashMap<String, String>
§body: Vec<u8>
§ip: Option<String>
Implementations§
Source§impl HttpRequest
impl HttpRequest
pub fn new() -> Self
Sourcepub fn get() -> Self
pub fn get() -> Self
Builds a default GET request equal to:
HttpRequest::new().method(“GET”).path(“/”)
Sourcepub fn post() -> Self
pub fn post() -> Self
Builds a default POST request equal to:
HttpRequest::new().method(“POST”).path(“/”)
Sourcepub fn put() -> Self
pub fn put() -> Self
Builds a default PUT request equal to:
HttpRequest::new().method(“PUT”).path(“/”)
Sourcepub fn delete() -> Self
pub fn delete() -> Self
Builds a default DELETE request equal to:
HttpRequest::new().method(“DELETE”).path(“/”)
pub fn header(self, key: &str, value: &str) -> Self
pub fn body_bytes(self, body: &[u8]) -> Self
pub fn body_string(self, body: &str) -> Self
pub fn method(self, method: &str) -> Self
pub fn path(self, path: &str) -> Self
pub fn ip(self, ip: String) -> Self
pub fn body_to_string(&self) -> String
pub fn to_bytes(&self) -> Vec<u8> ⓘ
pub async fn from_stream<S: AsyncRead + AsyncWrite + Unpin>( stream: &mut S, ) -> Result<HttpRequest>
Trait Implementations§
Source§impl Clone for HttpRequest
impl Clone for HttpRequest
Source§fn clone(&self) -> HttpRequest
fn clone(&self) -> HttpRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for HttpRequest
impl RefUnwindSafe for HttpRequest
impl Send for HttpRequest
impl Sync for HttpRequest
impl Unpin for HttpRequest
impl UnwindSafe for HttpRequest
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