From f17b48e73e2fa58e536d96b31c94468e018c1272 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2018 14:22:52 +0100 Subject: some cleanup --- .../Handlers/GetTexture/GetTextureRobustHandler.cs | 56 ++++++++++------------ 1 file changed, 26 insertions(+), 30 deletions(-) (limited to 'OpenSim/Capabilities/Handlers/GetTexture') diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs index 0685c5e..a9b3d48 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs @@ -131,9 +131,7 @@ namespace OpenSim.Capabilities.Handlers /// False for "caller try another codec"; true otherwise private bool FetchTexture(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID textureID, string format) { - // m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); - AssetBase texture; - + // m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); if(!String.IsNullOrEmpty(m_RedirectURL)) { string textureUrl = m_RedirectURL + "?texture_id=" + textureID.ToString(); @@ -142,39 +140,37 @@ namespace OpenSim.Capabilities.Handlers httpResponse.RedirectLocation = textureUrl; return true; } - else // no redirect + + // Fetch, Misses or invalid return a 404 + AssetBase texture = m_assetService.Get(textureID.ToString()); + if (texture != null) { - texture = m_assetService.Get(textureID.ToString()); - if(texture != null) + if (texture.Type != (sbyte)AssetType.Texture) { - if(texture.Type != (sbyte)AssetType.Texture) - { - httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; - return true; - } - if(format == DefaultFormat) - { - WriteTextureData(httpRequest, httpResponse, texture, format); - return true; - } - else - { - AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID); - newTexture.Data = ConvertTextureData(texture, format); - if(newTexture.Data.Length == 0) - return false; // !!! Caller try another codec, please! - - newTexture.Flags = AssetFlags.Collectable; - newTexture.Temporary = true; - newTexture.Local = true; - WriteTextureData(httpRequest, httpResponse, newTexture, format); - return true; - } + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; + return true; } + if (format == DefaultFormat) + { + WriteTextureData(httpRequest, httpResponse, texture, format); + return true; + } + + // need to convert format + AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID); + newTexture.Data = ConvertTextureData(texture, format); + if (newTexture.Data.Length == 0) + return false; // !!! Caller try another codec, please! + + newTexture.Flags = AssetFlags.Collectable; + newTexture.Temporary = true; + newTexture.Local = true; + WriteTextureData(httpRequest, httpResponse, newTexture, format); + return true; } // not found - // m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); + // m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; return true; } -- cgit v1.1