From 87e9062862ad8bc906b51b41d11641e1bccc551c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 15 Dec 2009 16:34:27 +0000 Subject: Make sure that we catch and display any exceptions that get right to the top of our incoming http request handling stack --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 98 ++++++++++++---------- 1 file changed, 52 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 6f41714..08f1bec 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -253,60 +253,66 @@ namespace OpenSim.Framework.Servers.HttpServer private void OnRequest(object source, RequestEventArgs args) { - IHttpClientContext context = (IHttpClientContext)source; - IHttpRequest request = args.Request; - - PollServiceEventArgs psEvArgs; - - if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) + try { - PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); - - if (psEvArgs.Request != null) + IHttpClientContext context = (IHttpClientContext)source; + IHttpRequest request = args.Request; + + PollServiceEventArgs psEvArgs; + + if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) { - OSHttpRequest req = new OSHttpRequest(context, request); - - Stream requestStream = req.InputStream; - - Encoding encoding = Encoding.UTF8; - StreamReader reader = new StreamReader(requestStream, encoding); - - string requestBody = reader.ReadToEnd(); - - Hashtable keysvals = new Hashtable(); - Hashtable headervals = new Hashtable(); - - string[] querystringkeys = req.QueryString.AllKeys; - string[] rHeaders = req.Headers.AllKeys; - - keysvals.Add("body", requestBody); - keysvals.Add("uri", req.RawUrl); - keysvals.Add("content-type", req.ContentType); - keysvals.Add("http-method", req.HttpMethod); - - foreach (string queryname in querystringkeys) - { - keysvals.Add(queryname, req.QueryString[queryname]); - } - - foreach (string headername in rHeaders) + PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); + + if (psEvArgs.Request != null) { - headervals[headername] = req.Headers[headername]; + OSHttpRequest req = new OSHttpRequest(context, request); + + Stream requestStream = req.InputStream; + + Encoding encoding = Encoding.UTF8; + StreamReader reader = new StreamReader(requestStream, encoding); + + string requestBody = reader.ReadToEnd(); + + Hashtable keysvals = new Hashtable(); + Hashtable headervals = new Hashtable(); + + string[] querystringkeys = req.QueryString.AllKeys; + string[] rHeaders = req.Headers.AllKeys; + + keysvals.Add("body", requestBody); + keysvals.Add("uri", req.RawUrl); + keysvals.Add("content-type", req.ContentType); + keysvals.Add("http-method", req.HttpMethod); + + foreach (string queryname in querystringkeys) + { + keysvals.Add(queryname, req.QueryString[queryname]); + } + + foreach (string headername in rHeaders) + { + headervals[headername] = req.Headers[headername]; + } + + keysvals.Add("headers",headervals); + keysvals.Add("querystringkeys", querystringkeys); + + psEvArgs.Request(psreq.RequestID, keysvals); } - - keysvals.Add("headers",headervals); - keysvals.Add("querystringkeys", querystringkeys); - - psEvArgs.Request(psreq.RequestID, keysvals); + + m_PollServiceManager.Enqueue(psreq); + } + else + { + OnHandleRequestIOThread(context, request); } - - m_PollServiceManager.Enqueue(psreq); } - else + catch (Exception e) { - OnHandleRequestIOThread(context, request); + m_log.ErrorFormat("[BASE HTTP SERVER]: OnRequest() failed with {0} {1}", e.Message, e.StackTrace); } - } public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) -- cgit v1.1