TChilkatHttpRequest Delphi Reference
TChilkatHttpRequest
Represents a complete HTTP request.
Object Creation
var
obj: TChilkatHttpRequest;
...
begin
obj := TChilkatHttpRequest.Create(Self);
...
// When finished, free the object instance.
obj.Free();
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 ContentType: WideString
To be documented soon...
property EntireHeader: WideString
To be documented soon...
property HttpVerb: WideString
To be documented soon...
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 AddBytesForUpload(name: WideString, remoteFileName: WideString, byteData: OleVariant): Integer;
Adds a file to an upload request where the contents of the file come from an in-memory byte array. To create a file upload request, call UseUpload and then call AddBytesForUpload, AddStringForUpload, or AddFileForUpload for each file to be uploaded.
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
remoteFileName is the name of the file to be created on the HTTP server.
byteData contains the contents (bytes) to be uploaded.
function AddBytesForUpload2(name: WideString, remoteFileName: WideString, byteData: OleVariant, contentType: WideString): Integer;
Same as AddBytesForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the remoteFileName's file extension.)
function AddFileForUpload(name: WideString, filePath: WideString): Integer;
Adds a file to an upload request. To create a file upload request, call UseUpload and then call AddFileForUpload, AddBytesForUpload, or AddStringForUpload for each file to be uploaded. This method does not read the file into memory. When the upload occurs, the data is streamed directly from the file, thus allowing for very large files to be uploaded without consuming large amounts of memory.
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
filePath is the path to an existing file in the local filesystem.
function AddFileForUpload2(name: WideString, filePath: WideString, contentType: WideString): Integer;
Same as AddFileForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the file extension.)
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
filePath is the path to an existing file in the local filesystem.
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 AddStringForUpload(name: WideString, filename: WideString, strData: WideString, charset: WideString): Integer;
Same as AddFileForUpload, but the upload data comes from an in-memory string instead of a file.
function AddStringForUpload2(name: WideString, filename: WideString, strData: WideString, charset: WideString, contentType: WideString): Integer;
Same as AddStringForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the ARG2's file extension.)
function GenerateRequestText(): WideString;
Returns the request text that would be sent if Http.SynchronousRequest was called. Returns a zero-length WideString on failure
function GetHeaderField(name: WideString): WideString;
Returns the value of a request header field. Returns a zero-length WideString 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 zero-length WideString 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 zero-length WideString on failure
function GetParam(name: WideString): WideString;
Returns a request query parameter value by name. Returns a zero-length WideString 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 zero-length WideString 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 zero-length WideString on failure
function GetUrlEncodedParams(): WideString;
To be documented soon. Returns a zero-length WideString on failure
function LoadBodyFromBytes(byteData: OleVariant): Integer;
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of the byteData.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
function LoadBodyFromFile(filePath: WideString): Integer;
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of filePath.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
function LoadBodyFromString(bodyStr: WideString, charset: WideString): Integer;
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of bodyStr.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
charset indicates the charset, such as "utf-8" or "iso-8859-1", to be used. The HTTP body will contain the bodyStr converted to this character encoding.
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 zero-length WideString on failure
procedure SetFromUrl(url: WideString);
Parses a URL and sets the Path and query parameters (NumParams, GetParam, GetParamName, GetParamValue).
function StreamBodyFromFile(filename: WideString): Integer;
To be documented soon...
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 UsePostMultipartForm();
Makes the HttpRequest a POST request that uses the "multipart/form-data" content type.
procedure UsePut();
Makes the HttpRequest a PUT request.
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 UseUploadPut();
To be documented soon...
procedure UseXmlHttp(xmlDoc: WideString);
Makes the HttpRequest a POST request using the "application/xml" content type. The request body is set to the XML string passed to this method.
|