This will be true
if the handle was added to a Multi
handle.
This will be true
if monitorSocketEvents
was called.
This will be true
if close
was not called.
You can set this to anything - Use it to bind some data to this Easy instance.
This will not be copied to other instaces created when duplicating this one.
Close this handle and dispose any resources bound to it. After closed, the handle MUST not be used again, doing so will throw an Error.
This is basically the same than curl_easy_cleanup()
Duplicate this handle with all their options and callbacks.
Official libcurl documentation: curl_easy_duphandle()
Official libcurl documentation: curl_easy_getinfo()
Info to retrieve. Use {@link "Curl".Curl.info | Curl.info
} for predefined constants.
Returns information about the finished connection.
Official libcurl documentation: curl_easy_getinfo()
Info to retrieve. Use {@link "Curl".Curl.info | Curl.info
} for predefined constants.
Start monitoring for events in the connection socket used by this handle.
This is only useful if using the onSocketEvent
callback.
This method will throw an Error if the handle is already monitoring socket events.
You can use isMonitoringSockets
to check if socket events are already being monitored or not.
This method is only useful when the internal polling of the connection socket is enabled by calling
monitorSocketEvents
.
The passed callback is going to be called everytime there are changes to the connection socket.
One use case for this is when using the send
and recv
methods
A full example is available at examples/15-send-recv-methods.js
Pass null
to remove the current callback set.
Using this function, you can explicitly mark a running connection to get paused, and you can unpause a connection that was previously paused.
Use the CurlPause
enum for predefined constants.
Official libcurl documentation: curl_easy_pause()
Performs the entire request in a blocking manner and returns when done.
Official libcurl documentation: curl_easy_perform()
Receives data over the established connection, data will be written to the passed buffer.
See also onSocketEvent
.
Official libcurl documentation: curl_easy_recv()
Reset this handle to their original state.
This method is useful if you plan to reuse this handle later on.
Official libcurl documentation: curl_easy_reset()
Sends arbitrary data over the established connection.
See also onSocketEvent
.
Official libcurl documentation: curl_easy_send()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
You can either return a single CurlHstsReadCallbackResult
object or an array of CurlHstsReadCallbackResult
objects.
If returning an array, the callback will only be called once per request.
If returning a single object, the callback will be called multiple times until null
is returned.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Use {@link "Curl".Curl.option|Curl.option
} for predefined constants.
Official libcurl documentation: curl_easy_setopt()
Stop monitoring for events in the connection socket used by this handle.
This method will throw an Error if the handle is not monitoring socket events.
You can use isMonitoringSockets
to check if socket events are already being monitored or not.
Perform any connection upkeep checks.
Official libcurl documentation: curl_easy_upkeep()
Returns a description for the given error code.
Official libcurl documentation: curl_easy_strerror()
Generated using TypeDoc
Easy
class that acts as an wrapper around the libcurl connection handle.It can be used by itself, in a synchronous way:
import { Curl, CurlCode, Easy } from 'node-libcurl' import { StringDecoder } from 'string_decoder' const decoder = new StringDecoder('utf8') const easyHandle = new Easy() easyHandle.setOpt(Curl.option.URL, 'https://www.google.com') // This is used to receive the headers // See https://curl.haxx.se/libcurl/c/CURLOPT_HEADERFUNCTION.html easyHandle.setOpt(Curl.option.HEADERFUNCTION, function (buf, size, nmemb) { console.log('Received some headers:', decoder.write(buf)) return size * nmemb }) // This is used to receive the response data // See https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html easyHandle.setOpt(Curl.option.WRITEFUNCTION, function (buf, size, nmemb) { console.log('Received some body:', decoder.write(buf)) return size * nmemb }) // this will trigger the request const ret = easyHandle.perform() // The Easy handle will block the JS main thread: console.log('I will only show after the request has finished') // In case there is something wrong, you can use Easy.strError to get a human readable string about the error console.log(ret, ret === CurlCode.CURLE_OK, Easy.strError(ret)) // Remember to always close the handle after you have finished using it for good easyHandle.close()
or with the Multi class, allowing asynchronous usage.