HttpCurl ActiveX Reference Documentation

HttpCurl

Current Version: 11.5.0

The Chilkat.HttpCurl class executes curl commands and can automatically resolve dependent values needed by a request.

Variables such as {{access_token}}, {{site_id}}, or {{drive_id}} may appear in URLs, headers, query parameters, or request bodies. If a variable is not yet known, HttpCurl builds an execution plan from previously defined curl functions, runs the required steps, extracts values from JSON responses, and then executes the final target request.

Use AddFunction with AddOutput or AddOutput2 to define how prerequisite values are obtained. Use SetVar to provide known values, ClearVar to invalidate them, and ExaminePlan to inspect the dependency plan before running it.

After DoYourThing completes, the response can be read as text, binary data, JSON, XML, or streamed directly to a file. Diagnostic properties such as StatusCode, FailReason, FailedCurl, and LastErrorText help troubleshoot failures.

Note: Chilkat's HttpCurl does not derived from curl/libcurl, and does not wrap libcurl.

See Also:
  • HttpCurl Overview — A more complete introduction to the HttpCurl class, including concepts, variable substitution, dependency resolution, and workflow examples.
  • Dependency Engine — Explains how HttpCurl automatically derives execution plans, resolves unknown variables, determines prerequisite requests, and manages cached variables.

Object Creation

Note:
For a specific major version, use "Chilkat.HttpCurl.<major_version>", such as "Chilkat.HttpCurl.10" for Chilkat v10.*.*
See Chilkat ActiveX Object Creation

(ASP)
set obj = Server.CreateObject("Chilkat.HttpCurl")

(AutoIt)
$obj = ObjCreate("Chilkat.HttpCurl")

(Visual Basic 6.0)
Dim obj As New ChilkatHttpCurl

(VBScript)
set obj = CreateObject("Chilkat.HttpCurl")

(VBA, such as Excel)
Dim obj As New ChilkatHttpCurl
See How to Use ActiveX in Excel

(Delphi)
obj := TChilkatHttpCurl.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat.HttpCurl')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat.HttpCurl")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.HttpCurl', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat.HttpCurl");

Properties

DebugLogFilePath
DebugLogFilePath As String

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

top
EnableBodyVars
EnableBodyVars As Long
Introduced in version 11.5.0

Enables variable substitution in the body of the request. The default value is 1.

top
FailedCurl
FailedCurl As String (read-only)
Introduced in version 11.5.0

Set to the specific curl command in the execution plan that failed.

top
FailReason
FailReason As Long (read-only)
Introduced in version 11.5.0

Set to an integer value indicating the reason for failure for the methods DoYourThing and ExaminePlan

Possible values are:

  1. No error - the method succeeded or hasn't yet been called.
  2. curl command syntax error.
  3. HTTP response status code indidcates an authentication (401) or authorization (403) error.
  4. HTTP response status code indicates an error, but not an authentication or authorization error.
  5. HTTP communications failure.
  6. Impossible to derive an execution plan from defined outputs and inputs.
  7. A step in the execution plan did not resolve any dependency variables.
  8. Failed to get curl data from a local file source (see the note below).
  9. If we are within a Chilkat.Js context and don't have permission to read the local filesystem.
  10. Chilkat has not been successfully unlocked by previously and successfully calling UnlockBundle.
  11. Failed to open or create the local output file (if a curl option directed output to a file).

Note: curl can read data from a local file and send it in a request (usually POST/PUT) using special syntax:

  • -d @file.txt → reads the file and sends it as request body (form-style encoding).
  • --data-binary @file.bin → sends raw file contents exactly as-is.
  • -F "file=@file.txt" → uploads the file as multipart/form-data.

The @ tells curl to load the data from a local file instead of using a literal string.

top
HeartbeatMs
HeartbeatMs As Long
Introduced in version 11.5.0

Specifies the interval, in milliseconds, between AbortCheck event callbacks.

This allows an application to periodically decide whether a long-running operation should be aborted.

The default value is 0, which means no AbortCheck callbacks are generated.

top
LastBinaryResult
LastBinaryResult As Variant (read-only)

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastErrorHtml
LastErrorHtml As String (read-only)

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
LastErrorText As String (read-only)

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
LastErrorXml As String (read-only)

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
LastMethodSuccess As Long

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LastStringResult
LastStringResult As String (read-only)

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
LastStringResultLen As Long (read-only)

The length, in characters, of the string contained in the LastStringResult property.

top
ResponseBodyStr
ResponseBodyStr As String (read-only)
Introduced in version 11.5.0

Returns the HTTP response body from the last call to DoYourThing .

