using System.IO; namespace SimpleHttpServer { public static class HttpBuilder { private static HttpResponse httpRsp_404 = null; private static HttpResponse httpRsp_500 = null; private static HttpResponse httpRsp_405 = null; public static HttpResponse InternalServerError() { if (httpRsp_500 == null) { httpRsp_500 = new HttpResponse() { ReasonPhrase = "InternalServerError", StatusCode = "500", }; string content = File.ReadAllText("../cfg/sog/httpsvr/Resources/Pages/500.html"); if (! string.IsNullOrEmpty(content)) { httpRsp_500.ContentAsUTF8 = content; } } return httpRsp_500; } public static HttpResponse NotFound() { if (httpRsp_404 == null) { httpRsp_404 = new HttpResponse() { ReasonPhrase = "NotFound", StatusCode = "404", }; string content = File.ReadAllText("../cfg/sog/httpsvr/Resources/Pages/404.html"); if (! string.IsNullOrEmpty(content)) { httpRsp_404.ContentAsUTF8 = content; } } return httpRsp_404; } public static HttpResponse MethodNotAllowed() { if (httpRsp_405 == null) { httpRsp_405 = new HttpResponse { ReasonPhrase = "Method Not Allowed", StatusCode = "405" }; } return httpRsp_405; } } }