diff options
author | Justin Clark-Casey (justincc) | 2009-12-15 16:34:27 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-12-15 16:34:27 +0000 |
commit | 87e9062862ad8bc906b51b41d11641e1bccc551c (patch) | |
tree | 2d909092a81c1c8b10256f0e99a1da921f54300b /OpenSim/Framework/Servers | |
parent | Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-87e9062862ad8bc906b51b41d11641e1bccc551c.zip opensim-SC_OLD-87e9062862ad8bc906b51b41d11641e1bccc551c.tar.gz opensim-SC_OLD-87e9062862ad8bc906b51b41d11641e1bccc551c.tar.bz2 opensim-SC_OLD-87e9062862ad8bc906b51b41d11641e1bccc551c.tar.xz |
Make sure that we catch and display any exceptions that get right to the top of our incoming http request handling stack
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 98 |
1 files changed, 52 insertions, 46 deletions
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 | |||
253 | 253 | ||
254 | private void OnRequest(object source, RequestEventArgs args) | 254 | private void OnRequest(object source, RequestEventArgs args) |
255 | { | 255 | { |
256 | IHttpClientContext context = (IHttpClientContext)source; | 256 | try |
257 | IHttpRequest request = args.Request; | ||
258 | |||
259 | PollServiceEventArgs psEvArgs; | ||
260 | |||
261 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | ||
262 | { | 257 | { |
263 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); | 258 | IHttpClientContext context = (IHttpClientContext)source; |
264 | 259 | IHttpRequest request = args.Request; | |
265 | if (psEvArgs.Request != null) | 260 | |
261 | PollServiceEventArgs psEvArgs; | ||
262 | |||
263 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | ||
266 | { | 264 | { |
267 | OSHttpRequest req = new OSHttpRequest(context, request); | 265 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); |
268 | 266 | ||
269 | Stream requestStream = req.InputStream; | 267 | if (psEvArgs.Request != null) |
270 | |||
271 | Encoding encoding = Encoding.UTF8; | ||
272 | StreamReader reader = new StreamReader(requestStream, encoding); | ||
273 | |||
274 | string requestBody = reader.ReadToEnd(); | ||
275 | |||
276 | Hashtable keysvals = new Hashtable(); | ||
277 | Hashtable headervals = new Hashtable(); | ||
278 | |||
279 | string[] querystringkeys = req.QueryString.AllKeys; | ||
280 | string[] rHeaders = req.Headers.AllKeys; | ||
281 | |||
282 | keysvals.Add("body", requestBody); | ||
283 | keysvals.Add("uri", req.RawUrl); | ||
284 | keysvals.Add("content-type", req.ContentType); | ||
285 | keysvals.Add("http-method", req.HttpMethod); | ||
286 | |||
287 | foreach (string queryname in querystringkeys) | ||
288 | { | ||
289 | keysvals.Add(queryname, req.QueryString[queryname]); | ||
290 | } | ||
291 | |||
292 | foreach (string headername in rHeaders) | ||
293 | { | 268 | { |
294 | headervals[headername] = req.Headers[headername]; | 269 | OSHttpRequest req = new OSHttpRequest(context, request); |
270 | |||
271 | Stream requestStream = req.InputStream; | ||
272 | |||
273 | Encoding encoding = Encoding.UTF8; | ||
274 | StreamReader reader = new StreamReader(requestStream, encoding); | ||
275 | |||
276 | string requestBody = reader.ReadToEnd(); | ||
277 | |||
278 | Hashtable keysvals = new Hashtable(); | ||
279 | Hashtable headervals = new Hashtable(); | ||
280 | |||
281 | string[] querystringkeys = req.QueryString.AllKeys; | ||
282 | string[] rHeaders = req.Headers.AllKeys; | ||
283 | |||
284 | keysvals.Add("body", requestBody); | ||
285 | keysvals.Add("uri", req.RawUrl); | ||
286 | keysvals.Add("content-type", req.ContentType); | ||
287 | keysvals.Add("http-method", req.HttpMethod); | ||
288 | |||
289 | foreach (string queryname in querystringkeys) | ||
290 | { | ||
291 | keysvals.Add(queryname, req.QueryString[queryname]); | ||
292 | } | ||
293 | |||
294 | foreach (string headername in rHeaders) | ||
295 | { | ||
296 | headervals[headername] = req.Headers[headername]; | ||
297 | } | ||
298 | |||
299 | keysvals.Add("headers",headervals); | ||
300 | keysvals.Add("querystringkeys", querystringkeys); | ||
301 | |||
302 | psEvArgs.Request(psreq.RequestID, keysvals); | ||
295 | } | 303 | } |
296 | 304 | ||
297 | keysvals.Add("headers",headervals); | 305 | m_PollServiceManager.Enqueue(psreq); |
298 | keysvals.Add("querystringkeys", querystringkeys); | 306 | } |
299 | 307 | else | |
300 | psEvArgs.Request(psreq.RequestID, keysvals); | 308 | { |
309 | OnHandleRequestIOThread(context, request); | ||
301 | } | 310 | } |
302 | |||
303 | m_PollServiceManager.Enqueue(psreq); | ||
304 | } | 311 | } |
305 | else | 312 | catch (Exception e) |
306 | { | 313 | { |
307 | OnHandleRequestIOThread(context, request); | 314 | m_log.ErrorFormat("[BASE HTTP SERVER]: OnRequest() failed with {0} {1}", e.Message, e.StackTrace); |
308 | } | 315 | } |
309 | |||
310 | } | 316 | } |
311 | 317 | ||
312 | public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) | 318 | public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) |