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.
remotes/origin/0.6.7-post-fixes
Melanie 2009-09-22 06:19:02 +01:00
parent c5be401d46
commit dafe5bf05f
4 changed files with 46 additions and 41 deletions

View File

@ -198,7 +198,7 @@ namespace OpenSim.Framework.Console
string uri = "/ReadResponses/" + sessionID.ToString() + "/"; string uri = "/ReadResponses/" + sessionID.ToString() + "/";
m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll, m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll,
new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents,
sessionID)); sessionID));
XmlDocument xmldoc = new XmlDocument(); XmlDocument xmldoc = new XmlDocument();

View File

@ -256,17 +256,51 @@ namespace OpenSim.Framework.Servers.HttpServer
IHttpClientContext context = (IHttpClientContext)source; IHttpClientContext context = (IHttpClientContext)source;
IHttpRequest request = args.Request; IHttpRequest request = args.Request;
PollServiceEventArgs psEvArgs; PollServiceEventArgs psEvArgs;
if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs))
{ {
// OSHttpRequest req = new OSHttpRequest(context, request);
PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, 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); m_PollServiceManager.Enqueue(psreq);
//DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request)));
} }
else else
{ {
@ -279,48 +313,16 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
OSHttpRequest req = new OSHttpRequest(context, request); OSHttpRequest req = new OSHttpRequest(context, request);
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 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); HandleRequest(req, resp);
} }
public void ConvertIHttpClientContextToOSHttp(object stateinfo) public void ConvertIHttpClientContextToOSHttp(object stateinfo)
{ {
HttpServerContextObj objstate = (HttpServerContextObj)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; OSHttpRequest request = objstate.oreq;
OSHttpResponse resp = objstate.oresp; 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); HandleRequest(request,resp);
} }

View File

@ -30,6 +30,7 @@ using System.Collections;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer namespace OpenSim.Framework.Servers.HttpServer
{ {
public delegate void RequestMethod(UUID requestID, Hashtable request);
public delegate bool HasEventsMethod(UUID requestID, UUID pId); public delegate bool HasEventsMethod(UUID requestID, UUID pId);
public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request);
@ -41,9 +42,11 @@ namespace OpenSim.Framework.Servers.HttpServer
public HasEventsMethod HasEvents; public HasEventsMethod HasEvents;
public GetEventsMethod GetEvents; public GetEventsMethod GetEvents;
public NoEventsMethod NoEvents; public NoEventsMethod NoEvents;
public RequestMethod Request;
public UUID Id; 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; HasEvents = pHasEvents;
GetEvents = pGetEvents; GetEvents = pGetEvents;
NoEvents = pNoEvents; NoEvents = pNoEvents;

View File

@ -316,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
// This will persist this beyond the expiry of the caps handlers // This will persist this beyond the expiry of the caps handlers
MainServer.Instance.AddPollServiceHTTPHandler( MainServer.Instance.AddPollServiceHTTPHandler(
capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, agentID)); capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
Random rnd = new Random(Environment.TickCount); Random rnd = new Random(Environment.TickCount);
lock (m_ids) lock (m_ids)