From 368ceee0f09304d288850d530520de3f7cf45bf5 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Fri, 27 Dec 2024 19:27:40 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[#197]=20features=20flag=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80:=20http2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rupring/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rupring/Cargo.toml b/rupring/Cargo.toml index 7561830..20c2ea7 100644 --- a/rupring/Cargo.toml +++ b/rupring/Cargo.toml @@ -47,3 +47,4 @@ default = [] full = ["aws-lambda"] aws-lambda = [] tls = ["tokio-rustls", "rustls-pemfile", "rustls"] +http2 = [] From 317aa743830f2b706a999cf5b1dd564c79961330 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Fri, 27 Dec 2024 19:29:42 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[#197]=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EA=B8=B0=EB=B0=98=20http2=20=ED=94=8C=EB=9E=98?= =?UTF-8?q?=EA=B7=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rupring/src/application_properties.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/rupring/src/application_properties.rs b/rupring/src/application_properties.rs index 7bae3bf..8aa0995 100644 --- a/rupring/src/application_properties.rs +++ b/rupring/src/application_properties.rs @@ -29,7 +29,6 @@ | server.thread.limit | The thread limit to use. | None(max) | | server.request-timeout | The request timeout. (300 = 300 millisecond, 3s = 3 second, 2m = 2 minute) | No Timeout | | server.http1.keep-alive | Whether to keep-alive for HTTP/1. (false=disable, true=enable) | false | -| server.http2.enabled | Whether to enable HTTP/2. | false | | server.ssl.key | The SSL key file. (SSL is enabled by feature="tls") | None | | server.ssl.cert | The SSL cert file. (SSL is enabled by feature="tls") | None | | banner.enabled | Whether to enable the banner. | true | @@ -168,13 +167,11 @@ impl Default for Http1 { } #[derive(Debug, PartialEq, Clone)] -pub struct Http2 { - pub enabled: bool, -} +pub struct Http2 {} impl Default for Http2 { fn default() -> Self { - Http2 { enabled: false } + Http2 {} } } @@ -337,11 +334,6 @@ impl ApplicationProperties { server.http1.keep_alive = value; } } - "server.http2.enabled" => { - if let Ok(value) = value.parse::() { - server.http2.enabled = value; - } - } "server.ssl.key" => { server.ssl.key = value.to_string(); } From 4e5bceae568cf61e2d29980526d3686eff4c3e93 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Fri, 27 Dec 2024 19:31:35 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[#197]=20features=20flag=20=EA=B8=B0?= =?UTF-8?q?=EB=B0=98=20http2=20=EC=8A=A4=EC=9C=84=EC=B9=AD=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rupring/src/core/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rupring/src/core/mod.rs b/rupring/src/core/mod.rs index a25c8e4..32d21cb 100644 --- a/rupring/src/core/mod.rs +++ b/rupring/src/core/mod.rs @@ -10,7 +10,6 @@ use bootings::aws_lambda::LambdaRequestEvent; #[cfg(feature = "tls")] use bootings::tls; -use hyper_util::rt::TokioExecutor; use tokio::time::error::Elapsed; use tokio::time::Instant; @@ -85,7 +84,6 @@ pub async fn run_server( } let keep_alive = application_properties.server.http1.keep_alive.to_owned(); - let http2_enabled = application_properties.server.http2.enabled.to_owned(); #[cfg(feature = "tls")] let tls_acceptor = { @@ -219,7 +217,10 @@ pub async fn run_server( #[cfg(not(feature = "tls"))] let io = TokioIo::new(tcp_stream); - if http2_enabled { + #[cfg(feature = "http2")] + { + use hyper_util::rt::TokioExecutor; + let mut http_builder = hyper_util::server::conn::auto::Builder::new(TokioExecutor::new()); @@ -231,7 +232,10 @@ pub async fn run_server( { println!("Error serving connection: {:?}", err); } - } else { + } + + #[cfg(not(feature = "http2"))] + { let mut http_builder = hyper::server::conn::http1::Builder::new(); if keep_alive { From 467911af665df194c6facfb14f3616b4d25fb9f4 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Fri, 27 Dec 2024 19:33:01 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[#197]=20http2=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rupring/src/core/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rupring/src/core/mod.rs b/rupring/src/core/mod.rs index 32d21cb..2d50a2b 100644 --- a/rupring/src/core/mod.rs +++ b/rupring/src/core/mod.rs @@ -92,6 +92,11 @@ pub async fn run_server( tls::new_tls_acceptor(&application_properties)? }; + #[cfg(feature = "http2")] + { + print_system_log(Level::Info, "HTTP/2 Enabled"); + } + // 5. Main Server Loop // Spawns a new async Task for each request. loop { From dcf6888794be118223adfe0d784279ee82305e29 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Fri, 27 Dec 2024 19:34:53 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[#197]=20=EA=B2=BD=EA=B3=A0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rupring/src/core/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rupring/src/core/mod.rs b/rupring/src/core/mod.rs index 2d50a2b..f178693 100644 --- a/rupring/src/core/mod.rs +++ b/rupring/src/core/mod.rs @@ -83,6 +83,7 @@ pub async fn run_server( ); } + #[cfg(not(feature = "http2"))] let keep_alive = application_properties.server.http1.keep_alive.to_owned(); #[cfg(feature = "tls")]