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.cs46
1 files changed, 1 insertions, 45 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 57ec2f5..51332bc 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Capabilities.Handlers
210 { 210 {
211 // Range request 211 // Range request
212 int start, end; 212 int start, end;
213 if (TryParseRange(range, out start, out end)) 213 if (Util.TryParseHttpRange(range, out start, out end))
214 { 214 {
215 // Before clamping start make sure we can satisfy it in order to avoid 215 // Before clamping start make sure we can satisfy it in order to avoid
216 // sending back the last byte instead of an error status 216 // sending back the last byte instead of an error status
@@ -289,50 +289,6 @@ namespace OpenSim.Capabilities.Handlers
289// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); 289// texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length);
290 } 290 }
291 291
292 /// <summary>
293 /// Parse a range header.
294 /// </summary>
295 /// <remarks>
296 /// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html,
297 /// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-).
298 /// Where there is no value, -1 is returned.
299 /// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1
300 /// for start.</remarks>
301 /// <returns></returns>
302 /// <param name='header'></param>
303 /// <param name='start'>Start of the range. Undefined if this was not a number.</param>
304 /// <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>
305 private bool TryParseRange(string header, out int start, out int end)
306 {
307 start = end = 0;
308
309 if (header.StartsWith("bytes="))
310 {
311 string[] rangeValues = header.Substring(6).Split('-');
312
313 if (rangeValues.Length == 2)
314 {
315 if (!Int32.TryParse(rangeValues[0], out start))
316 return false;
317
318 string rawEnd = rangeValues[1];
319
320 if (rawEnd == "")
321 {
322 end = -1;
323 return true;
324 }
325 else if (Int32.TryParse(rawEnd, out end))
326 {
327 return true;
328 }
329 }
330 }
331
332 start = end = 0;
333 return false;
334 }
335
336 private byte[] ConvertTextureData(AssetBase texture, string format) 292 private byte[] ConvertTextureData(AssetBase texture, string format)
337 { 293 {
338 m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format); 294 m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format);