top
ResponseFilePath
ResponseFilePath As String
Introduced in version 11.5.0

Set this property to the path of a file to stream the response body to a file. If the response is streamed to a file, it will not be available in ResponseBodyStr , GetResponseSb , or GetResponseBd .

top
StatusCode
StatusCode As Long (read-only)
Introduced in version 11.5.0

Returns the HTTP status code from the last call to DoYourThing. A value of 0 indicates no response header was received.

top
UncommonOptions
UncommonOptions As String
Introduced in version 11.5.0

Provides a comma-separated list of uncommon option keywords.

This property defaults to an empty string and should normally remain empty.

top
VerboseLogging
VerboseLogging As Long

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
Version As String (read-only)

Version of the component/library, such as "10.1.0"

top

Methods

AddFunction
AddFunction(funcName As String, curl As String) As Long
Introduced in version 11.5.0

Adds a named curl function that can be used in dependency resolution. Inputs required by the curl function are indicated by the variable names enclosed in {{ and }}. Outputs are defined in one or more calls to AddOutput .

Returns 1 for success, 0 for failure.

top
AddOutput
AddOutput(funcName As String, jsonPath As String, varName As String) As Long
Introduced in version 11.5.0

Adds or updates a defined output for a dependency resolution curl function previously defined by calling AddFunction. The jsonPath is the JSON path in the JSON response body where the varName's value is located. If either the funcName or jsonPath already exist for the funcName, then the output is updated.

Returns 1 for success, 0 for failure.

top
AddOutput2
AddOutput2(funcName As String, arrayPath As String, wherePath As String, whereValue As String, ByVal caseSensitive As Long, subPath As String, varName As String) As Long
Introduced in version 11.5.0

Adds or updates an output variable definition for a dependency-resolution curl function previously created by calling AddFunction. Use this method when the curl response is JSON containing an array of objects, and a value needs to be extracted from one specific array element.

The method searches the array located at arrayPath, finds the array element where the value at wherePath matches whereValue, and then extracts the value at subPath. The extracted value is assigned to the variable named by varName.

The wherePath and subPath values are paths relative to each individual array element. The comparison between whereValue and the JSON value found at wherePath is either case-sensitive or case-insensitive depending on the value of caseSensitive.

Parameters

  • funcName — The name of the curl function previously added by calling AddFunction. The output definition is associated with this function.
  • arrayPath — The JSON path identifying the array of records within the JSON response.
  • wherePath — A relative JSON path within each array element used to locate the matching record.
  • whereValue — The value to match against the JSON value found at wherePath.
  • caseSensitive — If 1, the comparison between whereValue and the JSON value is case-sensitive. If 0, the comparison is case-insensitive.
  • subPath — A relative JSON path within the matched array element identifying the value to extract.
  • varName — The name of the variable that will receive the extracted value.

Example

Given the following JSON response:

{
  "drives": [
    {
      "name": "Documents",
      "id": "A123"
    },
    {
      "name": "Shared",
      "id": "B456"
    }
  ]
}

The following call:

AddOutput2("GetDrive","drives","name","shared",false,"id","drive_id")

searches the drives array for the element whose name matches "shared" using case-insensitive comparison. The matching element is:

{
  "name": "Shared",
  "id": "B456"
}

The value of id is extracted and assigned to the variable drive_id, resulting in:

drive_id = "B456"

Returns 1 for success, 0 for failure.

top
AddTargetOutput
AddTargetOutput(jsonPath As String, varName As String)
Introduced in version 11.5.0

Adds an automatically mapped variable for the target curl command. When a JSON response is received from a curl request, the value at the JSON path specified by jsonPath is extracted (if present) and assigned to the variable named by varName.

This is useful in common workflows where one request returns an identifier (such as an `id`) that must be reused in a subsequent curl request.

Returns 1 for success, 0 for failure.

top
ClearTargetOutput
ClearTargetOutput(varName As String)
Introduced in version 11.5.0

Clears (undefines) the target output for the specified varName. If varName equals "*", then all target outputs are cleared.

top
ClearVar
ClearVar(varName As String)
Introduced in version 11.5.0

Undefines the variable with the specified name. If varName equals "*", then all variables are cleared.

Returns 1 for success, 0 for failure.

top
DoYourThing
DoYourThing(targetCurl As String) As Long
Introduced in version 11.5.0

Runs a the targetCurl command specified in targetCurl. If the targetCurl contains variable names enclosed in {{ and }}, then an execution plan is constructed from defined functions and outputs to resolve unknown variables, and the execution plan is run. The final step in the execution plan is always the targetCurl command.

