node-libcurl

    Class Easy

    Easy class that acts as an wrapper around the libcurl connection handle.

    C++ source code

    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.

    Index

    Constructors

    Properties

    id: number

    This is the unique ID of the Easy handle.

    This ID is also unique across threads.

    isInsideMultiHandle: boolean

    This will be true if the handle was added to a Multi handle.

    isMonitoringSockets: boolean

    This will be true if monitorSocketEvents was called.

    isOpen: boolean

    This will be true if close was not called.

    isPausedRecv: boolean
    isPausedSend: boolean
    pauseFlags: CurlPause
    private: any

    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.

    Methods

    • 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()

      Returns void

    • Official libcurl documentation: curl_easy_getinfo()

      Parameters

      • info: "CERTINFO"

        Info to retrieve. Use Curl.info for predefined constants.

      Returns GetInfoReturn<string[]>

    • Returns information about the finished connection.

      Official libcurl documentation: curl_easy_getinfo()

      Parameters

      • info:
            | "ACTIVESOCKET"
            | "APPCONNECT_TIME"
            | "APPCONNECT_TIME_T"
            | "CAINFO"
            | "CAPATH"
            | "CONDITION_UNMET"
            | "CONN_ID"
            | "CONNECT_TIME"
            | "CONNECT_TIME_T"
            | "CONTENT_LENGTH_DOWNLOAD"
            | "CONTENT_LENGTH_DOWNLOAD_T"
            | "CONTENT_LENGTH_UPLOAD"
            | "CONTENT_LENGTH_UPLOAD_T"
            | "CONTENT_TYPE"
            | "COOKIELIST"
            | "EARLYDATA_SENT_T"
            | "EFFECTIVE_METHOD"
            | "EFFECTIVE_URL"
            | "FILETIME"
            | "FILETIME_T"
            | "FTP_ENTRY_PATH"
            | "HEADER_SIZE"
            | "HTTP_CONNECTCODE"
            | "HTTP_VERSION"
            | "HTTPAUTH_AVAIL"
            | "HTTPAUTH_USED"
            | "LASTSOCKET"
            | "LOCAL_IP"
            | "LOCAL_PORT"
            | "NAMELOOKUP_TIME"
            | "NAMELOOKUP_TIME_T"
            | "NUM_CONNECTS"
            | "OS_ERRNO"
            | "POSTTRANSFER_TIME_T"
            | "PRETRANSFER_TIME"
            | "PRETRANSFER_TIME_T"
            | "PRIMARY_IP"
            | "PRIMARY_PORT"
            | "PRIVATE"
            | "PROTOCOL"
            | "PROXY_ERROR"
            | "PROXY_SSL_VERIFYRESULT"
            | "PROXYAUTH_AVAIL"
            | "PROXYAUTH_USED"
            | "QUEUE_TIME_T"
            | "REDIRECT_COUNT"
            | "REDIRECT_TIME"
            | "REDIRECT_TIME_T"
            | "REDIRECT_URL"
            | "REFERER"
            | "REQUEST_SIZE"
            | "RESPONSE_CODE"
            | "RETRY_AFTER"
            | "RTSP_CLIENT_CSEQ"
            | "RTSP_CSEQ_RECV"
            | "RTSP_SERVER_CSEQ"
            | "RTSP_SESSION_ID"
            | "SCHEME"
            | "SIZE_DOWNLOAD"
            | "SIZE_DOWNLOAD_T"
            | "SIZE_UPLOAD"
            | "SIZE_UPLOAD_T"
            | "SPEED_DOWNLOAD"
            | "SPEED_DOWNLOAD_T"
            | "SPEED_UPLOAD"
            | "SPEED_UPLOAD_T"
            | "SSL_ENGINES"
            | "SSL_VERIFYRESULT"
            | "STARTTRANSFER_TIME"
            | "STARTTRANSFER_TIME_T"
            | "TLS_SESSION"
            | "TLS_SSL_PTR"
            | "TOTAL_TIME"
            | "TOTAL_TIME_T"
            | "USED_PROXY"
            | "XFER_ID"

        Info to retrieve. Use Curl.info for predefined constants.

      Returns GetInfoReturn

    • 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.

      Returns this

    • 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.

      Parameters

      • cb: null | ((error: null | Error, events: SocketState) => void)

      Returns this

    • Receives data over the established connection, data will be written to the passed buffer.

      See also onSocketEvent.

      Official libcurl documentation: curl_easy_recv()

      Parameters

      • storage: Buffer

      Returns { bytesReceived: number; code: CurlCode }

    • Build and set a MIME structure from a declarative configuration.

      This is a high-level method that accepts an array of MIME part specifications and internally builds a CurlMime structure, then sets it using the MIMEPOST option. This is the recommended way to create multipart form data.

      For stream-based parts, the unpause callback is automatically generated, so you don't need to provide it.

      Available since libcurl 7.56.0.

      Parameters

      • parts: CurlyMimePart[]

        Array of MIME part specifications

      Returns this

      This Easy instance for method chaining

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: ProgressCallbackOptions
      • value:
            | null
            | (
                (
                    this: Easy,
                    dltotal: number,
                    dlnow: number,
                    ultotal: number,
                    ulnow: number,
                ) => number
            )

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: BlobOptions
      • value: null | string | ArrayBuffer | Buffer<ArrayBufferLike>

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "CHUNK_BGN_FUNCTION"
      • value: null | ((this: Easy, fileInfo: FileInfo, remains: number) => CurlChunk)

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "CHUNK_END_FUNCTION"
      • value: null | ((this: Easy) => CurlChunk)

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "DEBUGFUNCTION"
      • value: null | ((this: Easy, type: CurlInfoDebug, data: Buffer) => 0)

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "FNMATCH_FUNCTION"
      • value: null | ((this: Easy, pattern: string, value: string) => CurlFnMatchFunc)

      Returns CurlCode

    • Use 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()

      Parameters

      • option: "HSTSREADFUNCTION"
      • value:
            | null
            | (
                (
                    this: Easy,
                    options: { maxHostLengthBytes: number },
                ) => null | CurlHstsCacheEntry | CurlHstsCacheEntry[]
            )

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "HSTSWRITEFUNCTION"
      • value:
            | null
            | (
                (
                    this: Easy,
                    cacheEntry: CurlHstsCacheEntry,
                    cacheCount: CurlHstsCacheCount,
                ) => any
            )

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "INTERLEAVEFUNCTION"
      • value: null | ((this: Easy, data: Buffer, size: number, nmemb: number) => number)

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "PREREQFUNCTION"
      • value:
            | null
            | (
                (
                    this: Easy,
                    connPrimaryIp: string,
                    connLocalIp: string,
                    connPrimaryPort: number,
                    conLocalPort: number,
                ) => CurlPreReqFunc
            )

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "SEEKFUNCTION"
      • value: null | ((this: Easy, offset: number, origin: number) => number)

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "TRAILERFUNCTION"
      • value: null | ((this: Easy) => false | string[])

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "SHARE"
      • value: null | Share

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "STREAM_DEPENDS"
      • value: null | Easy

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "STREAM_DEPENDS_E"
      • value: null | Easy

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "GSSAPI_DELEGATION"
      • value: null | CurlGssApi

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "MIMEPOST"
      • value: null | CurlMime

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "PROXY_SSL_OPTIONS"
      • value: null | CurlSslOpt

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option: "HSTS_CTRL"
      • value: null | CurlHsts

      Returns CurlCode

    • Use Curl.option for predefined constants.

      Official libcurl documentation: curl_easy_setopt()

      Parameters

      • option:
            | "CAINFO"
            | "CAPATH"
            | "CERTINFO"
            | "COOKIELIST"
            | "FILETIME"
            | "REFERER"
            | "RTSP_CLIENT_CSEQ"
            | "RTSP_SERVER_CSEQ"
            | "RTSP_SESSION_ID"
            | "MAXCONNECTS"
            | "URL"
            | "ABSTRACT_UNIX_SOCKET"
            | "ACCEPT_ENCODING"
            | "ACCEPTTIMEOUT_MS"
            | "ADDRESS_SCOPE"
            | "ALTSVC"
            | "ALTSVC_CTRL"
            | "APPEND"
            | "AUTOREFERER"
            | "AWS_SIGV4"
            | "BUFFERSIZE"
            | "CA_CACHE_TIMEOUT"
            | "CONNECT_ONLY"
            | "CONNECTTIMEOUT"
            | "CONNECTTIMEOUT_MS"
            | "COOKIE"
            | "COOKIEFILE"
            | "COOKIEJAR"
            | "COOKIESESSION"
            | "CRLF"
            | "CRLFILE"
            | "CUSTOMREQUEST"
            | "DEFAULT_PROTOCOL"
            | "DIRLISTONLY"
            | "DISALLOW_USERNAME_IN_URL"
            | "DNS_CACHE_TIMEOUT"
            | "DNS_INTERFACE"
            | "DNS_LOCAL_IP4"
            | "DNS_LOCAL_IP6"
            | "DNS_SERVERS"
            | "DNS_SHUFFLE_ADDRESSES"
            | "DNS_USE_GLOBAL_CACHE"
            | "DOH_SSL_VERIFYHOST"
            | "DOH_SSL_VERIFYPEER"
            | "DOH_SSL_VERIFYSTATUS"
            | "DOH_URL"
            | "ECH"
            | "EGDSOCKET"
            | "EXPECT_100_TIMEOUT_MS"
            | "FAILONERROR"
            | "FOLLOWLOCATION"
            | "FORBID_REUSE"
            | "FRESH_CONNECT"
            | "FTP_ACCOUNT"
            | "FTP_ALTERNATIVE_TO_USER"
            | "FTP_CREATE_MISSING_DIRS"
            | "FTP_SKIP_PASV_IP"
            | "FTP_USE_EPRT"
            | "FTP_USE_EPSV"
            | "FTP_USE_PRET"
            | "FTPPORT"
            | "FTPSSLAUTH"
            | "HAPPY_EYEBALLS_TIMEOUT_MS"
            | "HAPROXY_CLIENT_IP"
            | "HAPROXYPROTOCOL"
            | "HEADER"
            | "HSTS"
            | "HTTP_CONTENT_DECODING"
            | "HTTP_TRANSFER_DECODING"
            | "HTTP09_ALLOWED"
            | "HTTPAUTH"
            | "HTTPGET"
            | "HTTPPROXYTUNNEL"
            | "IGNORE_CONTENT_LENGTH"
            | "INFILESIZE"
            | "INFILESIZE_LARGE"
            | "INTERFACE"
            | "ISSUERCERT"
            | "KEEP_SENDING_ON_ERROR"
            | "KEYPASSWD"
            | "KRBLEVEL"
            | "LOCALPORT"
            | "LOCALPORTRANGE"
            | "LOGIN_OPTIONS"
            | "LOW_SPEED_LIMIT"
            | "LOW_SPEED_TIME"
            | "MAIL_AUTH"
            | "MAIL_FROM"
            | "MAIL_RCPT_ALLOWFAILS"
            | "MAX_RECV_SPEED_LARGE"
            | "MAX_SEND_SPEED_LARGE"
            | "MAXAGE_CONN"
            | "MAXFILESIZE"
            | "MAXFILESIZE_LARGE"
            | "MAXLIFETIME_CONN"
            | "MAXREDIRS"
            | "NETRC_FILE"
            | "NEW_DIRECTORY_PERMS"
            | "NEW_FILE_PERMS"
            | "NOBODY"
            | "NOPROGRESS"
            | "NOPROXY"
            | "NOSIGNAL"
            | "PASSWORD"
            | "PATH_AS_IS"
            | "PINNEDPUBLICKEY"
            | "PIPEWAIT"
            | "PORT"
            | "POST"
            | "POSTFIELDS"
            | "POSTFIELDSIZE"
            | "POSTFIELDSIZE_LARGE"
            | "POSTREDIR"
            | "PRE_PROXY"
            | "PROTOCOLS_STR"
            | "PROXY"
            | "PROXY_CAINFO"
            | "PROXY_CAPATH"
            | "PROXY_CRLFILE"
            | "PROXY_ISSUERCERT"
            | "PROXY_ISSUERCERT_BLOB"
            | "PROXY_KEYPASSWD"
            | "PROXY_PINNEDPUBLICKEY"
            | "PROXY_SERVICE_NAME"
            | "PROXY_SSL_CIPHER_LIST"
            | "PROXY_SSL_VERIFYHOST"
            | "PROXY_SSL_VERIFYPEER"
            | "PROXY_SSLCERTTYPE"
            | "PROXY_SSLKEY"
            | "PROXY_SSLKEYTYPE"
            | "PROXY_SSLVERSION"
            | "PROXY_TLS13_CIPHERS"
            | "PROXY_TLSAUTH_PASSWORD"
            | "PROXY_TLSAUTH_TYPE"
            | "PROXY_TLSAUTH_USERNAME"
            | "PROXY_TRANSFER_MODE"
            | "PROXYAUTH"
            | "PROXYPASSWORD"
            | "PROXYPORT"
            | "PROXYUSERNAME"
            | "PROXYUSERPWD"
            | "PUT"
            | "QUICK_EXIT"
            | "RANDOM_FILE"
            | "RANGE"
            | "READDATA"
            | "REDIR_PROTOCOLS_STR"
            | "REQUEST_TARGET"
            | "RESUME_FROM"
            | "RESUME_FROM_LARGE"
            | "RTSP_STREAM_URI"
            | "RTSP_TRANSPORT"
            | "SASL_AUTHZID"
            | "SASL_IR"
            | "SERVER_RESPONSE_TIMEOUT"
            | "SERVER_RESPONSE_TIMEOUT_MS"
            | "SERVICE_NAME"
            | "SOCKS5_AUTH"
            | "SOCKS5_GSSAPI_NEC"
            | "SOCKS5_GSSAPI_SERVICE"
            | "SSH_COMPRESSION"
            | "SSH_HOST_PUBLIC_KEY_MD5"
            | "SSH_HOST_PUBLIC_KEY_SHA256"
            | "SSH_KNOWNHOSTS"
            | "SSH_PRIVATE_KEYFILE"
            | "SSH_PUBLIC_KEYFILE"
            | "SSL_CIPHER_LIST"
            | "SSL_EC_CURVES"
            | "SSL_ENABLE_ALPN"
            | "SSL_ENABLE_NPN"
            | "SSL_FALSESTART"
            | "SSL_SESSIONID_CACHE"
            | "SSL_SIGNATURE_ALGORITHMS"
            | "SSL_VERIFYHOST"
            | "SSL_VERIFYPEER"
            | "SSL_VERIFYSTATUS"
            | "SSLCERT"
            | "SSLCERTTYPE"
            | "SSLENGINE"
            | "SSLENGINE_DEFAULT"
            | "SSLKEY"
            | "SSLKEYTYPE"
            | "STREAM_WEIGHT"
            | "SUPPRESS_CONNECT_HEADERS"
            | "TCP_FASTOPEN"
            | "TCP_KEEPALIVE"
            | "TCP_KEEPCNT"
            | "TCP_KEEPIDLE"
            | "TCP_KEEPINTVL"
            | "TCP_NODELAY"
            | "TFTP_BLKSIZE"
            | "TFTP_NO_OPTIONS"
            | "TIMEOUT"
            | "TIMEOUT_MS"
            | "TIMEVALUE"
            | "TIMEVALUE_LARGE"
            | "TLS13_CIPHERS"
            | "TLSAUTH_PASSWORD"
            | "TLSAUTH_TYPE"
            | "TLSAUTH_USERNAME"
            | "TRANSFER_ENCODING"
            | "TRANSFERTEXT"
            | "UNIX_SOCKET_PATH"
            | "UNRESTRICTED_AUTH"
            | "UPKEEP_INTERVAL_MS"
            | "UPLOAD"
            | "UPLOAD_BUFFERSIZE"
            | "UPLOAD_FLAGS"
            | "USERAGENT"
            | "USERNAME"
            | "USERPWD"
            | "VERBOSE"
            | "WILDCARDMATCH"
            | "XOAUTH2_BEARER"
      • value: null | string | number | boolean

      Returns CurlCode

    • 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.

      Returns this

    • Get WebSocket frame metadata when called from within a WRITEFUNCTION callback.

      This function provides additional information about the current WebSocket frame being received. It only works from within the callback, and only when receiving WebSocket data.

      Requires libcurl >= 7.86.0

      Official libcurl documentation: curl_ws_meta()

      Returns null | CurlWsFrame

      Frame metadata or null if not available

    • Receive WebSocket data when using CONNECT_ONLY mode.

      Retrieves as much as possible of a received WebSocket frame into the buffer, but not more than buflen bytes. Check meta.bytesleft to determine whether the complete frame has been received. If more payload is pending, call this function again with an updated buffer to resume receiving.

      Requires libcurl >= 7.86.0

      Official libcurl documentation: curl_ws_recv()

      Parameters

      • buffer: Buffer

      Returns { bytesReceived: number; code: CurlCode; meta: null | CurlWsFrame }

    • Send WebSocket data when using CONNECT_ONLY mode.

      Sends a specific message chunk over an established WebSocket connection. flags must contain at least one flag indicating the type of the message (Text, Binary, Close, Ping, Pong). For fragmented messages, set the Cont bit in all frames except the final one.

      Requires libcurl >= 7.86.0

      Official libcurl documentation: curl_ws_send()

      Parameters

      • buffer: Buffer

        The data to send

      • flags: number

        Frame type and flags from CurlWs

      • Optionalfragsize: number

        Optional fragment size, only used with CURLWS_OFFSET flag

      Returns { bytesSent: number; code: CurlCode }

    • Start a new WebSocket frame.

      This should only be called from within a READFUNCTION callback. Calling it from anywhere else is undefined behavior.

      Official libcurl documentation: curl_ws_start_frame()

      Parameters

      • flags: number
      • frameLength: number

      Returns CurlCode

    MMNEPVFCICPMFPCPTTAAATR