Skip to content

Commit aee894f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into server-ffi
2 parents 023c9b2 + ad89b53 commit aee894f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2168
-568
lines changed

.github/workflows/CI.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545

4646
- name: cargo fmt --check
4747
run: |
48-
if ! rustfmt --check --edition 2018 $(git ls-files '*.rs'); then
49-
printf "Please run \`rustfmt --edition 2018 \$(git ls-files '*.rs')\` to fix rustfmt errors.\nSee CONTRIBUTING.md for more details.\n" >&2
48+
if ! rustfmt --check --edition 2021 $(git ls-files '*.rs'); then
49+
printf "Please run \`rustfmt --edition 2021 \$(git ls-files '*.rs')\` to fix rustfmt errors.\nSee docs/CODE_STYLE.md for more details.\n" >&2
5050
exit 1
5151
fi
5252
@@ -115,6 +115,10 @@ jobs:
115115

116116
- uses: Swatinem/rust-cache@v2
117117

118+
- name: Pin some dependencies
119+
run: |
120+
cargo update -p tokio --precise 1.38.1
121+
118122
- name: Check
119123
run: cargo check --features full
120124

@@ -201,12 +205,12 @@ jobs:
201205
uses: dtolnay/rust-toolchain@stable
202206

203207
- name: Install cbindgen
204-
uses: taiki-e/cache-cargo-install-action@v1
208+
uses: taiki-e/cache-cargo-install-action@v2
205209
with:
206210
tool: cbindgen
207211

208212
- name: Install cargo-expand
209-
uses: taiki-e/cache-cargo-install-action@v1
213+
uses: taiki-e/cache-cargo-install-action@v2
210214
with:
211215
tool: cargo-expand
212216

@@ -247,12 +251,12 @@ jobs:
247251
- name: Install Rust
248252
uses: dtolnay/rust-toolchain@master
249253
with:
250-
toolchain: nightly-2023-10-10 # Compatible version for cargo-check-external-types
254+
toolchain: nightly-2024-05-01 # Compatible version for cargo-check-external-types
251255

252256
- name: Install cargo-check-external-types
253-
uses: taiki-e/cache-cargo-install-action@v1
257+
uses: taiki-e/cache-cargo-install-action@v2
254258
with:
255-
259+
256260

257261
- uses: Swatinem/rust-cache@v2
258262

CHANGELOG.md

