Ejemplo n.º 1
0
        private void NotifyErrors(HTTPRequest HTTPRequest,
                                  TCPConnection TCPConnection,
                                  DateTime Timestamp,
                                  HTTPStatusCode HTTPStatusCode,
                                  HTTPRequest Request     = null,
                                  HTTPResponse Response   = null,
                                  String Error            = null,
                                  Exception LastException = null,
                                  Boolean CloseConnection = true)
        {
            #region Call OnError delegates

            var ErrorLogLocal = ErrorLog;
            if (ErrorLogLocal != null)
            {
                ErrorLogLocal(this, Timestamp, Request, Response, Error, LastException);
            }

            #endregion

            #region Send error page to HTTP client

            var Content = String.Empty;

            if (Error != null)
            {
                Content += Error + Environment.NewLine;
            }

            if (LastException != null)
            {
                Content += LastException.Message + Environment.NewLine;
            }

            var _HTTPResponse = new HTTPResponseBuilder(HTTPRequest)
            {
                HTTPStatusCode = HTTPStatusCode,
                Date           = Timestamp,
                Content        = Content.ToUTF8Bytes()
            };

            TCPConnection.WriteLineToResponseStream(_HTTPResponse.ToString());

            if (CloseConnection)
            {
                TCPConnection.Close();
            }

            #endregion
        }