예제 #1
0
        private void StartDownload()
        {
            if (this.IsCancelled())
            {
                return;
            }

            this.localFileName = this.ComposeLocalFilename();

            if (!this.UseCaching)
            {
                this.TriggerWebClientDownloadFileAsync();
                return;
            }

            this.TotalBytesToReceive = -1;
            WebHeaderCollection headers = this.GetHttpHeaders(this.fileSource);

            if (headers != null)
            {
                this.TotalBytesToReceive = headers.GetContentLength();
            }

            if (this.TotalBytesToReceive == -1)
            {
                this.TotalBytesToReceive = 0;
                this.TriggerWebClientDownloadFileAsync();
            }
            else
            {
                this.ResumeDownload(headers);
            }
        }
예제 #2
0
        private void StartDownload()
        {
            if (IsCancelled())
            {
                return;
            }

            logger.Debug("FileDownloader attempt {0} of {1}.", attemptNumber, MaxAttempts);

            localFileName = ComposeLocalFilename();

            if (!UseCaching)
            {
                TriggerWebClientDownloadFileAsync();
                return;
            }

            TotalBytesToReceive = -1;
            WebHeaderCollection headers = GetHttpHeaders(fileSource);

            if (headers != null)
            {
                TotalBytesToReceive = headers.GetContentLength();
            }

            if (TotalBytesToReceive == -1)
            {
                TotalBytesToReceive = 0;
                logger.Warn("Received no Content-Length header from server for {0}. Cache is not used, Resume is not supported", fileSource);
                TriggerWebClientDownloadFileAsync();
            }
            else
            {
                ResumeDownload(headers);
            }
        }