/// <summary>
        /// Parses the <paramref name="ranges"/> into a new <see cref="RangeHeader"/> instance
        /// </summary>
        /// <remarks>
        /// The range must be in the form <c>unit=(range)+</c>
        /// </remarks>
        /// <param name="ranges">The ranges to parse</param>
        /// <returns>The new <see cref="RangeHeader"/></returns>
        public static RangeHeader Parse(IEnumerable <string> ranges)
        {
            var    rangeItems = new List <RangeHeaderItem>();
            var    firstEntry = true;
            string unit       = null;

            foreach (var range in ranges)
            {
                string rangeValue;
                if (firstEntry)
                {
                    var parts = range.Split(_splitEqualChar, 2);
                    if (parts.Length == 1)
                    {
                        rangeValue = parts[0];
                    }
                    else
                    {
                        unit       = parts[0].TrimEnd();
                        rangeValue = parts[1].TrimStart();
                    }

                    firstEntry = false;
                }
                else
                {
                    rangeValue = range;
                }

                foreach (var rangeValueItem in rangeValue.Split(',').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)))
                {
                    var item = RangeHeaderItem.Parse(rangeValueItem);
                    rangeItems.Add(item);
                }
            }

            return(new RangeHeader(unit ?? "bytes", true, rangeItems));
        }
 /// <summary>
 /// Returns the textual representation of a single <see cref="RangeHeaderItem"/>
 /// </summary>
 /// <remarks>
 /// The return value of this function looks like <c>unit range/length</c>
 /// </remarks>
 /// <param name="rangeItem">The <see cref="RangeHeaderItem"/> to get the textual representation for</param>
 /// <param name="length">The length value to be used in the textual representation</param>
 /// <returns>The textual representation of <paramref name="rangeItem"/></returns>
 public virtual string ToString(RangeHeaderItem rangeItem, long?length)
 {
     return($"{Unit} {rangeItem}/{length?.ToString(CultureInfo.InvariantCulture) ?? "*"}");
 }
 /// <summary>
 /// Returns the textual representation of a single <see cref="RangeHeaderItem"/>
 /// </summary>
 /// <remarks>
 /// The return value of this function looks like <c>unit range/length</c>
 /// </remarks>
 /// <param name="rangeItem">The <see cref="RangeHeaderItem"/> to get the textual representation for</param>
 /// <returns>The textual representation of <paramref name="rangeItem"/></returns>
 public virtual string ToString(RangeHeaderItem rangeItem)
 {
     return(ToString(rangeItem, null));
 }