[][src]Struct cabot::request::RequestBuilder

pub struct RequestBuilder { /* fields omitted */ }

Construct Request

Methods

impl RequestBuilder[src]

pub fn new(url: &str) -> Self[src]

Create a new RequestBuilder with the given url.

url will be parsed to get the host to contact and the uri to send. When building a request object after creating the builder, the http method will be GET with neither header nor body and the http version will be HTTP/1.1

pub fn set_url(self, url: &str) -> Self[src]

Replace the url in case the RequestBuilder is used many time for multiple query.

pub fn set_http_method(self, http_method: &str) -> Self[src]

Set the http method such as GET POST. Default value is GET.

pub fn set_http_version(self, http_version: &str) -> Self[src]

Set the protocol version to use.. Default value is HTTP/1.1.

pub fn add_header(self, header: &str) -> Self[src]

Add a HTTP header.

pub fn add_headers(self, headers: &[&str]) -> Self[src]

Add many headers.

pub fn set_user_agent(self, user_agent: &str) -> Self[src]

Override the default user-agent

Important: don't add a user_agent usering the add_header function to avoid a duplicate header User-Agent

pub fn set_body(self, buf: &[u8]) -> Self[src]

Set a response body.

If a body is set, the Content-Length headers is added by cabot.

pub fn set_body_as_str(self, body: &str) -> Self[src]

Set a body to send in the query. By default a query has no body.

pub fn build(&self) -> CabotResult<Request>[src]

Construct the Request. To perform the query, a Client has to be created.

Errors:

  • CabotError::ParseUrlError in case the url is not parsable
  • CabotError::OpaqueUrlError in case the url is parsed but miss informations such as hostname.

Auto Trait Implementations

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<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]