* Refactor: Remove redundant try/catch from asset request since this is now handled by the base http server
parent
acb0b06fed
commit
afb06c7b88
|
@ -62,58 +62,53 @@ namespace OpenSim.Grid.AssetServer
|
||||||
{
|
{
|
||||||
string param = GetParam(path);
|
string param = GetParam(path);
|
||||||
byte[] result = new byte[] {};
|
byte[] result = new byte[] {};
|
||||||
try
|
|
||||||
|
string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
if (p.Length > 0)
|
||||||
{
|
{
|
||||||
string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
|
LLUUID assetID = null;
|
||||||
|
|
||||||
if (p.Length > 0)
|
if (!LLUUID.TryParse(p[0], out assetID))
|
||||||
{
|
{
|
||||||
LLUUID assetID = null;
|
m_log.InfoFormat(
|
||||||
|
"[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!LLUUID.TryParse(p[0], out assetID))
|
if (StatsManager.AssetStats != null)
|
||||||
{
|
StatsManager.AssetStats.AddRequest();
|
||||||
m_log.InfoFormat(
|
|
||||||
"[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
AssetBase asset = m_assetProvider.FetchAsset(assetID);
|
||||||
|
if (asset != null)
|
||||||
|
{
|
||||||
|
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
|
||||||
|
xw.Formatting = Formatting.Indented;
|
||||||
|
xs.Serialize(xw, asset);
|
||||||
|
xw.Flush();
|
||||||
|
|
||||||
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
|
//StreamReader sr = new StreamReader(ms);
|
||||||
|
|
||||||
|
result = ms.GetBuffer();
|
||||||
|
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
|
||||||
|
assetID, asset.Name, result.Length);
|
||||||
|
|
||||||
|
Array.Resize<byte>(ref result, (int) ms.Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (StatsManager.AssetStats != null)
|
if (StatsManager.AssetStats != null)
|
||||||
StatsManager.AssetStats.AddRequest();
|
StatsManager.AssetStats.AddNotFoundRequest();
|
||||||
|
|
||||||
AssetBase asset = m_assetProvider.FetchAsset(assetID);
|
m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
|
||||||
if (asset != null)
|
|
||||||
{
|
|
||||||
XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
|
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
|
|
||||||
xw.Formatting = Formatting.Indented;
|
|
||||||
xs.Serialize(xw, asset);
|
|
||||||
xw.Flush();
|
|
||||||
|
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
|
||||||
//StreamReader sr = new StreamReader(ms);
|
|
||||||
|
|
||||||
result = ms.GetBuffer();
|
|
||||||
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
|
|
||||||
assetID, asset.Name, result.Length);
|
|
||||||
|
|
||||||
Array.Resize<byte>(ref result, (int) ms.Length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (StatsManager.AssetStats != null)
|
|
||||||
StatsManager.AssetStats.AddNotFoundRequest();
|
|
||||||
|
|
||||||
m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.Error(e.ToString());
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue