From b783244a504ae9979c937acef6c18c839de24aa7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 30 Nov 2018 23:10:29 +0000 Subject: move http range parser to util --- .../Handlers/GetTexture/GetTextureHandler.cs | 46 +--------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'OpenSim/Capabilities/Handlers/GetTexture') 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 { // Range request int start, end; - if (TryParseRange(range, out start, out end)) + if (Util.TryParseHttpRange(range, out start, out end)) { // Before clamping start make sure we can satisfy it in order to avoid // sending back the last byte instead of an error status @@ -289,50 +289,6 @@ namespace OpenSim.Capabilities.Handlers // texture.FullID, range, response.StatusCode, response.ContentLength, texture.Data.Length); } - /// - /// Parse a range header. - /// - /// - /// As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, - /// this obeys range headers with two values (e.g. 533-4165) and no second value (e.g. 533-). - /// Where there is no value, -1 is returned. - /// FIXME: Need to cover the case where only a second value is specified (e.g. -4165), probably by returning -1 - /// for start. - /// - /// - /// Start of the range. Undefined if this was not a number. - /// End of the range. Will be -1 if no end specified. Undefined if there was a raw string but this was not a number. - private bool TryParseRange(string header, out int start, out int end) - { - start = end = 0; - - if (header.StartsWith("bytes=")) - { - string[] rangeValues = header.Substring(6).Split('-'); - - if (rangeValues.Length == 2) - { - if (!Int32.TryParse(rangeValues[0], out start)) - return false; - - string rawEnd = rangeValues[1]; - - if (rawEnd == "") - { - end = -1; - return true; - } - else if (Int32.TryParse(rawEnd, out end)) - { - return true; - } - } - } - - start = end = 0; - return false; - } - private byte[] ConvertTextureData(AssetBase texture, string format) { m_log.DebugFormat("[GETTEXTURE]: Converting texture {0} to {1}", texture.ID, format); -- cgit v1.1