move EstateChangeInfo cap to simpleStreamHandler

master
UbitUmarov 2020-04-24 20:01:03 +01:00
parent bac6890391
commit 23961abf8a
1 changed files with 22 additions and 47 deletions

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net;
using System.Text; using System.Text;
using System.Reflection; using System.Reflection;
@ -130,57 +131,44 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
string capUrl = "/CAPS/" + UUID.Random() + "/"; string capUrl = "/CAPS/" + UUID.Random() + "/";
caps.RegisterHandler( caps.RegisterSimpleHandler("EstateChangeInfo",
"EstateChangeInfo", new SimpleStreamHandler("/CAPS/" + UUID.Random(), delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
new RestHTTPHandler( {
"POST", ProcessRequest(httpRequest, httpResponse, agentID, caps);
capUrl, }));
httpMethod => ProcessRequest(httpMethod, agentID, caps),
"EstateChangeInfo",
agentID.ToString())); ;
} }
public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap) public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUID AgentId, Caps cap)
{ {
Hashtable responsedata = new Hashtable(); if(request.HttpMethod != "POST")
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
ScenePresence avatar; ScenePresence avatar;
if (!m_scene.TryGetScenePresence(AgentId, out avatar) || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) if (!m_scene.TryGetScenePresence(AgentId, out avatar) || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
{ {
responsedata["int_response_code"] = 401; response.StatusCode = (int)HttpStatusCode.Unauthorized;
responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty; return;
responsedata["keepalive"] = false;
return responsedata;
} }
if (m_scene.RegionInfo == null if (m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null)
|| m_scene.RegionInfo.EstateSettings == null)
{ {
responsedata["int_response_code"] = 501; response.StatusCode = (int)HttpStatusCode.NotImplemented;
responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty; return;
responsedata["keepalive"] = false;
return responsedata;
} }
OSDMap r; OSDMap r;
try try
{ {
r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]); r = (OSDMap)OSDParser.Deserialize(request.InputStream);
} }
catch (Exception ex) catch (Exception ex)
{ {
m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString()); m_log.Error("[UPLOAD OBJECT ASSET MODULE]: Error deserializing message " + ex.ToString());
r = null; response.StatusCode = (int)HttpStatusCode.BadRequest;
} return;
if (r == null)
{
responsedata["int_response_code"] = 400; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
return responsedata;
} }
bool ok = true; bool ok = true;
@ -213,20 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden
ok = false; ok = false;
} }
if(ok) response.StatusCode = ok ? (int)HttpStatusCode.OK : (int)HttpStatusCode.BadRequest;
{
responsedata["int_response_code"] = 200;
responsedata["content_type"] = "text/plain";
responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
}
else
{
responsedata["int_response_code"] = 400; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = LLSDxmlEncode.LLSDEmpty;
}
return responsedata;
} }
} }
} }