aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs17
1 files changed, 11 insertions, 6 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index b497fde..828e943 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -56,15 +56,18 @@ namespace OpenSim.Capabilities.Handlers
56 public const string DefaultFormat = "x-j2c"; 56 public const string DefaultFormat = "x-j2c";
57 57
58 // TODO: Change this to a config option 58 // TODO: Change this to a config option
59 const string REDIRECT_URL = null; 59 private string m_RedirectURL = null;
60 60
61 public GetTextureHandler(string path, IAssetService assService, string name, string description) 61 public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL)
62 : base("GET", path, name, description) 62 : base("GET", path, name, description)
63 { 63 {
64 m_assetService = assService; 64 m_assetService = assService;
65 m_RedirectURL = redirectURL;
66 if (m_RedirectURL != null && !m_RedirectURL.EndsWith("/"))
67 m_RedirectURL += "/";
65 } 68 }
66 69
67 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 70 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
68 { 71 {
69 // Try to parse the texture ID from the request URL 72 // Try to parse the texture ID from the request URL
70 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); 73 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
@@ -85,7 +88,7 @@ namespace OpenSim.Capabilities.Handlers
85// m_log.DebugFormat("[GETTEXTURE]: Received request for texture id {0}", textureID); 88// m_log.DebugFormat("[GETTEXTURE]: Received request for texture id {0}", textureID);
86 89
87 string[] formats; 90 string[] formats;
88 if (format != null && format != string.Empty) 91 if (!string.IsNullOrEmpty(format))
89 { 92 {
90 formats = new string[1] { format.ToLower() }; 93 formats = new string[1] { format.ToLower() };
91 } 94 }
@@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers
134 if (format != DefaultFormat) 137 if (format != DefaultFormat)
135 fullID = fullID + "-" + format; 138 fullID = fullID + "-" + format;
136 139
137 if (!String.IsNullOrEmpty(REDIRECT_URL)) 140 if (!String.IsNullOrEmpty(m_RedirectURL))
138 { 141 {
139 // Only try to fetch locally cached textures. Misses are redirected 142 // Only try to fetch locally cached textures. Misses are redirected
140 texture = m_assetService.GetCached(fullID); 143 texture = m_assetService.GetCached(fullID);
@@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers
150 } 153 }
151 else 154 else
152 { 155 {
153 string textureUrl = REDIRECT_URL + textureID.ToString(); 156 string textureUrl = m_RedirectURL + "?texture_id="+ textureID.ToString();
154 m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); 157 m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
158 httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently;
155 httpResponse.RedirectLocation = textureUrl; 159 httpResponse.RedirectLocation = textureUrl;
156 return true; 160 return true;
157 } 161 }
@@ -189,6 +193,7 @@ namespace OpenSim.Capabilities.Handlers
189 193
190 newTexture.Flags = AssetFlags.Collectable; 194 newTexture.Flags = AssetFlags.Collectable;
191 newTexture.Temporary = true; 195 newTexture.Temporary = true;
196 newTexture.Local = true;
192 m_assetService.Store(newTexture); 197 m_assetService.Store(newTexture);
193 WriteTextureData(httpRequest, httpResponse, newTexture, format); 198 WriteTextureData(httpRequest, httpResponse, newTexture, format);
194 return true; 199 return true;