forked from seanmonstar/reqwest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.rs
40 lines (31 loc) · 746 Bytes
/
post.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//#![feature(proc_macro)]
extern crate reqwest;
extern crate env_logger;
//#[macro_use] extern crate serde_derive;
/*
#[derive(Serialize)]
struct Thingy {
a: i32,
b: bool,
c: String,
}
*/
fn main() {
env_logger::init().unwrap();
println!("POST https://httpbin.org/post");
/*
let thingy = Thingy {
a: 5,
b: true,
c: String::from("reqwest")
};
*/
let client = reqwest::Client::new();
let mut res = client.post("https://httpbin.org/post")
.body("foo=bar")
.send().unwrap();
println!("Status: {}", res.status());
println!("Headers:\n{}", res.headers());
::std::io::copy(&mut res, &mut ::std::io::stdout()).unwrap();
println!("\n\nDone.");
}