aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs46
1 files changed, 45 insertions, 1 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index b24336d..70c531c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -54,6 +54,16 @@ namespace OpenSim.Framework.Servers.HttpServer
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
56 56
57
58 /// <summary>
59 /// This is a pending websocket request before it got an sucessful upgrade response.
60 /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
61 /// start the connection and optionally provide an origin authentication method.
62 /// </summary>
63 /// <param name="servicepath"></param>
64 /// <param name="handler"></param>
65 public delegate void WebSocketRequestDelegate(string servicepath, WebSocketHttpServerHandler handler);
66
57 /// <summary> 67 /// <summary>
58 /// Gets or sets the debug level. 68 /// Gets or sets the debug level.
59 /// </summary> 69 /// </summary>
@@ -87,6 +97,9 @@ namespace OpenSim.Framework.Servers.HttpServer
87 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = 97 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
88 new Dictionary<string, PollServiceEventArgs>(); 98 new Dictionary<string, PollServiceEventArgs>();
89 99
100 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
101 new Dictionary<string, WebSocketRequestDelegate>();
102
90 protected uint m_port; 103 protected uint m_port;
91 protected uint m_sslport; 104 protected uint m_sslport;
92 protected bool m_ssl; 105 protected bool m_ssl;
@@ -170,6 +183,22 @@ namespace OpenSim.Framework.Servers.HttpServer
170 } 183 }
171 } 184 }
172 185
186 public void AddWebSocketHandler(string servicepath, WebSocketRequestDelegate handler)
187 {
188 lock (m_WebSocketHandlers)
189 {
190 if (!m_WebSocketHandlers.ContainsKey(servicepath))
191 m_WebSocketHandlers.Add(servicepath, handler);
192 }
193 }
194
195 public void RemoveWebSocketHandler(string servicepath)
196 {
197 lock (m_WebSocketHandlers)
198 if (m_WebSocketHandlers.ContainsKey(servicepath))
199 m_WebSocketHandlers.Remove(servicepath);
200 }
201
173 public List<string> GetStreamHandlerKeys() 202 public List<string> GetStreamHandlerKeys()
174 { 203 {
175 lock (m_streamHandlers) 204 lock (m_streamHandlers)
@@ -409,9 +438,24 @@ namespace OpenSim.Framework.Servers.HttpServer
409 438
410 public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) 439 public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
411 { 440 {
441
412 OSHttpRequest req = new OSHttpRequest(context, request); 442 OSHttpRequest req = new OSHttpRequest(context, request);
443 WebSocketRequestDelegate dWebSocketRequestDelegate = null;
444 lock (m_WebSocketHandlers)
445 {
446 if (m_WebSocketHandlers.ContainsKey(req.RawUrl))
447 dWebSocketRequestDelegate = m_WebSocketHandlers[req.RawUrl];
448 }
449 if (dWebSocketRequestDelegate != null)
450 {
451 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192));
452 return;
453 }
454
413 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 455 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
456
414 HandleRequest(req, resp); 457 HandleRequest(req, resp);
458
415 459
416 // !!!HACK ALERT!!! 460 // !!!HACK ALERT!!!
417 // There seems to be a bug in the underlying http code that makes subsequent requests 461 // There seems to be a bug in the underlying http code that makes subsequent requests
@@ -500,7 +544,7 @@ namespace OpenSim.Framework.Servers.HttpServer
500 LogIncomingToStreamHandler(request, requestHandler); 544 LogIncomingToStreamHandler(request, requestHandler);
501 545
502 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 546 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
503 547
504 if (requestHandler is IStreamedRequestHandler) 548 if (requestHandler is IStreamedRequestHandler)
505 { 549 {
506 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 550 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;