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
- Add `Body::Kind::H2` to contain the content length of the body.
- Update `Body::content_length` to return the content length if `Body::Kind` is `H2`, instead of returning `None`.
Reference: #1556, #1557Closes#1546
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
these upgrades when using lower-level API (because of a missing
`Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
upgrade requests.
- Returns a smaller `DecodedLength` type instead of the fatter
`Decoder`, which should also allow a couple fewer branches.
- Removes the `Decode::Ignore` wrapper enum, and instead ignoring
1xx responses is handled directly in the response parsing code.
Ref #1563Closes#1395
Automatically removes "connection" headers before sending over HTTP2.
These headers are illegal in HTTP2, and would otherwise cause errors.
Closes: #1551
When getting a `Body` from hyper, such as in a client response,
the method `Body::content_length()` now returns a value if the header
was present.
Closes#1545
- In the higher-level `Server` API, since connection upgrades aren't yet
supported, returning a 2xx response to a `CONNECT` request is a user
error. A 500 response is written to the client, the connection is
closed, and an error is reported back to the user.
- In the lower-level `server::Connection` API, where upgrades *are*
supported, a 2xx response correctly marks the response as the final
one, instead of trying to parse more requests afterwards.
- The `cause2` method adds a `'static` bound, allowing to downcast the error type.
- The `into_cause` method converts an `Error` into its optional cause.
Closes#1542
This allows a client or server to indicate that the body should be cut off
in an abnormal fashion so the server doesn't simply get a "valid" but
truncated body.
A new configuration http1_only to Builder and Connection are added, which indicates that the upgrading to h2 does not perform when a parsing error occurs.
Fixes#1512.
- When the `Body` is created from a buffer of bytes (such as
`Body::from("hello")`), we can skip some bookkeeping that is
normally required for streaming bodies.
- Orthogonally, optimize encoding body chunks when the strategy
is to flatten into the headers buf, by skipping the EncodedBuf
enum.