move a few more caps to simpleStreamHandler

master
UbitUmarov 2020-04-24 16:09:23 +01:00
parent 3d09ff57f0
commit 84cd4b4808
1 changed files with 45 additions and 29 deletions

View File

@ -285,11 +285,10 @@ namespace OpenSim.Region.ClientStack.Linden
new SimpleStreamHandler(GetNewCapPath(), HomeLocation)); new SimpleStreamHandler(GetNewCapPath(), HomeLocation));
} }
if(m_AllowCapGroupMemberData) if (m_AllowCapGroupMemberData)
{ {
IRequestHandler GroupMemberDataHandler = new RestStreamHandler( m_HostCapsObj.RegisterSimpleHandler("GroupMemberData",
"POST", GetNewCapPath(), GroupMemberData, "GroupMemberData", null); new SimpleStreamHandler(GetNewCapPath(), GroupMemberData));
m_HostCapsObj.RegisterHandler("GroupMemberData", GroupMemberDataHandler);
} }
@ -345,9 +344,8 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
if (m_UserManager != null) if (m_UserManager != null)
{ {
IRequestHandler GetDisplayNamesHandler = new RestStreamHandler( m_HostCapsObj.RegisterSimpleHandler("GetDisplayNames",
"GET", GetNewCapPath(), GetDisplayNames, "GetDisplayNames", null); new SimpleStreamHandler(GetNewCapPath() +"/", GetDisplayNames));
m_HostCapsObj.RegisterHandler("GetDisplayNames", GetDisplayNamesHandler);
} }
} }
catch (Exception e) catch (Exception e)
@ -2005,9 +2003,14 @@ namespace OpenSim.Region.ClientStack.Linden
return -(x.Members.CompareTo(y.Members)); return -(x.Members.CompareTo(y.Members));
} }
public string GroupMemberData(string request, string path, string param, IOSHttpRequest httpRequest, public void GroupMemberData(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
IOSHttpResponse httpResponse)
{ {
if (httpRequest.HttpMethod != "POST")
{
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
OSDMap resp = new OSDMap(); OSDMap resp = new OSDMap();
string response; string response;
@ -2033,11 +2036,22 @@ namespace OpenSim.Region.ClientStack.Linden
client = sp.ControllingClient; client = sp.ControllingClient;
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap req;
if(!req.ContainsKey("group_id")) try
{
req = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
}
catch
{
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
OSD tmp;
if(!req.TryGetValue("group_id", out tmp) || !(tmp is OSDUUID))
break; break;
groupID = req["group_id"].AsUUID(); groupID = tmp.AsUUID();
if(groupID == UUID.Zero) if(groupID == UUID.Zero)
break; break;
@ -2121,34 +2135,33 @@ namespace OpenSim.Region.ClientStack.Linden
resp["members"] = new OSDMap(); resp["members"] = new OSDMap();
} }
response = OSDParser.SerializeLLSDXmlString(resp); httpResponse.RawBuffer = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(resp));
return response; httpResponse.StatusCode = (int)HttpStatusCode.OK;
} }
public string GetDisplayNames(string request, string path, public void GetDisplayNames(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse)
{ {
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.Gone; if (httpRequest.HttpMethod != "GET")
httpResponse.ContentType = "text/plain"; {
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
ScenePresence sp = m_Scene.GetScenePresence(m_AgentID); ScenePresence sp = m_Scene.GetScenePresence(m_AgentID);
if(sp == null || sp.IsDeleted) if(sp == null || sp.IsDeleted)
return ""; {
httpResponse.StatusCode = (int)HttpStatusCode.Gone;
return;
}
if(sp.IsInTransit && !sp.IsInLocalTransit) if(sp.IsInTransit && !sp.IsInLocalTransit)
{ {
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.ServiceUnavailable; httpResponse.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
httpResponse.AddHeader("Retry-After","30"); httpResponse.AddHeader("Retry-After","30");
return ""; return;
} }
// Full content request // Full content request
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; NameValueCollection query = httpRequest.QueryString;
//httpResponse.ContentLength = ??;
httpResponse.ContentType = "application/llsd+xml";
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
string[] ids = query.GetValues("ids"); string[] ids = query.GetValues("ids");
Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids, m_scopeID); Dictionary<UUID,string> names = m_UserManager.GetUsersNames(ids, m_scopeID);
@ -2195,7 +2208,10 @@ namespace OpenSim.Region.ClientStack.Linden
} }
LLSDxmlEncode.AddEndMap(lsl); LLSDxmlEncode.AddEndMap(lsl);
return LLSDxmlEncode.End(lsl);;
httpResponse.RawBuffer = Encoding.UTF8.GetBytes(LLSDxmlEncode.End(lsl));
httpResponse.ContentType = "application/llsd+xml";
httpResponse.StatusCode = (int)HttpStatusCode.OK;
} }
} }