diff options
author | Melanie | 2009-09-22 06:19:02 +0100 |
---|---|---|
committer | Melanie | 2009-09-22 06:19:02 +0100 |
commit | dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37 (patch) | |
tree | 914b665eb98aea2fa218cf670a1c591614fe8542 /OpenSim/Framework/Servers/HttpServer | |
parent | Remove support for executing a handler on poll. It caused other issues (diff) | |
download | opensim-SC_OLD-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.zip opensim-SC_OLD-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.tar.gz opensim-SC_OLD-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.tar.bz2 opensim-SC_OLD-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.tar.xz |
Completely remove the prior implementation of the request event handling
on poll handlers. Introduce a new delegate on the PollServiceEventArgs that
allow access to the request headers and body.
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 78 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 5 |
2 files changed, 44 insertions, 39 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 0198960..db87958 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -256,17 +256,51 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
256 | IHttpClientContext context = (IHttpClientContext)source; | 256 | IHttpClientContext context = (IHttpClientContext)source; |
257 | IHttpRequest request = args.Request; | 257 | IHttpRequest request = args.Request; |
258 | 258 | ||
259 | |||
260 | PollServiceEventArgs psEvArgs; | 259 | PollServiceEventArgs psEvArgs; |
260 | |||
261 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | 261 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) |
262 | { | 262 | { |
263 | // OSHttpRequest req = new OSHttpRequest(context, request); | ||
264 | |||
265 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); | 263 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); |
266 | // req.Headers["X-PollServiceID"] = psreq.RequestID.ToString(); | 264 | |
267 | // HandleRequest(req, null); | 265 | if (psEvArgs.Request != null) |
266 | { | ||
267 | OSHttpRequest req = new OSHttpRequest(context, request); | ||
268 | |||
269 | Stream requestStream = req.InputStream; | ||
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 | { | ||
294 | headervals[headername] = req.Headers[headername]; | ||
295 | } | ||
296 | |||
297 | keysvals.Add("headers",headervals); | ||
298 | keysvals.Add("querystringkeys", querystringkeys); | ||
299 | |||
300 | psEvArgs.Request(psreq.RequestID, keysvals); | ||
301 | } | ||
302 | |||
268 | m_PollServiceManager.Enqueue(psreq); | 303 | m_PollServiceManager.Enqueue(psreq); |
269 | //DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request))); | ||
270 | } | 304 | } |
271 | else | 305 | else |
272 | { | 306 | { |
@@ -279,48 +313,16 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
279 | { | 313 | { |
280 | OSHttpRequest req = new OSHttpRequest(context, request); | 314 | OSHttpRequest req = new OSHttpRequest(context, request); |
281 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 315 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); |
282 | //resp.KeepAlive = req.KeepAlive; | ||
283 | //m_log.Info("[Debug BASE HTTP SERVER]: Got Request"); | ||
284 | //HttpServerContextObj objstate= new HttpServerContextObj(req,resp); | ||
285 | //ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertIHttpClientContextToOSHttp), (object)objstate); | ||
286 | HandleRequest(req, resp); | 316 | HandleRequest(req, resp); |
287 | } | 317 | } |
288 | 318 | ||
289 | public void ConvertIHttpClientContextToOSHttp(object stateinfo) | 319 | public void ConvertIHttpClientContextToOSHttp(object stateinfo) |
290 | { | 320 | { |
291 | HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; | 321 | HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; |
292 | //OSHttpRequest request = new OSHttpRequest(objstate.context,objstate.req); | ||
293 | //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req)); | ||
294 | 322 | ||
295 | OSHttpRequest request = objstate.oreq; | 323 | OSHttpRequest request = objstate.oreq; |
296 | OSHttpResponse resp = objstate.oresp; | 324 | OSHttpResponse resp = objstate.oresp; |
297 | //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req)); | ||
298 | |||
299 | /* | ||
300 | request.AcceptTypes = objstate.req.AcceptTypes; | ||
301 | request.ContentLength = (long)objstate.req.ContentLength; | ||
302 | request.Headers = objstate.req.Headers; | ||
303 | request.HttpMethod = objstate.req.Method; | ||
304 | request.InputStream = objstate.req.Body; | ||
305 | foreach (string str in request.Headers) | ||
306 | { | ||
307 | if (str.ToLower().Contains("content-type: ")) | ||
308 | { | ||
309 | request.ContentType = str.Substring(13, str.Length - 13); | ||
310 | break; | ||
311 | } | ||
312 | } | ||
313 | //request.KeepAlive = objstate.req. | ||
314 | foreach (HttpServer.HttpInput httpinput in objstate.req.QueryString) | ||
315 | { | ||
316 | request.QueryString.Add(httpinput.Name, httpinput[httpinput.Name]); | ||
317 | } | ||
318 | |||
319 | //request.Query = objstate.req.//objstate.req.QueryString; | ||
320 | //foreach ( | ||
321 | //request.QueryString = objstate.req.QueryString; | ||
322 | 325 | ||
323 | */ | ||
324 | HandleRequest(request,resp); | 326 | HandleRequest(request,resp); |
325 | } | 327 | } |
326 | 328 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 61cb8aa..7ed9e5c 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | namespace OpenSim.Framework.Servers.HttpServer | 31 | namespace OpenSim.Framework.Servers.HttpServer |
32 | { | 32 | { |
33 | public delegate void RequestMethod(UUID requestID, Hashtable request); | ||
33 | public delegate bool HasEventsMethod(UUID requestID, UUID pId); | 34 | public delegate bool HasEventsMethod(UUID requestID, UUID pId); |
34 | 35 | ||
35 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); | 36 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); |
@@ -41,9 +42,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
41 | public HasEventsMethod HasEvents; | 42 | public HasEventsMethod HasEvents; |
42 | public GetEventsMethod GetEvents; | 43 | public GetEventsMethod GetEvents; |
43 | public NoEventsMethod NoEvents; | 44 | public NoEventsMethod NoEvents; |
45 | public RequestMethod Request; | ||
44 | public UUID Id; | 46 | public UUID Id; |
45 | public PollServiceEventArgs(HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) | 47 | public PollServiceEventArgs(RequestMethod Request, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) |
46 | { | 48 | { |
49 | Request = Request; | ||
47 | HasEvents = pHasEvents; | 50 | HasEvents = pHasEvents; |
48 | GetEvents = pGetEvents; | 51 | GetEvents = pGetEvents; |
49 | NoEvents = pNoEvents; | 52 | NoEvents = pNoEvents; |