Struct cabot::request::RequestBuilder
[−]
[src]
pub struct RequestBuilder { /* fields omitted */ }
Construct Request
Methods
impl RequestBuilder
[src]
fn new(url: &str) -> Self
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
fn set_url(self, url: &str) -> Self
Replace the url in case the RequestBuilder is used many time for multiple query.
fn set_http_method(self, http_method: &str) -> Self
Set the http method such as GET
POST
. Default value is GET
.
fn set_http_version(self, http_version: &str) -> Self
Set the protocol version to use.. Default value is HTTP/1.1
.
fn add_header(self, header: &str) -> Self
Add a HTTP header.
fn add_headers(self, headers: &[&str]) -> Self
Add many headers.
fn set_user_agent(self, user_agent: &str) -> Self
Override the default user-agent
Important: don't add a user_agent usering the add_header
function
to avoid a duplicate header User-Agent
fn set_body(self, buf: &[u8]) -> Self
Set a response body.
If a body is set, the Content-Length
headers is added by cabot.
fn set_body_as_str(self, body: &str) -> Self
Set a body to send in the query. By default a query has no body.