Returns success (1) if a response was received, in which case the response status code will be available in StatusCode and the content of the response body will be available in one of two places:

Assuming the HTTP response is JSON, the target outputs (variables) specified by prior calls to AddTargetOutput will be populated by applying each variable's JSON path to the response JSON.

Returns 1 for success, 0 for failure.

top
DoYourThingAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
DoYourThingAsync(targetCurl As String) As ChilkatTask
Introduced in version 11.5.0

Creates an asynchronous task to call the DoYourThing method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
ExaminePlan
ExaminePlan(curl As String, json As ChilkatJsonObject) As Long
Introduced in version 11.5.0

Used for debugging. Returns in json the plan of execution that would occur for the curl based on the variables that are either unknown or already known. The plan of execution is what would occur if DoYourThing was called with the current state of knowledge.

If no execution plan is possible with the current known inputs and outputs, then json provides information about what is missing and the method returns 0.

Returns 1 for success, 0 for failure.

top
GetAllVars
GetAllVars(json As ChilkatJsonObject)
Introduced in version 11.5.0

Returns all defined variables in json.

top
GetResponseBd
GetResponseBd(bd As ChilkatBinData) As Long
Introduced in version 11.5.0

Appends to bd the HTTP response body from the last call to DoYourThing.

Returns 1 for success, 0 for failure.

top
GetResponseJarr
GetResponseJarr(jarr As ChilkatJsonArray) As Long
Introduced in version 11.5.0

Writes to jarr the HTTP response body from the last call to DoYourThing.

Returns 1 for success, 0 for failure.

top
GetResponseJson
GetResponseJson(json As ChilkatJsonObject) As Long
Introduced in version 11.5.0

Writes to json the HTTP response body from the last call to DoYourThing.

Returns 1 for success, 0 for failure.

top
GetResponseSb
GetResponseSb(sb As ChilkatStringBuilder) As Long
Introduced in version 11.5.0

Appends to sb the HTTP response body from the last call to DoYourThing.

Returns 1 for success, 0 for failure.

top
GetResponseXml
GetResponseXml(xml As ChilkatXml) As Long
Introduced in version 11.5.0

Writes to xml the HTTP response body from the last call to DoYourThing.

Returns 1 for success, 0 for failure.

top
GetVar
GetVar(varName As String) As String
Introduced in version 11.5.0

Retrieves the current value of the variable specified by varName.

Returns Nothing on failure

top
SetAuth
SetAuth(json As ChilkatJsonObject) As Long
Introduced in version 11.5.0

Sets authorization information that is applied to all calls to DoYourThing . See the examples below for details.

Returns 1 for success, 0 for failure.

top
SetVar
SetVar(varName As String, varValue As String)
Introduced in version 11.5.0

Sets the value of a variable to be replaced in curl commands. Variable names are enclosed in {{ and }} and can occur in the path, query params, or the body of the request.

Returns 1 for success, 0 for failure.

top
ToRawRequest
ToRawRequest(curlCommand As String, sb As ChilkatStringBuilder) As Long
Introduced in version 11.5.0

Used for debugging purposes. This method behaves the same as DoYourThing , but only converts the curlCommand to an HTTP request message in sb containing the full structure:

  • start line
  • headers
  • optional body or multipart body

It does not actually send the HTTP request.

Returns 1 for success, 0 for failure.

top
VarDefined
VarDefined(varName As String) As Long
Introduced in version 11.5.0

Returns 1 if the varName is defined, otherwise returns 0. Setting varName to "!" checks whether all target output variables have been defined. It returns 1 if every target output is set, and 0 if any are missing.

top

Events

AbortCheck
AbortCheck(abort As Long)

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myHttpcurl As HttpCurl

Private Sub myHttpcurl_AbortCheck(abort As Long)

	'Insert application code here.

End Sub
top
PercentDone
PercentDone(ByVal pctDone As Long, abort As Long)

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to 1. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myHttpcurl As HttpCurl

Private Sub myHttpcurl_PercentDone(ByVal pctDone As Long, abort As Long)

	'Insert application code here.

End Sub
top
ProgressInfo
ProgressInfo(ByVal name As String, ByVal value As String)

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myHttpcurl As HttpCurl

Private Sub myHttpcurl_ProgressInfo(ByVal name As String, ByVal value As String)

	'Insert application code here.

End Sub
top
TaskCompleted
TaskCompleted(task As ChilkatTask)

Called from the background thread when an asynchronous task completes.

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myHttpcurl As HttpCurl

Private Sub myHttpcurl_TaskCompleted(task As ChilkatTask)

	'Insert application code here.

End Sub
top