upgrade hyper to v0.11
This commit is contained in:
16
examples/async.rs
Normal file
16
examples/async.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
extern crate futures;
|
||||
extern crate reqwest;
|
||||
extern crate tokio_core;
|
||||
|
||||
use futures::Future;
|
||||
|
||||
fn main() {
|
||||
let mut core = tokio_core::reactor::Core::new().unwrap();
|
||||
let client = reqwest::unstable::async::Client::new(&core.handle()).unwrap();
|
||||
|
||||
let work = client.get("https://hyper.rs").unwrap().send().map(|res| {
|
||||
println!("{}", res.status());
|
||||
});
|
||||
|
||||
core.run(work).unwrap();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
//! `cargo run --example response_json`
|
||||
extern crate reqwest;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
ReqError(reqwest::Error);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Response {
|
||||
origin: String,
|
||||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let mut res = reqwest::get("https://httpbin.org/ip")?;
|
||||
let json = res.json::<Response>()?;
|
||||
println!("JSON: {:?}", json);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
quick_main!(run);
|
||||
@@ -16,7 +16,7 @@ fn run() -> Result<()> {
|
||||
|
||||
println!("GET https://www.rust-lang.org");
|
||||
|
||||
let mut res = reqwest::get("https://www.rust-lang.org")?;
|
||||
let mut res = reqwest::get("https://www.rust-lang.org/en-US/")?;
|
||||
|
||||
println!("Status: {}", res.status());
|
||||
println!("Headers:\n{}", res.headers());
|
||||
|
||||
Reference in New Issue
Block a user