diff options
author | Diva Canto | 2012-12-06 20:04:59 -0800 |
---|---|---|
committer | Diva Canto | 2012-12-06 20:04:59 -0800 |
commit | 3c9f8c9c46546da0944632b853313aa52f38cc00 (patch) | |
tree | 548bef5b08feb9e6df9e136de5e4a4fd4ca3c549 /OpenSim/Capabilities | |
parent | Trying to prevent old route of sending attachments, simulator version unknown... (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-3c9f8c9c46546da0944632b853313aa52f38cc00.zip opensim-SC_OLD-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.gz opensim-SC_OLD-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.bz2 opensim-SC_OLD-3c9f8c9c46546da0944632b853313aa52f38cc00.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 04cc33a..b497fde 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -246,6 +246,11 @@ namespace OpenSim.Capabilities.Handlers | |||
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | // Handle the case where no second range value was given. This is equivalent to requesting | ||
250 | // the rest of the entity. | ||
251 | if (end == -1) | ||
252 | end = int.MaxValue; | ||
253 | |||
249 | end = Utils.Clamp(end, 0, texture.Data.Length - 1); | 254 | end = Utils.Clamp(end, 0, texture.Data.Length - 1); |
250 | start = Utils.Clamp(start, 0, end); | 255 | start = Utils.Clamp(start, 0, end); |
251 | int len = end - start + 1; | 256 | int len = end - start + 1; |
@@ -299,15 +304,43 @@ namespace OpenSim.Capabilities.Handlers | |||
299 | // texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); | 304 | // texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); |
300 | } | 305 | } |
301 | 306 | ||
307 | /// <summary> | ||
308 | /// Parse a range header. | ||
309 | /// </summary> | ||
310 | /// <remarks> | ||
311 | /// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, | ||
312 | /// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-). | ||
313 | /// Where there is no value, -1 is returned. | ||
314 | /// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1 | ||
315 | /// for start.</remarks> | ||
316 | /// <returns></returns> | ||
317 | /// <param name='header'></param> | ||
318 | /// <param name='start'>Start of the range. Undefined if this was not a number.</param> | ||
319 | /// <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> | ||
302 | private bool TryParseRange(string header, out int start, out int end) | 320 | private bool TryParseRange(string header, out int start, out int end) |
303 | { | 321 | { |
322 | start = end = 0; | ||
323 | |||
304 | if (header.StartsWith("bytes=")) | 324 | if (header.StartsWith("bytes=")) |
305 | { | 325 | { |
306 | string[] rangeValues = header.Substring(6).Split('-'); | 326 | string[] rangeValues = header.Substring(6).Split('-'); |
327 | |||
307 | if (rangeValues.Length == 2) | 328 | if (rangeValues.Length == 2) |
308 | { | 329 | { |
309 | if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end)) | 330 | if (!Int32.TryParse(rangeValues[0], out start)) |
331 | return false; | ||
332 | |||
333 | string rawEnd = rangeValues[1]; | ||
334 | |||
335 | if (rawEnd == "") | ||
336 | { | ||
337 | end = -1; | ||
338 | return true; | ||
339 | } | ||
340 | else if (Int32.TryParse(rawEnd, out end)) | ||
341 | { | ||
310 | return true; | 342 | return true; |
343 | } | ||
311 | } | 344 | } |
312 | } | 345 | } |
313 | 346 | ||