- все о программировании
Вход  |  Регистрация  |  Поиск 
Сегодня :

День работников дорожного хозяйства

TURLDownloader - закачка данных по HTTP

URL: string (read only) - specifies the URL from which data are downloaded.

DownloadInProgress: boolean (read only) - indicates whether the downloading is in progress.

AutoDestroy:boolean - specifies whether to destroy the TURLDownloader instance automatically after the download completion (OnDownloadStop event).

BindFlags: DWord - specifies the download options. It can be combination of BINDF_xxx flags (UrlMon.pas). BINDF_ASYNCHRONOUS is always on, BINDF_ASYNCSTORAGE is always off. The setting of these flags is blocked.

TotalRead: integer (read only) - indicates how much data was read (for current download operation). Methods1)

StartDownload - starts the downloading of data from the URL specified.

procedure StartDownload(Caller:IUnknown; const ownloadURL:string; HTTPRequestData:PHTTPRequestData = nil);
The Caller should be a pointer to IUnknown interface of ActiveX control contained within Internet enabled framework (like MS Internet Explorer).

This parameter can be "nil" if such framework is absent. The DownloadURL specifies the URL to download data from. It can be a relative URL (if Caller <> nil).
Optional parameter HTTPRequestData specifies additional data for HTTP-request (Method, AdditionalHeaders, RequestBody). These data are used to form specific HTTP-requests. Method may be GET, POST, PUT or any custom. If Method is not specified then the GET method is assumed. HTTP-headers in AdditionalHeaders must be separated by #13#10 and the last HTTP-header must be ended by #13#10. RequestBody is ignored for the GET method.
2) AbortDownload - aborts the current download.

procedure AbortDownload;Events1) OnStartDownload - occurs when downloading is started. OnStartDownload:TDownloadStartNotify;

TDownloadStartNotify = procedure (Sender: TURLDownloader) of object; Write an OnStartDownload event handler to make necessary initializations.
2) OnDownloadProgress - notifies about download progress. OnDownloadProgress:


TDownloadProgressNotify = procedure (Sender: TURLDownloader; const Progress:TDownloadProgress) of object; StatusCode field of

TDownloadProgress structure tells about download stage. Values are taken from BINDSTATUS_xxx codes (UrlMon.pas). StatusText contains additional textual information specific for each download stage. ProgressMax indicates how much data is expected to receive. Progress field indicates how much data is received.3)

OnBytesAvailable - occurs when new data are available. OnBytesAvailable:

TBytesAvailableNotify; TBytesAvailableNotify = procedure (Sender: TURLDownloader;
BytesAvailable: integer; var BytesToRead: integer; var ReadBuffer: pointer) of object; On the arriving new portion of data two events occur. First OnBytesAvailable, second - OnDataRead. OnBytesAvailable event tells how much data is available to read and give you the following possibilities - first, to specify how much data you are ready to accept (parameter BytesToRead), and second (optinally), suply a pointer to a buffer where to write these data (parameter ReadBuffer). If you didn't specify the read buffer then it will be created automatically. OnDataRead event notifies you how much and where data has been written to. If not all of available data has been read then the firing of these events is repeated. If you set BytesToRead to zero or greater than BytesAvaible then the subsequent OnDataRead is not fired and next OnBytesAvailable event occurs when more data is received. Do not use this option if you specified BINDF_PULLDATA flag for BindFlags property (otherwise the downloading will be suspended and the only way to exit this state will be to abort the downloading). You have to read all available data if you specified BINDF_PULLDATA flag.

4) OnDataRead - notifies how much and where new data has been written to.

OnDataRead: TDataReadNotify; TDataReadNotify = procedure (Sender: TURLDownloader; Data:pointer; DataSize: integer) of object; You can process these data as you want (on fly visualization, processing and so on).

5) OnDownloadStop - occurs when the downloading is finished (successfully or not).

OnDownloadStop: DownloadStopNotify;

TDownloadStopNotify = procedure (Sender: TURLDownloader; ErrorCode: cardinal) of object; ErrorCode = S_OK if the downloading was successful. Otherwise ErrorCode specifies the error. Values usually are taken from INET_E_xxx codes (UrlMon.pas) but may be protocol specific.

6) OnHTTPResponse - occurs when HTTP response code and headers are recieved.

OnHTTPResponse: THTTPResponseNotify;

THTTPResponseNotify = procedure (Sender: TURLDownloader; ResponseCode: DWord; const ResponseHeaders: string) of object; Write OnHTTPResponse event handler if your want a special processing of HTTP response. Headers in ResponseHeaders are separated by #13#10

11 кб

2002-07-29 23:44:56
хостинг от .masterhost 
Rambler's Top100