[−][src]Struct minreq::Request
An HTTP request.
Generally created by the minreq::get
-style
functions, corresponding to the HTTP method we want to use.
Example
let request = minreq::post("http://example.com");
After creating the request, you would generally call
send
or
send_lazy
on it, as it
doesn't do much on its own.
Implementations
impl Request
[src]
pub fn new<T: Into<URL>>(method: Method, url: T) -> Request
[src]
Creates a new HTTP Request
.
This is only the request's data, it is not sent yet. For
sending the request, see send
.
pub fn with_header<T: Into<String>, U: Into<String>>(
self,
key: T,
value: U
) -> Request
[src]
self,
key: T,
value: U
) -> Request
Adds a header to the request this is called on. Use this function to add headers to your requests.
pub fn with_body<T: Into<Vec<u8>>>(self, body: T) -> Request
[src]
Sets the request body.
pub fn with_timeout(self, timeout: u64) -> Request
[src]
Sets the request timeout in seconds.
pub fn with_max_redirects(self, max_redirects: usize) -> Request
[src]
Sets the max redirects we follow until giving up. 100 by default.
Warning: setting this to a very high number, such as 1000, may cause a stack overflow if that many redirects are followed. If you have a use for so many redirects that the stack overflow becomes a problem, please open an issue.
pub fn send(self) -> Result<Response, Error>
[src]
Sends this request to the host.
Errors
Returns Err
if we run into an error while sending the
request, or receiving/parsing the response. The specific error
is described in the Err
, and it can be any
minreq::Error
except
SerdeJsonError
and
InvalidUtf8InBody
.
pub fn send_lazy(self) -> Result<ResponseLazy, Error>
[src]
Trait Implementations
impl Clone for Request
[src]
impl Debug for Request
[src]
impl PartialEq<Request> for Request
[src]
impl StructuralPartialEq for Request
[src]
Auto Trait Implementations
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,