Currently, the header read timeout is started before any part of the first request is received. This allows closing the connection if no requests are received. However, after the first request, the connection can remain open indefinitely. This change ensures that the header read timeout is started immediately after the connection is idle, following the transmission of the response, before the first part of the subsequent request is received.
This change allows a potential future addition of an idle_timeout, which if set, would be used instead of the header_read_timeout. This behavior is matched in other servers, such as Golang.
Fixes#3780Closes#3781
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 includes conditions where hyper knows the connection will end after the response, such as a request error that ruins the connection, or when graceful shutdown is triggered.
Closes#3720
If a chunked body had valid chunks, but ended without a `0` in the final
chunk (so, just `\r\n\r\n`), it would be parsed as a valid end. Now it
will be rejected as the final chunk MUST be `0\r\n\r\n`.
This was partially done before, but only if there were no chunks before
the final. This fixes both paths.
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`.
The `http1_header_read_timeout` used to start once there was a single
read of headers. This change makes it start the timer immediately, right
when the connection is estabilished.
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.
fix issue in the graceful shutdown logic
which causes the connection future to hang
when graceful shutdown is called prior to any
requests being made. This fix checks to see
if the connection is still in its initial state
when disable_keep_alive is called, and starts the
shutdown process if it is.
This addresses issue #2730
Co-authored-by: Robin Seitz <roseitz@microsoft.com>
change Service::call to take &self instead of &mut self.
Because of this change, the trait bound in the service::util::service_fn and
the trait bound in the impl for the ServiceFn struct were changed from FnMut to Fn.
This change was decided on for the following reasons:
- It prepares the way for async fn,
since then the future only borrows &self, and thus a Service can concurrently handle
multiple outstanding requests at once.
- It's clearer that Services can likely be cloned
- To share state across clones you generally need Arc<Mutex<_>>
that means you're not really using the &mut self and could do with a &self
Closes#3040
BREAKING CHANGE: The Service::call function no longer takes a mutable reference to self.
The FnMut trait bound on the service::util::service_fn function and the trait bound
on the impl for the ServiceFn struct were changed from FnMut to Fn.
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 continuation of work on #1675 issue. It slightly
reduces the number of duplicated code by using one common function for
init a logger and creating tcp listener for tests.
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 removes the dependency on `tower-service`, and simplifies the `Service` trait to be used by hyper's server connections.
Closes#2853
BREAKING CHANGE: Change any manual `impl tower::Service` to implement `hyper::service::Service` instead. The `poll_ready` method has been removed.
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.