[Opensim-dev] Accessing textures via HTTP [bayes]
Tommi Laukkanen
tommi.s.e.laukkanen at gmail.com
Mon Mar 16 15:24:06 UTC 2009
Reading the source code from OpenSimAssetFrontEndPlugin. Looks like
there is no handling yet for the binary data request url in the
proposal:
http://assets.virtualworld.com/c228d1cf-4b5d-4ba8-84f4-899a0796aa97/data
Could we add here handing for handing out the raw binary data:
public override byte[] Handle(string path, Stream request,
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
byte[] buffer = new byte[] {};
UUID assetID;
// Split the URL up to get the asset ID out
string[] rawUrl = httpRequest.Url.PathAndQuery.Split('/');
if (rawUrl.Length >= 3 && rawUrl[2].Length >= 36 &&
UUID.TryParse(rawUrl[2].Substring(0, 36), out assetID))
{
BackendResponse dataResponse;
AssetBase asset = new AssetBase();
if ((dataResponse =
m_server.StorageProvider.TryFetchDataMetadata(assetID, out asset)) ==
BackendResponse.Success)
{
XmlSerializer xs = new XmlSerializer(typeof
(AssetBase));
MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
xs.Serialize(xw, asset);
xw.Flush();
ms.Seek(0, SeekOrigin.Begin);
buffer = ms.GetBuffer();
Array.Resize<byte>(ref buffer, (int) ms.Length);
ms.Close();
httpResponse.StatusCode = (int) HttpStatusCode.OK;
}
else
{
m_log.WarnFormat("[OPENSIMASSETFRONTEND]:
Failed to fetch asset data or metadata for {0}: {1}", assetID,
dataResponse);
httpResponse.StatusCode = (int) HttpStatusCode.NotFound;
}
}
else
{
m_log.Warn("[OPENSIMASSETFRONTEND]: Unrecognized
OpenSim asset request: " + httpRequest.Url.PathAndQuery);
}
return buffer;
}
}
regards,
Tommi
More information about the Opensim-dev
mailing list