recover LLSD login handler
parent
6ffb5bcf23
commit
9d08f8307e
|
@ -610,22 +610,36 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
string path = request.UriPath;
|
string path = request.UriPath;
|
||||||
if (path == "/")
|
if (path == "/")
|
||||||
{
|
{
|
||||||
if (request.ContentType == "application/json-rpc")
|
response.StatusCode =(int)HttpStatusCode.NotFound; // falback
|
||||||
|
switch (request.ContentType)
|
||||||
|
{
|
||||||
|
case "application/json-rpc":
|
||||||
{
|
{
|
||||||
if (DebugLevel >= 3)
|
if (DebugLevel >= 3)
|
||||||
LogIncomingToContentTypeHandler(request);
|
LogIncomingToContentTypeHandler(request);
|
||||||
|
|
||||||
HandleJsonRpcRequests(request, response);
|
HandleJsonRpcRequests(request, response);
|
||||||
requestEndTick = Environment.TickCount;
|
break;
|
||||||
response.Send();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "application/llsd+xml":
|
||||||
|
{
|
||||||
|
HandleLLSDLogin(request, response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: // not sure about xmlrpc content type coerence at this point
|
||||||
|
{
|
||||||
if (DebugLevel >= 3)
|
if (DebugLevel >= 3)
|
||||||
LogIncomingToXmlRpcHandler(request);
|
LogIncomingToXmlRpcHandler(request);
|
||||||
|
|
||||||
// generic login request.
|
|
||||||
HandleXmlRpcRequests(request, response);
|
HandleXmlRpcRequests(request, response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.InputStream != null && request.InputStream.CanRead)
|
||||||
|
request.InputStream.Dispose();
|
||||||
|
|
||||||
requestEndTick = Environment.TickCount;
|
requestEndTick = Environment.TickCount;
|
||||||
response.Send();
|
response.Send();
|
||||||
return;
|
return;
|
||||||
|
@ -1209,8 +1223,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
// Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
|
// Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
|
||||||
xmlRpcResponse.SetFault(-32603, errorMessage);
|
xmlRpcResponse.SetFault(-32603, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
response.AddHeader("Access-Control-Allow-Origin", "*");
|
response.AddHeader("Access-Control-Allow-Origin", "*");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1326,67 +1338,68 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
response.StatusCode = (int)HttpStatusCode.OK;
|
response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleLLSDLogin(OSHttpRequest request, OSHttpResponse response)
|
||||||
|
{
|
||||||
|
if(m_defaultLlsdHandler == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
OSD llsdRequest;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
llsdRequest = OSDParser.DeserializeLLSDXml(request.InputStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(llsdRequest == null || !(llsdRequest is OSDMap))
|
||||||
|
return;
|
||||||
|
|
||||||
|
OSD llsdResponse = m_defaultLlsdHandler(llsdRequest, request.RemoteIPEndPoint);
|
||||||
|
if(llsdResponse != null)
|
||||||
|
{
|
||||||
|
response.ContentType = "application/llsd+xml";
|
||||||
|
response.RawBuffer = OSDParser.SerializeLLSDXmlBytes(llsdResponse);
|
||||||
|
response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response)
|
private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response)
|
||||||
{
|
{
|
||||||
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
|
//m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
|
||||||
bool notfound = false;
|
bool notfound = false;
|
||||||
string requestBody;
|
|
||||||
using(StreamReader reader = new StreamReader(request.InputStream, Encoding.UTF8))
|
|
||||||
requestBody= reader.ReadToEnd();
|
|
||||||
|
|
||||||
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
|
//m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
|
||||||
|
|
||||||
OSD llsdRequest = null;
|
OSD llsdRequest = null;
|
||||||
OSD llsdResponse = null;
|
OSD llsdResponse = null;
|
||||||
|
|
||||||
bool LegacyLLSDLoginLibOMV = (requestBody.Contains("passwd") && requestBody.Contains("mac") && requestBody.Contains("viewer_digest"));
|
|
||||||
|
|
||||||
if (requestBody.Length == 0)
|
|
||||||
// Get Request
|
|
||||||
{
|
|
||||||
requestBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><llsd><map><key>request</key><string>get</string></map></llsd>";
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
llsdRequest = OSDParser.Deserialize(requestBody);
|
llsdRequest = OSDParser.Deserialize(request.InputStream);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
|
m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llsdRequest != null)// && m_defaultLlsdHandler != null)
|
if (llsdRequest != null)
|
||||||
{
|
{
|
||||||
if (!LegacyLLSDLoginLibOMV && TryGetLLSDHandler(request.RawUrl, out LLSDMethod llsdhandler))
|
if (TryGetLLSDHandler(request.RawUrl, out LLSDMethod llsdhandler))
|
||||||
{
|
{
|
||||||
// we found a registered llsd handler to service this request
|
// we found a registered llsd handler to service this request
|
||||||
llsdResponse = llsdhandler(request.RawUrl, llsdRequest, request.RemoteIPEndPoint.ToString());
|
llsdResponse = llsdhandler(request.RawUrl, llsdRequest, request.RemoteIPEndPoint.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// we didn't find a registered llsd handler to service this request
|
|
||||||
// check if we have a default llsd handler
|
|
||||||
|
|
||||||
if (m_defaultLlsdHandler != null)
|
|
||||||
{
|
|
||||||
llsdResponse = m_defaultLlsdHandler(llsdRequest, request.RemoteIPEndPoint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Oops, no handler for this.. give em the failed message
|
|
||||||
notfound = true;
|
notfound = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
notfound = true;
|
notfound = true;
|
||||||
}
|
|
||||||
|
|
||||||
if(notfound)
|
if(notfound)
|
||||||
{
|
{
|
||||||
response.StatusCode = (int)HttpStatusCode.NotFound;
|
response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
response.StatusDescription = "Not found";
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1395,9 +1408,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
if (llsdResponse.ToString() == "shutdown404!")
|
if (llsdResponse.ToString() == "shutdown404!")
|
||||||
{
|
{
|
||||||
response.ContentType = "text/plain";
|
response.ContentType = "text/plain";
|
||||||
response.StatusCode = 404;
|
response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
response.StatusDescription = "Not Found";
|
|
||||||
buffer = Encoding.UTF8.GetBytes("Not found");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1405,6 +1416,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
buffer = BuildLLSDResponse(request, response, llsdResponse);
|
buffer = BuildLLSDResponse(request, response, llsdResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
response.ContentLength64 = buffer.Length;
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentEncoding = Encoding.UTF8;
|
response.ContentEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
@ -1485,13 +1497,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extra kicker to remove the default XMLRPC login case.. just in case..
|
|
||||||
if (path != "/" && bestMatch == "/" && searchquery != "/")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (path == "/")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(bestMatch))
|
if (String.IsNullOrEmpty(bestMatch))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1536,10 +1541,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extra kicker to remove the default XMLRPC login case.. just in case..
|
|
||||||
if (path == "/")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(bestMatch))
|
if (String.IsNullOrEmpty(bestMatch))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1687,28 +1688,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
keysvals.Add("requestvars", requestVars);
|
keysvals.Add("requestvars", requestVars);
|
||||||
// keysvals.Add("form", request.Form);
|
// keysvals.Add("form", request.Form);
|
||||||
|
|
||||||
if (keysvals.Contains("method"))
|
|
||||||
{
|
|
||||||
// m_log.Debug("[BASE HTTP SERVER]: Contains Method");
|
|
||||||
string method = (string) keysvals["method"];
|
|
||||||
// m_log.Debug("[BASE HTTP SERVER]: " + requestBody);
|
|
||||||
GenericHTTPMethod requestprocessor;
|
|
||||||
bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
|
|
||||||
if (foundHandler)
|
|
||||||
{
|
|
||||||
Hashtable responsedata1 = requestprocessor(keysvals);
|
|
||||||
buffer = DoHTTPGruntWork(responsedata1,response);
|
|
||||||
|
|
||||||
//SendHTML500(response);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found");
|
|
||||||
buffer = SendHTML404(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GenericHTTPMethod requestprocessor;
|
GenericHTTPMethod requestprocessor;
|
||||||
bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor);
|
bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor);
|
||||||
if (foundHandler)
|
if (foundHandler)
|
||||||
|
@ -1723,7 +1702,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
|
// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
|
||||||
buffer = SendHTML404(response);
|
buffer = SendHTML404(response);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue