A Cargo feature `runtime` is added, which is enabled by default, that
includes the following:
- The `client::HttpConnector`, which uses `tokio::net::TcpStream`.
- The `server::AddrStream`, which uses `tokio::net::TcpListener`.
- The `hyper::rt` module, which includes useful utilities to work with
the runtime without needing to import `futures` or `tokio` explicity.
Disabling the feature removes many of these niceties, but allows people
to use hyper in environments that have an alternative runtime, without
needing to download an unused one.
This introduces the `hyper::service` module, which replaces
`tokio-service`.
Since the trait is specific to hyper, its associated
types have been adjusted. It didn't make sense to need to define
`Service<Request=http::Request>`, since we already know the context is
HTTP. Instead, the request and response bodies are associated types now,
and slightly stricter bounds have been placed on `Error`.
The helpers `service_fn` and `service_fn_ok` should be sufficient for
now to ease creating `Service`s.
The `NewService` trait now allows service creation to also be
asynchronous.
These traits are similar to `tower` in nature, and possibly will be
replaced completely by it in the future. For now, hyper defining its own
allows the traits to have better context, and prevents breaking changes
in `tower` from affecting hyper.
Closes#1461
BREAKING CHANGE: The `Service` trait has changed: it has some changed
associated types, and `call` is now bound to `&mut self`.
The `NewService` trait has changed: it has some changed associated
types, and `new_service` now returns a `Future`.
`Client` no longer implements `Service` for now.
`hyper::server::conn::Serve` now returns `Connecting` instead of
`Connection`s, since `new_service` can now return a `Future`. The
`Connecting` is a future wrapping the new service future, returning
a `Connection` afterwards. In many cases, `Future::flatten` can be
used.
The `hyper::Server` is now a proper higher-level API for running HTTP
servers. There is a related `hyper::server::Builder` type, to construct
a `Server`. All other types (`Http`, `Serve`, etc) were moved into the
"lower-level" `hyper::server::conn` module.
The `Server` is a `Future` representing a listening HTTP server. Options
needed to build one are set on the `Builder`.
As `Server` is just a `Future`, it no longer owns a thread-blocking
executor, and can thus be run next to other servers, clients, or
what-have-you.
Closes#1322Closes#1263
BREAKING CHANGE: The `Server` is no longer created from `Http::bind`,
nor is it `run`. It is a `Future` that must be polled by an
`Executor`.
The `hyper::server::Http` type has move to
`hyper::server::conn::Http`.
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.
- Adds `Http::serve_addr_handle` which will bind to an address with a
provided `Handle`, and return a `Serve`.
- Adds `server::Serve` which is a `Stream` of incoming `Connection`s
being bound by a `NewService`.
- Renames `Http::no_proto` to `Http::serve_connection`.