Unit OSM.NetworkRequest
Description
Generic (no real network implementation) classes and declarations for requesting OSM tile images from network. Real network function from any framework must be supplied to actually execute request.
DEFINES:
OSM_Trace - print request trace messages to Windows debug log
(c) Fr0sT-Brutal https://github.com/Fr0sT-Brutal/Delphi_OSMMap
Overview
Classes, Interfaces, Objects and Records
Name | Description |
---|---|
Class THttpRequestProps |
Generic properties of request. |
Class TNetworkRequestQueue |
Queuer of network requests. |
Functions and Procedures
procedure CheckEngineCap(NeededCap: THttpRequestCapability; Caps: THttpRequestCapabilities); |
procedure CheckEngineCaps(RequestProps: THttpRequestProps; EngineCapabilities: THttpRequestCapabilities); |
function IsHTTPError(ResponseCode: Word): Boolean; |
procedure CheckHTTPError(ResponseCode: Word; const ResponseText: string); |
function GetSystemProxy(const URL: string; out Bypass: TArray<string>): string; overload; |
function GetSystemProxy(const URL: string): string; overload; |
Types
THttpRequestCapability = (...); |
THttpRequestCapabilities = set of THttpRequestCapability; |
TNetworkClient = TObject; |
TBlockingNetworkRequestProc = procedure (RequestProps: THttpRequestProps; ResponseStm: TStream; var Client: TNetworkClient); |
TGotTileCallbackBgThr = procedure (const Tile: TTile; Ms: TMemoryStream; const Error: string) of object; |
Constants
HTTPProto = 'http'; |
HTTPTLSProto = 'https'; |
ProtoSep = '://'; |
HTTPProxyProto = HTTPProto + ProtoSep; |
SystemProxy = HTTPProxyProto + 'SYSTEM'; |
ReqTimeout = 5*MSecsPerSec; |
SampleUserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0'; |
SampleHeaders: array[0..2] of string =
(
'User-Agent: ' + SampleUserAgent,
'Accept-Language: en-US;q=0.7,en;q=0.3',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
); |
Description
Functions and Procedures
procedure CheckEngineCap(NeededCap: THttpRequestCapability; Caps: THttpRequestCapabilities); |
Check if capability is in set of capabilities and raise exception if not |
procedure CheckEngineCaps(RequestProps: THttpRequestProps; EngineCapabilities: THttpRequestCapabilities); |
Check if a network engine is capable of handling all the request properties. Checks for: htcProxy, htcSystemProxy, htcProxyAuth, htcAuth, htcAuthURL, htcTLS, htcHeaders. |
function IsHTTPError(ResponseCode: Word): Boolean; |
Return true if response code means HTTP error |
procedure CheckHTTPError(ResponseCode: Word; const ResponseText: string); |
Check if response code means HTTP error, raise exception then |
function GetSystemProxy(const URL: string; out Bypass: TArray<string>): string; overload; |
Retrieve system proxy for given URL (http, https). Only returns HTTP proxies (not Socks). On Windows uses InternetQueryOption, on Linux takes env variables |
function GetSystemProxy(const URL: string): string; overload; |
Overload when addresses to bypass proxy are not of interest |
Types
THttpRequestCapability = (...); |
Capabilities that a network engine has Values
|
THttpRequestCapabilities = set of THttpRequestCapability; |
This item has no description. |
TNetworkClient = TObject; |
Base class for network client object. Used when request queue is performed through the same connection. Destructor of the object is called when the queue is empty and it must free all allocated resources. |
TBlockingNetworkRequestProc = procedure (RequestProps: THttpRequestProps; ResponseStm: TStream; var Client: TNetworkClient); |
Generic type of blocking network request procedure. Procedure must:
Parameters
Exceptions raised
|
TGotTileCallbackBgThr = procedure (const Tile: TTile; Ms: TMemoryStream; const Error: string) of object; |
Generic type of method to call when request is completed Parameters
|
Constants
HTTPProto = 'http'; |
This item has no description. |
HTTPTLSProto = 'https'; |
This item has no description. |
ProtoSep = '://'; |
This item has no description. |
HTTPProxyProto = HTTPProto + ProtoSep; |
Prefix to add to proxy URLs if it only contains |
SystemProxy = HTTPProxyProto + 'SYSTEM'; |
Internal constant to designate OS-wide proxy |
ReqTimeout = 5*MSecsPerSec; |
Timeout for connect and request |
SampleUserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0'; |
This item has no description. |
SampleHeaders: array[0..2] of string =
(
'User-Agent: ' + SampleUserAgent,
'Accept-Language: en-US;q=0.7,en;q=0.3',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
); |
Headers that you could add to TNetworkRequestQueue.RequestProps.HeaderLines. F.ex., openstreetmap.org dislikes requests without user-agent. |
Author
Generated by PasDoc 0.16.0.