aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-11-30 23:10:29 +0000
committerUbitUmarov2018-11-30 23:10:29 +0000
commitb783244a504ae9979c937acef6c18c839de24aa7 (patch)
tree2176b219dc7d5733a4715b9301efac8de0f6790f /OpenSim/Framework/Util.cs
parentadd a sound (diff)
downloadopensim-SC-b783244a504ae9979c937acef6c18c839de24aa7.zip
opensim-SC-b783244a504ae9979c937acef6c18c839de24aa7.tar.gz
opensim-SC-b783244a504ae9979c937acef6c18c839de24aa7.tar.bz2
opensim-SC-b783244a504ae9979c937acef6c18c839de24aa7.tar.xz
move http range parser to util
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index f8469b6..52f9aea 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -2382,6 +2382,38 @@ namespace OpenSim.Framework
2382 return sb.ToString(); 2382 return sb.ToString();
2383 } 2383 }
2384 2384
2385 public static bool TryParseHttpRange(string header, out int start, out int end)
2386 {
2387 start = end = 0;
2388
2389 if (header.StartsWith("bytes="))
2390 {
2391 string[] rangeValues = header.Substring(6).Split('-');
2392
2393 if (rangeValues.Length == 2)
2394 {
2395 string rawStart = rangeValues[0].Trim();
2396 if (rawStart != "" && !Int32.TryParse(rawStart, out start))
2397 return false;
2398
2399 if (start < 0)
2400 return false;
2401
2402 string rawEnd = rangeValues[1].Trim();
2403 if (rawEnd == "")
2404 {
2405 end = -1;
2406 return true;
2407 }
2408 else if (Int32.TryParse(rawEnd, out end))
2409 return end > 0;
2410 }
2411 }
2412
2413 start = end = 0;
2414 return false;
2415 }
2416
2385 /// <summary> 2417 /// <summary>
2386 /// Used to trigger an early library load on Windows systems. 2418 /// Used to trigger an early library load on Windows systems.
2387 /// </summary> 2419 /// </summary>