Struct reqwest::RequestBuilder
[−]
[src]
pub struct RequestBuilder { /* fields omitted */ }
A builder to construct the properties of a Request
.
Methods
impl RequestBuilder
[src]
fn header<H: Header + HeaderFormat>(self, header: H) -> RequestBuilder
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();
fn headers(self, headers: Headers) -> RequestBuilder
Add a set of Headers to the existing ones on this Request.
The headers will be merged in to any already set.
fn body<T: Into<Body>>(self, body: T) -> RequestBuilder
Set the request body.
fn form<T: Serialize>(self, form: &T) -> RequestBuilder
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();
fn json<T: Serialize>(self, json: &T) -> RequestBuilder
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();
fn send(self) -> Result<Response>
Constructs the Request and sends it the target URL, returning a Response.