Unit internetaccess

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

You can use this unit to configure and create internet connections.

Currently it only supports HTTP/S connections, but this might change in future (e.g. to also support ftp)

Overview

Classes, Interfaces, Objects and Records

Name Description
record TInternetConfig  
record TDecodedUrl A record storing a decoded url.
record TInternetAccessDataBlock  
record TMIMEMultipartSubData  
record TMIMEMultipartData  
record TCookieManager  
Class TInternetAccess Abstract base class for connections
Class EInternetException  

Functions and Procedures

function decodeURL(const totalURL: string; normalize: boolean = true): TDecodedUrl;
function decodeURL(const protocol, host, url: string; normalize: boolean = true): TDecodedUrl;
function guessType(const data: string): TRetrieveType;
function httpRequest(url: string): string; overload;
function httpRequest(url: string; rawpostdata: string): string; overload;
function httpRequest(url: string; postdata: TStringList): string; overload;
function httpRequest(const method, url, rawdata: string): string; overload;
function defaultInternet: TInternetAccess;
procedure freeThreadVars;

Types

PInternetConfigTInternetConfig;
TDecodedUrlParts = set of (dupProtocol, dupUsername, dupPassword, dupHost, dupPort, dupPath, dupParams, dupLinkTarget);
PMIMEMultipartSubData = ˆTMIMEMultipartSubData;
THTTPHeaderList = TStringList;
TCookieFlags = set of (cfHostOnly, cfSecure );
TInternetAccessReaction = (...);
TProgressEvent = procedure (sender: TObject; progress,maxprogress: longint) of object;
TTransferStartEvent = procedure (sender: TObject; var method: string; var url: TDecodedUrl; var data:string) of object;
TTransferClearEvent = procedure() of object;
TTransferBlockWriteEvent = TStreamLikeWrite;
TTransferReactEvent = procedure (sender: TInternetAccess; var method: string; var url: TDecodedUrl; var data: TInternetAccessDataBlock; var reaction: TInternetAccessReaction) of object;
TTransferEndEvent = procedure (sender: TObject; method: string; var url: TDecodedUrl; data:string; var result: string) of object;
TUrlEncodingModel = (...);
TInternetAccessClass=class of TInternetAccess;
TRetrieveType = (...);

Constants

DecodedUrlPartsALL = [dupProtocol, dupUsername, dupPassword, dupHost, dupPort, dupPath, dupParams, dupLinkTarget];
ContentTypeUrlEncoded: string = 'application/x-www-form-urlencoded';
ContentTypeMultipart: string = 'multipart/form-data';

Variables

defaultInternetConfiguration: TInternetConfig;
defaultInternetAccessClass:TInternetAccessClass = nil;

Description

Functions and Procedures

function decodeURL(const totalURL: string; normalize: boolean = true): TDecodedUrl;

Splits a url into parts

Parameters
normalize
performs some normalizations (e.g. foo//bar -> foo/bar)
function decodeURL(const protocol, host, url: string; normalize: boolean = true): TDecodedUrl;
 
function guessType(const data: string): TRetrieveType;

Guesses the type of a given string

E.g. for 'http://' it returns rtRemoteURL, for '/tmp' rtFile and for '<abc/>' rtXML.
Internally used by simpleinternet.retrieve to determine how to actually retrieve the data.

function httpRequest(url: string): string; overload;

Make a HTTP GET request to a certain url.

function httpRequest(url: string; rawpostdata: string): string; overload;

Make a HTTP POST request to a certain url, sending the data in rawpostdata unmodified to the server.

function httpRequest(url: string; postdata: TStringList): string; overload;

Make a HTTP POST request to a certain url, sending the data in postdata to the server, after url encoding all name=value pairs of it.

function httpRequest(const method, url, rawdata: string): string; overload;

Make a HTTP request to a certain url, sending the data in rawdata unmodified to the server.

function defaultInternet: TInternetAccess;

This provides a thread-safe default internet

procedure freeThreadVars;

If you use the procedural interface from different threads, you have to call freeThreadVars before the thread terminates to prevent memory leaks

Types

PInternetConfigTInternetConfig;
 
TDecodedUrlParts = set of (dupProtocol, dupUsername, dupPassword, dupHost, dupPort, dupPath, dupParams, dupLinkTarget);
 
PMIMEMultipartSubData = ˆTMIMEMultipartSubData;
 
THTTPHeaderList = TStringList;
 
TCookieFlags = set of (cfHostOnly, cfSecure );
 
TInternetAccessReaction = (...);
 
Values
  • iarAccept:  
  • iarFollowRedirectGET:  
  • iarFollowRedirectKeepMethod:  
  • iarRetry:  
  • iarReject:  
TProgressEvent = procedure (sender: TObject; progress,maxprogress: longint) of object;

Event to monitor the progress of a download (measured in bytes)

TTransferStartEvent = procedure (sender: TObject; var method: string; var url: TDecodedUrl; var data:string) of object;

Event to intercept transfers end/start

TTransferClearEvent = procedure() of object;
 
TTransferBlockWriteEvent = TStreamLikeWrite;
 
TTransferReactEvent = procedure (sender: TInternetAccess; var method: string; var url: TDecodedUrl; var data: TInternetAccessDataBlock; var reaction: TInternetAccessReaction) of object;
 
TTransferEndEvent = procedure (sender: TObject; method: string; var url: TDecodedUrl; data:string; var result: string) of object;
 
TUrlEncodingModel = (...);

URL Encoding encodes every special character #$AB by %AB. This model describes which characters are special:

Values
  • ueHTMLForm: Encode for application/x-www-form-urlencoded as defined in HTML 5 standard
  • ueURLPath: Encode for the path part of an URL
  • ueURLQuery: Encode for the query part of an URL
  • ueXPathURI: Encode for the XPath/XQuery function fn:encode-for-uri as defined in the XPath standard
  • ueXPathHTML4: Encode for the XPath/XQuery function fn:escape-html-uri as defined in the XPath standard (they quote the the HTML4 standard)
  • ueXPathFromIRI: Encode for the XPath/XQuery function fn:iri-to-uri as defined in the XPath standard
TInternetAccessClass=class of TInternetAccess;
 
TRetrieveType = (...);
 
Values
  • rtEmpty:  
  • rtRemoteURL:  
  • rtFile:  
  • rtXML:  
  • rtJSON:  

Constants

DecodedUrlPartsALL = [dupProtocol, dupUsername, dupPassword, dupHost, dupPort, dupPath, dupParams, dupLinkTarget];
 
ContentTypeUrlEncoded: string = 'application/x-www-form-urlencoded';
 
ContentTypeMultipart: string = 'multipart/form-data';
 

Variables

defaultInternetConfiguration: TInternetConfig;

default configuration, used by all internet access classes

defaultInternetAccessClass:TInternetAccessClass = nil;

default internet access. This controls which internet library the program will use.


Generated by PasDoc 0.14.0.