[−][src]Struct cabot::request::RequestBuilder
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]
Auto Trait Implementations
impl Send for RequestBuilder
impl Unpin for RequestBuilder
impl Sync for RequestBuilder
impl UnwindSafe for RequestBuilder
impl RefUnwindSafe for RequestBuilder
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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,