From 06871d51dd47cd59185e2123f8235b4d79aee02c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 22 Sep 2009 05:13:50 +0100 Subject: Disable the handler execution for poll services until the ramifications can be studied --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 5d83e34..5c9fa9b 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -260,11 +260,11 @@ namespace OpenSim.Framework.Servers.HttpServer PollServiceEventArgs psEvArgs; if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) { - OSHttpRequest req = new OSHttpRequest(context, request); +// OSHttpRequest req = new OSHttpRequest(context, request); PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); - req.Headers["X-PollServiceID"] = psreq.RequestID.ToString(); - HandleRequest(req, null); +// req.Headers["X-PollServiceID"] = psreq.RequestID.ToString(); +// HandleRequest(req, null); m_PollServiceManager.Enqueue(psreq); //DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request))); } -- cgit v1.1 From c5be401d46dfbb1e47927b4123130c43c6a054b5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 22 Sep 2009 05:24:22 +0100 Subject: Remove support for executing a handler on poll. It caused other issues --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 38 +++++++--------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 5c9fa9b..0198960 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -337,24 +337,19 @@ namespace OpenSim.Framework.Servers.HttpServer // handled //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); - // If the response is null, then we're not going to respond here. This case - // triggers when we're at the head of a HTTP poll - // - if (response != null) - { - IHttpAgentHandler agentHandler; + IHttpAgentHandler agentHandler; - if (TryGetAgentHandler(request, response, out agentHandler)) + if (TryGetAgentHandler(request, response, out agentHandler)) + { + if (HandleAgentRequest(agentHandler, request, response)) { - if (HandleAgentRequest(agentHandler, request, response)) - { - return; - } + return; } - - //response.KeepAlive = true; - response.SendChunked = false; } + + //response.KeepAlive = true; + response.SendChunked = false; + IRequestHandler requestHandler; string path = request.RawUrl; @@ -368,8 +363,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. byte[] buffer = null; - if (response != null) - response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. + response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. if (requestHandler is IStreamedRequestHandler) @@ -425,12 +419,7 @@ namespace OpenSim.Framework.Servers.HttpServer //m_log.Warn("[HTTP]: " + requestBody); } - // If we're not responding, we dont' care about the reply - // - if (response == null) - HTTPRequestHandler.Handle(path, keysvals); - else - DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response); + DoHTTPGruntWork(HTTPRequestHandler.Handle(path, keysvals), response); return; } else @@ -445,11 +434,6 @@ namespace OpenSim.Framework.Servers.HttpServer } } - // The handler has run and we're not yet ready to respond, bail - // - if (response == null) - return; - request.InputStream.Close(); // HTTP IN support. The script engine taes it from here -- cgit v1.1 From dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 22 Sep 2009 06:19:02 +0100 Subject: 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. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 78 +++++++++++----------- .../Servers/HttpServer/PollServiceEventArgs.cs | 5 +- 2 files changed, 44 insertions(+), 39 deletions(-) (limited to 'OpenSim/Framework/Servers') 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 IHttpClientContext context = (IHttpClientContext)source; IHttpRequest request = args.Request; - PollServiceEventArgs psEvArgs; + if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) { -// OSHttpRequest req = new OSHttpRequest(context, request); - PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); -// req.Headers["X-PollServiceID"] = psreq.RequestID.ToString(); -// HandleRequest(req, null); + + if (psEvArgs.Request != null) + { + 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); + } + m_PollServiceManager.Enqueue(psreq); - //DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request))); } else { @@ -279,48 +313,16 @@ namespace OpenSim.Framework.Servers.HttpServer { OSHttpRequest req = new OSHttpRequest(context, request); OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); - //resp.KeepAlive = req.KeepAlive; - //m_log.Info("[Debug BASE HTTP SERVER]: Got Request"); - //HttpServerContextObj objstate= new HttpServerContextObj(req,resp); - //ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertIHttpClientContextToOSHttp), (object)objstate); HandleRequest(req, resp); } public void ConvertIHttpClientContextToOSHttp(object stateinfo) { HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; - //OSHttpRequest request = new OSHttpRequest(objstate.context,objstate.req); - //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req)); OSHttpRequest request = objstate.oreq; OSHttpResponse resp = objstate.oresp; - //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req)); - - /* - request.AcceptTypes = objstate.req.AcceptTypes; - request.ContentLength = (long)objstate.req.ContentLength; - request.Headers = objstate.req.Headers; - request.HttpMethod = objstate.req.Method; - request.InputStream = objstate.req.Body; - foreach (string str in request.Headers) - { - if (str.ToLower().Contains("content-type: ")) - { - request.ContentType = str.Substring(13, str.Length - 13); - break; - } - } - //request.KeepAlive = objstate.req. - foreach (HttpServer.HttpInput httpinput in objstate.req.QueryString) - { - request.QueryString.Add(httpinput.Name, httpinput[httpinput.Name]); - } - - //request.Query = objstate.req.//objstate.req.QueryString; - //foreach ( - //request.QueryString = objstate.req.QueryString; - */ HandleRequest(request,resp); } 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; using OpenMetaverse; namespace OpenSim.Framework.Servers.HttpServer { + public delegate void RequestMethod(UUID requestID, Hashtable request); public delegate bool HasEventsMethod(UUID requestID, UUID pId); public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); @@ -41,9 +42,11 @@ namespace OpenSim.Framework.Servers.HttpServer public HasEventsMethod HasEvents; public GetEventsMethod GetEvents; public NoEventsMethod NoEvents; + public RequestMethod Request; public UUID Id; - public PollServiceEventArgs(HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) + public PollServiceEventArgs(RequestMethod Request, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) { + Request = Request; HasEvents = pHasEvents; GetEvents = pGetEvents; NoEvents = pNoEvents; -- cgit v1.1 From 97c18caa766e2dd72b152b78827ef554f2054f8c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 22 Sep 2009 17:04:34 +0100 Subject: Thank you, Intari, for a patch that implements the missing pieces of Http-in and makes the host name for URL generation configurable. Applied with changes: llGetSimulatorHostname was not changed, because the change breaks existing behavior and carries a data exposure risk. That value needs to be configurable, the proposed fixed change is not acceptable. --- OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 7ed9e5c..9d512c6 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -44,9 +44,9 @@ namespace OpenSim.Framework.Servers.HttpServer public NoEventsMethod NoEvents; public RequestMethod Request; public UUID Id; - public PollServiceEventArgs(RequestMethod Request, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) + public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) { - Request = Request; + Request = pRequest; HasEvents = pHasEvents; GetEvents = pGetEvents; NoEvents = pNoEvents; -- cgit v1.1