From a5b719e1610ad660c1b943f4d341677b5f30305b Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 30 Jan 2008 18:33:44 +0000 Subject: * Deal with asset requests with malformed guids to the asset server in more user-friendly way than throwing an Exception * Compact status messages to reduce verbosity and be more informative --- OpenSim/Grid/AssetServer/RestService.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 6e4ae8f..ab51b20 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs @@ -57,7 +57,6 @@ namespace OpenSim.Grid.AssetServer public override byte[] Handle(string path, Stream request) { - MainLog.Instance.Verbose("REST", "In Handle"); string param = GetParam(path); byte[] result = new byte[] {}; try @@ -66,16 +65,19 @@ namespace OpenSim.Grid.AssetServer if (p.Length > 0) { - LLUUID assetID = LLUUID.Parse(p[0]); + LLUUID assetID = null; + + if (!LLUUID.TryParse(p[0], out assetID)) + { + MainLog.Instance.Verbose("REST", "GET:/asset ignoring malformed UUID {0}", p[0]); + return result; + } - MainLog.Instance.Verbose("REST", "GET:/asset fetch param={0} UUID={1}", param, assetID); m_stats.AddRequest(); AssetBase asset = m_assetProvider.FetchAsset(assetID); if (asset != null) { - MainLog.Instance.Verbose("REST", "GET:/asset found {0}, {1}", assetID, asset.Name); - XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); MemoryStream ms = new MemoryStream(); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); @@ -87,7 +89,12 @@ namespace OpenSim.Grid.AssetServer //StreamReader sr = new StreamReader(ms); result = ms.GetBuffer(); - MainLog.Instance.Verbose("REST", "Buffer: {0}", result); + + MainLog.Instance.Verbose( + "REST", + "GET:/asset found {0} with name {1}, size {2} bytes", + assetID, asset.Name, result.Length); + Array.Resize(ref result, (int) ms.Length); } else -- cgit v1.1