コード例 #1
0
        /// <summary>
        /// Validate
        /// </summary>
        public bool ValidateHeaderRange(HttpRequest request, HttpRequestSimpleRangeInfo rangeInfo, long contentLength)
        {
            var validRanges = true;

            // Begin and end must not exceed the file size
            if ((rangeInfo.Begin > (contentLength - 1)) || (rangeInfo.End > (contentLength - 1)))
            {
                validRanges = false;
            }

            // Begin and end cannot be < 0
            if ((rangeInfo.Begin < 0) || (rangeInfo.End < 0))
            {
                validRanges = false;
            }

            // End must be larger or equal to begin value
            if (rangeInfo.End < rangeInfo.Begin)
            {
                // The requested Range is invalid...
                validRanges = false;
            }

            return(validRanges);
        }
コード例 #2
0
 public void InitializeRanges(HttpRequestSimpleRangeInfo rangeInfo)
 {
     IsRangeRequest = rangeInfo.IsRangeApplied;
     if (rangeInfo.IsRangeApplied)
     {
         RangeBegin = new long[] { rangeInfo.Begin };
         RangeEnd   = new long[] { rangeInfo.End };
     }
 }