diff options
author | Diva Canto | 2009-09-22 14:15:53 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-22 14:15:53 -0700 |
commit | 0fc2b73e7b33ace583aacf8a0bfe1f184f045f99 (patch) | |
tree | 3015532d8575d9ef17e13198efe5b8d49a549172 /OpenSim/Framework | |
parent | Added HGGridConnector and related code. (diff) | |
parent | Thank you, Intari, for a patch that implements the missing pieces of (diff) | |
download | opensim-SC-0fc2b73e7b33ace583aacf8a0bfe1f184f045f99.zip opensim-SC-0fc2b73e7b33ace583aacf8a0bfe1f184f045f99.tar.gz opensim-SC-0fc2b73e7b33ace583aacf8a0bfe1f184f045f99.tar.bz2 opensim-SC-0fc2b73e7b33ace583aacf8a0bfe1f184f045f99.tar.xz |
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 116 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 5 |
3 files changed, 56 insertions, 67 deletions
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 76276a5..c27072c 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -198,7 +198,7 @@ namespace OpenSim.Framework.Console | |||
198 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 198 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
199 | 199 | ||
200 | m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll, | 200 | m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll, |
201 | new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, | 201 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, |
202 | sessionID)); | 202 | sessionID)); |
203 | 203 | ||
204 | XmlDocument xmldoc = new XmlDocument(); | 204 | XmlDocument xmldoc = new XmlDocument(); |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 5d83e34..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 | 325 | ||
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 | |||
323 | */ | ||
324 | HandleRequest(request,resp); | 326 | HandleRequest(request,resp); |
325 | } | 327 | } |
326 | 328 | ||
@@ -337,24 +339,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
337 | // handled | 339 | // handled |
338 | //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); | 340 | //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); |
339 | 341 | ||
340 | // If the response is null, then we're not going to respond here. This case | 342 | IHttpAgentHandler agentHandler; |
341 | // triggers when we're at the head of a HTTP poll | ||
342 | // | ||
343 | if (response != null) | ||
344 | { | ||
345 | IHttpAgentHandler agentHandler; | ||
346 | 343 | ||
347 | if (TryGetAgentHandler(request, response, out agentHandler)) | 344 | if (TryGetAgentHandler(request, response, out agentHandler)) |
345 | { | ||
346 | if (HandleAgentRequest(agentHandler, request, response)) | ||
348 | { | 347 | { |
349 | if (HandleAgentRequest(agentHandler, request, response)) | 348 | return; |
350 | { | ||
351 | return; | ||
352 | } | ||
353 | } | 349 | } |
354 | |||
355 | //response.KeepAlive = true; | ||
356 | response.SendChunked = false; | ||
357 | } | 350 | } |
351 | |||
352 | //response.KeepAlive = true; | ||
353 | response.SendChunked = false; | ||
354 | |||
358 | IRequestHandler requestHandler; | 355 | IRequestHandler requestHandler; |
359 | 356 | ||
360 | string path = request.RawUrl; | 357 | string path = request.RawUrl; |
@@ -368,8 +365,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
368 | // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. | 365 | // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. |
369 | byte[] buffer = null; | 366 | byte[] buffer = null; |
370 | 367 | ||
371 | if (response != null) | 368 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. |
372 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. | ||
373 | 369 | ||
374 | 370 | ||
375 | if (requestHandler is IStreamedRequestHandler) | 371 | if (requestHandler is IStreamedRequestHandler) |
@@ -425,12 +421,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
425 | //m_log.Warn("[HTTP]: " + requestBody); | 421 | //m_log.Warn("[HTTP]: " + requestBody); |
426 | 422 | ||
427 | } | 423 | } |
428 | // If we're not responding, we dont' care about the reply | 424 | DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response); |
429 | // | ||
430 | if (response == null) | ||
431 | HTTPRequestHandler.Handle(path, keysvals); | ||
432 | else | ||
433 | DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response); | ||
434 | return; | 425 | return; |
435 | } | 426 | } |
436 | else | 427 | else |
@@ -445,11 +436,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
445 | } | 436 | } |
446 | } | 437 | } |
447 | 438 | ||
448 | // The handler has run and we're not yet ready to respond, bail | ||
449 | // | ||
450 | if (response == null) | ||
451 | return; | ||
452 | |||
453 | request.InputStream.Close(); | 439 | request.InputStream.Close(); |
454 | 440 | ||
455 | // HTTP IN support. The script engine taes it from here | 441 | // HTTP IN support. The script engine taes it from here |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 61cb8aa..9d512c6 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 pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) |
46 | { | 48 | { |
49 | Request = pRequest; | ||
47 | HasEvents = pHasEvents; | 50 | HasEvents = pHasEvents; |
48 | GetEvents = pGetEvents; | 51 | GetEvents = pGetEvents; |
49 | NoEvents = pNoEvents; | 52 | NoEvents = pNoEvents; |