[−][src]Struct idcurl::Request
Represent an unsent query.
Calling send
actually makes the request.
Methods
impl Request
[src]
pub fn new(method: Method, url: Url) -> Self
[src]
Create a request for a specific HTTP method and Url
pub fn get(url: Url) -> Self
[src]
create a GET request
You may then use the builder-pattern to configure the request
and then call send()
to begin it
pub fn post(url: Url) -> Self
[src]
create a POST request
You should specify a payload to send with body()
or set_body()
, which will be read
before the request turns into a Response.
pub fn put(url: Url) -> Self
[src]
create a PUT request
You should specify a payload to send with body()
or set_body()
, which will be read
before the request turns into a Response.
pub fn set_content_length(&mut self, l: u64)
[src]
set the HTTP Content-Length header
If specified, the value is sent as the Content-Length
header.
It's undefined what happens if you set this incorrectly.
pub fn content_length(self, l: u64) -> Self
[src]
set the HTTP Content-Length header
If specified, the value is sent as the Content-Length
header.
It's undefined what happens if you set this incorrectly.
pub fn set_header<K, V>(&mut self, k: K, v: V) where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
Add one HTTP header to the request.
Any values may be sent, even those that may be invalid
according to the HTTP specification. You should
prefer to use the Header
constants
in the idcurl::Header
module.
pub fn header<K, V>(self, k: K, v: V) -> Self where
K: AsRef<[u8]>,
V: AsRef<[u8]>,
[src]
K: AsRef<[u8]>,
V: AsRef<[u8]>,
pub fn set_body<R>(&mut self, r: R) where
R: Read + 'static,
[src]
R: Read + 'static,
Sets the reader which the payload to send is read from
The entire body is read before send()
completes.
The body is not read for the GET and DELETE methods.
pub fn body<R>(self, r: R) -> Self where
R: Read + 'static,
[src]
R: Read + 'static,
pub fn send(self) -> Result<Response>
[src]
Make the HTTP request.
The configured request is sent along with its headers,
then if specified, the body
is sent
if the Method is appropriate.
The function succeeds and you get a Response if the server could be contacted and an HTTP session was initiated.
You should then call Response::status().is_success()
to check for an HTTP status code in the 200 range.
pub fn set_redirect_limit(&mut self, n: Option<usize>) -> &mut Self
[src]
sets the number of redirects that will be followed
The default is 10. An error will be returned if the number is exceeded.
Specify None
to disable handling redirects. A redirect
is not an error, instead you will get a Response
for the redirect response.
pub fn redirect_limit(self, n: Option<usize>) -> Self
[src]
sets the number of redirects that will be followed
The default is 10. An error will be returned if the number is exceeded.
Specify None
to disable handling redirects. A redirect
is not an error, instead you will get a Response
for the redirect response.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,