HttpCurl CkPython Reference Documentation

CkHttpCurl

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

obj = chilkat.CkHttpCurl()

Properties

DebugLogFilePath
# strVal is a string
# ckStr is a CkString
httpCurl.get_DebugLogFilePath(ckStr);
strVal = httpCurl.debugLogFilePath();
httpCurl.put_DebugLogFilePath(strVal);

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.

More Information and Examples
top
EnableBodyVars
# boolVal is a boolean
boolVal = httpCurl.get_EnableBodyVars();
httpCurl.put_EnableBodyVars(boolVal);
Introduced in version 11.5.0

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

top
LastErrorHtml
# strVal is a string
# ckStr is a CkString
httpCurl.get_LastErrorHtml(ckStr);
strVal = httpCurl.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.

top
LastErrorText
# strVal is a string
# ckStr is a CkString
httpCurl.get_LastErrorText(ckStr);
strVal = httpCurl.lastErrorText();

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
# strVal is a string
# ckStr is a CkString
httpCurl.get_LastErrorXml(ckStr);
strVal = httpCurl.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.

top
LastMethodSuccess
# boolVal is a boolean
boolVal = httpCurl.get_LastMethodSuccess();
httpCurl.put_LastMethodSuccess(boolVal);

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
# strVal is a string
# ckStr is a CkString
httpCurl.get_ResponseBodyStr(ckStr);
strVal = httpCurl.responseBodyStr();
Introduced in version 11.5.0

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

top
ResponseFilePath
# strVal is a string
# ckStr is a CkString
httpCurl.get_ResponseFilePath(ckStr);
strVal = httpCurl.responseFilePath();
httpCurl.put_ResponseFilePath(strVal);
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
# intVal is an integer
intVal = httpCurl.get_StatusCode();
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
Utf8
# boolVal is a boolean
boolVal = httpCurl.get_Utf8();
httpCurl.put_Utf8(boolVal);

When set to True, all string arguments and return values are interpreted as UTF-8 strings. When set to False, they are interpreted as ANSI strings.

In Chilkat v11.0.0 and later, the default value is True. Before v11.0.0, it was False.

top
VerboseLogging
# boolVal is a boolean
boolVal = httpCurl.get_VerboseLogging();
httpCurl.put_VerboseLogging(boolVal);

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
# strVal is a string
# ckStr is a CkString
httpCurl.get_Version(ckStr);
strVal = httpCurl.version();

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

More Information and Examples
top

Methods

AddFunction
# funcName is a string
# curl is a string
status = httpCurl.AddFunction(funcName, curl);
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
# funcName is a string
# jsonPath is a string
# varName is a string
status = httpCurl.AddOutput(funcName, jsonPath, varName);
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
# jsonPath is a string
# varName is a string
status = httpCurl.AddTargetOutput(jsonPath, varName);
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
# varName is a string
httpCurl.ClearTargetOutput(varName);
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
# varName is a string
status = httpCurl.ClearVar(varName);
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
# targetCurl is a string
status = httpCurl.DoYourThing(targetCurl);
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)
# returns a CkTask
# targetCurl is a string
ret_task = httpCurl.DoYourThingAsync(targetCurl);
Introduced in version 11.5.0

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

Returns None on failure

top
ExaminePlan
# curl is a string
# outStr is a CkString (output)
status = httpCurl.ExaminePlan(curl, outStr);
retStr = httpCurl.examinePlan(curl);
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.

top
GetAllVars
# json is a CkJsonObject
httpCurl.GetAllVars(json);
Introduced in version 11.5.0

Returns all defined variables in json.

top
GetResponseBd
# bd is a CkBinData
status = httpCurl.GetResponseBd(bd);
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
# jarr is a CkJsonArray
status = httpCurl.GetResponseJarr(jarr);
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
# json is a CkJsonObject
status = httpCurl.GetResponseJson(json);
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
# sb is a CkStringBuilder
status = httpCurl.GetResponseSb(sb);
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
# xml is a CkXml
status = httpCurl.GetResponseXml(xml);
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
# varName is a string
# outStr is a CkString (output)
status = httpCurl.GetVar(varName, outStr);
retStr = httpCurl.getVar(varName);
Introduced in version 11.5.0

Retrieves the current value of the variable specified by varName.

Returns True for success, False for failure.

top
SetAuth
# json is a CkJsonObject
status = httpCurl.SetAuth(json);
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
# varName is a string
# varValue is a string
status = httpCurl.SetVar(varName, varValue);
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
# curlCommand is a string
# sb is a CkStringBuilder
status = httpCurl.ToRawRequest(curlCommand, sb);
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
# varName is a string
retBool = httpCurl.VarDefined(varName);
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