From 5ffe299ebe2d902780b672288f96421870c9a33e Mon Sep 17 00:00:00 2001 From: sta Date: Sun, 30 Jan 2022 22:22:43 +0900 Subject: [PATCH] [Modify] Polish it --- Example3/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Example3/Program.cs b/Example3/Program.cs index 58fb125f..81a405cb 100644 --- a/Example3/Program.cs +++ b/Example3/Program.cs @@ -90,12 +90,15 @@ namespace Example3 var res = e.Response; var path = req.RawUrl; + if (path == "/") path += "index.html"; byte[] contents; + if (!e.TryReadFile (path, out contents)) { res.StatusCode = (int) HttpStatusCode.NotFound; + return; } @@ -109,6 +112,7 @@ namespace Example3 } res.ContentLength64 = contents.LongLength; + res.Close (contents, true); };