[][src]Struct idcurl::Request

pub struct Request<'body> { /* fields omitted */ }

Represent an unsent query.

Calling send actually makes the request.

Methods

impl<'body> Request<'body>[src]

pub fn new(method: Method, url: Url) -> Request<'body>[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]

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]

pub fn set_body<R: 'body>(&mut self, r: R) where
    R: Read + 'body, 
[src]

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.

The specified body, if a reference, must outlive this Request.

pub fn body<'b, R: 'b>(self, r: R) -> Request<'b> where
    R: Read + 'b, 
[src]

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.

The returned Request has the lifetime of your Read, because the body you intend to send needs to outlive the Request. You can either give a reference with a reader (example: Cursor::new(&my_vector_object)) or you can give ownership (Cursor::new(owned_vector)).

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.

Auto Trait Implementations

impl<'body> !Send for Request<'body>

impl<'body> !Sync for Request<'body>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]