aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetServer
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-04-18 15:41:13 +0000
committerJustin Clarke Casey2008-04-18 15:41:13 +0000
commitafb06c7b88f4dab1a4cb0ba6b2002a19e40683c2 (patch)
tree43399eb0d436e9472d99bf05f5562e2a8e528a43 /OpenSim/Grid/AssetServer
parentMantis #851, 100% CPU on unhandlet HTTP event. Thanks cmickeyb. (diff)
downloadopensim-SC-afb06c7b88f4dab1a4cb0ba6b2002a19e40683c2.zip
opensim-SC-afb06c7b88f4dab1a4cb0ba6b2002a19e40683c2.tar.gz
opensim-SC-afb06c7b88f4dab1a4cb0ba6b2002a19e40683c2.tar.bz2
opensim-SC-afb06c7b88f4dab1a4cb0ba6b2002a19e40683c2.tar.xz
* Refactor: Remove redundant try/catch from asset request since this is now handled by the base http server
Diffstat (limited to 'OpenSim/Grid/AssetServer')
-rw-r--r--OpenSim/Grid/AssetServer/RestService.cs89
1 files changed, 42 insertions, 47 deletions
diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs
index a9856da..ae56a68 100644
--- a/OpenSim/Grid/AssetServer/RestService.cs
+++ b/OpenSim/Grid/AssetServer/RestService.cs
@@ -62,60 +62,55 @@ namespace OpenSim.Grid.AssetServer
62 { 62 {
63 string param = GetParam(path); 63 string param = GetParam(path);
64 byte[] result = new byte[] {}; 64 byte[] result = new byte[] {};
65 try
66 {
67 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
68 65
69 if (p.Length > 0) 66 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);
67
68 if (p.Length > 0)
69 {
70 LLUUID assetID = null;
71
72 if (!LLUUID.TryParse(p[0], out assetID))
73 {
74 m_log.InfoFormat(
75 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
76 return result;
77 }
78
79 if (StatsManager.AssetStats != null)
80 StatsManager.AssetStats.AddRequest();
81
82 AssetBase asset = m_assetProvider.FetchAsset(assetID);
83 if (asset != null)
70 { 84 {
71 LLUUID assetID = null; 85 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
86 MemoryStream ms = new MemoryStream();
87 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
88 xw.Formatting = Formatting.Indented;
89 xs.Serialize(xw, asset);
90 xw.Flush();
91
92 ms.Seek(0, SeekOrigin.Begin);
93 //StreamReader sr = new StreamReader(ms);
94
95 result = ms.GetBuffer();
72 96
73 if (!LLUUID.TryParse(p[0], out assetID)) 97 m_log.InfoFormat(
74 { 98 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
75 m_log.InfoFormat( 99 assetID, asset.Name, result.Length);
76 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 100
77 return result; 101 Array.Resize<byte>(ref result, (int) ms.Length);
78 } 102 }
79 103 else
104 {
80 if (StatsManager.AssetStats != null) 105 if (StatsManager.AssetStats != null)
81 StatsManager.AssetStats.AddRequest(); 106 StatsManager.AssetStats.AddNotFoundRequest();
82 107
83 AssetBase asset = m_assetProvider.FetchAsset(assetID); 108 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
84 if (asset != null)
85 {
86 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
87 MemoryStream ms = new MemoryStream();
88 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
89 xw.Formatting = Formatting.Indented;
90 xs.Serialize(xw, asset);
91 xw.Flush();
92
93 ms.Seek(0, SeekOrigin.Begin);
94 //StreamReader sr = new StreamReader(ms);
95
96 result = ms.GetBuffer();
97
98 m_log.InfoFormat(
99 "[REST]: GET:/asset found {0} with name {1}, size {2} bytes",
100 assetID, asset.Name, result.Length);
101
102 Array.Resize<byte>(ref result, (int) ms.Length);
103 }
104 else
105 {
106 if (StatsManager.AssetStats != null)
107 StatsManager.AssetStats.AddNotFoundRequest();
108
109 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
110 }
111 } 109 }
112 } 110 }
113 catch (Exception e) 111
114 { 112 return result;
115 m_log.Error(e.ToString()); 113 }
116 }
117 return result;
118 }
119 } 114 }
120 115
121 public class PostAssetStreamHandler : BaseStreamHandler 116 public class PostAssetStreamHandler : BaseStreamHandler