pub struct HttpRequest {
pub host: String,
pub path: String,
pub method: &'static str,
pub headers: Vec<(&'static str, Arc<str>)>,
pub body: String,
}
Expand description
HTTP request encapsulation.
This type represents an HTTP request. Supports pretty-printing the request as a string (through
the std::fmt::Display
trait).
§reqwest
/reqwest-blocking
feature
If the reqwest
/reqwest-blocking
feature is enabled, the
HttpRequest
type can be converted to a reqwest::Request
or
reqwest::blocking::Request
using the try_into_reqwest
or try_into_reqwest_blocking
methods.
Additionally, the From<HttpRequest>
trait is implemented for reqwest::Request
and
reqwest::blocking::Request
, beware that it will panic if the conversion fails.
Fields§
§host: String
Request host.
path: String
Request path.
method: &'static str
HTTP method.
headers: Vec<(&'static str, Arc<str>)>
Request headers.
body: String
Request body.
Implementations§
Source§impl HttpRequest
impl HttpRequest
Sourcepub fn render_headers(&self) -> String
pub fn render_headers(&self) -> String
Renders the headers as a string.
The returned string is suitable for use in an HTTP request unaltered. Does not include the
Host
header.
Trait Implementations§
Source§impl Debug for HttpRequest
impl Debug for HttpRequest
Auto 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