Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Easy

This is a Node.js wrapper around the binding native Easy class

Hierarchy

Index

Properties

Readonly isInsideMultiHandle

isInsideMultiHandle: boolean

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

Readonly isMonitoringSockets

isMonitoringSockets: boolean

This will be true if monitorSocketEvents was called.

Readonly isOpen

isOpen: boolean

This will be true if close was not called.

private

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

  • close(): void
  • 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

dupHandle

getInfo

monitorSocketEvents

  • monitorSocketEvents(): this
  • 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

onSocketEvent

  • onSocketEvent(cb: ((error: Error | null, events: SocketState) => void) | null): 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: ((error: Error | null, events: SocketState) => void) | null

    Returns this

pause

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

    Parameters

    Returns CurlCode

perform

recv

  • recv(storage: Buffer): { bytesReceived: number; code: CurlCode }
  • 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 }

reset

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

    Returns CurlCode

send

  • send(data: Buffer): { bytesSent: number; code: CurlCode }

setOpt

unmonitorSocketEvents

  • unmonitorSocketEvents(): this
  • 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

upkeep

Static strError

Generated using TypeDoc