feat(lib): add support to disable tokio-proto internals
For now, this adds `client::Config::no_proto`, `server::Http::no_proto`, and `server::Server::no_proto` to skip tokio-proto implementations, and use an internal dispatch system instead. `Http::no_proto` is similar to `Http::bind_connection`, but returns a `Connection` that is a `Future` to drive HTTP with the provided service. Any errors prior to parsing a request, and after delivering a response (but before flush the response body) will be returned from this future. See #1342 for more.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings)]
|
||||
//#![deny(warnings)]
|
||||
extern crate futures;
|
||||
extern crate hyper;
|
||||
extern crate tokio_core;
|
||||
@@ -32,7 +32,9 @@ fn main() {
|
||||
|
||||
let mut core = tokio_core::reactor::Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
let client = Client::new(&handle);
|
||||
let client = Client::configure()
|
||||
.no_proto()
|
||||
.build(&handle);
|
||||
|
||||
let work = client.get(url).and_then(|res| {
|
||||
println!("Response: {}", res.status());
|
||||
|
||||
@@ -31,7 +31,8 @@ impl Service for Hello {
|
||||
fn main() {
|
||||
pretty_env_logger::init().unwrap();
|
||||
let addr = "127.0.0.1:3000".parse().unwrap();
|
||||
let server = Http::new().bind(&addr, || Ok(Hello)).unwrap();
|
||||
let mut server = Http::new().bind(&addr, || Ok(Hello)).unwrap();
|
||||
server.no_proto();
|
||||
println!("Listening on http://{} with 1 thread.", server.local_addr().unwrap());
|
||||
server.run().unwrap();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ fn main() {
|
||||
pretty_env_logger::init().unwrap();
|
||||
let addr = "127.0.0.1:1337".parse().unwrap();
|
||||
|
||||
let server = Http::new().bind(&addr, || Ok(Echo)).unwrap();
|
||||
let mut server = Http::new().bind(&addr, || Ok(Echo)).unwrap();
|
||||
server.no_proto();
|
||||
println!("Listening on http://{} with 1 thread.", server.local_addr().unwrap());
|
||||
server.run().unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user