HttpCurl ActiveX Reference Documentation
HttpCurl
Current Version: 11.4.0
A class for running curl commands within your application. Mirrors the curl command syntax. It is not derived from curl/libcurl, and does not wrap libcurl.
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
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.
EnableBodyVars
Enables variable substitution in the body of the request. The default value is 1.
LastBinaryResult
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.
LastErrorHtml
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.
topLastErrorText
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.
LastErrorXml
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.
topLastMethodSuccess
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.
LastStringResult
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.
LastStringResultLen
The length, in characters, of the string contained in the LastStringResult property.
topResponseBodyStr
Returns the HTTP response body from the last call to DoYourThing .
ResponseFilePath
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 .
StatusCode
Returns the HTTP status code from the last call to DoYourThing. A value of 0 indicates no response header was received.
VerboseLogging
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.
Version
Version of the component/library, such as "10.1.0"
Methods
AddFunction
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.
topAddOutput
Adds 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.
Returns 1 for success, 0 for failure.
topAddTargetOutput
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.
topClearTargetOutput
Clears (undefines) the target output for the specified varName. If varName equals "*", then all target outputs are cleared.
ClearVar
Undefines the variable with the specified name. If varName equals "*", then all variables are cleared.
Returns 1 for success, 0 for failure.
topDoYourThing
Runs a the curl command specified in targetCurl. 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:
- If
ResponseFilePathis non-empty, the response body was streamed to the specified file path. - If
ResponseFilePathis empty, the response body can be retrieved viaResponseBodyStr,GetResponseSb, orGetResponseBd. Binary responses should only be retrieved viaResponseBodyBd.
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.
topDoYourThingAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
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
ExaminePlan
Used for debugging. Returns a string that provides information about 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.
Returns Nothing on failure
GetAllVars
Returns all defined variables in json.
topGetResponseBd
Writes to bd the HTTP response body from the last call to DoYourThing.
Returns 1 for success, 0 for failure.
topGetResponseJarr
Writes to jarr the HTTP response body from the last call to DoYourThing.
Returns 1 for success, 0 for failure.
topGetResponseJson
Writes to json the HTTP response body from the last call to DoYourThing.
Returns 1 for success, 0 for failure.
topGetResponseSb
Writes to sb the HTTP response body from the last call to DoYourThing.
Returns 1 for success, 0 for failure.
topGetResponseXml
Writes to xml the HTTP response body from the last call to DoYourThing.
Returns 1 for success, 0 for failure.
topGetVar
SetAuth
Sets authorization information that is applied to all calls to DoYourThing . See the examples below for details.
Returns 1 for success, 0 for failure.
topSetVar
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.
ToRawRequest
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.
topVarDefined
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.
Events
AbortCheck
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.
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
PercentDone
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.
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
ProgressInfo
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.
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
TaskCompleted
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