NanoByte.Common  2.7.0
NanoByte.Common.Net.DownloadTask Class Referenceabstract

Abstract base class for tasks that download a file from the web. More...

Inheritance diagram for NanoByte.Common.Net.DownloadTask:
NanoByte.Common.Tasks.TaskBase NanoByte.Common.Tasks.ITask NanoByte.Common.Net.DownloadFile NanoByte.Common.Net.DownloadMemory

Protected Member Functions

 DownloadTask (Uri source, long bytesTotal=-1)
 Creates a new download task. More...
 
override void Execute ()
 The actual code to be executed.
 
abstract Stream CreateTargetStream ()
 Creates the Stream to write the downloaded data to. More...
 

Properties

override string Name [get]
 
override bool UnitsByte [get]
 
long BytesMaximum = long.MaxValue [get, set]
 The maximum number of bytes to download. More...
 
Uri Source [get]
 The URL the file is to be downloaded from. More...
 
bool NoCache [get, set]
 Set to true to add a No-Cache header to the request for any intermediate proxy servers. More...
 
WebHeaderCollection? ResponseHeaders [get]
 The HTTP header data returned by the server for the download request. An empty collection in case of an FTP download. More...
 
- Properties inherited from NanoByte.Common.Tasks.TaskBase
abstract string Name [get]
 
object? Tag [get, set]
 
virtual bool CanCancel [get]
 
TaskState State [get, protected set]
 The current State of the task. More...
 
abstract bool UnitsByte [get]
 true if UnitsProcessed and UnitsTotal are measured in bytes; false if they are measured in generic units. More...
 
long UnitsProcessed [get, set]
 The number of units that have been processed so far. More...
 
long UnitsTotal [get, set]
 The total number of units that are to be processed; -1 for unknown. More...
 
- Properties inherited from NanoByte.Common.Tasks.ITask
string Name [get]
 A name describing the task in human-readable form. More...
 
object? Tag [get, set]
 An object used to associate the task with a specific process; can be null. More...
 
bool CanCancel [get]
 Indicates whether this task can be canceled once it has been started. More...
 

Additional Inherited Members

- Public Member Functions inherited from NanoByte.Common.Tasks.TaskBase
void Run (CancellationToken cancellationToken=default, ICredentialProvider? credentialProvider=null, IProgress< TaskSnapshot >? progress=null)
 Runs the task and blocks until it is complete.
 
- Protected Attributes inherited from NanoByte.Common.Tasks.TaskBase
CancellationToken CancellationToken
 Signaled when the user wishes to cancel the task execution. More...
 
ICredentialProviderCredentialProvider
 Used to retrieve credentials for specific Uris on demand; can be null. More...
 

Detailed Description

Abstract base class for tasks that download a file from the web.

Constructor & Destructor Documentation

◆ DownloadTask()

NanoByte.Common.Net.DownloadTask.DownloadTask ( Uri  source,
long  bytesTotal = -1 
)
inlineprotected

Creates a new download task.

Parameters
sourceThe URL the file is to be downloaded from.
bytesTotalThe number of bytes the file to be downloaded is long. The file will be rejected if it does not have this length. -1 if the size is unknown.

Member Function Documentation

◆ CreateTargetStream()

abstract Stream NanoByte.Common.Net.DownloadTask.CreateTargetStream ( )
protectedpure virtual

Creates the Stream to write the downloaded data to.

Implemented in NanoByte.Common.Net.DownloadMemory, and NanoByte.Common.Net.DownloadFile.

Property Documentation

◆ BytesMaximum

long NanoByte.Common.Net.DownloadTask.BytesMaximum = long.MaxValue
getset

The maximum number of bytes to download.

◆ NoCache

bool NanoByte.Common.Net.DownloadTask.NoCache
getset

Set to true to add a No-Cache header to the request for any intermediate proxy servers.

◆ ResponseHeaders

WebHeaderCollection? NanoByte.Common.Net.DownloadTask.ResponseHeaders
get

The HTTP header data returned by the server for the download request. An empty collection in case of an FTP download.

This value is always null until TaskState.Data has been reached.

◆ Source

Uri NanoByte.Common.Net.DownloadTask.Source
get

The URL the file is to be downloaded from.

This value may change once TaskState.Data has been reached, based on HTTP redirections.


The documentation for this class was generated from the following file: