public HttpResponse(HttpRequest request) { this.request = request; const string PDF_IDENT = "-pdf"; try { if (this.request.Path == @"") { if (HttpController.Primary == null) throw new ApplicationException("Primary Controller Not Defined"); if (HttpController.Primary.PrimaryAction == null) throw new ApplicationException("Primary Action Not Defined"); this.content = HttpController.RequestPrimary(this.request); } else if (this.request.Path.ToLower().EndsWith(PDF_IDENT, StringComparison.CurrentCulture)) { string url = "http://localhost:" + request.Server.Port.ToString() + this.request.FullUrl; url = url.Replace(this.request.Path, StringHelper.TrimEnd(this.request.Path, PDF_IDENT.Length)); this.content = new HttpContent(HtmlToPdfHelper.ReadPDF(url), "application/pdf"); } else if (HttpController.ActionExists(this.request)) { this.content = HttpController.RequestAction(this.request); } else { this.content = HttpContent.Read(this.request.Server, this.request.Path); } if (this.content is HttpErrorContent) { this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } else if (this.content.ETag == this.request.ETag && !this.content.ParsingRequired) { this.bytes = this.ConstructResponse(HttpStatusCode.NOT_MODIFIED); } else { this.bytes = this.ConstructResponse(HttpStatusCode.OK); } } catch (FileNotFoundException ex) { Program.Log(ex); this.content = ErrorController.Display(this.request, ex, HttpStatusCode.NOTFOUND); this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } catch (Exception ex) { Program.Log(ex); this.content = ErrorController.Display(this.request, ex, HttpStatusCode.SERVERERROR); this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } }