Previously, hyper returned an "Invalid chunk end CR" error on chunked
responses with trailers, as described in RFC 7230 Section 4.1.2. This
commit adds code to ignore the trailers.
Closes#2171
Move state required for protocol upgrades to head
representations, instead of associating it with the body.
Closes#2340.
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
We use hyper in a proxy-like way where an incoming HTTP/2 request is
proxied to a HTTP/1 backend and it was reported that the protocol
coercion warnings were a limiting factor in the total throughput
of the system.
While it can be worked around by explicitly setting the request version
to HTTP_11, it seems likely other people also hit this performance snag.
That's why this commit changes them from warnings to debug messages.
The DNS resolver part of `HttpConnector` used to require resolving to
`IpAddr`s, and this changes it so that they resolve to `SocketAddr`s.
The main benefit here is allowing for resolvers to set the IPv6 zone ID
when resolving, but it also just more closely matches
`std::net::ToSocketAddrs`.
Closes#1937
BREAKING CHANGE: Custom resolvers used with `HttpConnector` must change
to resolving to an iterator of `SocketAddr`s instead of `IpAddr`s.
Add basic, module level example for the Builder performing a handshake,
spawning a task to run the Connection and sending a single request and
receiving the response.
Closes#2272
Closes#2326
BREAKING CHANGE: hyper no longer emits `log` records automatically.
If you need hyper to integrate with a `log` logger (as opposed to `tracing`),
you can add `tracing = { version = "0.1", features = ["log"] }` to activate them.
Tokio's `AsyncWrite` trait once again has support for vectored writes in
Tokio 0.3.4 (see tokio-rs/tokio#3149).
This branch re-enables vectored writes in Hyper for HTTP/1. Using
vectored writes in HTTP/2 will require an upstream change in the `h2`
crate as well.
I've removed the adaptive write buffer implementation
that attempts to detect whether vectored IO is or is not available,
since the Tokio 0.3.4 `AsyncWrite` trait exposes this directly via the
`is_write_vectored` method. Now, we just ask the IO whether or not it
supports vectored writes, and configure the buffer accordingly. This
makes the implementation somewhat simpler.
This also removes `http1_writev()` methods from the builders. These are
no longer necessary, as Hyper can now determine whether or not
to use vectored writes based on `is_write_vectored`, rather than trying
to auto-detect it.
Closes#2320
BREAKING CHANGE: Removed `http1_writev` methods from `client::Builder`,
`client::conn::Builder`, `server::Builder`, and `server::conn::Builder`.
Vectored writes are now enabled based on whether the `AsyncWrite`
implementation in use supports them, rather than though adaptive
detection. To explicitly disable vectored writes, users may wrap the IO
in a newtype that implements `AsyncRead` and `AsyncWrite` and returns
`false` from its `AsyncWrite::is_write_vectored` method.
This branch updates `bytes` and `http-body` to the latest versions. The
`http-body` version that uses `bytes` 0.6 hasn't been released yet, so
we depend on it via a git dep for now. Presumably Hyper and `http-body`
will synchronize their releases.
Other than that, this is a pretty mechanical update. Should fix the
build and unblock the `h2` update to use vectored writes.
cc #2223
BREAKING CHANGE: The HTTP server code is now an optional feature. To
enable the server, add `features = ["server"]` to the dependency in
your `Cargo.toml`.
cc #2223
BREAKING CHANGE: The HTTP client of hyper is now an optional feature. To
enable the client, add `features = ["client"]` to the dependency in
your `Cargo.toml`.
cc #2251
BREAKING CHANGE: This puts all HTTP/1 methods and support behind an
`http1` cargo feature, which will not be enabled by default. To use
HTTP/1, add `features = ["http1"]` to the hyper dependency in your
`Cargo.toml`.
The current implementation of `drain` uses a `tokio::sync::watch`
channel to send the shutdown signal, and a `tokio::sync::mpsc` to signal
when all draining tasks have completed. No data is ever actually sent on
the MPSC; instead, it is simply used to notify the task that signalled
the drain when all draining tasks have been dropped.
Tokio 0.3's `watch::Sender` has a `closed` method that can be used to
await the dropping of all receivers. This can be used instead of the
MPSC channel. This commit updates `drain` to use `watch::Sender::closed`
instead. This has fewer moving parts, and may have slightly less
overhead (as it doesn't require additional allocation forthe MPSC which
is never actually used).
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
cc #2251
BREAKING CHANGE: This puts all HTTP/2 methods and support behind an
`http2` cargo feature, which will not be enabled by default. To use
HTTP/2, add `features = ["http2"]` to the hyper dependency in your
`Cargo.toml`.
`KeepAliveState` did not transition from `PingSent` to `Scheduled` after
a pong was received. This prevented more than one ping to be sent by the
server. This fix checks if `ping_sent_at` has already been cleared by
`Ponger::poll` when `KeepAliveState::PingSent` state is active.
Fixes#2310
Currently HttpConnector::set_local_address method accepts a single
argument. Server might not support IPv6 or IPv4. Therefore, the only
solution at the moment is to manually perform DNS resolution and pick
appropriate local address family. This is inefficient, as leads to
2 DNS lookups per request. This commit allows specifying both IPv4
and IPv6, so connector can decide which one to use based on DNS
resolution results.
Previously, calling `http1_writev(true)` would just keep the default behavior, which was to auto detect if writev was optimal. Now, the auto-detection is still default, but explicitly calling `http1_writev(true)` will skip the auto-detection, and always use writev queue strategy.
Closes#2282
Add basic, module-level example for the Http struct in the server::conn module that shows how to customize the configuration of the HTTP protocol handling and then serve requests received through a tokio TCP stream.
- update proto::h1::end_body to return Result<()>
- update Encoder::end to return Error(NotEof) only when there's Content-length left to be addressed
Closes#2263