public HttpResponse(HttpRequest request) { this.request = request; 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.IsWebSocket && HttpWebSocket.WebSocketControllerExists(this.request)) { var type = HttpWebSocket.GetWebSocketController(this.request); this.request.WebSocket = (HttpWebSocket)Activator.CreateInstance(type, this.request); } 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 HttpExceptionContent) { this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } else if (this.request.IsWebSocket) { this.bytes = this.ConstructResponse(HttpStatusCode.SWITCHING_PROTOCOLS); } 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) { this.content = new HttpExceptionContent(ex); this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } catch (Exception ex) { this.content = new HttpExceptionContent(ex); this.bytes = this.ConstructResponse(HttpStatusCode.SERVERERROR); } }