Beispiel #1
0
        public void SendError(string msg, int status)
        {
            try
            {
                var response = _context.Response;
                response.StatusCode  = status;
                response.ContentType = "text/html";
                var description = HttpListenerResponseHelper.GetStatusDescription(status);
                var str         = msg != null
                    ? string.Format("<h1>{0} ({1})</h1>", description, msg)
                    : string.Format("<h1>{0}</h1>", description);

                var error = _context.Response.ContentEncoding.GetBytes(str);
                response.Close(error, false);
            }
            catch
            {
                // response was already closed
            }
        }
Beispiel #2
0
 internal HttpResponse(HttpStatusCode code)
     : this((int)code, HttpListenerResponseHelper.GetStatusDescription((int)code), HttpVersion.Version11, new NameValueCollection())
 {
 }
Beispiel #3
0
 internal HttpResponse(HttpStatusCode code)
     : this(code, HttpListenerResponseHelper.GetStatusDescription((int)code))
 {
 }