HttpCurl Delphi DLL 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.

Create/Dispose

var
myObject: HCkHttpCurl;

begin
myObject := CkHttpCurl_Create();

// ...

CkHttpCurl_Dispose(myObject);
end;
function CkHttpCurl_Create: HCkHttpCurl; stdcall;

Creates an instance of the HCkHttpCurl object and returns a handle (i.e. a Pointer). The handle is passed in the 1st argument for the functions listed on this page.

procedure CkHttpCurl_Dispose(handle: HCkHttpCurl); stdcall;

Objects created by calling CkHttpCurl_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

Properties

DebugLogFilePath
procedure CkHttpCurl_getDebugLogFilePath(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
procedure CkHttpCurl_putDebugLogFilePath(objHandle: HCkHttpCurl; newPropVal: PWideChar); stdcall;
function CkHttpCurl__debugLogFilePath(objHandle: HCkHttpCurl): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
EnableBodyVars
function CkHttpCurl_getEnableBodyVars(objHandle: HCkHttpCurl): wordbool; stdcall;
procedure CkHttpCurl_putEnableBodyVars(objHandle: HCkHttpCurl; newPropVal: wordbool); stdcall;
Introduced in version 11.5.0

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

top
LastErrorHtml
procedure CkHttpCurl_getLastErrorHtml(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
function CkHttpCurl__lastErrorHtml(objHandle: HCkHttpCurl): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorText
procedure CkHttpCurl_getLastErrorText(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
function CkHttpCurl__lastErrorText(objHandle: HCkHttpCurl): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorXml
procedure CkHttpCurl_getLastErrorXml(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
function CkHttpCurl__lastErrorXml(objHandle: HCkHttpCurl): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastMethodSuccess
function CkHttpCurl_getLastMethodSuccess(objHandle: HCkHttpCurl): wordbool; stdcall;
procedure CkHttpCurl_putLastMethodSuccess(objHandle: HCkHttpCurl; newPropVal: wordbool); stdcall;

Indicates the success or failure of the most recent method call: True means success, False 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
ResponseBodyStr
procedure CkHttpCurl_getResponseBodyStr(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
function CkHttpCurl__responseBodyStr(objHandle: HCkHttpCurl): PWideChar; stdcall;
Introduced in version 11.5.0

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

See the notes about PWideChar memory ownership and validity.

top
ResponseFilePath
procedure CkHttpCurl_getResponseFilePath(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
procedure CkHttpCurl_putResponseFilePath(objHandle: HCkHttpCurl; newPropVal: PWideChar); stdcall;
function CkHttpCurl__responseFilePath(objHandle: HCkHttpCurl): PWideChar; stdcall;
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 .

See the notes about PWideChar memory ownership and validity.

top
StatusCode
function CkHttpCurl_getStatusCode(objHandle: HCkHttpCurl): Integer; stdcall;
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
VerboseLogging
function CkHttpCurl_getVerboseLogging(objHandle: HCkHttpCurl): wordbool; stdcall;
procedure CkHttpCurl_putVerboseLogging(objHandle: HCkHttpCurl; newPropVal: wordbool); stdcall;

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

top
Version
procedure CkHttpCurl_getVersion(objHandle: HCkHttpCurl; outPropVal: HCkString); stdcall;
function CkHttpCurl__version(objHandle: HCkHttpCurl): PWideChar; stdcall;

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

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top

Methods

AddFunction
function CkHttpCurl_AddFunction(objHandle: HCkHttpCurl;
    funcName: PWideChar;
    curl: PWideChar): wordbool; stdcall;
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 True for success, False for failure.

top
AddOutput
function CkHttpCurl_AddOutput(objHandle: HCkHttpCurl;
    funcName: PWideChar;
    jsonPath: PWideChar;
    varName: PWideChar): wordbool; stdcall;
Introduced in version 11.5.0

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 True for success, False for failure.

top
AddTargetOutput
procedure CkHttpCurl_AddTargetOutput(objHandle: HCkHttpCurl;
    jsonPath: PWideChar;
    varName: PWideChar) stdcall;
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 True for success, False for failure.

top
ClearTargetOutput
procedure CkHttpCurl_ClearTargetOutput(objHandle: HCkHttpCurl;
    varName: PWideChar) stdcall;
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
procedure CkHttpCurl_ClearVar(objHandle: HCkHttpCurl;
    varName: PWideChar) stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
DoYourThing
function CkHttpCurl_DoYourThing(objHandle: HCkHttpCurl;
    targetCurl: PWideChar): wordbool; stdcall;
Introduced in version 11.5.0

Runs a the curl command specified in targetCurl. Returns success (True) 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 True for success, False for failure.

top
DoYourThingAsync (1)
function CkHttpCurl_DoYourThingAsync(objHandle: HCkHttpCurl;
    targetCurl: PWideChar): HCkTask; stdcall;
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 nil on failure

top
ExaminePlan
function CkHttpCurl_ExaminePlan(objHandle: HCkHttpCurl;
    curl: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkHttpCurl__examinePlan(objHandle: HCkHttpCurl;
    curl: PWideChar): PWideChar; stdcall;
Introduced in version 11.5.0

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetAllVars
procedure CkHttpCurl_GetAllVars(objHandle: HCkHttpCurl;
    json: HCkJsonObject) stdcall;
Introduced in version 11.5.0

Returns all defined variables in json.

top
GetResponseBd
function CkHttpCurl_GetResponseBd(objHandle: HCkHttpCurl;
    bd: HCkBinData): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
GetResponseJarr
function CkHttpCurl_GetResponseJarr(objHandle: HCkHttpCurl;
    jarr: HCkJsonArray): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
GetResponseJson
function CkHttpCurl_GetResponseJson(objHandle: HCkHttpCurl;
    json: HCkJsonObject): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
GetResponseSb
function CkHttpCurl_GetResponseSb(objHandle: HCkHttpCurl;
    sb: HCkStringBuilder): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
GetResponseXml
function CkHttpCurl_GetResponseXml(objHandle: HCkHttpCurl;
    xml: HCkXml): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
GetVar
function CkHttpCurl_GetVar(objHandle: HCkHttpCurl;
    varName: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkHttpCurl__getVar(objHandle: HCkHttpCurl;
    varName: PWideChar): PWideChar; stdcall;
Introduced in version 11.5.0

Retrieves the current value of the variable specified by varName.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
SetAuth
function CkHttpCurl_SetAuth(objHandle: HCkHttpCurl;
    json: HCkJsonObject): wordbool; stdcall;
Introduced in version 11.5.0

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

Returns True for success, False for failure.

top
SetVar
procedure CkHttpCurl_SetVar(objHandle: HCkHttpCurl;
    varName: PWideChar;
    varValue: PWideChar) stdcall;
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 True for success, False for failure.

top
ToRawRequest
function CkHttpCurl_ToRawRequest(objHandle: HCkHttpCurl;
    curlCommand: PWideChar;
    sb: HCkStringBuilder): wordbool; stdcall;
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 True for success, False for failure.

top
VarDefined
function CkHttpCurl_VarDefined(objHandle: HCkHttpCurl;
    varName: PWideChar): wordbool; stdcall;
Introduced in version 11.5.0

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

top

Events

AbortCheck
function MyAbortCheck(): Integer; cdecl;
Introduced in version 9.5.0.82

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. Return True to abort; return False to continue (not abort)

More Information and Examples
top
PercentDone
function MyPercentDone(pctDone: Integer): Integer; cdecl;
Introduced in version 9.5.0.82

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.

Return True to abort; return False to continue (not abort)

More Information and Examples
top
ProgressInfo
procedure MyProgressInfo(name: PWideChar; value: PWideChar) cdecl;
Introduced in version 9.5.0.82

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
top
TaskCompleted
procedure MyTaskCompleted(task: HCkTask) cdecl;
Introduced in version 9.5.0.82

Called from the background thread when an asynchronous task completes.

top