Ejemplo n.º 1
0
        void ProcessInternalError(HttpConnection conn, IHttpRequest req, HttpResponseHeader header, bool header_sent, Exception exception, ref bool keepAlive)
        {
            if (!header_sent)
            {
                object result = new byte[0];
                if (exception is HttpException)
                {
                    header.Status = (exception as HttpException).HttpStatusCode;
                }
                else
                {
                    header.Status = HttpStatusCode.InternalServerError;
                }

                if (header.Status == HttpStatusCode.NotModified /*|| header.Status == HttpStatusCode.ResetContent(205)*/)
                {
                    header.Remove(HttpHeaderNames.ContentLength);                      // Not allowed contains response body
                }
                else
                {
                    if (req.HttpMethod == HttpMethod.HEAD || _errApp == null)
                    {
                        header[HttpHeaderNames.ContentLength] = "0";
                    }
                    else
                    {
                    }
                }

                _logger.Trace("HTTP {0} {1}", (int)header.Status, ServerHelper.GetStatusDescription(header.Status));
                ProcessResponse(conn, req, header, result, ref keepAlive, ref header_sent);
                //byte[] raw = header.CreateResponseHeaderBytes ();
                //conn.Send (raw);
            }
            else
            {
                keepAlive = false;                 // force disconnect
            }
        }