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.
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
`Client` API has had it replaced with `hyper::Uri`.
This also means `Error::Uri` has changed types to
`hyper::error::UriError`.
The type `hyper::header::parsing::HTTP_VALUE` has been made private,
as an implementation detail. The function `http_percent_encoding`
should be used instead.
The main changes are:
* The entry point is how `Http`, the implementation of `ServerProto`.
This type has a `new` constructor as well as builder methods to
configure it.
* A high-level entry point of `Http::bind` was added which returns a
`Server`. Binding a protocol to a port requires a socket address
(where to bind) as well as the instance of `NewService`. Internally
this creates a core and a TCP listener.
* The returned `Server` has a few methods to learn about itself, e.g.
`local_addr` and `handle`, but mainly has two methods: `run` and
`run_until`.
* The `Server::run` entry point will execute a server infinitely, never
having it exit.
* The `Server::run_until` method is intended as a graceful shutdown
mechanism. When the provided future resolves the server stops
accepting connections immediately and then waits for a fixed period of
time for all active connections to get torn down, after which the
whole server is torn down anyway.
* Finally a `Http::bind_connection` method exists as a low-level entry
point to spawning a server connection. This is used by `Server::run`
as is intended for external use in other event loops if necessary or
otherwise low-level needs.
BREAKING CHANGE: `Server` is no longer the pimary entry point. Instead,
an `Http` type is created and then either `bind` to receiver a `Server`,
or it can be passed to other Tokio things.
There are many changes involved with this, but let's just talk about
user-facing changes.
- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.
BREAKING CHANGE: A big sweeping set of breaking changes.
Closes#896Closes#897
BREAKING CHANGE: `RequestUri::AbsolutePath` variant is changed to a struct variant. Consider using `req.path()` or `req.query()` to get the relevant slice.
BREAKING CHANGE: Server::https was changed to allow any implementation
of Ssl. Server in general was also changed. HttpConnector no longer
uses SSL; using HttpsConnector instead.
Connector::connect already used &self, and so would require
synchronization to be handled per connector anyway. Adding Sync to the
Client allows users to setup config for a Client once, such as using a
single connection Pool, and then making requests across multiple
threads.
Closes#254
BREAKING CHANGE: Connectors and Protocols passed to the `Client` must
now also have a `Sync` bounds, but this shouldn't break default usage.
httparse is a http1 stateless push parser. This not only speeds up
parsing right now with sync io, but will also be useful for when we get
async io, since it's push based instead of pull.
BREAKING CHANGE: Several public functions and types in the `http` module
have been removed. They have been replaced with 2 methods that handle
all of the http1 parsing.
All instances of `old_io` and `old_path` were switched to use the new
shiny `std::io`, `std::net`, and `std::path` modules. This means that
`Request` and `Response` implement `Read` and `Write` now.
Because of the changes to `TcpListener`, this also takes the opportunity
to correct the method usage of `Server`. As with other
languages/frameworks, the server is first created with a handler, and
then a host/port is passed to a `listen` method. This reverses what
`Server` used to do.
Closes#347
BREAKING CHANGE: Check the docs. Everything was touched.
This is a modified and specialized thread pool meant for
managing an acceptor in a multi-threaded way. A single handler
is provided which will be invoked on each stream.
Unlike the old thread pool, this returns a join guard which
will block until the acceptor closes, enabling friendly behavior
for the listening guard.
The task pool itself is also faster as it only pays for message passing
if sub-threads panic. In the optimistic case where there are few panics,
this saves using channels for any other communication.
This improves performance by around 15%, all the way to 105k req/sec
on my machine, which usually gets about 90k.
BREAKING_CHANGE: server::Listening::await is removed.
Currently headers are exported at many places. For example you can access
`Transfer-Encoding` header at `header`, `header::common` and
`header::common::transfer_encoding`. Per discussion on IRC with
@seanmonstar and @reem, all contents of headers will be exposed at `header`
directly. Parsing utilities will be exposed at `header::parsing`. Header
macros can now be used from other crates.
This breaks much code using headers. It should use everything it needs
directly from `header::`, encodings are exposed at `header::Encoding::`,
connection options are exposed at `header::ConnectionOption`.
- Includes ergonomic traits like IntoUrl and IntoBody, allowing easy
usage.
- Client can have a RedirectPolicy.
- Client can have a SslVerifier.
Updated benchmarks for client. (Disabled rust-http client bench since it
hangs.)