Class TUrlAsynchronousReader

Unit

Declaration

type TUrlAsynchronousReader = class(TObject)

Description

Implement this class, and pass to RegisterUrlProtocol, to read protocols asynchronously (such that TCastleDownload can read them asynchronously).

There is no point in using this class unless you want to handle custom URL protocols. If you just want to download asynchronously from standard URLs, like file or http, then use TCastleDownload class.

Source: src/files/castledownload_register.inc (line 34).

Hierarchy

  • TObject
  • TUrlAsynchronousReader

Overview

Fields

Public Url: String;
Public ForceSynchronous: Boolean;
Public HttpMethod: THttpMethod;
Public HttpPostData: TStrings;
Public HttpHeadersKeys: TStrings;
Public HttpHeadersValues: TStrings;
Public HttpRequestBody: TMemoryStream;
Public Status: TDownloadStatus;
Public DownloadedBytes: Int64;
Public TotalBytes: Int64;
Public Contents: TStream;
Public ErrorMessage: String;
Public MimeType: String;
Public HttpResponseCode: Integer;
Public HttpResponseHeaders: TStrings;
Public FinalUrl: String;

Methods

Protected function CheckNetworkAccess: Boolean;
Public procedure Start; virtual;
Public procedure Update; virtual;
Public procedure UpdateOnlySynchronous; virtual;

Description

Fields

Public Url: String;

Fields set before Start is called. Should not be modified by this instance after Start.

Source: src/files/castledownload_register.inc (line 55).

Public ForceSynchronous: Boolean;

This item has no description.

Source: src/files/castledownload_register.inc (line 56).

Public HttpMethod: THttpMethod;

This item has no description.

Source: src/files/castledownload_register.inc (line 57).

Public HttpPostData: TStrings;

This item has no description.

Source: src/files/castledownload_register.inc (line 58).

Public HttpHeadersKeys: TStrings;

This item has no description.

Source: src/files/castledownload_register.inc (line 58).

Public HttpHeadersValues: TStrings;

This item has no description.

Source: src/files/castledownload_register.inc (line 58).

Public HttpRequestBody: TMemoryStream;

This item has no description.

Source: src/files/castledownload_register.inc (line 59).

Public Status: TDownloadStatus;

Fields that should be updated during downloading. They will set TCastleDownload properties of the same name.

Source: src/files/castledownload_register.inc (line 65).

Public DownloadedBytes: Int64;

This item has no description.

Source: src/files/castledownload_register.inc (line 66).

Public TotalBytes: Int64;

This item has no description.

Source: src/files/castledownload_register.inc (line 66).

Public Contents: TStream;

Not owned by this instance, TCastleDownload takes care of freeing this.

Source: src/files/castledownload_register.inc (line 67).

Public ErrorMessage: String;

When Status = dsError, download failed with this error.

Source: src/files/castledownload_register.inc (line 68).

Public MimeType: String;

May be updated at any point, even when dsDownloading, or only when dsSuccess.

Source: src/files/castledownload_register.inc (line 69).

Public HttpResponseCode: Integer;

This item has no description.

Source: src/files/castledownload_register.inc (line 70).

Public HttpResponseHeaders: TStrings;

In case of HTTP(S) requests, HTTP response code.

Source: src/files/castledownload_register.inc (line 71).

Public FinalUrl: String;

In case of HTTP(S) requests, this must contain HTTP response headers.

Source: src/files/castledownload_register.inc (line 72).

Methods

Protected function CheckNetworkAccess: Boolean;

Call this from Start overrides in descendants that access the network. Call this after they called "inherited Start" which may change ForceSynchronous.

This returns False if

- It seems that we do synchronous download (maybe because we are called from Download(), or maybe we don't have thread support).

- And EnableBlockingDownloads is False.

IOW, this makes sure we honor EnableBlockingDownloads.

When it sets False, it also sets Status and ErrorMessage. The caller Start should just Exit if this returns False.

Source: src/files/castledownload_register.inc (line 51).

Public procedure Start; virtual;

Start downloading, called when TCastleDownload.Start is called.

Note for descendant implementors: Exceptions raised inside this will make an actual exception from TCastleDownload.Start. In case of normal download failure, e.g. file (or HTTP resource) doesn't exist (so it is not some bug in code), this method should set Status to dsError and not raise an exception.

Source: src/files/castledownload_register.inc (line 83).

Public procedure Update; virtual;

Called continuously to push the download further.

Note for descendant implementors: Exceptions raised inside this will make an actual exception (from undefined place, for now ApplicationProperties._Update, called by TCastleWindow and TCastleControl). In case of normal download failure, e.g. file (or HTTP resource) doesn't exist (so it is not some bug in code), this method should set Status to dsError and not raise an exception.

Source: src/files/castledownload_register.inc (line 93).

Public procedure UpdateOnlySynchronous; virtual;

Called continuously to push the download further only when we're doing synchronous download and waiting in TCastleDownload.WaitForFinish.

This allows to do additional tasks, before what Update is doing, to push the download. For example, if you rely on CastleMessaging processing, you can call ApplicationProperties._Update from here, as it will happen automatically during TCastleDownload.WaitForFinish.

Source: src/files/castledownload_register.inc (line 104).


Generated by PasDoc 0.17.0.snapshot.