ChilkatHttpRequest ActiveX Reference

ChilkatHttpRequest

Represents a complete HTTP request.

Object Creation

(Visual Basic 6.0)
Dim obj As New ChilkatHttpRequest
(ASP)
set obj = Server.CreateObject("Chilkat.HttpRequest")
(VBScript)
set obj = CreateObject("Chilkat.HttpRequest")
(Delphi)
obj := TChilkatHttpRequest.Create(Self);
(FoxPro)
loObject = CreateObject('Chilkat.HttpRequest')
(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.HttpRequest', @obj OUT
(Javascript)
var obj = new ActiveXObject("Chilkat.HttpRequest");

Properties

Charset As String

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.

ContentType As String

To be documented soon...

EntireHeader As String

To be documented soon...

HttpVerb As String

To be documented soon...

HttpVersion As String

The HTTP version in the request header. Defaults to "1.1".

LastErrorHtml As String (read-only)

Error information in HTML format for the last method called.

LastErrorText As String (read-only)

Error information in plain-text format for the last method called.

LastErrorXml As String (read-only)

Error information in XML format for the last method called.

NumHeaderFields As Long (read-only)

Returns the number of request header fields.

NumParams As Long (read-only)

Returns the number of query parameters.

Path As String

The path of the resource requested. A path of "/" indicates the default document for a domain.

SendCharset As Long

Controls whether the charset is explicitly included in the content-type header field of the HTTP POST request.

Methods

AddBytesForUpload(name As String, remoteFileName As String, byteData As Variant) As Long

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.

AddBytesForUpload2(name As String, remoteFileName As String, byteData As Variant, contentType As String) As Long

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.)

AddFileForUpload(name As String, filePath As String) As Long

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.

AddFileForUpload2(name As String, filePath As String, contentType As String) As Long

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.

AddHeader(name As String, value As String)

Adds a request header to the HTTP request. If a header having the same field name is already present, this method replaces it.

(ASP) Adding Cookies to an HTTP Request

(VB6) Adding Cookies to an HTTP Request

(Delphi) Adding Cookies to an HTTP Request

(FoxPro) Adding Cookies to an HTTP Request

(PHP using ActiveX) Adding Cookies to an HTTP Request

(VBScript) Adding Cookies to an HTTP Request

AddParam(name As String, value As String)

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.

AddStringForUpload(name As String, filename As String, strData As String, charset As String) As Long

Same as AddFileForUpload, but the upload data comes from an in-memory string instead of a file.

AddStringForUpload2(name As String, filename As String, strData As String, charset As String, contentType As String) As Long

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.)

GenerateRequestText() As String

Returns the request text that would be sent if Http.SynchronousRequest was called.

Returns a null on failure

GetHeaderField(name As String) As String

Returns the value of a request header field.

Returns a null on failure

GetHeaderName(index As Long) As String

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

GetHeaderValue(index As Long) As String

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

GetParam(name As String) As String

Returns a request query parameter value by name.

Returns a null on failure

GetParamName(index As Long) As String

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

GetParamValue(index As Long) As String

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

GetUrlEncodedParams() As String

To be documented soon.

Returns a null on failure

LoadBodyFromBytes(byteData As Variant) As Long

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.

LoadBodyFromFile(filePath As String) As Long

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.

LoadBodyFromString(bodyStr As String, charset As String) As Long

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.

RemoveAllParams()

Removes all request parameters.

RemoveParam(name As String)

Removes a single HTTP request parameter by name.

SaveLastError(filename As String) As Long

Saves the last error information to an XML formatted file.

Serialize() As String

Serializes the HttpRequest object to a string.

Returns a null on failure

SetFromUrl(url As String)

Parses a URL and sets the Path and query parameters (NumParams, GetParam, GetParamName, GetParamValue).

StreamBodyFromFile(filename As String) As Long

To be documented soon...

UseGet()

Makes the HttpRequest a GET request.

UseHead()

Makes the HttpRequest a HEAD request.

UsePost()

Makes the HttpRequest a POST request that uses the "application/x-www-form-urlencoded" content type.

UsePostMultipartForm()

Makes the HttpRequest a POST request that uses the "multipart/form-data" content type.

UsePut()

Makes the HttpRequest a PUT request.

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.

UseUploadPut()

To be documented soon...

UseXmlHttp(xmlDoc As String)

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.