Exemple #1
0
        public void ProcessRequest(HttpContextBase context, FileInfo file)
        {
            var request  = context.Request;
            var response = context.Response;

            var fileSettingEntity = _fileEntitySettingProvider.GetSetting(file);

            var fileEntity = new FileEntity(_cacheManager, _retryableFileOpener, _mimeTyper, _hasher, MaxFileSizeToServe, BufferSize, file, fileSettingEntity);

            if (_webServerType == WebServerType.NotSet || _httpResponseHeaderHelper == null || _httpRequestResponder == null)
            {
                Initialize(context);
            }

            //We don't want to use up all the servers memory keeping a copy of the file, we just want to stream file to client
            response.BufferOutput = false;

            try
            {
                _httpRequestResponder.ServeRequest(request, response, fileEntity);
            }
            catch (HttpException httpException)
            {
                //Client disconnected half way through us sending data
                if (httpException.ErrorCode != ErrorTheRemoteHostClosedTheConnection)
                {
                    return;
                }

                throw;
            }
        }