From f35094f01d9a782645c2ddba1a8be89792c41e42 Mon Sep 17 00:00:00 2001 From: Sunli Date: Wed, 20 Nov 2024 14:13:52 +0800 Subject: [PATCH] poem v3.1.4 --- .github/workflows/ci.yml | 4 +-- .github/workflows/code-coverage.yml | 2 +- Cargo.toml | 2 +- README.md | 6 ++-- poem-derive/Cargo.toml | 2 +- poem-grpc-build/Cargo.toml | 2 +- poem-grpc/CHANGELOG.md | 5 +++ poem-grpc/Cargo.toml | 4 +-- poem-grpc/README.md | 8 ++--- poem-grpc/src/client.rs | 21 +++++++++++-- poem-lambda/CHANGELOG.md | 4 +++ poem-lambda/Cargo.toml | 2 +- poem-lambda/README.md | 8 ++--- poem-openapi-derive/Cargo.toml | 2 +- poem-openapi/CHANGELOG.md | 4 +++ poem-openapi/Cargo.toml | 2 +- poem-openapi/README.md | 48 ++++++++++++++--------------- poem/CHANGELOG.md | 7 ++++- poem/Cargo.toml | 2 +- poem/README.md | 8 ++--- poem/src/server.rs | 33 +++++++++++++++----- 21 files changed, 115 insertions(+), 61 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7aedde9b0b..51eeaac500 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: # Switch to stable Rust - uses: actions-rs/toolchain@v1 with: - toolchain: 1.76.0 + toolchain: stable components: rustfmt, clippy override: true - name: Cache Rust @@ -91,7 +91,7 @@ jobs: # Switch to stable Rust - uses: actions-rs/toolchain@v1 with: - toolchain: 1.76.0 + toolchain: stable components: rustfmt, clippy - name: Cache Rust uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 88fdfc2fb2..089f985492 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -21,7 +21,7 @@ jobs: - name: Install Stable Toolchain uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.76.0 + toolchain: 1.81.0 components: rustfmt - name: Cache Rust uses: Swatinem/rust-cache@v2 diff --git a/Cargo.toml b/Cargo.toml index f654247267..0b8aea4d6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ license = "MIT OR Apache-2.0" documentation = "https://docs.rs/poem/" homepage = "https://github.com/poem-web/poem" repository = "https://github.com/poem-web/poem" -rust-version = "1.75" +rust-version = "1.81" [workspace.dependencies] poem = { path = "poem", version = "3.1.0", default-features = false } diff --git a/README.md b/README.md index 7a9003b6a2..1fe1864df6 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ Unsafe Rust forbidden - - rustc 1.76.0+ + + rustc 1.81.0+ diff --git a/poem-derive/Cargo.toml b/poem-derive/Cargo.toml index 122ba3c392..f6123bf5ce 100644 --- a/poem-derive/Cargo.toml +++ b/poem-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-derive" -version = "3.1.0" +version = "3.1.4" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-grpc-build/Cargo.toml b/poem-grpc-build/Cargo.toml index 34500d3355..48febae3d7 100644 --- a/poem-grpc-build/Cargo.toml +++ b/poem-grpc-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-grpc-build" -version = "0.5.0" +version = "0.5.2" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-grpc/CHANGELOG.md b/poem-grpc/CHANGELOG.md index 490e3f4792..816bd41307 100644 --- a/poem-grpc/CHANGELOG.md +++ b/poem-grpc/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [0.5.2] 2024-11-20 + +- Add `ClientConfigBuilder::http2_max_header_list_size` method to set the max size of received header frames. +- Update MSRV to `1.81.0` + # [0.5.1] 2024-09-12 - set the correct `content-type` for `GrpcClient` diff --git a/poem-grpc/Cargo.toml b/poem-grpc/Cargo.toml index 6094f48ca3..216acde75c 100644 --- a/poem-grpc/Cargo.toml +++ b/poem-grpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-grpc" -version = "0.5.1" +version = "0.5.2" authors.workspace = true edition.workspace = true license.workspace = true @@ -42,7 +42,7 @@ thiserror.workspace = true fastrand = "2.0.0" http.workspace = true hyper = { version = "1.0.0", features = ["http1", "http2"] } -hyper-util = { version = "0.1.3", features = ["client-legacy", "tokio"] } +hyper-util = { version = "0.1.10", features = ["client-legacy", "tokio"] } http-body-util = "0.1.0" tokio-rustls.workspace = true tower-service = "0.3.2" diff --git a/poem-grpc/README.md b/poem-grpc/README.md index c8d4ba8105..205c5d8410 100644 --- a/poem-grpc/README.md +++ b/poem-grpc/README.md @@ -20,9 +20,9 @@ Unsafe Rust forbidden - - rustc 1.76.0+ + + rustc 1.81.0+ @@ -63,7 +63,7 @@ This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in ## MSRV -The minimum supported Rust version for this crate is `1.76.0`. +The minimum supported Rust version for this crate is `1.81.0`. ## Contributing diff --git a/poem-grpc/src/client.rs b/poem-grpc/src/client.rs index da9861e2a9..560ac58068 100644 --- a/poem-grpc/src/client.rs +++ b/poem-grpc/src/client.rs @@ -27,19 +27,25 @@ use crate::{ pub(crate) type BoxBody = http_body_util::combinators::BoxBody; /// A configuration for GRPC client -#[derive(Default)] pub struct ClientConfig { uris: Vec, origin: Option, user_agent: Option, tls_config: Option, + max_header_list_size: u32, } impl ClientConfig { /// Create a `ClientConfig` builder pub fn builder() -> ClientConfigBuilder { ClientConfigBuilder { - config: Ok(ClientConfig::default()), + config: Ok(ClientConfig { + uris: vec![], + origin: None, + user_agent: None, + tls_config: None, + max_header_list_size: 16384, + }), } } } @@ -146,6 +152,16 @@ impl ClientConfigBuilder { self } + /// Sets the max size of received header frames. + /// + /// Default is `16384` bytes. + pub fn http2_max_header_list_size(mut self, max: u32) -> Self { + if let Ok(config) = &mut self.config { + config.max_header_list_size = max; + } + self + } + /// Consumes this builder and returns the `ClientConfig` pub fn build(self) -> Result { self.config @@ -451,6 +467,7 @@ fn create_client_endpoint( let mut config = config; let cli = Client::builder(TokioExecutor::new()) .http2_only(true) + .http2_max_header_list_size(config.max_header_list_size) .build(HttpsConnector::new(config.tls_config.take())); let config = Arc::new(config); diff --git a/poem-lambda/CHANGELOG.md b/poem-lambda/CHANGELOG.md index f9c612503b..4186a4c4e0 100644 --- a/poem-lambda/CHANGELOG.md +++ b/poem-lambda/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [5.1.1] 2024-11-20 + +- Update MSRV to `1.81.0` + # [5.0.0] 2024-03-30 - use AFIT instead of `async_trait` diff --git a/poem-lambda/Cargo.toml b/poem-lambda/Cargo.toml index 52c493d338..1b4ead54f8 100644 --- a/poem-lambda/Cargo.toml +++ b/poem-lambda/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-lambda" -version = "5.1.0" +version = "5.1.1" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-lambda/README.md b/poem-lambda/README.md index 0dcec1fd3b..7e79b5d186 100644 --- a/poem-lambda/README.md +++ b/poem-lambda/README.md @@ -20,9 +20,9 @@ Unsafe Rust forbidden - - rustc 1.76.0+ + + rustc 1.81.0+ @@ -49,7 +49,7 @@ This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in ## MSRV -The minimum supported Rust version for this crate is `1.76.0`. +The minimum supported Rust version for this crate is `1.81.0`. ## Contributing diff --git a/poem-openapi-derive/Cargo.toml b/poem-openapi-derive/Cargo.toml index 08c7d59b66..2af6ade6bc 100644 --- a/poem-openapi-derive/Cargo.toml +++ b/poem-openapi-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-openapi-derive" -version = "5.1.1" +version = "5.1.3" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-openapi/CHANGELOG.md b/poem-openapi/CHANGELOG.md index 4a8208f602..a4df99f10e 100644 --- a/poem-openapi/CHANGELOG.md +++ b/poem-openapi/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +#[5.1.3] 2024-11-20 + +- Update MSRV to `1.81.0` + # [5.1.2] 2024-10-02 - implements `Serialize` and `Deserialize` for `poem_openapi::types::Any`. diff --git a/poem-openapi/Cargo.toml b/poem-openapi/Cargo.toml index 9a97c9fcd0..57b95a25b3 100644 --- a/poem-openapi/Cargo.toml +++ b/poem-openapi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem-openapi" -version = "5.1.2" +version = "5.1.3" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem-openapi/README.md b/poem-openapi/README.md index 974ab6a88a..9e89603536 100644 --- a/poem-openapi/README.md +++ b/poem-openapi/README.md @@ -21,9 +21,9 @@ Unsafe Rust forbidden - - rustc 1.76.0+ + + rustc 1.81.0+ @@ -50,26 +50,26 @@ important business implementations. To avoid compiling unused dependencies, Poem gates certain features, some of which are disabled by default: -| Feature | Description | -|------------------|----------------------------------------------------------------------------------------| -| chrono | Integrate with the [`chrono` crate](https://crates.io/crates/chrono). | -| time | Integrate with the [`time` crate](https://crates.io/crates/time). | -| humantime | Integrate with the [`humantime` crate](https://crates.io/crates/humantime) | -| openapi-explorer | Add OpenAPI Explorer support | -| swagger-ui | Add swagger UI support | -| rapidoc | Add RapiDoc UI support | -| redoc | Add Redoc UI support | -| email | Support for email address string | -| hostname | Support for hostname string | -| uuid | Integrate with the [`uuid` crate](https://crates.io/crates/uuid) | -| url | Integrate with the [`url` crate](https://crates.io/crates/url) | -| geo | Integrate with the [`geo-types` crate](https://crates.io/crates/geo-types) | -| bson | Integrate with the [`bson` crate](https://crates.io/crates/bson) | -| rust_decimal | Integrate with the [`rust_decimal` crate](https://crates.io/crates/rust_decimal) | -| prost-wkt-types | Integrate with the [`prost-wkt-types` crate](https://crates.io/crates/prost-wkt-types) | -| static-files | Support for static file response | -| websocket | Support for websocket | -|sonic-rs | Uses [`sonic-rs`](https://github.com/cloudwego/sonic-rs) instead of `serde_json`. Pls, checkout `sonic-rs` requirements to properly enable `sonic-rs` capabilities | +| Feature | Description | +|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| chrono | Integrate with the [`chrono` crate](https://crates.io/crates/chrono). | +| time | Integrate with the [`time` crate](https://crates.io/crates/time). | +| humantime | Integrate with the [`humantime` crate](https://crates.io/crates/humantime) | +| openapi-explorer | Add OpenAPI Explorer support | +| swagger-ui | Add swagger UI support | +| rapidoc | Add RapiDoc UI support | +| redoc | Add Redoc UI support | +| email | Support for email address string | +| hostname | Support for hostname string | +| uuid | Integrate with the [`uuid` crate](https://crates.io/crates/uuid) | +| url | Integrate with the [`url` crate](https://crates.io/crates/url) | +| geo | Integrate with the [`geo-types` crate](https://crates.io/crates/geo-types) | +| bson | Integrate with the [`bson` crate](https://crates.io/crates/bson) | +| rust_decimal | Integrate with the [`rust_decimal` crate](https://crates.io/crates/rust_decimal) | +| prost-wkt-types | Integrate with the [`prost-wkt-types` crate](https://crates.io/crates/prost-wkt-types) | +| static-files | Support for static file response | +| websocket | Support for websocket | +| sonic-rs | Uses [`sonic-rs`](https://github.com/cloudwego/sonic-rs) instead of `serde_json`. Pls, checkout `sonic-rs` requirements to properly enable `sonic-rs` capabilities | ## Safety @@ -131,7 +131,7 @@ hello, sunli! ## MSRV -The minimum supported Rust version for this crate is `1.76.0`. +The minimum supported Rust version for this crate is `1.81.0`. ## Contributing diff --git a/poem/CHANGELOG.md b/poem/CHANGELOG.md index 54e93bb5cf..093de6a688 100644 --- a/poem/CHANGELOG.md +++ b/poem/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [3.1.4] 2024-11-20 + +- Add `Server::http2_max_header_list_size` method to set the max size of received header frames. +- Update MSRV to `1.81.0` + # [3.1.3] 2024-10-21 - Add `Middlware::combine_if` method. @@ -26,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - feat: allow to set a custom name for the csrf cookie (#801) [#864](https://github.com/poem-web/poem/pull/864) - add `sonic-rs` feature to replace `serde_json` with `sonic_rs` [#819](https://github.com/poem-web/poem/pull/819) - fix: setting path pattern in opentelemetry traces [#878](https://github.com/poem-web/poem/pull/878) -- update MSRV to `1.76.0` +- update MSRV to `1.81.0` - feat: implement StdErr for poem::Error [#868](https://github.com/poem-web/poem/pull/868) diff --git a/poem/Cargo.toml b/poem/Cargo.toml index ddf1f0a177..ba51e6815e 100644 --- a/poem/Cargo.toml +++ b/poem/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "poem" -version = "3.1.3" +version = "3.1.4" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/poem/README.md b/poem/README.md index dab8626c4e..39151f4c07 100644 --- a/poem/README.md +++ b/poem/README.md @@ -20,9 +20,9 @@ Unsafe Rust forbidden - - rustc 1.76.0+ + + rustc 1.81.0+ @@ -108,7 +108,7 @@ More examples can be found [here][examples]. ## MSRV -The minimum supported Rust version for this crate is `1.76.0`. +The minimum supported Rust version for this crate is `1.81.0`. ## Contributing diff --git a/poem/src/server.rs b/poem/src/server.rs index 8113c96495..551e5ed3d9 100644 --- a/poem/src/server.rs +++ b/poem/src/server.rs @@ -44,6 +44,7 @@ pub struct Server { idle_timeout: Option, http2_max_concurrent_streams: Option, http2_max_pending_accept_reset_streams: Option, + http2_max_header_list_size: u32, } impl Server { @@ -55,6 +56,7 @@ impl Server { idle_timeout: None, http2_max_concurrent_streams: None, http2_max_pending_accept_reset_streams: Some(20), + http2_max_header_list_size: 16384, } } } @@ -68,6 +70,7 @@ impl Server { idle_timeout: None, http2_max_concurrent_streams: None, http2_max_pending_accept_reset_streams: Some(20), + http2_max_header_list_size: 16384, } } } @@ -110,6 +113,16 @@ where } } + /// Sets the max size of received header frames. + /// + /// Default is `16384` bytes. + pub fn http2_max_header_list_size(self, max: u32) -> Self { + Self { + http2_max_header_list_size: max, + ..self + } + } + /// Configures the maximum number of pending reset streams allowed before a /// GOAWAY will be sent. /// @@ -150,6 +163,7 @@ where idle_timeout, http2_max_concurrent_streams, http2_max_pending_accept_reset_streams, + http2_max_header_list_size, } = self; let name = name.as_deref(); let alive_connections = Arc::new(AtomicUsize::new(0)); @@ -212,6 +226,7 @@ where idle_connection_close_timeout: idle_timeout, http2_max_concurrent_streams, http2_max_pending_accept_reset_streams, + http2_max_header_list_size, }); if timeout.is_some() { @@ -376,10 +391,14 @@ struct ConnectionOptions { idle_connection_close_timeout: Option, http2_max_concurrent_streams: Option, http2_max_pending_accept_reset_streams: Option, + http2_max_header_list_size: u32, } -async fn serve_connection( - ConnectionOptions { +async fn serve_connection(opts: ConnectionOptions) +where + Io: AsyncRead + AsyncWrite + Send + Unpin + 'static, +{ + let ConnectionOptions { socket, local_addr, remote_addr, @@ -389,10 +408,9 @@ async fn serve_connection( idle_connection_close_timeout, http2_max_concurrent_streams, http2_max_pending_accept_reset_streams, - }: ConnectionOptions, -) where - Io: AsyncRead + AsyncWrite + Send + Unpin + 'static, -{ + http2_max_header_list_size, + } = opts; + let connection_shutdown_token = CancellationToken::new(); let service = hyper::service::service_fn({ @@ -435,7 +453,8 @@ async fn serve_connection( .max_concurrent_streams(http2_max_concurrent_streams) .max_pending_accept_reset_streams( http2_max_pending_accept_reset_streams.map(|x| x as usize), - ); + ) + .max_header_list_size(http2_max_header_list_size); let conn = builder.serve_connection_with_upgrades(hyper_util::rt::TokioIo::new(socket), service);