Difference between revisions of "THTTPClient"

From Ultibo.org
Jump to: navigation, search
(Created page with "Return to Unit HTTP __TOC__ === Description === ---- ''To be documented'' === Class definitions === ---- <div class="toccolours mw-collapsible mw-collapse...")
 
(No difference)

Latest revision as of 06:30, 17 May 2018

Return to Unit HTTP


Description


To be documented

Class definitions



THTTPClient = class(TWinsock2TCPClient)

public
constructor Create;  
destructor Destroy; override;  
private
FLock:TCriticalSectionHandle;  
 
FState:LongWord; Internal request state
FBuffer:THTTPBuffer; Buffer for received data
 
FRequest:THTTPClientRequest;  
FResponse:THTTPClientResponse;  
 
FTimeout:LongWord;  
FUserAgent:String;  
FAllowRedirect:Boolean;  
FMaxRedirects:LongWord;  
FKeepAlive:Boolean;  
FKeepAliveTimeout:LongWord;  
 
FOnRedirect:THTTPRedirectEvent;  
FOnPassword:THTTPPasswordEvent;  
 
FHost:String;  
FPort:String;  
FUsername:String;  
FPassword:String;  
 
FProxyHost:String;  
FProxyPort:String;  
FProxyUsername:String;  
FProxyPassword:String;  
 
FURL:String;  
FMethod:LongWord;  
FVersion:LongWord;  
FMimeType:String;  
FRangeStart:LongWord;  
FRangeEnd:LongWord;  
FEncoding:LongWord;  
 
procedure SetTimeout(ATimeout:LongWord);  
function GetUserAgent:String;  
procedure SetUserAgent(const AUserAgent:String);  
procedure SetAllowRedirect(AAllowRedirect:Boolean);  
procedure SetMaxRedirects(AMaxRedirects:LongWord);  
procedure SetKeepAlive(AKeepAlive:Boolean);  
procedure SetKeepAliveTimeout(AKeepAliveTimeout:LongWord);  
 
function GetHost:String;  
procedure SetHost(const AHost:String);  
function GetPort:String;  
procedure SetPort(const APort:String);  
function GetUsername:String;  
procedure SetUsername(const AUsername:String);  
function GetPassword:String;  
procedure SetPassword(const APassword:String);  
 
function GetProxyHost:String;  
procedure SetProxyHost(const AProxyHost:String);  
function GetProxyPort:String;  
procedure SetProxyPort(const AProxyPort:String);  
function GetProxyUsername:String;  
procedure SetProxyUsername(const AProxyUsername:String);  
function GetProxyPassword:String;  
procedure SetProxyPassword(const AProxyPassword:String);  
 
function GetURL:String;  
procedure SetURL(const AURL:String);  
procedure SetMethod(AMethod:LongWord);  
procedure SetVersion(AVersion:LongWord);  
function GetMimeType:String;  
procedure SetMimeType(const AMimeType:String);  
procedure SetRangeStart(ARangeStart:LongWord);  
procedure SetRangeEnd(ARangeEnd:LongWord);  
procedure SetEncoding(AEncoding:LongWord);  
 
function GetResponseStatus:LongWord;  
function GetResponseReason:String;  
function GetResponseVersion:LongWord;  
function GetResponseMimeType:String;  
function GetResponseEncoding:LongWord;  
function GetResponseContentSize:LongWord;  
protected
function AcquireLock:Boolean;  
function ReleaseLock:Boolean;  
 
function DoRedirect(const AURL:String; var ALocation:String):Boolean;  
function DoPassword(var AUsername,APassword:String):Boolean;  
 
function ReadResponseLine(AResponse:THTTPClientResponse):Boolean;  
function ReadResponseHeaders(AResponse:THTTPClientResponse):Boolean;  
function ReadResponseContentStream(AResponse:THTTPClientResponse; AContent:TStream; ASize:LongWord):Boolean;  
function ReadResponseContentString(AResponse:THTTPClientResponse; var AContent:String; ASize:LongWord):Boolean;  
 
function WriteRequestLine(ARequest:THTTPClientRequest):Boolean;  
function WriteRequestHeaders(ARequest:THTTPClientRequest):Boolean;  
function WriteRequestContentStream(ARequest:THTTPClientRequest; AContent:TStream; ASize:LongWord):Boolean;  
function WriteRequestContentString(ARequest:THTTPClientRequest; const AContent:String; ASize:LongWord):Boolean;  
public
property Request:THTTPClientRequest read FRequest;  
property Response:THTTPClientResponse read FResponse;  
 
property Timeout:LongWord read FTimeout write SetTimeout;  
property UserAgent:String read GetUserAgent write SetUserAgent;  
property AllowRedirect:Boolean read FAllowRedirect write SetAllowRedirect;  
property MaxRedirects:LongWord read FMaxRedirects write SetMaxRedirects;  
property KeepAlive:Boolean read FKeepAlive write SetKeepAlive;  
property KeepAliveTimeout:LongWord read FKeepAliveTimeout write SetKeepAliveTimeout;  
 
property OnRedirect:THTTPRedirectEvent read FOnRedirect write FOnRedirect;  
property OnPassword:THTTPPasswordEvent read FOnPassword write FOnPassword;  
 
property Host:String read GetHost write SetHost;  
property Port:String read GetPort write SetPort;  
property Username:String read GetUsername write SetUsername;  
property Password:String read GetPassword write SetPassword;  
 
property ProxyHost:String read GetProxyHost write SetProxyHost;  
property ProxyPort:String read GetProxyPort write SetProxyPort;  
property ProxyUsername:String read GetProxyUsername write SetProxyUsername;  
property ProxyPassword:String read GetProxyPassword write SetProxyPassword;  
 
property RequestURL:String read GetURL write SetURL;  
property RequestMethod:LongWord read FMethod write SetMethod;  
property RequestVersion:LongWord read FVersion write SetVersion;  
property RequestMimeType:String read GetMimeType write SetMimeType;  
property RequestRangeStart:LongWord read FRangeStart write SetRangeStart;  
property RequestRangeEnd:LongWord read FRangeEnd write SetRangeEnd;  
property RequestEncoding:LongWord read FEncoding write SetEncoding;  
 
property ResponseStatus:LongWord read GetResponseStatus;  
property ResponseReason:String read GetResponseReason;  
property ResponseVersion:LongWord read GetResponseVersion;  
property ResponseMimeType:String read GetResponseMimeType;  
property ResponseEncoding:LongWord read GetResponseEncoding;  
property ResponseContentSize:LongWord read GetResponseContentSize;  
 
function Head(const AURL:String):Boolean;  
 
function GetString(const AURL:String; var AContent:String):Boolean;  
function GetStream(const AURL:String; AContent:TStream):Boolean;  
 
function PostString(const AURL:String; var AContent:String):Boolean;  
function PostStream(const AURL:String; AContent:TStream):Boolean;  
 
function SendRequest:Boolean;  
function CloseRequest(Close:Boolean):Boolean;  
function ClearRequest:Boolean;  
function CancelRequest:Boolean;  
 
function SetRequestParam(const AName,AValue:String):Boolean;  
function SetRequestParamEx(const AName,AValue:String; AReplace:Boolean):Boolean;  
 
function SetRequestHeader(const AName,AValue:String):Boolean;  
function SetRequestHeaderEx(const AName,AValue:String; AReplace:Boolean):Boolean;  
 
function SetRequestContentStream(AContent:TStream):Boolean;  
function AddRequestContentString(const AContent:String):Boolean;  
function SetRequestContentString(const AContent:String):Boolean;  
 
function GetResponseHeader(const AName:String):String;  
function GetResponseHeaderEx(const AName:String):TStringList;  
 
function GetResponseContentStream(AContent:TStream; ASize:LongWord):Boolean;  
function GetResponseContentString(var AContent:String; ASize:LongWord):Boolean;  


Function declarations



constructor THTTPClient.Create;
Description: To be documented
Note None documented


destructor THTTPClient.Destroy;
Description: To be documented
Note None documented


procedure THTTPClient.SetTimeout(ATimeout:LongWord);
Description: To be documented
Note None documented


function THTTPClient.GetUserAgent:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetUserAgent(const AUserAgent:String);
Description: To be documented
Note None documented


procedure THTTPClient.SetAllowRedirect(AAllowRedirect:Boolean);
Description: To be documented
Note None documented


procedure THTTPClient.SetMaxRedirects(AMaxRedirects:LongWord);
Description: To be documented
Note None documented


procedure THTTPClient.SetKeepAlive(AKeepAlive:Boolean);
Description: To be documented
Note None documented


procedure THTTPClient.SetKeepAliveTimeout(AKeepAliveTimeout:LongWord);
Description: To be documented
Note None documented


function THTTPClient.GetHost:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetHost(const AHost:String);
Description: To be documented
Note None documented


function THTTPClient.GetPort:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetPort(const APort:String);
Description: To be documented
Note None documented


function THTTPClient.GetUsername:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetUsername(const AUsername:String);
Description: To be documented
Note None documented


function THTTPClient.GetPassword:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetPassword(const APassword:String);
Description: To be documented
Note None documented


function THTTPClient.GetProxyHost:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetProxyHost(const AProxyHost:String);
Description: To be documented
Note None documented


function THTTPClient.GetProxyPort:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetProxyPort(const AProxyPort:String);
Description: To be documented
Note None documented


function THTTPClient.GetProxyUsername:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetProxyUsername(const AProxyUsername:String);
Description: To be documented
Note None documented


function THTTPClient.GetProxyPassword:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetProxyPassword(const AProxyPassword:String);
Description: To be documented
Note None documented


function THTTPClient.GetURL:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetURL(const AURL:String);
Description: To be documented
Note None documented


procedure THTTPClient.SetMethod(AMethod:LongWord);
Description: To be documented
Note None documented


procedure THTTPClient.SetVersion(AVersion:LongWord);
Description: To be documented
Note None documented


function THTTPClient.GetMimeType:String;
Description: To be documented
Note None documented


procedure THTTPClient.SetMimeType(const AMimeType:String);
Description: To be documented
Note None documented


procedure THTTPClient.SetRangeStart(ARangeStart:LongWord);
Description: To be documented
Note None documented


procedure THTTPClient.SetRangeEnd(ARangeEnd:LongWord);
Description: To be documented
Note None documented


procedure THTTPClient.SetEncoding(AEncoding:LongWord);
Description: To be documented
Note None documented


function THTTPClient.GetResponseStatus:LongWord;
Description: To be documented
Note None documented


function THTTPClient.GetResponseReason:String;
Description: To be documented
Note None documented


function THTTPClient.GetResponseVersion:LongWord;
Description: To be documented
Note None documented


function THTTPClient.GetResponseMimeType:String;
Description: To be documented
Note None documented


function THTTPClient.GetResponseEncoding:LongWord;
Description: To be documented
Note None documented


function THTTPClient.GetResponseContentSize:LongWord;
Description: To be documented
Note None documented


function THTTPClient.AcquireLock:Boolean;
Description: To be documented
Note None documented


function THTTPClient.ReleaseLock:Boolean;
Description: To be documented
Note None documented


function THTTPClient.DoRedirect(const AURL:String; var ALocation:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.DoPassword(var AUsername,APassword:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.ReadResponseLine(AResponse:THTTPClientResponse):Boolean;
Description: To be documented
Note None documented


function THTTPClient.ReadResponseHeaders(AResponse:THTTPClientResponse):Boolean;
Description: To be documented
Note None documented


function THTTPClient.ReadResponseContentStream(AResponse:THTTPClientResponse; AContent:TStream; ASize:LongWord):Boolean;
Description: If Size is 0 then read the entire content to the stream
Note None documented


function THTTPClient.ReadResponseContentString(AResponse:THTTPClientResponse; var AContent:String; ASize:LongWord):Boolean;
Description: If Size is 0 then read the entire content to the string
Note None documented


function THTTPClient.WriteRequestLine(ARequest:THTTPClientRequest):Boolean;
Description: To be documented
Note None documented


function THTTPClient.WriteRequestHeaders(ARequest:THTTPClientRequest):Boolean;
Description: To be documented
Note None documented


function THTTPClient.WriteRequestContentStream(ARequest:THTTPClientRequest; AContent:TStream; ASize:LongWord):Boolean;
Description: To be documented
Note None documented


function THTTPClient.WriteRequestContentString(ARequest:THTTPClientRequest; const AContent:String; ASize:LongWord):Boolean;
Description: To be documented
Note None documented


function THTTPClient.Head(const AURL:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.GetString(const AURL:String; var AContent:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.GetStream(const AURL:String; AContent:TStream):Boolean;
Description: To be documented
Note None documented


function THTTPClient.PostString(const AURL:String; var AContent:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.PostStream(const AURL:String; AContent:TStream):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SendRequest:Boolean;
Description: To be documented
Note None documented


function THTTPClient.CloseRequest(Close:Boolean):Boolean;
Description: To be documented
Note None documented


function THTTPClient.ClearRequest:Boolean;
Description: To be documented
Note None documented


function THTTPClient.CancelRequest:Boolean;
Description: To be documented
Note No lock to allow another thread to cancel the request


function THTTPClient.SetRequestParam(const AName,AValue:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SetRequestParamEx(const AName,AValue:String; AReplace:Boolean):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SetRequestHeader(const AName,AValue:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SetRequestHeaderEx(const AName,AValue:String; AReplace:Boolean):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SetRequestContentStream(AContent:TStream):Boolean;
Description: To be documented
Note None documented


function THTTPClient.AddRequestContentString(const AContent:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.SetRequestContentString(const AContent:String):Boolean;
Description: To be documented
Note None documented


function THTTPClient.GetResponseHeader(const AName:String):String;
Description: To be documented
Note None documented


function THTTPClient.GetResponseHeaderEx(const AName:String):TStringList;
Description: To be documented
Note None documented


function THTTPClient.GetResponseContentStream(AContent:TStream; ASize:LongWord):Boolean;
Description: To be documented
Note None documented


function THTTPClient.GetResponseContentString(var AContent:String; ASize:LongWord):Boolean;
Description: To be documented
Note None documented


Return to Unit Reference