This new function allows attaching a callback to a request, such that
when it is sent through a hyper client connection, and any 1xx
informational responses are received, they are passed to the callback.
This takes the unstable client informational feature (introduced in
#2594, tracking issue in #2565), and promotes it to a stable API.
Closes#2565
This method returns a `TrySendError` type, which allows for returning
the request back to the caller if an error occured between queuing and
trying to write the request.
This method is added for both `http1` and `http2`.
This allows receiving HTTP/1 chunked trailers, both as a client
and as a server.
The number of trailer pairs is limited to 1024.
The size of the trailer fields is limited. The limit accounts for a
single, very large trailer field or many trailer fields that exceed the
limit in aggregate.
Closes#2703
Most request methods define a payload. If hyper detects that no body has
been included, it will now include a `content-length: 0` header
automatically.
It will not do this for methods that don't have defined payloads (GET,
HEAD, and CONNECT).
hyper's `Error` used to print the error source automatically, preferring
to provide a better default for users who do not know about `Report`.
But, to fit better with the wider ecosystem, this changes the format to
only print the hyper `Error` itself, and not its source.
Closes#2844
BREAKING CHANGE: The format no longer prints the error chain. Be sure to
check if you are logging errors directly.
The `Error::message()` method is removed, it is no longer needed.
The `Error::into_cause()` method is removed.
This replaces the usage of `tokio::io::{AsyncRead, AsyncWrite}` in hyper's public API with new traits in the `hyper::rt` module.
Closes#3110
BREAKING CHANGE: Any IO transport type provided must not implement `hyper::rt::{Read, Write}` instead of
`tokio::io` traits. You can grab a helper type from `hyper-util` to wrap Tokio types, or implement the traits yourself,
if it's a custom type.
This commit removes `common::Exec::Default` that just panics when used. We are
removing `tokio`, leaving `Exec::Default` with no implementation and
panics when `Exec::execute` is called.
Since `Exec::Default` has no purpose, it is being removed and user
should now provide an implementation of executor.
Closes#3128
BREAKING CHANGE: `hyper::client::conn::Http2::Builder::new` now requires an executor argument.
This is a part of #1675 issue. It slightly reduces the number of
duplicated code by using one common function for init a logger and
creating a Tokio server.
The `Body` trait was adjusted to be forwards compatible with adding new
frame types. That resulted in changing from `poll_data` and `poll_trailers`
to a single `poll_frame` function. More can be learned from the proposal
in https://github.com/hyperium/hyper/issues/2840.
Closes#3010
BREAKING CHANGE: The polling functions of the `Body` trait have been
redesigned.
The free functions `hyper::body::to_bytes` and `aggregate` have been
removed. Similar functionality is on
`http_body_util::BodyExt::collect`.
The connection types have been split into version-specific types, in the
`server::conn::{http1, http2}` modules.
Closes#3012
BREAKING CHANGE: Either choose a version-specific `Connection` type, or
look for the auto-version type in `hyper-util`.
- There is no longer a `runtime` feature to enable in the `Cargo.toml.`
- Forgetting to set an executor will now panic.
Closes#2857
BREAKING CHANGE: No longer need to enable a `runtime` feature. All connection builders should set an executor.
This adds a `hyper::rt::Timer` trait, and it is used in connection
builders to configure a custom timer source for timeouts.
Co-authored-by: Robert Cunningham <robertvcunningham@gmail.com>
Now that the concrete `Body` type has been temporarily replaced with `Recv` in #2966,
we can rename and export `http_body::Body` as just `Body` instead of `HttpBody`.
Closes#2839
BREAKING CHANGE: The trait has been renamed.
The constructors of `hyper::Body` from a full bytes are removed. Along
with `Body::empty()`.
BREAKING CHANGE: Use the types from `http-body-util`.
Co-authored-by: Xuanwo <github@xuanwo.io>
This removes the following types and methods from hyper:
- `Client`
- `Error::is_connect()`
BREAKING CHANGE: A pooling client is in the hyper-util crate.
This removes the `tcp` feature from hyper's `Cargo.toml`, and the code it enabled:
- `HttpConnector`
- `GaiResolver`
- `AddrStream`
And parts of `Client` and `Server` that used those types. Alternatives will be available in the `hyper-util` crate.
Closes#2856
Co-authored-by: MrGunflame <mrgunflame@protonmail.com>
Add a new extension type `hyper::ext::ReasonPhrase` gated by either the `ffi` or `http1` Cargo
features. When enabled, store any non-canonical reason phrases in this extension when parsing
responses, and write this reason phrase instead of the canonical reason phrase when emitting
responses.
Reason phrases are a disused corner of the spec that implementations ought to treat as opaque blobs
of bytes. Unfortunately, real-world traffic sometimes does depend on being able to inspect and
manipulate them.
Non-canonical reason phrases are checked for validity at runtime to prevent invalid and dangerous
characters from being emitted when writing responses. An `unsafe` escape hatch is present for hyper
itself to create reason phrases that have been parsed (and therefore implicitly validated) by
httparse.
The client now has an option to allow parsing responses with obsolete line folding in headers. The option is off by default, since the spec recommends to reject such things if you can.
The discussion in #2462 opened up some larger questions about more comprehensive approaches to the
error API, with the agreement that additional methods would be desirable in the short term. These
methods address an immediate need of our customers, so I would like to get them in first before we
flesh out a future solution.
One potentially controversial choice here is to still return `true` from `is_parse_error()` for
these variants. I hope the naming of the methods make it clear that the new predicates are
refinements of the existing one, but I didn't want to change the behavior of `is_parse_error()`
which would require a major version bump.
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