Class TInternetAccess

DescriptionHierarchyInternal TypesFieldsMethodsProperties

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.

Hierarchy

  • TObject
  • TInternetAccess

Overview

Internal Types

Published THeaderEnumCallback = procedure (data: pointer; headerKindHint: THeaderKind; const name, value: string);
Published THeaderKind = (...);

Fields

Public internetConfig: PInternetConfig;
Public additionalHeaders: TStringList;
Public ContentTypeForData: string;
Public multipartFormData: TMIMEMultipartData;
Public lastHTTPResultCode: longint;
Public lastUrl: String;
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 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;
Public function needConnection():boolean; virtual; abstract;
Public procedure closeOpenedConnections(); virtual; abstract;
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 lastHTTPHeaders: TStringList read FLastHTTPHeaders;
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

Internal Types

Published THeaderEnumCallback = procedure (data: pointer; headerKindHint: THeaderKind; const name, value: string);
 
Published THeaderKind = (...);
 
Values
  • iahUnknown:  
  • iahContentType:  
  • iahAccept:  
  • iahReferer:  
  • iahLocation:  
  • iahSetCookie:  
  • iahCookie:  

Fields

Public internetConfig: PInternetConfig;

Configuration to use. Defaults to defaultInternetConfig

Public additionalHeaders: TStringList;

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 lastHTTPResultCode: longint;

HTTP Status code of the last request

Public lastUrl: String;

Last retrieved URL

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 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;

checks if an internet connection exists

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

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

Public procedure closeOpenedConnections(); virtual; abstract;

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 lastHTTPHeaders: TStringList read FLastHTTPHeaders;

HTTP headers received by the last request

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.14.0.