HttpCurl Node.js 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
var obj = new chilkat.HttpCurl();
Properties
DebugLogFilePath
· 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.
EnableBodyVars
· boolean
Enables variable substitution in the body of the request. The default value is true.
LastErrorHtml
· 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.
topLastErrorText
· 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.
LastErrorXml
· 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.
topLastMethodSuccess
· boolean
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.
ResponseBodyStr
· string, read-only
Returns the HTTP response body from the last call to DoYourThing .
ResponseFilePath
· string
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
· integer, read-only
Returns the HTTP status code from the last call to DoYourThing. A value of 0 indicates no response header was received.
VerboseLogging
· boolean
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.
Version
· string, read-only
Methods
AddFunction
· Returns Boolean (true for success, false for failure).
· funcName String
· curl String
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.
topAddOutput
· Returns Boolean (true for success, false for failure).
· funcName String
· jsonPath String
· varName String
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.
topAddTargetOutput
· Does not return anything (returns Undefined).
· jsonPath String
· varName String
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.
topClearTargetOutput
· Does not return anything (returns Undefined).
· varName String
Clears (undefines) the target output for the specified varName. If varName equals "*", then all target outputs are cleared.
ClearVar
· Does not return anything (returns Undefined).
· varName String
Undefines the variable with the specified name. If varName equals "*", then all variables are cleared.
Returns true for success, false for failure.
topDoYourThing
· Returns Boolean (true for success, false for failure).
· targetCurl String
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:
- 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 true for success, false for failure.
topDoYourThingAsync (1)
· Returns a Task
· targetCurl String
Creates an asynchronous task to call the DoYourThing method with the arguments provided.
Returns null on failure
ExaminePlan
· Returns a String.
· curl String
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 null on failure
GetAllVars
· Does not return anything (returns Undefined).
· json JsonObject
Returns all defined variables in json.
topGetResponseBd
· Returns Boolean (true for success, false for failure).
· bd BinData
Writes to bd the HTTP response body from the last call to DoYourThing.
Returns true for success, false for failure.
topGetResponseJarr
· Returns Boolean (true for success, false for failure).
· jarr JsonArray
Writes to jarr the HTTP response body from the last call to DoYourThing.
Returns true for success, false for failure.
topGetResponseJson
· Returns Boolean (true for success, false for failure).
· json JsonObject
Writes to json the HTTP response body from the last call to DoYourThing.
Returns true for success, false for failure.
topGetResponseSb
· Returns Boolean (true for success, false for failure).
· sb StringBuilder
Writes to sb the HTTP response body from the last call to DoYourThing.
Returns true for success, false for failure.
topGetResponseXml
· Returns Boolean (true for success, false for failure).
· xml Xml
Writes to xml the HTTP response body from the last call to DoYourThing.
Returns true for success, false for failure.
topGetVar
· Returns a String.
· varName String
SetAuth
· Returns Boolean (true for success, false for failure).
· json JsonObject
Sets authorization information that is applied to all calls to DoYourThing . See the examples below for details.
Returns true for success, false for failure.
topSetVar
· Does not return anything (returns Undefined).
· varName String
· varValue String
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.
ToRawRequest
· Returns Boolean (true for success, false for failure).
· curlCommand String
· sb StringBuilder
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.
topVarDefined
· Returns a Boolean.
· varName String
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.