Class TInternetAccess
Unit
internetaccess
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
Methods
|
class function parseHeaderLineKind(const line: string): THeaderKind; static; |
|
function getFinalMultipartFormData: string; |
|
function getLastContentType: string; |
|
constructor create(); virtual; |
|
constructor create(const internetConfig: TInternetConfig); virtual; |
|
destructor Destroy; override; |
|
function post(const totalUrl, data:string):string; |
|
function post(const protocol,host,url: string; data:string):string; |
|
procedure get(const totalUrl: string; stream:TStream); |
|
function get(const totalUrl: string):string; |
|
procedure get(const protocol,host,url: string; stream:TStream); |
|
function get(const protocol,host,url: string):string; |
|
function request(const method, fullUrl, data:string):string; |
|
function request(method, protocol,host,url, data:string):string; |
|
function request(method: string; url: TDecodedUrl; data:string):string; |
|
procedure request(const method: string; const url: TDecodedUrl; const uploadData:string; outStream: TStream); |
|
procedure request(const method: string; const url: TDecodedUrl; const uploadData: TInternetAccessDataBlock; const onClear: TTransferClearEvent; const onReceivedBlock: TTransferBlockWriteEvent); |
|
function existsConnection():boolean; virtual; deprecated; |
|
function needConnection():boolean; virtual; deprecated; |
|
procedure closeOpenedConnections(); virtual; deprecated; |
|
class function urlEncodeData(const data: string; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static; |
|
class function urlEncodeData(data: TStringList; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static; |
|
class function reactFromCodeString(const codes: string; actualCode: integer; var reaction: TInternetAccessReaction): string; static; |
|
function internalHandle: TObject; virtual; abstract; |
Properties
Description
Fields
|
additionalHeaders: THTTPHeaderList; |
Defines additional headers that should be send to the server
|
|
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.
|
Methods
|
class function parseHeaderLineKind(const line: string): THeaderKind; static; |
|
|
function getFinalMultipartFormData: string; |
|
|
function getLastContentType: string; |
Same as getLastHTTPHeader('Content-Type') but easier to remember and without magic string
|
|
constructor create(); virtual; |
|
|
destructor Destroy; override; |
|
|
function post(const totalUrl, data:string):string; |
post the (raw) data to the given url and returns the resulting document as string
|
|
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
|
|
procedure get(const totalUrl: string; stream:TStream); |
get the url as stream
|
|
function get(const totalUrl: string):string; |
get the url as string
|
|
procedure get(const protocol,host,url: string; stream:TStream); |
get the url as stream
|
|
function get(const protocol,host,url: string):string; |
get the url as string
|
|
function request(const method, fullUrl, data:string):string; |
performs a HTTP request
|
|
function request(method, protocol,host,url, data:string):string; |
performs a HTTP request
|
|
function request(method: string; url: TDecodedUrl; data:string):string; |
performs a HTTP request
|
|
procedure request(const method: string; const url: TDecodedUrl; const uploadData:string; outStream: TStream); |
performs a HTTP request
|
|
function existsConnection():boolean; virtual; deprecated; |
Warning: this symbol is deprecated.
checks if an internet connection exists
|
|
function needConnection():boolean; virtual; deprecated; |
Warning: this symbol is deprecated.
call this to open a connection (very unreliable). It will return true on success
|
|
procedure closeOpenedConnections(); virtual; deprecated; |
Warning: this symbol is deprecated.
Should close all connections (doesn''t work)
|
|
class function urlEncodeData(const data: string; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static; |
Encodes the passed string in the url encoded format
|
|
class function urlEncodeData(data: TStringList; encodingModel: TUrlEncodingModel = ueHTMLForm): string; static; |
Encodes all var=... pairs of data in the url encoded format
|
|
class function reactFromCodeString(const codes: string; actualCode: integer; var reaction: TInternetAccessReaction): string; static; |
parses a string like 200=accept,400=abort,300=redirect
|
|
function internalHandle: TObject; virtual; abstract; |
|
Properties
|
property lastHTTPResultCode: longint read getlastHTTPResultCode; |
HTTP Status code of the last request
|
|
property lastUrl: string read getLastUrl write setLastUrl; |
Last retrieved URL
|
|
property lastHTTPHeaders: THTTPHeaderList read getLastHTTPHeaders; |
HTTP headers received by the last request
|
|
property OnProgress: TProgressEvent read FOnProgress write FOnProgress; |
|
Generated by PasDoc 0.16.0.