- Placed all cases of "unexpected bytes" errors into the
`UnexpectedMessage` variant.
- Placed all cases of "unexpected EOF" errors into the
`IncompleteMessage` variant. Description is now generic about
"connection closed before message completed", instead of mentioning
"request" or "response.
- Added `Error::is_incomplete_message()` accessor to help checking for
unexpected closures.
- Renamed some variants to be clearer when viewing the `Debug` format.
- Collected all "user" errors into an internal `User` enum, to prevent
forgetting to update the `is_user()` method.
- Adds `Connected::negotiated_h2()` method to signal the connection must
use HTTP2. `Connect` implementations should set this if using ALPN.
If a connection to a host is detected to have been upgraded via ALPN,
any other oustanding connect futures will be canceled, and the waiting
requests will make use of the single HTTP2 connection.
The `http2_only` builder configuration still works the same, not
requiring ALPN at all, and always using only a single connection.
If a checkout wins, meaning an idle connection became available before
a connect future completed, instead of just dropping the connect future,
it spawns it into the background executor to allow being placed into
the pool on completion.
If executing an internal task fails, a new variant of `hyper::Error` is
returned to the user, with improved messaging.
If a non-critical task fails to spawn, it no longer panics, instead just
logging a warning.
Closes#1566
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.
- `Client::new()` no longer needs a `Handle`, and instead makes use of
tokio's implicit default.
- Changed `Client::configure()` to `Client::builder()`.
- `Builder` is a by-ref builder, since all configuration is now
cloneable pieces.
BREAKING CHANGE: `Client:new(&handle)` and `Client::configure()` are now
`Client::new()` and `Client::builder()`.
**The `Error` is now an opaque struct**, which allows for more variants to
be added freely, and the internal representation to change without being
breaking changes.
For inspecting an `Error`, there are several `is_*` methods to check for
certain classes of errors, such as `Error::is_parse()`. The `cause` can
also be inspected, like before. This likely seems like a downgrade, but
more inspection can be added as needed!
The `Error` now knows about more states, which gives much more context
around when a certain error occurs. This is also expressed in the
description and `fmt` messages.
**Most places where a user would provide an error to hyper can now pass
any error type** (`E: Into<Box<std::error::Error>>`). This error is passed
back in relevant places, and can be useful for logging. This should make
it much clearer about what error a user should provide to hyper: any it
feels is relevant!
Closes#1128Closes#1130Closes#1431Closes#1338
BREAKING CHANGE: `Error` is no longer an enum to pattern match over, or
to construct. Code will need to be updated accordingly.
For body streams or `Service`s, inference might be unable to determine
what error type you mean to return. Starting in Rust 1.26, you could
just label that as `!` if you never return an error.
If a request sees an error on a pooled connection before ever writing
any bytes, it will now retry with a new connection.
This can be configured with `Config::retry_canceled_requests(bool)`.
On some OSes, `Instant` would start counting 0 from the boot time. That
would mean that any `Instant::now() - dur` soon after boot had a higher
risk of overflowing. Now, the expiration is determined by calling
`idle.elapsed()`, and comparing durations.
Closes#1215