Class TInternetAccess

Unit

Declaration

type TInternetAccess = class(TObject)

Description

Abstract base class for connections

This class defines the interface methods for HTTP requests, like get, post or request.
If a method fails, it will raise a EInternetException

Since this is an abstract class, you cannot use it directly, but need to use one of the implementing child classes TW32InternetAccess, TSynapseInternetAccess, TAndroidInternetAccess or TMockInternetAccess.
The recommended usage is to assign one of the child classes to defaultInternetAccessClass and then create an actual internet access class with defaultInternetAccessClass.create().
Then it is trivial to swap between different implementations on different platforms, and the depending units (e.g. simpleinternet or xquery ) will use the implementation you have choosen. Default options will be taken from the global defaultInternetConfig record.

Hierarchy

Overview

Fields

Public additionalHeaders: THTTPHeaderList;
Public ContentTypeForData: string;
Public multipartFormData: TMIMEMultipartData;
Public cookies: TCookieManager;

Methods

Public class function parseHeaderLineKind(const line: string): THeaderKind; static;
Public function getFinalMultipartFormData: string;
Public function getLastContentType: string;
Public constructor create(); virtual;
Public constructor create(const internetConfig: TInternetConfig); virtual;
Public destructor Destroy; override;
Public function post(const totalUrl, data:string):string;
Public function post(const protocol,host,url: string; data:string):string;
Public procedure get(const totalUrl: string; stream:TStream);
Public function get(const totalUrl: string):string;
Public procedure get(const protocol,host,url: string; stream:TStream);
Public function get(const protocol,host,url: string):string;
Public function request(const method, fullUrl, data:string):string;
Public function request(method, protocol,host,url, data:string):string;
Public function request(method: string; url: TDecodedUrl; data:string):string;
Public procedure request(const method: string; const url: TDecodedUrl; const uploadData:string; outStream: TStream);
Public procedure request(const method: string; const url: TDecodedUrl; const uploadData: TInternetAccessDataBlock; const onClear: TTransferClearEvent; const onReceivedBlock: TTransferBlockWriteEvent);
Public function existsConnection():boolean; virtual; deprecated;
Public function needConnection():boolean; virtual; deprecated;
Public procedure closeOpenedConnections(); virtual; deprecated;
Public class function urlEncodeData(const data: string; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static;
Public class function urlEncodeData(data: TStringList; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static;
Public class function reactFromCodeString(const codes: string; actualCode: integer; var reaction: TInternetAccessReaction): string; static;
Public function internalHandle: TObject; virtual; abstract;

Properties

Public property lastHTTPResultCode: longint read getlastHTTPResultCode;
Public property lastUrl: string read getLastUrl write setLastUrl;
Public property lastHTTPHeaders: THTTPHeaderList read getLastHTTPHeaders;
Public property config: PInternetConfig read getConfig write setConfig;
Published property OnTransferStart: TTransferStartEvent read FOnTransferStart write FOnTransferStart;
Published property OnTransferReact: TTransferReactEvent read FOnTransferReact write FOnTransferReact;
Published property OnTransferEnd: TTransferEndEvent read FOnTransferEnd write FOnTransferEnd;
Published property OnProgress: TProgressEvent read FOnProgress write FOnProgress;

Description

Fields

Public additionalHeaders: THTTPHeaderList;

Defines additional headers that should be send to the server

Public ContentTypeForData: string;

Defines the Content-Type that is used to transmit data. Usually application/x-www-form-urlencoded or multipart/form-data; boundary=....
This is overriden by a Content-Type set in additionalHeaders.

Public multipartFormData: TMIMEMultipartData;
 
Public cookies: TCookieManager;

Cookies receive from/to-send the server

Methods

Public class function parseHeaderLineKind(const line: string): THeaderKind; static;
 
Public function getFinalMultipartFormData: string;
 
Public function getLastContentType: string;

Same as getLastHTTPHeader('Content-Type') but easier to remember and without magic string

Public constructor create(); virtual;
 
Public constructor create(const internetConfig: TInternetConfig); virtual;
 
Public destructor Destroy; override;
 
Public function post(const totalUrl, data:string):string;

post the (raw) data to the given url and returns the resulting document as string

Public function post(const protocol,host,url: string; data:string):string;

post the (raw) data to the url given as three parts and returns the page as string

Public procedure get(const totalUrl: string; stream:TStream);

get the url as stream

Public function get(const totalUrl: string):string;

get the url as string

Public procedure get(const protocol,host,url: string; stream:TStream);

get the url as stream

Public function get(const protocol,host,url: string):string;

get the url as string

Public function request(const method, fullUrl, data:string):string;

performs a HTTP request

Public function request(method, protocol,host,url, data:string):string;

performs a HTTP request

Public function request(method: string; url: TDecodedUrl; data:string):string;

performs a HTTP request

Public procedure request(const method: string; const url: TDecodedUrl; const uploadData:string; outStream: TStream);

performs a HTTP request

Public procedure request(const method: string; const url: TDecodedUrl; const uploadData: TInternetAccessDataBlock; const onClear: TTransferClearEvent; const onReceivedBlock: TTransferBlockWriteEvent);

performs a HTTP request

Public function existsConnection():boolean; virtual; deprecated;

Warning: this symbol is deprecated.

checks if an internet connection exists

Public function needConnection():boolean; virtual; deprecated;

Warning: this symbol is deprecated.

call this to open a connection (very unreliable). It will return true on success

Public procedure closeOpenedConnections(); virtual; deprecated;

Warning: this symbol is deprecated.

Should close all connections (doesn''t work)

Public class function urlEncodeData(const data: string; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static;

Encodes the passed string in the url encoded format

Public class function urlEncodeData(data: TStringList; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static;

Encodes all var=... pairs of data in the url encoded format

Public class function reactFromCodeString(const codes: string; actualCode: integer; var reaction: TInternetAccessReaction): string; static;

parses a string like 200=accept,400=abort,300=redirect

Public function internalHandle: TObject; virtual; abstract;
 

Properties

Public property lastHTTPResultCode: longint read getlastHTTPResultCode;

HTTP Status code of the last request

Public property lastUrl: string read getLastUrl write setLastUrl;

Last retrieved URL

Public property lastHTTPHeaders: THTTPHeaderList read getLastHTTPHeaders;

HTTP headers received by the last request

Public property config: PInternetConfig read getConfig write setConfig;
 
Published property OnTransferStart: TTransferStartEvent read FOnTransferStart write FOnTransferStart;
 
Published property OnTransferReact: TTransferReactEvent read FOnTransferReact write FOnTransferReact;
 
Published property OnTransferEnd: TTransferEndEvent read FOnTransferEnd write FOnTransferEnd;
 
Published property OnProgress: TProgressEvent read FOnProgress write FOnProgress;
 

Generated by PasDoc 0.16.0.