Reference THttpClient
Declared in Codebot.Networking.Web.pas on line 181
THttpClient implements the http 1.0 client protocol
THttpClient = class
protected
{ Complete is invoked when Process is about to return true }
procedure Complete; virtual;
{ Invoke the OnCancel event }
procedure DoCancel; virtual;
{ Invoke the OnHeaderComplete event }
procedure DoHeaderComplete; virtual;
{ Invoke the OnResponseComplete event }
procedure DoComplete; virtual;
{ Invoke the OnProgress event }
procedure DoProgress(const Size, Transmitted: LargeWord); virtual;
public
{ Create an http client instance }
constructor Create;
destructor Destroy; override;
{ Clear the last response }
procedure Clear;
{ Cancel an ongoing response, can be invoked automatically when an
unexpected condition is encountered }
procedure Cancel;
{ Request a copy of the response header }
procedure CopyHeader(out Header: THttpResponseHeader);
{ Send an HTTP GET request }
function Get(const Url: TUrl): Boolean; overload;
{ Send an HTTP GET request with custom headers }
function Get(const Url: TUrl; const Headers: TNamedStrings): Boolean; overload;
{ Send an HTTP POST request with custom headers and content }
function Post(const Url: TUrl; const Headers: TNamedStrings; const ContentType: string; const Content: string): Boolean;
{ Send an HTTP POST request with an arguments form body }
function PostArgs(const Url: TUrl; const Args: TNamedStrings): Boolean;
{ Send an HTTP POST request with a json body }
function PostJson(const Url: TUrl; const Json: string): Boolean;
{ Send an HTTP POST request with an xml body }
function PostXml(const Url: TUrl; const Xml: string): Boolean;
{ Optional size in bytes of the response buffer }
property BufferSize: Integer read FBufferSize write FBufferSize;
{ Holds true if the last request completed properly }
property Completed: Boolean read FCompleted;
{ The user agent as seen by the server }
property UserAgent: string read FUserAgent write FUserAgent;
{ The response code returned from the server }
property Code: Integer read GetCode;
{ The response status returned from the server }
property Status: string read GetStatus;
{ Response header names }
property Names[Index: Integer]: string read GetName;
{ Response header values }
property Values[Name: string]: string read GetValue;
{ Response header name count }
property NameCount: Integer read GetNameCount;
{ Set ResponseStream to write the response body to a stream }
property ResponseStream: TStream read FResponseStream write FResponseStream;
{ If ResponseStream is nil then the response body is stored in ResponseText
instead }
property ResponseText: string read GetResponseText;
{ OnCancel is invoked if the request is stopped before completion }
property OnCancel: TNotifyEvent read FFOnCancel write FFOnCancel;
{ OnHeaderComplete is invoked after a complete response header is read }
property OnHeaderComplete: TTransmistHeaderCompleteEvent read FOnHeaderComplete write FOnHeaderComplete;
{ OnProgress is invoked after the response header is received while bytes
are being read }
property OnProgress: TTransmitEvent read FOnProgress write FOnProgress;
{ OnComplete is invoked after a response is read in its entirety }
property OnComplete: TNotifyEvent read FOnComplete write FOnComplete;
end;See also
LargeWord in Codebot.System.pas
TNamedStrings in Codebot.System.pas
TTransmitEvent in Codebot.Networking.pas