Changeset 182 for SimpleHttpServer

Show
Ignore:
Timestamp:
04/07/07 02:12:57 (21 months ago)
Author:
mayuki
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • SimpleHttpServer/SimpleHttpServer/SimpleHttpServer.cs

    r181 r182  
    170170        public SimpleHttpServer() 
    171171        { 
    172             _versionString = String.Format("{0}/{1}", GetType().Name, GetType().Assembly.GetName().Version); 
     172            _versionString = String.Format("{0}/{1}", GetType().FullName, GetType().Assembly.GetName().Version); 
    173173        } 
    174174 
     
    188188 
    189189        public event EventHandler<HttpErrorEventArgs> HttpErrorHandled; 
    190         protected virtual void OnHttpErrorHandled(HttpException e) 
     190        protected virtual void OnHttpErrorHandled(HttpException he) 
    191191        { 
    192192            if (HttpErrorHandled != null) 
    193193            { 
     194                HttpErrorHandled(this, new HttpErrorEventArgs(he)); 
    194195            } 
    195196            else 
    196197            { 
    197198                // default error handling 
     199                using (StreamWriter sw = new StreamWriter(Context.Current.Stream)) 
     200                { 
     201                    sw.WriteLine("HTTP/1.0 {0} {1}", he.GetHttpCode(), he.Message); 
     202                    sw.WriteLine("Content-Type: text/html; charset=utf-8"); 
     203                    sw.WriteLine("Server: {0}", VersionString); 
     204                    sw.WriteLine("Connection: close"); 
     205                    sw.WriteLine(""); 
     206                    sw.WriteLine("<title>{0} {1}</title>", he.GetHttpCode(), he.Message); 
     207                    sw.WriteLine("<h1>{0} {1}</h1>", he.GetHttpCode(), he.Message); 
     208                    sw.WriteLine("<p>{0}</p>", he.GetHtmlErrorMessage()); 
     209                    sw.WriteLine("<h2>��</h2>"); 
     210                    sw.WriteLine("<pre>{0}</pre>", HttpUtility.HtmlEncode(he.ToString())); 
     211                } 
    198212            } 
    199213        } 
     
    217231                    { 
    218232                        Trace.WriteLineIf(_loggingEnabled, he.Message, "error"); 
    219                         sw.WriteLine("HTTP/1.0 {0} {1}", he.GetHttpCode(), he.Message); 
    220                         sw.WriteLine("Content-Type: text/html; charset=utf-8"); 
    221                         sw.WriteLine("Server: {0}", VersionString); 
    222                         sw.WriteLine("Connection: close"); 
    223                         sw.WriteLine(""); 
    224                         sw.WriteLine("<title>{0} {1}</title>", he.GetHttpCode(), he.Message); 
    225                         sw.WriteLine("<h1>{0} {1}</h1>", he.GetHttpCode(), he.Message); 
    226                         sw.WriteLine("<p>{0}</p>", he.GetHtmlErrorMessage()); 
    227                         sw.WriteLine("<h2>��</h2>"); 
    228                         sw.WriteLine("<pre>{0}</pre>", HttpUtility.HtmlEncode(he.ToString())); 
    229                         sw.Flush(); 
     233                        OnHttpErrorHandled(he); 
    230234                    } 
    231235                }