Struct reqwest::RequestBuilder
[−]
[src]
pub struct RequestBuilder { /* fields omitted */ }
A builder to construct the properties of a Request
.
Methods
impl RequestBuilder
[src]
pub fn header<H: Header + HeaderFormat>(self, header: H) -> RequestBuilder
[src]
Add a Header
to this Request.
use reqwest::header::UserAgent; let client = reqwest::Client::new().expect("client failed to construct"); let res = client.get("https://www.rust-lang.org") .header(UserAgent("foo".to_string())) .send();
pub fn headers(self, headers: Headers) -> RequestBuilder
[src]
Add a set of Headers to the existing ones on this Request.
The headers will be merged in to any already set.
pub fn body<T: Into<Body>>(self, body: T) -> RequestBuilder
[src]
Set the request body.
pub fn form<T: Serialize>(self, form: &T) -> RequestBuilder
[src]
Send a form body.
Sets the body to the url encoded serialization of the passed value,
and also sets the Content-Type: application/www-form-url-encoded
header.
let mut params = HashMap::new(); params.insert("lang", "rust"); let client = reqwest::Client::new().unwrap(); let res = client.post("http://httpbin.org") .form(¶ms) .send();
pub fn json<T: Serialize>(self, json: &T) -> RequestBuilder
[src]
Send a JSON body.
Sets the body to the JSON serialization of the passed value, and
also sets the Content-Type: application/json
header.
let mut map = HashMap::new(); map.insert("lang", "rust"); let client = reqwest::Client::new().unwrap(); let res = client.post("http://httpbin.org") .json(&map) .send();
pub fn send(self) -> Result<Response>
[src]
Constructs the Request and sends it the target URL, returning a Response.