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.
0.6.5-rc1
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

@ -303,6 +303,9 @@ namespace OpenSim.Framework.Servers
//m_log.Debug("[BASE HTTP SERVER]: Found Stream Handler"); //m_log.Debug("[BASE HTTP SERVER]: Found Stream Handler");
// Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
byte[] buffer; byte[] buffer;
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
if (requestHandler is IStreamedRequestHandler) if (requestHandler is IStreamedRequestHandler)
{ {
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@ -371,7 +374,7 @@ namespace OpenSim.Framework.Servers
} }
request.InputStream.Close(); request.InputStream.Close();
response.ContentType = requestHandler.ContentType;
if (!response.SendChunked) if (!response.SendChunked)
response.ContentLength64 = buffer.LongLength; response.ContentLength64 = buffer.LongLength;

View File

@ -38,6 +38,7 @@ using OpenSim.Data;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics; using OpenSim.Framework.Statistics;
using System.Net;
namespace OpenSim.Framework.Servers namespace OpenSim.Framework.Servers
{ {
@ -90,7 +91,14 @@ namespace OpenSim.Framework.Servers
// { // {
// asset.Data = ProcessOutgoingAssetData(asset.Data); // 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)); XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
@ -105,6 +113,7 @@ namespace OpenSim.Framework.Servers
Array.Resize<byte>(ref result, (int)ms.Length); Array.Resize<byte>(ref result, (int)ms.Length);
} }
}
else else
{ {
if (StatsManager.AssetStats != null) if (StatsManager.AssetStats != null)
@ -161,5 +170,47 @@ namespace OpenSim.Framework.Servers
return data; 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";
}
}
} }
} }

View File

@ -113,7 +113,15 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
AssetBase asset = new AssetBase(); AssetBase asset = new AssetBase();
if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) == BackendResponse.Success) if ((dataResponse = m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) == BackendResponse.Success)
{ {
XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); if (rawUrl.Length >= 4 && rawUrl[3] == "data")
{
httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.ContentType = Utils.SLAssetTypeToContentType(asset.Type);
buffer=asset.Data;
}
else
{
XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
MemoryStream ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
xs.Serialize(xw, asset); xs.Serialize(xw, asset);
@ -121,9 +129,10 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);
buffer = ms.GetBuffer(); buffer = ms.GetBuffer();
Array.Resize<byte>(ref buffer, (int) ms.Length); Array.Resize<byte>(ref buffer, (int)ms.Length);
ms.Close(); ms.Close();
httpResponse.StatusCode = (int) HttpStatusCode.OK; httpResponse.StatusCode = (int)HttpStatusCode.OK;
}
} }
else else
{ {

View File

@ -58,7 +58,9 @@ namespace OpenSim.Region.CoreModules.Framework.Services
m_scene = scene; m_scene = scene;
// This module is only on for standalones in hypergrid mode // This module is only on for standalones in hypergrid mode
enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
(config.Configs["Startup"].GetBoolean("hypergrid", true)||
config.Configs["MXP"].GetBoolean("Enabled", true));
} }
} }