+86
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,89 @@
1+
### v1.4.1 (2024-07-09)
2+
3+
4+
#### Bug Fixes
5+
6+
* **http1:** reject final chunked if missing 0 ([8e5de1bb](https://github.com/hyperium/hyper/commit/8e5de1bb57e10b5bd9e70ab22489da787517238a))
7+
8+
9+
## v1.4.0 (2024-07-01)
10+
11+
12+
#### Bug Fixes
13+
14+
* **http2:** stop removing "Trailer" header in HTTP/2 responses as per RFC 9110 (#3648) ([a3269f7a](https://github.com/hyperium/hyper/commit/a3269f7ab285dbeb44a3a7dbc163fcadd65087f9))
15+
* **server:** start header read timeout immediately (#3185) ([0eb1b6cf](https://github.com/hyperium/hyper/commit/0eb1b6cf4d914ce9c3f8e92a8b43754eba27a327))
16+
17+
18+
#### Features
19+
20+
* **client:**
21+
* add `SendRequest::try_send_request()` method (#3691) ([4ffaad53](https://github.com/hyperium/hyper/commit/4ffaad53c78572c500584e0cb5d76ae6ffc6adb6))
22+
* remove `Send +Sync` bounds requirement of `http2::Connection` executor (#3682) ([56c3cd56](https://github.com/hyperium/hyper/commit/56c3cd560bc10671d3d8b638f3f17a304f920c6b))
23+
* remove `'static` lifetime bound on http1/2 client IO (#3667) ([9580b357](https://github.com/hyperium/hyper/commit/9580b357635031f3d631303f3afffc2afae77933))
24+
* **http1:** add support for receiving trailer fields (#3637) ([ac84af6b](https://github.com/hyperium/hyper/commit/ac84af6b32a5d37d9343013ace088aaae47587b6), closes [#2703](https://github.com/hyperium/hyper/issues/2703))
25+
* **server:** add `Builder::auto_date_header(bool)` to allow disabling Date headers ([721785ef](https://github.com/hyperium/hyper/commit/721785efad8537513e48d900a85c05ce79483018))
26+
* **service:** implement Service for reference types (#3607) ([eade122d](https://github.com/hyperium/hyper/commit/eade122db25f51619aee5db845de2a61b7ff2f74))
27+
28+
29+
### v1.3.1 (2024-04-16)
30+
31+
#### Bug Fixes
32+
33+
* **client:** revert auto content-length header for some requests (#3633)
34+
35+
36+
## v1.3.0 (2024-04-15)
37+
38+
39+
#### Bug Fixes
40+
41+
* **client:** send content-length even with no body ([172fdfaf](https://github.com/hyperium/hyper/commit/172fdfaf0e0d9222917f271a83339238082e2657))
42+
* **http2:**
43+
* `max_header_list_size(num)` defaults to 16kb ([203d1b09](https://github.com/hyperium/hyper/commit/203d1b090d0d0349c7e373e881ac4ddba72129be))
44+
* `initial_max_send_streams` defaults to 100 ([2d1bd708](https://github.com/hyperium/hyper/commit/2d1bd7085e37a55ed6393f0e3f1b9a0b06db4d5d))
45+
* **server:**
46+
* avoid unwrapping for the `Future` impl of HTTP/1 `UpgradeableConnection` (#3627) ([b79be911](https://github.com/hyperium/hyper/commit/b79be911696f6a93e8d408080ebbf558b612ce3c), closes [#3621](https://github.com/hyperium/hyper/issues/3621))
47+
* avoid `graceful_shutdown` panic on upgraded H1 connection (#3616) ([6ecf8521](https://github.com/hyperium/hyper/commit/6ecf85218fb24531184c53d5ed0eb7caf13cdcef))
48+
49+
50+
#### Features
51+
52+
* **client:**
53+
* add `max_header_list_size(num)` to `http2::Builder`. ([1c5b1b87](https://github.com/hyperium/hyper/commit/1c5b1b87ae1497a702e30ea82a486fb61a3f8133))
54+
* add `max_pending_accept_reset_streams` HTTP2 option (#3617) ([330ddf1d](https://github.com/hyperium/hyper/commit/330ddf1de1ca2841469d30d24143902e5ff06365))
55+
* **ext:** implement From ReasonPhrase for Bytes ([dc27043a](https://github.com/hyperium/hyper/commit/dc27043aa319c0e630b7385a36aca0f3bee70670))
56+
* **service:** expose Service and HttpService trait unconditionally ([6aee2e6e](https://github.com/hyperium/hyper/commit/6aee2e6e260e7d407256d6b7da6a0d90c1bb9c67))
57+
* **server:** relax `'static` from connection IO trait bounds (#3595) ([0013bdda](https://github.com/hyperium/hyper/commit/0013bdda5cd34ed6fca089eceb0133395b7be041))
58+
59+
60+
## v1.2.0 (2024-02-21)
61+
62+
63+
#### Bug Fixes
64+
65+
* **http2:** typo in trace logging (#3536) ([79862ec2](https://github.com/hyperium/hyper/commit/79862ec2e84c32122c820958ceec06d8b7701ff7))
66+
* **rt:** `Sleep::downcast_mut_pin()` no longer extend lifetime ([7206fe30](https://github.com/hyperium/hyper/commit/7206fe30302937075c51c16a69d1eb3bbce6a671), closes [#3556](https://github.com/hyperium/hyper/issues/3556))
67+
68+
69+
#### Features
70+
71+
* **http1:** support configurable `max_headers(num)` to client and server (#3523) ([b1142448](https://github.com/hyperium/hyper/commit/b114244898828e9fb254bea1f0bbdd24850b2f3f))
72+
* **http2:**
73+
* add config for `max_local_error_reset_streams` in server (#3530) ([d7680e30](https://github.com/hyperium/hyper/commit/d7680e30e48926a5a3f94a0986d39181d5ab2218))
74+
* add `initial_max_send_streams` method to HTTP/2 client builder (#3524) ([fdfa60d9](https://github.com/hyperium/hyper/commit/fdfa60d9fafb8a6bfb40acc4042ee54a2b9aad32))
75+
* add `max_pending_accept_reset_streams(num)` back to HTTP/2 server builder (#3507 ([a9fa893f](https://github.com/hyperium/hyper/commit/a9fa893f18c6409abae2e1dcbba0f4487df54d4f))
76+
77+
78+
#### Breaking Changes
79+
80+
* The returned lifetime from `Sleep::downcast_mut_pin()`
81+
is no longer `'static`. This shouldn't affect most usage. This sort of
82+
breaking change is needed because it is _wrong_.
83+
84+
([7206fe30](https://github.com/hyperium/hyper/commit/7206fe30302937075c51c16a69d1eb3bbce6a671))
85+
86+
187
## v1.1.0 (2023-12-18)
288

389

CONTRIBUTING.md

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
11
# Contributing to Hyper
22

3-
You want to contribute? You're awesome! Don't know where to start? Check the [list of easy issues](https://github.com/hyperium/hyper/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy).
3+
You want to contribute? You're awesome!
4+
5+
Contributions come in all shapes and sizes. Let's take a tour of some of the different wants you could contribute.
6+
7+
## [Code of Conduct](./docs/CODE_OF_CONDUCT.md)
8+
9+
Firstly, all interactions with the project need to abide by the code of conduct. This is to make sure everyone is treated kindly.
10+
11+
## [Issues](./docs/ISSUES.md)
12+
13+
- **Filing an issue** is a contribution. We appreciate you letting us know about bugs you've found, and any information that you can provide that we can use to make hyper better. Without your filing it, we may not be aware of the bug.
14+
- [Triaging issues](./docs/ISSUES.md#triaging) is a huge help. By your helping make issues better, the reporters can get answers sooner, and others can fix them with less effort. You can also volunteer as a frequent [triager](./docs/MAINTAINERS.md#triagers).
15+
- Discuss [feature requests][feat] (especially those marked [request-for-comment][b-rfc]).
16+
17+
[feat]: https://github.com/hyperium/hyper/issues?q=is%3Aissue+is%3Aopen+label%3AC-feature
18+
[b-rfc]: https://github.com/hyperium/hyper/issues?q=is%3Aissue+is%3Aopen+label%3AB-rfc
419

5-
[easy tag]: https://github.com/hyperium/hyper/issues?q=label%3AE-easy+is%3Aopen
620

721
## [Pull Requests](./docs/PULL_REQUESTS.md)
822

23+
By the way, consider checking the [list of easy issues](https://github.com/hyperium/hyper/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy) if you want to submit something.
24+
925
- [Submitting a Pull Request](./docs/PULL_REQUESTS.md#submitting-a-pull-request)
1026
- [Commit Guidelines](./docs/COMMITS.md)
27+
28+
## Documentation
29+
30+
Improving hyper's documentation is a huge help for everyone who is trying to _use_ hyper.
31+
32+
- The API documentation (rendered at https://docs.rs/hyper) is stored as rustdoc comments directly in the source.
33+
- The main website has [tutorial-style guides](https://hyper.rs/guides). As of v1, they are currently in a [revamp](https://github.com/hyperium/hyper/issues/3411), and would greatly benefit from being filled out.
34+
35+
## Help
36+
37+
Helping others use hyper in their specific workflows is a very valuable way to contribute.
38+
39+
- Answer questions asked directly in hyper's [Discussions](https://github.com/hyperium/hyper/discussions).
40+
- Join our [Discord](https://discord.gg/kkwpueZ) and help those who show up with questions.
41+
- **Blog about hyper.** You writing a blog post about how you use hyper to do something specific, or how you contributed a new feature, or debugged something in it, is a great idea. Not all examples can fit in the hyper repo. Search engines will help people find their use cases on your blog. And you can describe processes in more depth or from a different perspective.

Cargo.toml

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyper"
3-
version = "1.1.0"
3+
version = "1.4.1"
44
description = "A fast and correct HTTP library."
55
readme = "README.md"
66
homepage = "https://hyper.rs"
@@ -10,7 +10,7 @@ license = "MIT"
1010
authors = ["Sean McArthur <[email protected]>"]
1111
keywords = ["http", "hyper", "hyperium"]
1212
categories = ["network-programming", "web-programming::http-client", "web-programming::http-server"]
13-
edition = "2018"
13+
edition = "2021"
1414
rust-version = "1.63" # keep in sync with MSRV.md dev doc
1515

1616
include = [
@@ -20,10 +20,9 @@ include = [
2020
]
2121

2222
[dependencies]
23-
bytes = "1"
23+
bytes = "1.2"
2424
http = "1"
2525
http-body = "1"
26-
pin-project-lite = "0.2.4"
2726
tokio = { version = "1", features = ["sync"] }
2827

2928
# Optional
@@ -36,6 +35,8 @@ httparse = { version = "1.8", optional = true }
3635
httpdate = { version = "1.0", optional = true }
3736
itoa = { version = "1", optional = true }
3837
libc = { version = "0.2", optional = true }
38+
pin-project-lite = { version = "0.2.4", optional = true }
39+
smallvec = { version = "1.12", features = ["const_generics", "const_new"], optional = true }
3940
tracing = { version = "0.1", default-features = false, features = ["std"], optional = true }
4041
want = { version = "0.3", optional = true }
4142

@@ -68,28 +69,35 @@ tokio-util = "0.7.10"
6869
default = []
6970

7071
# Easily turn it all on
71-
full = ["client", "http1", "http2", "server"]
72+
full = ["client", "http1", "http2", "server", "futures-util?/alloc"]
7273

7374
# HTTP versions
7475
http1 = ["dep:futures-channel", "dep:futures-util", "dep:httparse", "dep:itoa"]
7576
http2 = ["dep:futures-channel", "dep:futures-util", "dep:h2"]
7677

7778
# Client/Server
78-
client = ["dep:want"]
79-
server = ["dep:httpdate"]
79+
client = ["dep:want", "dep:pin-project-lite", "dep:smallvec"]
80+
server = ["dep:httpdate", "dep:pin-project-lite", "dep:smallvec"]
8081

8182
# C-API support (currently unstable (no semver))
82-
ffi = ["dep:libc", "full", "dep:http-body-util"]
83+
ffi = ["dep:libc", "full", "dep:http-body-util", "futures-util?/alloc"]
8384

8485
# Utilize tracing (currently unstable)
8586
tracing = ["dep:tracing"]
8687

8788
# internal features used in CI
8889
nightly = []
8990

91+
[lints.rust.unexpected_cfgs]
92+
level = "warn"
93+
check-cfg = [
94+
'cfg(hyper_unstable_tracing)',
95+
'cfg(hyper_unstable_ffi)'
96+
]
97+
9098
[package.metadata.docs.rs]
9199
features = ["ffi", "full", "tracing"]
92-
rustdoc-args = ["--cfg", "docsrs", "--cfg", "hyper_unstable_ffi", "--cfg", "hyper_unstable_tracing"]
100+
rustdoc-args = ["--cfg", "hyper_unstable_ffi", "--cfg", "hyper_unstable_tracing"]
93101

94102
[package.metadata.playground]
95103
features = ["full"]

benches/end_to_end.rs

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ fn spawn_server(rt: &tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
413413
let body = opts.response_body;
414414
let opts = opts.clone();
415415
rt.spawn(async move {
416+
let _ = &opts;
416417
while let Ok((sock, _)) = listener.accept().await {
417418
let io = support::TokioIo::new(sock);
418419
if opts.http2 {

benches/support/tokiort.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(dead_code)]
22
//! Various runtimes for hyper
33
use std::{
4-
future::Future,
54
pin::Pin,
65
task::{Context, Poll},
76
time::{Duration, Instant},
@@ -24,7 +23,6 @@ where
2423
}
2524

2625
/// A Timer that uses the tokio runtime.
27-
2826
#[derive(Clone, Debug)]
2927
pub struct TokioTimer;
3028

@@ -44,18 +42,10 @@ impl Timer for TokioTimer {
4442
}
4543
}
4644

47-
struct TokioTimeout<T> {
48-
inner: Pin<Box<tokio::time::Timeout<T>>>,
49-
}
50-
51-
impl<T> Future for TokioTimeout<T>
52-
where
53-
T: Future,
54-
{
55-
type Output = Result<T::Output, tokio::time::error::Elapsed>;
56-
57-
fn poll(mut self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Self::Output> {
58-
self.inner.as_mut().poll(context)
45+
impl TokioTimer {
46+
/// Create a new TokioTimer
47+
pub fn new() -> Self {
48+
Self {}
5949
}
6050
}
6151

capi/include/hyper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -807,5 +807,5 @@ void hyper_waker_free(struct hyper_waker *waker);
807807
void hyper_waker_wake(struct hyper_waker *waker);
808808

809809
#ifdef __cplusplus
810-
} // extern "C"
811-
#endif // __cplusplus
810+
} // extern "C"
811+
#endif // __cplusplus

docs/CODE_STYLE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ hyper uses the default configuration of `rustfmt`.
88

99
```txt
1010
# Mac or Linux
11-
rustfmt --check --edition 2018 $(git ls-files '*.rs')
11+
rustfmt --check --edition 2021 $(git ls-files '*.rs')
1212
1313
# Powershell
14-
Get-ChildItem . -Filter "*.rs" -Recurse | foreach { rustfmt --check --edition 2018 $_.FullName }
14+
Get-ChildItem . -Filter "*.rs" -Recurse | foreach { rustfmt --check --edition 2021 $_.FullName }
1515
```
1616

1717
> **NOTE**: If you are using `rust-analyzer`, you can add the following two lines in your `settings.json` to make sure the features get taken into account when checking the project:

docs/MAINTAINERS.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ To see what these roles do, and how to become one, look at [GOVERNANCE](./GOVERN
66

77
- Eray Karatay (@programatik29)
88
- Oddbjørn Grødem (@oddgrd)
9-
- Noah Kennedy (@Noah-Kennedy)
10-
- tottoto (@tottoto)
11-
- dswij (@dswij)
129

1310
## Collaborators
1411

@@ -20,6 +17,9 @@ To see what these roles do, and how to become one, look at [GOVERNANCE](./GOVERN
2017
- Anthony Ramine (@nox)
2118
- David Pedersen (@davidpdrsn)
2219
- Adam Foltzer (@acfoltzer)
20+
- Noah Kennedy (@Noah-Kennedy)
21+
- dswij (@dswij)
22+
- tottoto (@tottoto)
2323

2424
<details>
2525
<summary>Emeriti</summary>

examples/hello.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5353
// Handle the connection from the client using HTTP1 and pass any
5454
// HTTP requests received on that connection to the `hello` function
5555
if let Err(err) = http1::Builder::new()
56-
.timer(TokioTimer)
56+
.timer(TokioTimer::new())
5757
.serve_connection(io, service_fn(hello))
5858
.await
5959
{

examples/send_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async fn response_examples(
4949
match (req.method(), req.uri().path()) {
5050
(&Method::GET, "/") | (&Method::GET, "/index.html") => simple_file_send(INDEX).await,
5151
(&Method::GET, "/no_file.html") => {
52-
// Test what happens when file cannot be be found
52+
// Test what happens when file cannot be found
5353
simple_file_send("this_file_should_not_exist.html").await
5454
}
5555
_ => Ok(not_found()),

examples/service_struct_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ impl Service<Request<IncomingBody>> for Svc {
6565
"authors extraordinare! counter = {:?}",
6666
self.counter
6767
)),
68-
// Return the 404 Not Found for other routes, and don't increment counter.
69-
_ => return Box::pin(async { mk_response("oh no! not found".into()) }),
68+
_ => mk_response("oh no! not found".into()),
7069
};
7170

7271
Box::pin(async { res })

0 commit comments

Comments
 (0)