2899 Commits

Author SHA1 Message Date
Dongpo Liu
0f0b6ed3ac docs(examples): replace unwraps with expects explaining why (#4001)
Just avoid unwrap as much as possible. Use expect to assert that it will always succeed.

Closes #3984
2026-01-12 15:28:42 -05:00
jasmy
79d40f3693 chore(license): update copyright year to 2026 (#4007) 2026-01-12 10:59:40 -05:00
tottoto
04ea6b9a3f chore(ci): update to cargo-check-external-types 0.4.0 (#4006) 2026-01-12 09:55:30 -05:00
tottoto
7f2d814da8 chore(ci): update to actions/checkout@v6 (#4005) 2026-01-12 09:54:32 -05:00
Sean McArthur
18913ffd8e test(server): fix flaky disable_keep_alive_mid_request (#4009)
This test would make use of the OS TCP stack, and sometimes on Mac of Windows, it would fail.

The change switches to an in-memory transport, since the purpose is to test the timing on hyper's side, not the TCP stack.

Closes #3949
2026-01-12 09:53:46 -05:00
Dongpo Liu
bcb8ec5766 fix(http1): use httparse config for Servers (#4002)
Previously, you could config the httparse config on the server `Builder`, just like you can for clients, but unlike clients, hyper forgot to _use_ that config when parsing requests.

This fixes the mistake.

Closes #3923
2026-01-05 09:12:59 -05:00
lif
32b76f4742 docs(rt): improve Read and ReadBufCursor documentation (#4000)
Add comprehensive documentation for implementing the Read trait:
- Explain the difference from tokio's AsyncRead
- Provide a complete example of implementing Read using put_slice
- Document when to use unsafe methods

Improve ReadBufCursor documentation:
- Describe safe vs unsafe approaches
- Add examples for both put_slice and as_mut/advance usage
- Link to relevant methods

Fixes #3649
2025-12-19 09:51:53 -05:00
Sean McArthur
da80d2a224 test(lib): fix unused warnings due to feature gating test imports (#3997) 2025-12-16 14:00:54 -05:00
Carlos O'Ryan
1c70fab64e docs(rt): fix comment in put_slice() (#3986)
Nitpicky, I know, but renders poorly in the docs.
2025-12-01 09:47:45 -05:00
Sean McArthur
be18a92bb5 refactor(http1): replace many args of Chunked::step with struct (#3982)
It's kind of the same thing, but by using a struct, the arguments are
essentially named, instead of relying of position.
2025-11-25 16:50:07 -05:00
Sean McArthur
4bfe65af8f refactor(http1): use saturating_sub instead of manual impl (#3983) 2025-11-25 16:49:55 -05:00
Sean McArthur
9da1814439 refactor(http1): simplify match of Token parse error (#3981) 2025-11-24 14:10:16 -05:00
Michael Rodler
2968dbcd75 chore(ci): run cargo-audit weekly to check for known vulnerabilities in dependencies. (#3246)
`cargo audit` checks for dependencies with known issues. This PR adds a github workflow that runs `cargo audit` on a weekly basis on `HEAD` and whenever a dependency changes.

Signed-off-by: Michael Rodler <mrodler@amazon.de>
Co-authored-by: Michael Rodler <mrodler@amazon.de>
Co-authored-by: f0rki <m@mrodler.eu>
2025-11-24 10:37:31 -05:00
Sean McArthur
793af1ed2a docs(error): add more information about is_incomplete_message() (#3978) 2025-11-14 12:33:06 -05:00
Sean McArthur
166c6cacc7 v1.8.1 v1.8.1 2025-11-13 16:12:46 -05:00
Sean McArthur
4492f31e94 fix(http1): fix consuming extra CPU from previous change (#3977)
Revert "fix(http1): fix rare missed write wakeup on connections (#3952)"

This reverts commit 2377b893f6.
2025-11-13 16:11:36 -05:00
Sean McArthur
dbe6f25ba2 v1.8.0 v1.8.0 2025-11-11 08:44:41 -05:00
Sean McArthur
58e0e7dc70 fix(http2): fix internals of HTTP/2 CONNECT upgrades (#3967)
This refactors the way hyper handles HTTP/2 CONNECT / Extended CONNECT. Before,
an uninhabited enum was used to try to prevent sending of the `Buf` type once
the STREAM had been upgraded. However, the way it was originally written was
incorrect, and will eventually have compilation issues.

The change here is to spawn an extra task and use a channel to bridge the IO
operations of the `Upgraded` object to be `Cursor` buffers in the new task.

ref: https://github.com/rust-lang/rust/issues/147588
Closes #3966 

BREAKING CHANGE: The HTTP/2 client connection no longer allows an executor
  that can not spawn itself.
  
  This was an oversight originally. The client connection will now include spawning
  a future that keeps a copy of the executor to spawn other futures. Thus, if it is
  `!Send`, it needs to spawn `!Send` futures. The likelihood of executors that match
  the previously allowed behavior should be very remote.

  There is also technically a semver break in here, which is that the
  `Http2ClientConnExec` trait no longer dyn-compatible, because it now expects to
  be `Clone`. This should not break usage of the `conn` builder, because it already
  separately had `E: Clone` bounds. If someone were using `dyn Http2ClientConnExec`,
  that will break. However, there is no purpose for doing so, and it is not usable
  otherwise, since the trait only exists to propagate bounds into hyper. Thus, the
  breakage should not affect anyone.
2025-11-10 11:20:31 -05:00
Sean McArthur
0a37a8cd9d test(ready_stream): replace tracing with printlns (#3973) 2025-11-10 10:09:27 -05:00
Louis Thiery
2377b893f6 fix(http1): fix rare missed write wakeup on connections (#3952) 2025-11-10 09:51:16 -05:00
Ariel Ben-Yehuda
5509ebe615 feat(rt): add Timer::now() method to allow overriding the instant returned (#3965)
The new trait method has a default implementation just returning `Instant::now()`.

An implementer can override that, such as Tokio providing support for it's pausable clock.
2025-11-10 09:38:43 -05:00
katelyn martin
f9f8f44058 tests(client): port tests to in-memory socket (#3947)
see https://github.com/hyperium/hyper/issues/3896.

this commit ports an assortment of test cases for the client to an
in-memory socket using `tokio::io::duplex()`.

this should help reduce test flakes related to TCP close behavior.

this supersedes https://github.com/hyperium/hyper/pull/3946.

Signed-off-by: katelyn martin <git@katelyn.world>
2025-09-08 12:39:18 -04:00
Will-Low
5803a9c059 docs(server): update default values for http1::Builder (#3938) 2025-08-29 14:32:20 -04:00
Name
e1e1f2b461 refactor(ffi): specify "C" ABI explicitly in ffi_fn! macro (#3937)
Co-authored-by: 1911860538 <alxps1911@gmail.com>
2025-08-27 09:05:13 -04:00
tottoto
64ab7ae339 chore(ci): update to actions/checkout@v5 (#3935) 2025-08-22 06:18:49 -04:00
Sean McArthur
400bdfdace v1.7.0 v1.7.0 2025-08-18 09:52:43 -04:00
Ryan
9749184f8a feat(server): add allow_multiple_spaces_in_request_line_delimiters http1 builder method (#3929) 2025-08-15 11:42:20 -04:00
Hanna Kruppe
caa166c756 chore(dependencies): avoid implicit cargo feature of futures-util (#3931)
Fix a mistake in commit e11b2ad: use the 'dep:' syntax for futures-util, so
that Cargo won't implicitly create a feature called 'futures-util'.
Removing features is semver-breaking, but said commit hasn't been in any
release yet, so it can still be fixed now.
2025-08-12 13:25:33 -04:00
Name
8ad2595c03 test(common): add missing assertion in full_rewind test (#3926)
Co-authored-by: 1911860538 <alxps1911@gmail.com>
2025-08-11 09:07:14 -04:00
tottoto
24f0da8636 chore(ci): update to cargo-check-external-types-0.3.0 (#3928) 2025-08-11 08:30:05 -04:00
Sean McArthur
974289fb3d docs(rt): improve rt module overview (#3920) 2025-07-28 08:11:30 -04:00
Sean McArthur
283fd2381d docs: improve ext module overview and Protocol docs (#3921) 2025-07-28 08:11:10 -04:00
Josh McKinney
b8affd8a2e feat(error): add Error::is_shutdown() (#3863)
Benchmarking tools often cause connections to be ungracefully shutdown.
This makes it possible to filter these errors out.

Closes #2745
2025-06-27 12:49:12 -04:00
Sean McArthur
c88df7886c docs(SECURITY): update policy to use GSA drafts when reporting vulnerabilities (#3894) 2025-05-26 14:55:09 -04:00
Patryk Wychowaniec
436cadd1ac fix(server): improve caching accuracy of Date header (#3887)
`CachedDate` gets updated every second, but the current logic doesn't
take into account milliseconds - if the application starts at
`12:00:00.600`, hyper will report `date: ...T120000` up until
`12:00:01.599`, which is overzealous.

We can sidestep this by subtracing the nanoseconds part (which includes
milliseconds) from the time passed to `CachedDate::update()`.
2025-05-19 16:39:39 -04:00
Hanna Kruppe
e11b2ad91c refactor(lib): drop futures-util except in ffi (#3890)
Make hyper usable for h1/h2 and client/server without this heavyweight
dependency. It's about 17k lines of code and takes up to 1.7 seconds to
compile on my machine, but hyper is only using a tiny fraction of it.
Larger applications probably still pull in futures-util by other means,
but it's no longer as unavoidable as in the early days of the ecosystem.

To remove futures-util without raising MSRV, I took these steps:

* When futures-util just re-exports something from its dependencies,
  use it directly from the source.
* Inline trivial helpers like `poll_unpin` that "only" communicate
  intent a little better but don't save any significant amount of code.
* Refactor the h2 client code to avoid `StreamFuture` for the "Client
  has been dropped" detection -- just poll the mpsc channel directly.
* Implement a couple of small helpers from scratch when they're
  straightforward and fit on one screen each. The majority of this is
  polyfills for standard library APIs that would require a higher MSRV.
* Use `AtomicWaker` from the `atomic-waker` crate, a separately
  published copy of the futures-util type of the same name. While the
  two crates are owned by different organizations (smol-rs vs.
  rust-lang), it's mostly the same people maintaining both copies.

The uses of future-util in hyper's tests/benches/examples and in the
`ffi` module seem much harder to remove entirely, so I did not touch
those modules at all.
2025-05-19 14:37:45 -04:00
Sam Praneis
42aff8726d refactor(http2): add decriptive error for non-empty body in CONNECT request (#3886)
Closes #3858
2025-05-06 17:17:39 -04:00
katelyn martin
efa0b26958 feat(client): add a TrySendError::error() method (#3885)
this commit introduces a new inherent method to
`hyper::client::conn::TrySendError<T>`.

this error type includes a `TrySendError::into_error()` method today
that will consume the `TrySendError<T>`, returning the inner error. this
commit introduces a new method that allows callers to inspect the error,
e.g. to update metrics, without needing to consume the error.

this is akin to #3884, which added the `TrySendError::message()` method
that returns a reference to the `T`-typed message when applicable.

Signed-off-by: katelyn martin <git@katelyn.world>
2025-05-06 10:51:36 -04:00
katelyn martin
03fd6aff88 feat(client): add a TrySendError::message() method (#3884)
this commit introduces a new inherent method to
`hyper::client::conn::TrySendError<T>`.

this error type includes a `TrySendError::take_message()` method today
that will return an owned instance of the inbound message, should the
underlying dispatch have been closed before serialization of the message
ever began.

this commit introduces a new method that allows callers to inspect the
message, e.g. to update metrics, without needing to take ownership of
the message.

Signed-off-by: katelyn martin <git@katelyn.world>
2025-05-05 22:43:22 -04:00
katelyn martin
12d9b55a03 chore(proto/h2): fix module-level documentation (#3881)
`proto::h2::ping` has some documentation that won't be rendered
properly, because it is written as documentation of an item rather than
documenting the enclosing submodule.

this commit updates this comment, using `//!` notation.

Signed-off-by: katelyn martin <git@katelyn.world>
2025-04-28 17:04:25 -04:00
Sean McArthur
0369f5e864 docs(MAINTAINERS): add katelyn martin as collaborator (#3878) 2025-04-21 10:09:14 -04:00
ZenTeaCC
ea5b49b7d4 docs(examples): alias Builder for clarity in http_proxy (#3873) 2025-04-07 08:17:10 -04:00
katelyn martin
ede24d2714 docs(service): add HttpService documentation (#3869)
this commit introduces some additional documentation to the
`HttpService` trait, and the `Service` trait.

notably, this commit introduces some intradoc links, so that rustdoc
will render links to types like `http::Request` and `http::Response`, or
to the `Body` trait.

additionally, mention of `hyper-util` is added to the `Service` trait,
to direct users to the glue implementations that they will likely need
to interact with e.g. `tower`.

Signed-off-by: katelyn martin <me+cratelyn@katelyn.world>
2025-04-04 14:54:23 -04:00
Hugo
c449528a33 test(body): add proper cfgs to body unit tests (#3864)
Running `cargo test` fails to compile because tests rely on types which
are behind a #[cfg(…)] which is disabled by default.

Add a #[cfg(…)] directive to tests which rely on types which are also
behind a #[cfg(…)] directive, so that these tests run only if the types
on which they depend exist.
2025-03-24 12:58:46 -04:00
jimmycathy
68bae2b53f docs(ffi): remove redundant backticks (#3855)
Signed-off-by: jimmycathy <clonecode@outlook.com>
2025-03-16 15:02:17 +00:00
Sean McArthur
621d8e4d77 v1.6.0 v1.6.0 2025-01-28 08:51:52 -05:00
Sean McArthur
83f45887e7 chore(LICENSE): update copyright year 2025-01-28 08:50:25 -05:00
Finn Bear
10b09ffc04 fix(server): start http1 header read timeout when conn is idle (#3828)
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 #3780
Closes #3781
2025-01-27 15:23:46 -05:00
Sean McArthur
8ce1fcfae9 feat(ext): add ext::on_informational() callback extension (#3818)
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
2025-01-27 14:15:58 -05:00
tottoto
de28b0e5b2 chore(ci): use msrv aware dependency resolver (#3831) 2025-01-20 10:20:34 -05:00