コード例 #1
0
        public virtual async Task ProcessRequestAsync(HttpContext context)
        {
            //context.Response.TrySkipIisCustomErrors = TrySkipIisCustomErrors;

            try
            {
                ParseRequestParameters(context);

                if (CheckAuthorizationRules(context) == false)
                {
                    return;
                }

                if (CheckRequestResourceExists(context) == false)
                {
                    return;
                }

                InternalRequestedFileInfo = GetRequestedFileInfo(context);

                InternalRequestedFileEntityTag = GetRequestedFileEntityTag(context);

                await CreateResponseContentIfRequiredAsync(context);

                InternalRequestedFileMimeType = GetRequestedFileMimeType(context);
                ParseRequestHeaderRanges(context);

                // Perform each check; exit if any check returns false
                if (ProcessRequestCheckSteps.Any(check => check(context) == false) || (await CheckIfRangeHeader(context) == false))
                {
                    return;
                }

                if (!EnableRangeRequests || !IsRangeRequest)
                {
                    await ReturnEntireEntity(context);
                }
                else
                {
                    await ReturnPartialEntity(context);
                }
            }
            catch (OperationCanceledException)
            {
                //do nothing
            }
            catch
            {
                //HandleException(context, ex);
            }

            //EndRequest(context);
        }
        public void ProcessRequest(HttpContext context)
        {
            InternalRequestedFileInfo      = GetRequestedFileInfo(context);
            InternalRequestedFileEntityTag = GetRequestedFileEntityTag(context);
            InternalRequestedFileMimeType  = GetRequestedFileMimeType(context);
            ParseRequestHeaderRanges(context);

            // Perform each check; exit if any check returns false
            if (ProcessRequestCheckSteps.Any(check => check(context) == false))
            {
                return;
            }

            if (!EnableRangeRequests || !IsRangeRequest)
            {
                ReturnEntireEntity(context);
            }
            else
            {
                ReturnPartialEntity(context);
            }
        }