aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities
diff options
context:
space:
mode:
authorMelanie2011-12-05 19:01:35 +0000
committerMelanie2011-12-05 19:01:35 +0000
commite7cb63fcf7da315557efe84015b7b7564810c39a (patch)
treefb18aae0f32335b8cdb3bd264b0e28d06fe4ab03 /OpenSim/Capabilities
parentFix CHANGED_TEXTURE and CHANGED_COLOR. (diff)
parentFor the GetTexture capability, if a data range is requested that covers the w... (diff)
downloadopensim-SC-e7cb63fcf7da315557efe84015b7b7564810c39a.zip
opensim-SC-e7cb63fcf7da315557efe84015b7b7564810c39a.tar.gz
opensim-SC-e7cb63fcf7da315557efe84015b7b7564810c39a.tar.bz2
opensim-SC-e7cb63fcf7da315557efe84015b7b7564810c39a.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Capabilities')
-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);