diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 35 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | 2 |
2 files changed, 35 insertions, 2 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 6437d0b..822c50d 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -225,6 +225,11 @@ namespace OpenSim.Capabilities.Handlers | |||
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | // Handle the case where no second range value was given. This is equivalent to requesting | ||
229 | // the rest of the entity. | ||
230 | if (end == -1) | ||
231 | end = int.MaxValue; | ||
232 | |||
228 | end = Utils.Clamp(end, 0, texture.Data.Length - 1); | 233 | end = Utils.Clamp(end, 0, texture.Data.Length - 1); |
229 | start = Utils.Clamp(start, 0, end); | 234 | start = Utils.Clamp(start, 0, end); |
230 | int len = end - start + 1; | 235 | int len = end - start + 1; |
@@ -283,15 +288,43 @@ namespace OpenSim.Capabilities.Handlers | |||
283 | // texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); | 288 | // texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); |
284 | } | 289 | } |
285 | 290 | ||
291 | /// <summary> | ||
292 | /// Parse a range header. | ||
293 | /// </summary> | ||
294 | /// <remarks> | ||
295 | /// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, | ||
296 | /// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-). | ||
297 | /// Where there is no value, -1 is returned. | ||
298 | /// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1 | ||
299 | /// for start.</remarks> | ||
300 | /// <returns></returns> | ||
301 | /// <param name='header'></param> | ||
302 | /// <param name='start'>Start of the range. Undefined if this was not a number.</param> | ||
303 | /// <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> | ||
286 | private bool TryParseRange(string header, out int start, out int end) | 304 | private bool TryParseRange(string header, out int start, out int end) |
287 | { | 305 | { |
306 | start = end = 0; | ||
307 | |||
288 | if (header.StartsWith("bytes=")) | 308 | if (header.StartsWith("bytes=")) |
289 | { | 309 | { |
290 | string[] rangeValues = header.Substring(6).Split('-'); | 310 | string[] rangeValues = header.Substring(6).Split('-'); |
311 | |||
291 | if (rangeValues.Length == 2) | 312 | if (rangeValues.Length == 2) |
292 | { | 313 | { |
293 | if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end)) | 314 | if (!Int32.TryParse(rangeValues[0], out start)) |
315 | return false; | ||
316 | |||
317 | string rawEnd = rangeValues[1]; | ||
318 | |||
319 | if (rawEnd == "") | ||
320 | { | ||
321 | end = -1; | ||
322 | return true; | ||
323 | } | ||
324 | else if (Int32.TryParse(rawEnd, out end)) | ||
325 | { | ||
294 | return true; | 326 | return true; |
327 | } | ||
295 | } | 328 | } |
296 | } | 329 | } |
297 | 330 | ||
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index b6ae41b..217a265 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common.Mock; | |||
43 | namespace OpenSim.Capabilities.Handlers.GetTexture.Tests | 43 | namespace OpenSim.Capabilities.Handlers.GetTexture.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class GetTextureHandlerTests | 46 | public class GetTextureHandlerTests : OpenSimTestCase |
47 | { | 47 | { |
48 | [Test] | 48 | [Test] |
49 | public void TestTextureNotFound() | 49 | public void TestTextureNotFound() |