reqwest 0.2.0

higher level HTTP client library

Struct reqwest::RequestBuilder [] [src]

pub struct RequestBuilder { /* fields omitted */ }

A builder to construct the properties of a Request.

Methods

impl 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();

Add a set of Headers to the existing ones on this Request.

The headers will be merged in to any already set.

Set the request body.

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(&params)
    .send();

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();

Constructs the Request and sends it the target URL, returning a Response.

Trait Implementations

impl Debug for RequestBuilder
[src]

Formats the value using the given formatter.