aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs7
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs83
2 files changed, 72 insertions, 18 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index fc2d36a..121b8a8 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -303,6 +303,9 @@ namespace OpenSim.Framework.Servers
303 //m_log.Debug("[BASE HTTP SERVER]: Found Stream Handler"); 303 //m_log.Debug("[BASE HTTP SERVER]: Found Stream Handler");
304 // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. 304 // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
305 byte[] buffer; 305 byte[] buffer;
306
307 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
308
306 if (requestHandler is IStreamedRequestHandler) 309 if (requestHandler is IStreamedRequestHandler)
307 { 310 {
308 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 311 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@@ -371,7 +374,7 @@ namespace OpenSim.Framework.Servers
371 } 374 }
372 375
373 request.InputStream.Close(); 376 request.InputStream.Close();
374 response.ContentType = requestHandler.ContentType; 377
375 if (!response.SendChunked) 378 if (!response.SendChunked)
376 response.ContentLength64 = buffer.LongLength; 379 response.ContentLength64 = buffer.LongLength;
377 380
@@ -1620,4 +1623,4 @@ namespace OpenSim.Framework.Servers
1620 return; 1623 return;
1621 } 1624 }
1622 } 1625 }
1623} \ No newline at end of file 1626}
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}