aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
diff options
context:
space:
mode:
authorMelanie2009-09-22 06:19:02 +0100
committerMelanie2009-09-22 06:19:02 +0100
commitdafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37 (patch)
tree914b665eb98aea2fa218cf670a1c591614fe8542 /OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
parentRemove support for executing a handler on poll. It caused other issues (diff)
downloadopensim-SC-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.zip
opensim-SC-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.tar.gz
opensim-SC-dafe5bf05f6d85d4140a0b733f0fbf9a5c43cf37.tar.bz2
opensim-SC-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/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs78
1 files changed, 40 insertions, 38 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