aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-05 18:35:03 +0000
committerJustin Clark-Casey (justincc)2011-12-05 18:35:03 +0000
commit37889eb3fa8e172fb8c1b73a5c5443fc7bf4e5a3 (patch)
treeb0ffb93ac3e16db44bc86fb38e4b8c1123586f0c /OpenSim/Capabilities/Handlers
parentHG: Added HEAD method to Helo service. This is the preferred method, but its ... (diff)
downloadopensim-SC_OLD-37889eb3fa8e172fb8c1b73a5c5443fc7bf4e5a3.zip
opensim-SC_OLD-37889eb3fa8e172fb8c1b73a5c5443fc7bf4e5a3.tar.gz
opensim-SC_OLD-37889eb3fa8e172fb8c1b73a5c5443fc7bf4e5a3.tar.bz2
opensim-SC_OLD-37889eb3fa8e172fb8c1b73a5c5443fc7bf4e5a3.tar.xz
For the GetTexture capability, if a data range is requested that covers the whole asset length, return HTTP PartialContent instead of NotFound
NotFound is obviously wrong, and this change stops viewer 3.2.2 (and v probably earlier) complaining in the log about missing textures that are actually present. We still return PartialContent even if the range requested is a superset of the data range as per httpd's behaviour https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 Viewer 3.2.2 and very probably earlier appear happy with this. Whether fixing this NotFound bug has any practical effect apart from resolve viewer log messages is unknown.
Diffstat (limited to 'OpenSim/Capabilities/Handlers')
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs39
1 files changed, 25 insertions, 14 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 245d931..7ab30ce 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -111,6 +111,10 @@ namespace OpenSim.Capabilities.Handlers
111 m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url); 111 m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url);
112 } 112 }
113 113
114// m_log.DebugFormat(
115// "[GETTEXTURE]: For texture {0} sending back response {1}, data length {2}",
116// textureID, httpResponse.StatusCode, httpResponse.ContentLength);
117
114 httpResponse.Send(); 118 httpResponse.Send();
115 return null; 119 return null;
116 } 120 }
@@ -210,7 +214,7 @@ namespace OpenSim.Capabilities.Handlers
210 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format) 214 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
211 { 215 {
212 string range = request.Headers.GetOne("Range"); 216 string range = request.Headers.GetOne("Range");
213 //m_log.DebugFormat("[GETTEXTURE]: Range {0}", range); 217
214 if (!String.IsNullOrEmpty(range)) // JP2's only 218 if (!String.IsNullOrEmpty(range)) // JP2's only
215 { 219 {
216 // Range request 220 // Range request
@@ -222,23 +226,27 @@ namespace OpenSim.Capabilities.Handlers
222 if (start >= texture.Data.Length) 226 if (start >= texture.Data.Length)
223 { 227 {
224 response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; 228 response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
225 return;
226 } 229 }
230 else
231 {
232 end = Utils.Clamp(end, 0, texture.Data.Length - 1);
233 start = Utils.Clamp(start, 0, end);
234 int len = end - start + 1;
227 235
228 end = Utils.Clamp(end, 0, texture.Data.Length - 1); 236 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
229 start = Utils.Clamp(start, 0, end);
230 int len = end - start + 1;
231
232 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
233 237
234 if (len < texture.Data.Length) 238 // Always return PartialContent, even if the range covered the entire data length
239 // We were accidentally sending back 404 before in this situation
240 // https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the
241 // entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this.
235 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; 242 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
236 243
237 response.ContentLength = len; 244 response.ContentLength = len;
238 response.ContentType = texture.Metadata.ContentType; 245 response.ContentType = texture.Metadata.ContentType;
239 response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length)); 246 response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length));
240 247
241 response.Body.Write(texture.Data, start, len); 248 response.Body.Write(texture.Data, start, len);
249 }
242 } 250 }
243 else 251 else
244 { 252 {
@@ -257,6 +265,10 @@ namespace OpenSim.Capabilities.Handlers
257 response.ContentType = "image/" + format; 265 response.ContentType = "image/" + format;
258 response.Body.Write(texture.Data, 0, texture.Data.Length); 266 response.Body.Write(texture.Data, 0, texture.Data.Length);
259 } 267 }
268
269// m_log.DebugFormat(
270// "[GETTEXTURE]: For texture {0} requested range {1} responded {2} with content length {3} (actual {4})",
271// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
260 } 272 }
261 273
262 private bool TryParseRange(string header, out int start, out int end) 274 private bool TryParseRange(string header, out int start, out int end)
@@ -275,7 +287,6 @@ namespace OpenSim.Capabilities.Handlers
275 return false; 287 return false;
276 } 288 }
277 289
278
279 private byte[] ConvertTextureData(AssetBase texture, string format) 290 private byte[] ConvertTextureData(AssetBase texture, string format)
280 { 291 {
281 m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format); 292 m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format);