aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs')
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs35
1 files changed, 34 insertions, 1 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 68686c5..aa6203b 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -240,6 +240,11 @@ namespace OpenSim.Capabilities.Handlers
240 } 240 }
241 else 241 else
242 { 242 {
243 // Handle the case where no second range value was given. This is equivalent to requesting
244 // the rest of the entity.
245 if (end == -1)
246 end = int.MaxValue;
247
243 end = Utils.Clamp(end, 0, texture.Data.Length - 1); 248 end = Utils.Clamp(end, 0, texture.Data.Length - 1);
244 start = Utils.Clamp(start, 0, end); 249 start = Utils.Clamp(start, 0, end);
245 int len = end - start + 1; 250 int len = end - start + 1;
@@ -298,15 +303,43 @@ namespace OpenSim.Capabilities.Handlers
298// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); 303// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
299 } 304 }
300 305
306 /// <summary>
307 /// Parse a range header.
308 /// </summary>
309 /// <remarks>
310 /// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html,
311 /// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-).
312 /// Where there is no value, -1 is returned.
313 /// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1
314 /// for start.</remarks>
315 /// <returns></returns>
316 /// <param name='header'></param>
317 /// <param name='start'>Start of the range. Undefined if this was not a number.</param>
318 /// <param name='end'>End of the range. Will be -1 if no end specified. Undefined if there was a raw string but this was not a number.</param>
301 private bool TryParseRange(string header, out int start, out int end) 319 private bool TryParseRange(string header, out int start, out int end)
302 { 320 {
321 start = end = 0;
322
303 if (header.StartsWith("bytes=")) 323 if (header.StartsWith("bytes="))
304 { 324 {
305 string[] rangeValues = header.Substring(6).Split('-'); 325 string[] rangeValues = header.Substring(6).Split('-');
326
306 if (rangeValues.Length == 2) 327 if (rangeValues.Length == 2)
307 { 328 {
308 if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end)) 329 if (!Int32.TryParse(rangeValues[0], out start))
330 return false;
331
332 string rawEnd = rangeValues[1];
333
334 if (rawEnd == "")
335 {
336 end = -1;
337 return true;
338 }
339 else if (Int32.TryParse(rawEnd, out end))
340 {
309 return true; 341 return true;
342 }
310 } 343 }
311 } 344 }
312 345