TChilkatHttpRequest Delphi Reference
TChilkatHttpRequest
Represents a complete HTTP request.
Object Creation
var
obj: TChilkatHttpRequest;
...
begin
obj := TChilkatHttpRequest.Create(Self);
Properties
property Charset: WideString
Controls the character encoding used for HTTP request parameters for POST requests. The default value is "utf-8". The charset should match the charset expected by the form target.
property HttpVersion: WideString
The HTTP version in the request header. Defaults to "1.1".
property LastErrorHtml: WideString readonly
Error information in HTML format for the last method called.
property LastErrorText: WideString readonly
Error information in plain-text format for the last method called.
property LastErrorXml: WideString readonly
Error information in XML format for the last method called.
property NumHeaderFields: Integer readonly
Returns the number of request header fields.
property NumParams: Integer readonly
Returns the number of query parameters.
property Path: WideString
The path of the resource requested. A path of "/" indicates the default document for a domain.
property SendCharset: Integer
Controls whether the charset is explicitly included in the content-type header field of the HTTP POST request.
Methods
function AddFileForUpload(name: WideString, filename: WideString): Integer;
Adds a file to an upload request. To create a file upload request, call UseUpload and then call AddFileForUpload for each file to be uploaded.
procedure AddHeader(name: WideString, value: WideString);
Adds a request header to the HTTP request. If a header having the same field name is already present, this method replaces it.
procedure AddParam(name: WideString, value: WideString);
Adds a request query parameter (name/value pair) to the HTTP request. The name and value strings passed to this method should not be URL encoded.
function GenerateRequestText(): WideString;
Returns the request text that would be sent if Http.SynchronousRequest was called. Returns a null on failure
function GetHeaderField(name: WideString): WideString;
Returns the value of a request header field. Returns a null on failure
function GetHeaderName(index: Integer): WideString;
Returns the Nth request header field name. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns a null on failure
function GetHeaderValue(index: Integer): WideString;
Returns the Nth request header field value. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns a null on failure
function GetParam(name: WideString): WideString;
Returns a request query parameter value by name. Returns a null on failure
function GetParamName(index: Integer): WideString;
Returns the Nth request query parameter field name. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns a null on failure
function GetParamValue(index: Integer): WideString;
Returns the Nth request query parameter field value. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns a null on failure
function LoadBodyFromBytes(binaryData: OleVariant): Integer;
To be documented soon...
function LoadBodyFromFile(filename: WideString): Integer;
To be documented soon...
function LoadBodyFromString(bodyStr: WideString): Integer;
To be documented soon...
procedure RemoveAllParams();
Removes all request parameters.
procedure RemoveParam(name: WideString);
Removes a single HTTP request parameter by name.
function SaveLastError(filename: WideString): Integer;
Saves the last error information to an XML formatted file.
function Serialize(): WideString;
Serializes the HttpRequest object to a string. Returns a null on failure
procedure SetFromUrl(url: WideString);
Parses a URL and sets the Path and query parameters (NumParams, GetParam, GetParamName, GetParamValue).
procedure UseGet();
Makes the HttpRequest a GET request.
procedure UseHead();
Makes the HttpRequest a HEAD request.
procedure UsePost();
Makes the HttpRequest a POST request that uses the "application/x-www-form-urlencoded" content type.
procedure UseUpload();
Makes the HttpRequest a POST request that uses the "multipart/form-data" content type. To create a file upload request, call UseUpload and then call AddFileForUpload for each file to be uploaded.
procedure UseXmlHttp(xmlDoc: WideString);
Makes the HttpRequest a POST request using the "text/xml" content type. The request body is set to the XML string passed to this method.
|