Example #1
0
        public void RaiseError(string details, HttpStatusCode status)
        {
            Clear();

            _httpStatus = status;

            ContentType = "text/html; charset=UTF-8";

            Write(@"<html><head><title>Error</title></head><body>
<h2>" + (int)status + " " + HttpStatusHelper.GetHttpStatusFromCode(status) + @"</h2>
" + (details != null && details.Length > 0 ? "<p>" + details + "</p>": "") + @"
</body></html>");
        }
Example #2
0
        internal string GetResponseHeader()
        {
            StringBuilder sb = new StringBuilder();

            string response = _httpVersion + " " + (int)_httpStatus + " " + HttpStatusHelper.GetHttpStatusFromCode(_httpStatus) + "\r\n";

#if (MF)
            AddHeader("Date", _date.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"));
#else
            AddHeader("Date", _date.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", DateTimeFormatInfo.InvariantInfo));
#endif



            AddHeader("Content-Length", (_content != null ? _content.Length.ToString() : "0"));

            AddHeader("X-Powered-By", "MSchwarz HTTP Server");

            if (_cookies != null)
            {
                for (int i = 0; i < _cookies.Count; i++)
                {
                    HttpCookie cookie = _cookies[i] as HttpCookie;

                    if (cookie != null)
                    {
                        AddHeader("Set-Cookie", cookie.ToString(), false);
                    }
                }
            }


            if (_headers != null && _headers.Length > 0)
            {
                for (int i = 0; i < _headers.Length; i++)
                {
                    response += _headers[i].Name + ": " + _headers[i].Value + "\r\n";
                }
            }

            response += "\r\n";

            return(response);
        }