[Opensim-dev] Accessing textures via HTTP [bayes]

Mike Mazur mmazur at gmail.com
Mon Mar 16 23:40:16 UTC 2009


Hi,

On Mon, 16 Mar 2009 17:24:06 +0200
Tommi Laukkanen <tommi.s.e.laukkanen at gmail.com> wrote:

> 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:

Sure. Please create a bug with your patch and I'll take a look.
Unfortunately I'm busy with other things at the moment and won't be
able to look into this myself.

> public override byte[] Handle(string path, Stream request,
> OSHttpRequest httpRequest, OSHttpResponse httpResponse)
>             {
> 
> --- 8< ---
> 
>                     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;

You do realize that this code will send the serialized AssetBase class
(like the AssetServer currently does) and not just the binary data. For
that, you want to send asset.Data only.

You may also want to inspect the asset type to have the handler return
the appropriate (proposed) content-type[1].

HTH,
Mike


[1]
http://opensimulator.org/wiki/AssetServerProposal/ClientDocs#Content-Types



More information about the Opensim-dev mailing list