From e7655d3d47f7f926d74bc18fdbc9aabcb3079c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Sun, 29 Mar 2026 09:05:23 +0200 Subject: [PATCH 1/3] [C#] GenHTTP: Enable SSL and configure compression globally --- frameworks/genhttp/Folder.DotSettings.user | 2 ++ frameworks/genhttp/Program.cs | 16 ++++++++++++++-- frameworks/genhttp/Project.cs | 2 -- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 frameworks/genhttp/Folder.DotSettings.user diff --git a/frameworks/genhttp/Folder.DotSettings.user b/frameworks/genhttp/Folder.DotSettings.user new file mode 100644 index 00000000..94b6688b --- /dev/null +++ b/frameworks/genhttp/Folder.DotSettings.user @@ -0,0 +1,2 @@ + + ForceIncluded \ No newline at end of file diff --git a/frameworks/genhttp/Program.cs b/frameworks/genhttp/Program.cs index 9ba1d467..538fea54 100644 --- a/frameworks/genhttp/Program.cs +++ b/frameworks/genhttp/Program.cs @@ -1,13 +1,25 @@ using System.Net; - +using System.Security.Cryptography.X509Certificates; using genhttp; using GenHTTP.Engine.Internal; +using GenHTTP.Modules.Practices; + +var certPath = Environment.GetEnvironmentVariable("TLS_CERT") ?? "/certs/server.crt"; +var keyPath = Environment.GetEnvironmentVariable("TLS_KEY") ?? "/certs/server.key"; +var hasCert = File.Exists(certPath) && File.Exists(keyPath); var app = Project.Create(); -var host = Host.Create().Handler(app); +var host = Host.Create() + .Handler(app) + .Defaults(clientCaching: false); host.Bind(IPAddress.Any, 8080); +if (hasCert) +{ + host.Bind(IPAddress.Any, 8443, X509Certificate2.CreateFromPemFile(certPath, keyPath)); +} + await host.RunAsync(); \ No newline at end of file diff --git a/frameworks/genhttp/Project.cs b/frameworks/genhttp/Project.cs index e361a9b5..670bbad2 100644 --- a/frameworks/genhttp/Project.cs +++ b/frameworks/genhttp/Project.cs @@ -74,8 +74,6 @@ private static LayoutBuilder AddCompression(this LayoutBuilder app) { var service = ServiceResource.From().ExecutionMode(ExecutionMode.Auto); - service.Add(CompressedContent.Default()); - return app.Add("compression", service); } From 62c2e67f62c46f604a55d647b39bb75a64e4b5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Sun, 29 Mar 2026 09:16:13 +0200 Subject: [PATCH 2/3] Remove IDE clutter --- .gitignore | 3 +++ frameworks/genhttp/Folder.DotSettings.user | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 frameworks/genhttp/Folder.DotSettings.user diff --git a/.gitignore b/.gitignore index c9f9ab88..58771a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ bin/ target/ frameworks/blitz/zig-linux-* frameworks/blitz/.zig-cache + +# IDE settings +*.user \ No newline at end of file diff --git a/frameworks/genhttp/Folder.DotSettings.user b/frameworks/genhttp/Folder.DotSettings.user deleted file mode 100644 index 94b6688b..00000000 --- a/frameworks/genhttp/Folder.DotSettings.user +++ /dev/null @@ -1,2 +0,0 @@ - - ForceIncluded \ No newline at end of file From 5e39bbf84e48811198e64bca3abdbbdac41090c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Sun, 29 Mar 2026 09:45:07 +0200 Subject: [PATCH 3/3] Switch from Defaults() to compression as there are lots of side effects with SSL endpoints --- frameworks/genhttp/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/genhttp/Program.cs b/frameworks/genhttp/Program.cs index 538fea54..ef623ccb 100644 --- a/frameworks/genhttp/Program.cs +++ b/frameworks/genhttp/Program.cs @@ -3,7 +3,7 @@ using genhttp; using GenHTTP.Engine.Internal; -using GenHTTP.Modules.Practices; +using GenHTTP.Modules.Compression; var certPath = Environment.GetEnvironmentVariable("TLS_CERT") ?? "/certs/server.crt"; var keyPath = Environment.GetEnvironmentVariable("TLS_KEY") ?? "/certs/server.key"; @@ -13,7 +13,7 @@ var host = Host.Create() .Handler(app) - .Defaults(clientCaching: false); + .Compression(); host.Bind(IPAddress.Any, 8080);