From a845c1a893a203f1a9bc38dc754a6f94e4c02ea5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 7 May 2014 19:38:33 -0700 Subject: Finished implementing redirects in GetTexture. --- .../Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs') diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 7b3124a..4dfa847 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -56,12 +56,15 @@ namespace OpenSim.Capabilities.Handlers public const string DefaultFormat = "x-j2c"; // TODO: Change this to a config option - const string REDIRECT_URL = null; + private string m_RedirectURL = null; - public GetTextureHandler(string path, IAssetService assService, string name, string description) + public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL) : base("GET", path, name, description) { m_assetService = assService; + m_RedirectURL = redirectURL; + if (!m_RedirectURL.EndsWith("/")) + m_RedirectURL += "/"; } protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) @@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers if (format != DefaultFormat) fullID = fullID + "-" + format; - if (!String.IsNullOrEmpty(REDIRECT_URL)) + if (!String.IsNullOrEmpty(m_RedirectURL)) { // Only try to fetch locally cached textures. Misses are redirected texture = m_assetService.GetCached(fullID); @@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers } else { - string textureUrl = REDIRECT_URL + textureID.ToString(); + string textureUrl = m_RedirectURL + textureID.ToString(); m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); + httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; httpResponse.RedirectLocation = textureUrl; return true; } -- cgit v1.1