mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
Merge branch 'master' into careminster
Conflicts: bin/HttpServer_OpenSim.dll
This commit is contained in:
@@ -54,6 +54,16 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is a pending websocket request before it got an sucessful upgrade response.
|
||||
/// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
|
||||
/// start the connection and optionally provide an origin authentication method.
|
||||
/// </summary>
|
||||
/// <param name="servicepath"></param>
|
||||
/// <param name="handler"></param>
|
||||
public delegate void WebSocketRequestDelegate(string servicepath, WebSocketHttpServerHandler handler);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the debug level.
|
||||
/// </summary>
|
||||
@@ -87,6 +97,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
|
||||
new Dictionary<string, PollServiceEventArgs>();
|
||||
|
||||
protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
|
||||
new Dictionary<string, WebSocketRequestDelegate>();
|
||||
|
||||
protected uint m_port;
|
||||
protected uint m_sslport;
|
||||
protected bool m_ssl;
|
||||
@@ -170,6 +183,22 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
public void AddWebSocketHandler(string servicepath, WebSocketRequestDelegate handler)
|
||||
{
|
||||
lock (m_WebSocketHandlers)
|
||||
{
|
||||
if (!m_WebSocketHandlers.ContainsKey(servicepath))
|
||||
m_WebSocketHandlers.Add(servicepath, handler);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveWebSocketHandler(string servicepath)
|
||||
{
|
||||
lock (m_WebSocketHandlers)
|
||||
if (m_WebSocketHandlers.ContainsKey(servicepath))
|
||||
m_WebSocketHandlers.Remove(servicepath);
|
||||
}
|
||||
|
||||
public List<string> GetStreamHandlerKeys()
|
||||
{
|
||||
lock (m_streamHandlers)
|
||||
@@ -410,9 +439,24 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
|
||||
public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
|
||||
{
|
||||
|
||||
OSHttpRequest req = new OSHttpRequest(context, request);
|
||||
WebSocketRequestDelegate dWebSocketRequestDelegate = null;
|
||||
lock (m_WebSocketHandlers)
|
||||
{
|
||||
if (m_WebSocketHandlers.ContainsKey(req.RawUrl))
|
||||
dWebSocketRequestDelegate = m_WebSocketHandlers[req.RawUrl];
|
||||
}
|
||||
if (dWebSocketRequestDelegate != null)
|
||||
{
|
||||
dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192));
|
||||
return;
|
||||
}
|
||||
|
||||
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
|
||||
|
||||
HandleRequest(req, resp);
|
||||
|
||||
|
||||
// !!!HACK ALERT!!!
|
||||
// There seems to be a bug in the underlying http code that makes subsequent requests
|
||||
@@ -501,7 +545,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
LogIncomingToStreamHandler(request, requestHandler);
|
||||
|
||||
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
|
||||
|
||||
|
||||
if (requestHandler is IStreamedRequestHandler)
|
||||
{
|
||||
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
|
||||
|
||||
Reference in New Issue
Block a user