feat(lib): replace types with those from http crate

BREAKING CHANGE: `Method`, `Request`, `Response`, `StatusCode`,
  `Version`, and `Uri` have been replaced with types from the `http`
  crate. The `hyper::header` module is gone for now.

  Removed `Client::get`, since it needed to construct a `Request<B>`
  with an empty body. Just use `Client::request` instead.

  Removed `compat` cargo feature, and `compat` related API.
This commit is contained in:
Sean McArthur
2018-02-28 16:37:17 -08:00
parent a37e6b59e6
commit 3cd48b45fb
109 changed files with 1004 additions and 14411 deletions

View File

@@ -11,7 +11,7 @@ use std::io::{self, Write};
use futures::Future;
use futures::stream::Stream;
use hyper::Client;
use hyper::{Body, Client, Request};
fn main() {
pretty_env_logger::init();
@@ -25,7 +25,7 @@ fn main() {
};
let url = url.parse::<hyper::Uri>().unwrap();
if url.scheme() != Some("http") {
if url.scheme_part().map(|s| s.as_ref()) != Some("http") {
println!("This example only works with 'http' URLs.");
return;
}
@@ -34,11 +34,13 @@ fn main() {
let handle = core.handle();
let client = Client::new(&handle);
let work = client.get(url).and_then(|res| {
let mut req = Request::new(Body::empty());
*req.uri_mut() = url;
let work = client.request(req).and_then(|res| {
println!("Response: {}", res.status());
println!("Headers: \n{}", res.headers());
println!("Headers: {:#?}", res.headers());
res.body().for_each(|chunk| {
res.into_parts().1.for_each(|chunk| {
io::stdout().write_all(&chunk).map_err(From::from)
})
}).map(|_| {