aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs83
1 files changed, 67 insertions, 16 deletions
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
index d7fb72b..33b9e6e 100644
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
@@ -38,6 +38,7 @@ using OpenSim.Data;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Statistics; 40using OpenSim.Framework.Statistics;
41using System.Net;
41 42
42namespace OpenSim.Framework.Servers 43namespace OpenSim.Framework.Servers
43{ 44{
@@ -90,20 +91,28 @@ namespace OpenSim.Framework.Servers
90// { 91// {
91// asset.Data = ProcessOutgoingAssetData(asset.Data); 92// asset.Data = ProcessOutgoingAssetData(asset.Data);
92// } 93// }
93 94 if (p.Length > 1 && p[1] == "data")
94 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 95 {
95 MemoryStream ms = new MemoryStream(); 96 httpResponse.StatusCode = (int)HttpStatusCode.OK;
96 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 97 httpResponse.ContentType = SLAssetTypeToContentType(asset.Type);
97 xw.Formatting = Formatting.Indented; 98 result = asset.Data;
98 xs.Serialize(xw, asset); 99 }
99 xw.Flush(); 100 else
100 101 {
101 ms.Seek(0, SeekOrigin.Begin); 102 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
102 //StreamReader sr = new StreamReader(ms); 103 MemoryStream ms = new MemoryStream();
103 104 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
104 result = ms.GetBuffer(); 105 xw.Formatting = Formatting.Indented;
105 106 xs.Serialize(xw, asset);
106 Array.Resize<byte>(ref result, (int)ms.Length); 107 xw.Flush();
108
109 ms.Seek(0, SeekOrigin.Begin);
110 //StreamReader sr = new StreamReader(ms);
111
112 result = ms.GetBuffer();
113
114 Array.Resize<byte>(ref result, (int)ms.Length);
115 }
107 } 116 }
108 else 117 else
109 { 118 {
@@ -160,6 +169,48 @@ namespace OpenSim.Framework.Servers
160 169
161 return data; 170 return data;
162 } 171 }
163 172
173 private string SLAssetTypeToContentType(int assetType)
174 {
175 switch (assetType)
176 {
177 case 0:
178 return "image/jp2";
179 case 1:
180 return "application/ogg";
181 case 2:
182 return "application/x-metaverse-callingcard";
183 case 3:
184 return "application/x-metaverse-landmark";
185 case 5:
186 return "application/x-metaverse-clothing";
187 case 6:
188 return "application/x-metaverse-primitive";
189 case 7:
190 return "application/x-metaverse-notecard";
191 case 8:
192 return "application/x-metaverse-folder";
193 case 10:
194 return "application/x-metaverse-lsl";
195 case 11:
196 return "application/x-metaverse-lso";
197 case 12:
198 return "image/tga";
199 case 13:
200 return "application/x-metaverse-bodypart";
201 case 17:
202 return "audio/x-wav";
203 case 19:
204 return "image/jpeg";
205 case 20:
206 return "application/x-metaverse-animation";
207 case 21:
208 return "application/x-metaverse-gesture";
209 case 22:
210 return "application/x-metaverse-simstate";
211 default:
212 return "application/octet-stream";
213 }
214 }
164 } 215 }
165} \ No newline at end of file 216}