Thank you kindly, TLaukkan for a patch that:

Added support for loading bare asset binaries (as opposed to 
xml encoded asset base) to both sandbox asset service and cable beach.
* Added support for enabling region asset service when mxp is enabled.
* Moved base http server content type defaulting before invocation of 
request handle method to allow for variable content type in the response.
This commit is contained in:
Charles Krinke
2009-04-21 19:42:36 +00:00
parent 48720ea7a2
commit 27c8cc5b1f
4 changed files with 91 additions and 26 deletions

View File

@@ -38,6 +38,7 @@ using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using System.Net;
namespace OpenSim.Framework.Servers
{
@@ -90,20 +91,28 @@ namespace OpenSim.Framework.Servers
// {
// asset.Data = ProcessOutgoingAssetData(asset.Data);
// }
if (p.Length > 1 && p[1] == "data")
{
httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.ContentType = SLAssetTypeToContentType(asset.Type);
result = asset.Data;
}
else
{
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();
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);
ms.Seek(0, SeekOrigin.Begin);
//StreamReader sr = new StreamReader(ms);
result = ms.GetBuffer();
result = ms.GetBuffer();
Array.Resize<byte>(ref result, (int)ms.Length);
Array.Resize<byte>(ref result, (int)ms.Length);
}
}
else
{
@@ -160,6 +169,48 @@ namespace OpenSim.Framework.Servers
return data;
}
private string SLAssetTypeToContentType(int assetType)
{
switch (assetType)
{
case 0:
return "image/jp2";
case 1:
return "application/ogg";
case 2:
return "application/x-metaverse-callingcard";
case 3:
return "application/x-metaverse-landmark";
case 5:
return "application/x-metaverse-clothing";
case 6:
return "application/x-metaverse-primitive";
case 7:
return "application/x-metaverse-notecard";
case 8:
return "application/x-metaverse-folder";
case 10:
return "application/x-metaverse-lsl";
case 11:
return "application/x-metaverse-lso";
case 12:
return "image/tga";
case 13:
return "application/x-metaverse-bodypart";
case 17:
return "audio/x-wav";
case 19:
return "image/jpeg";
case 20:
return "application/x-metaverse-animation";
case 21:
return "application/x-metaverse-gesture";
case 22:
return "application/x-metaverse-simstate";
default:
return "application/octet-stream";
}
}
}
}
}