fix CopyInventoryFromNotecard error handling

0.9.1.0-post-fixes
UbitUmarov 2018-11-29 20:21:25 +00:00
parent 2eee87fea3
commit 98b12278f0
1 changed files with 18 additions and 16 deletions

View File

@ -1312,7 +1312,7 @@ namespace OpenSim.Region.ClientStack.Linden
if(folder == null) if(folder == null)
break; break;
StringBuilder sb = LLSDxmlEncode.Start(256); StringBuilder sb = LLSDxmlEncode.Start();
LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddMap(sb);
LLSDxmlEncode.AddElem("folder_id", folder.ID, sb); LLSDxmlEncode.AddElem("folder_id", folder.ID, sb);
LLSDxmlEncode.AddElem("name", folder.Name, sb); LLSDxmlEncode.AddElem("name", folder.Name, sb);
@ -1324,9 +1324,7 @@ namespace OpenSim.Region.ClientStack.Linden
return resp; return resp;
} }
httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest; httpResponse.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
httpResponse.StatusDescription = "Error";
httpResponse.KeepAlive = false;
return ""; return "";
} }
@ -1376,21 +1374,25 @@ namespace OpenSim.Region.ClientStack.Linden
return LLSDHelpers.SerialiseLLSDReply(uploadResponse); return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
} }
private string CopyInventoryFromNotecardError(IOSHttpResponse response)
{
response.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
response.StatusDescription = "";
return "";
}
/// <summary> /// <summary>
/// Called by the CopyInventoryFromNotecard caps handler. /// Called by the CopyInventoryFromNotecard caps handler.
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="param"></param> /// <param name="param"></param>
public string CopyInventoryFromNotecard(string request, string path, string param, public string CopyInventoryFromNotecard(string request, string path, string param,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
Hashtable response = new Hashtable(); InventoryItemBase copyItem = null;
response["int_response_code"] = 404;
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["str_response_string"] = "";
try try
{ {
OSDMap content = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap content = (OSDMap)OSDParser.DeserializeLLSDXml(request);
@ -1408,14 +1410,11 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
// TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID); // TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID);
if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID)) if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID))
{ return CopyInventoryFromNotecardError(httpResponse);
return LLSDHelpers.SerialiseLLSDReply(response);
}
} }
} }
InventoryItemBase item = null; InventoryItemBase item = null;
InventoryItemBase copyItem = null;
IClientAPI client = null; IClientAPI client = null;
m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
@ -1440,10 +1439,13 @@ namespace OpenSim.Region.ClientStack.Linden
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString()); m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString());
copyItem = null;
} }
response["int_response_code"] = 200; if(copyItem == null)
return LLSDHelpers.SerialiseLLSDReply(response); return CopyInventoryFromNotecardError(httpResponse);
return "";
} }
public string GetObjectPhysicsData(string request, string path, public string GetObjectPhysicsData(string request, string path,