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.

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;

Description

Fields

Public Url: String;

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

Public ForceSynchronous: Boolean;

This item has no description.

Public HttpMethod: THttpMethod;

This item has no description.

Public HttpPostData: TStrings;

This item has no description.

Public HttpHeadersKeys: TStrings;

This item has no description.

Public HttpHeadersValues: TStrings;

This item has no description.

Public HttpRequestBody: TMemoryStream;

This item has no description.

Public Status: TDownloadStatus;

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

Public DownloadedBytes: Int64;

This item has no description.

Public TotalBytes: Int64;

This item has no description.

Public Contents: TStream;

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

Public ErrorMessage: String;

When Status = dsError, download failed with this error.

Public MimeType: String;

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

Public HttpResponseCode: Integer;

This item has no description.

Public HttpResponseHeaders: TStrings;

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

Public FinalUrl: String;

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

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.

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.

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.


Generated by PasDoc 0.16.0-snapshot.