aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/GetTexture
diff options
context:
space:
mode:
authorMelanie2012-12-07 03:49:04 +0000
committerMelanie2012-12-07 03:49:04 +0000
commit2cb824d3fcd37b9f9c9a9981702b81643c531a1b (patch)
tree8bfb77166642a49f142e60a3486a264e7635ef83 /OpenSim/Capabilities/Handlers/GetTexture
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-2cb824d3fcd37b9f9c9a9981702b81643c531a1b.zip
opensim-SC-2cb824d3fcd37b9f9c9a9981702b81643c531a1b.tar.gz
opensim-SC-2cb824d3fcd37b9f9c9a9981702b81643c531a1b.tar.bz2
opensim-SC-2cb824d3fcd37b9f9c9a9981702b81643c531a1b.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim/Capabilities/Handlers/GetTexture')
-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 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