node-libcurl
Version:
The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl
599 lines • 25.9 kB
TypeScript
/**
* Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import './moduleSetup';
import { Share } from './Share';
import { CurlMime } from './CurlMime';
import { CurlOptionName, DataCallbackOptions, ProgressCallbackOptions, BlobOptions, StringListOptions, SpecificOptions } from './generated/CurlOption';
import { CurlInfoName } from './generated/CurlInfo';
import { CurlyMimePart } from './CurlyMimeTypes';
import { CurlChunk } from './enum/CurlChunk';
import { CurlCode } from './enum/CurlCode';
import { CurlFnMatchFunc } from './enum/CurlFnMatchFunc';
import { CurlFtpMethod } from './enum/CurlFtpMethod';
import { CurlFtpSsl } from './enum/CurlFtpSsl';
import { CurlGssApi } from './enum/CurlGssApi';
import { CurlHeader } from './enum/CurlHeader';
import { CurlHsts, CurlHstsCacheEntry, CurlHstsCacheCount } from './enum/CurlHsts';
import { CurlHttpVersion } from './enum/CurlHttpVersion';
import { CurlInfoDebug } from './enum/CurlInfoDebug';
import { CurlIpResolve } from './enum/CurlIpResolve';
import { CurlMimeOpt } from './enum/CurlMimeOpt';
import { CurlNetrc } from './enum/CurlNetrc';
import { CurlPause } from './enum/CurlPause';
import { CurlPreReqFunc } from './enum/CurlPreReqFunc';
import { CurlProgressFunc } from './enum/CurlProgressFunc';
import { CurlProtocol } from './enum/CurlProtocol';
import { CurlProxy } from './enum/CurlProxy';
import { CurlRtspRequest } from './enum/CurlRtspRequest';
import { CurlSshAuth } from './enum/CurlSshAuth';
import { CurlSshKeyType, CurlSshKeyMatch } from './enum/CurlSshKey';
import { CurlSslOpt } from './enum/CurlSslOpt';
import { CurlSslVersion } from './enum/CurlSslVersion';
import { CurlTimeCond } from './enum/CurlTimeCond';
import { CurlUseSsl } from './enum/CurlUseSsl';
import { CurlWsOptions } from './enum/CurlWs';
import { SocketState } from './enum/SocketState';
import { CurlWsFrame, FileInfo, HttpPostField } from './';
export interface GetInfoReturn<DataType = number | string | null> {
data: DataType;
code: CurlCode;
}
export type CurlInfoNameSpecific = 'CERTINFO';
/**
* `Easy` class that acts as an wrapper around the libcurl connection handle.
* > [C++ source code](https://github.com/JCMais/node-libcurl/blob/master/src/Easy.cc)
*
* It can be used by itself, in a synchronous way:
* ```javascript
* 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 {@link Multi | Multi} class, allowing asynchronous usage.
*
* @public
*/
declare class Easy {
/**
* This will be `true` if the handle was added to a {@link Multi | `Multi`} handle.
*/
readonly isInsideMultiHandle: boolean;
/**
* This is the unique ID of the Easy handle.
*
* This ID is also unique across threads.
*/
readonly id: number;
/**
* This will be `true` if {@link monitorSocketEvents | `monitorSocketEvents`} was called.
*/
readonly isMonitoringSockets: boolean;
/**
* This will be `true` if {@link close | `close`} was not called.
*/
readonly isOpen: boolean;
readonly pauseFlags: CurlPause;
readonly isPausedRecv: boolean;
readonly isPausedSend: boolean;
/**
* 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.
*/
private: any;
/**
* @private
*/
debugLog(message: string): void;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: DataCallbackOptions, value: ((this: Easy, data: Buffer, size: number, nmemb: number) => number) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: ProgressCallbackOptions, value: ((this: Easy, dltotal: number, dlnow: number, ultotal: number, ulnow: number) => number | CurlProgressFunc) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: StringListOptions, value: string[] | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: BlobOptions, value: ArrayBuffer | Buffer | string | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'CHUNK_BGN_FUNCTION', value: ((this: Easy, fileInfo: FileInfo, remains: number) => CurlChunk) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'CHUNK_END_FUNCTION', value: ((this: Easy) => CurlChunk) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'DEBUGFUNCTION', value: ((this: Easy, type: CurlInfoDebug, data: Buffer) => 0) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'FNMATCH_FUNCTION', value: ((this: Easy, pattern: string, value: string) => CurlFnMatchFunc) | null): CurlCode;
/**
* Use {@link 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()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HSTSREADFUNCTION', value: ((this: Easy, options: {
maxHostLengthBytes: number;
}) => null | CurlHstsCacheEntry | CurlHstsCacheEntry[]) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HSTSWRITEFUNCTION', value: ((this: Easy, cacheEntry: CurlHstsCacheEntry, cacheCount: CurlHstsCacheCount) => any) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'INTERLEAVEFUNCTION', value: ((this: Easy, data: Buffer, size: number, nmemb: number) => number) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'PREREQFUNCTION', value: ((this: Easy, connPrimaryIp: string, connLocalIp: string, connPrimaryPort: number, conLocalPort: number) => CurlPreReqFunc) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SEEKFUNCTION', value: ((this: Easy, offset: number, origin: number) => number) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SSH_HOSTKEYFUNCTION', value: ((this: Easy, keytype: CurlSshKeyType, key: Buffer) => CurlSshKeyMatch) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'TRAILERFUNCTION', value: ((this: Easy) => string[] | false) | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SHARE', value: Share | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HTTPPOST', value: HttpPostField[] | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'STREAM_DEPENDS', value: Easy | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'STREAM_DEPENDS_E', value: Easy | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'FTP_SSL_CCC', value: CurlFtpSsl | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'FTP_FILEMETHOD', value: CurlFtpMethod | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'GSSAPI_DELEGATION', value: CurlGssApi | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HEADEROPT', value: CurlHeader | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HTTP_VERSION', value: CurlHttpVersion | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'IPRESOLVE', value: CurlIpResolve | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'MIMEPOST', value: CurlMime | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'MIME_OPTIONS', value: CurlMimeOpt | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'NETRC', value: CurlNetrc | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'PROTOCOLS', value: CurlProtocol | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'PROXY_SSL_OPTIONS', value: CurlSslOpt | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'PROXYTYPE', value: CurlProxy | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'REDIR_PROTOCOLS', value: CurlProtocol | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'RTSP_REQUEST', value: CurlRtspRequest | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SSH_AUTH_TYPES', value: CurlSshAuth | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SSL_OPTIONS', value: CurlSslOpt | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'SSLVERSION', value: CurlSslVersion | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'TIMECONDITION', value: CurlTimeCond | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'USE_SSL', value: CurlUseSsl | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'WS_OPTIONS', value: CurlWsOptions | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: 'HSTS_CTRL', value: CurlHsts | null): CurlCode;
/**
* Use {@link Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(option: Exclude<CurlOptionName, SpecificOptions>, value: string | number | boolean | null): CurlCode;
/**
* Official libcurl documentation: [`curl_easy_getinfo()`](http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html)
*
* @param info Info to retrieve. Use {@link Curl.info | `Curl.info`} for predefined constants.
*/
getInfo(info: 'CERTINFO'): GetInfoReturn<string[]>;
/**
* Returns information about the finished connection.
*
* Official libcurl documentation: [`curl_easy_getinfo()`](http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html)
*
* @param info Info to retrieve. Use {@link Curl.info | `Curl.info`} for predefined constants.
*/
getInfo(info: Exclude<CurlInfoName, CurlInfoNameSpecific>): GetInfoReturn;
/**
* Sends arbitrary data over the established connection.
*
* See also {@link onSocketEvent | `onSocketEvent`}.
*
* Official libcurl documentation: [`curl_easy_send()`](http://curl.haxx.se/libcurl/c/curl_easy_send.html)
*/
send(data: Buffer): {
code: CurlCode;
bytesSent: number;
};
/**
* Receives data over the established connection, data will be written to the passed buffer.
*
* See also {@link onSocketEvent | `onSocketEvent`}.
*
* Official libcurl documentation: [`curl_easy_recv()`](http://curl.haxx.se/libcurl/c/curl_easy_recv.html)
*/
recv(storage: Buffer): {
code: CurlCode;
bytesReceived: number;
};
/**
* 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()`](https://curl.se/libcurl/c/curl_ws_recv.html)
*/
wsRecv(buffer: Buffer): {
code: CurlCode;
bytesReceived: number;
meta: CurlWsFrame | null;
};
/**
* 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()`](https://curl.se/libcurl/c/curl_ws_send.html)
*
* @param buffer The data to send
* @param flags Frame type and flags from {@link CurlWs | `CurlWs`}
* @param fragsize Optional fragment size, only used with CURLWS_OFFSET flag
*/
wsSend(buffer: Buffer, flags: number, fragsize?: number): {
code: CurlCode;
bytesSent: number;
};
/**
* 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()`](https://curl.se/libcurl/c/curl_ws_meta.html)
*
* @returns Frame metadata or null if not available
*/
wsMeta(): CurlWsFrame | null;
/**
* 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()`](https://curl.se/libcurl/c/curl_ws_start_frame.html)
*/
wsStartFrame(flags: number, frameLength: number): CurlCode;
/**
* Performs the entire request in a blocking manner and returns when done.
*
* Official libcurl documentation: [`curl_easy_perform()`](http://curl.haxx.se/libcurl/c/curl_easy_perform.html)
*/
perform(): CurlCode;
/**
* Perform any connection upkeep checks.
*
* Official libcurl documentation: [curl_easy_upkeep()](http://curl.haxx.se/libcurl/c/curl_easy_upkeep.html)
*/
upkeep(): CurlCode;
/**
* 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 {@link CurlPause | `CurlPause`} enum for predefined constants.
*
* Official libcurl documentation: [`curl_easy_pause()`](http://curl.haxx.se/libcurl/c/curl_easy_pause.html)
*/
pause(bitmask: CurlPause): CurlCode;
/**
* 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()`](http://curl.haxx.se/libcurl/c/curl_easy_reset.html)
*/
reset(): CurlCode;
/**
* Duplicate this handle with all their options and callbacks.
*
* Official libcurl documentation: [`curl_easy_duphandle()`](http://curl.haxx.se/libcurl/c/curl_easy_duphandle.html)
*/
dupHandle(): Easy;
/**
* This method is only useful when the internal polling of the connection socket is enabled by calling
* {@link monitorSocketEvents | `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 {@link send | `send`} and {@link recv | `recv`} methods
*
* A full example is available at [examples/15-send-recv-methods.js](https://github.com/JCMais/node-libcurl/blob/master/examples/15-send-recv-methods.js)
*
* Pass `null` to remove the current callback set.
*/
onSocketEvent(cb: ((error: Error | null, events: SocketState) => void) | null): this;
/**
* Start monitoring for events in the connection socket used by this handle.
*
* This is only useful if using the {@link onSocketEvent | `onSocketEvent`} callback.
*
* This method will throw an Error if the handle is already monitoring socket events.
* You can use {@link isMonitoringSockets | `isMonitoringSockets`} to check if socket events are already being monitored or not.
*/
monitorSocketEvents(): 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 {@link isMonitoringSockets | `isMonitoringSockets`} to check if socket events are already being monitored or not.
*/
unmonitorSocketEvents(): this;
/**
* 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 {@link 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.
*
* @param parts Array of MIME part specifications
* @returns This Easy instance for method chaining
*/
setMimePost(parts: CurlyMimePart[]): this;
/**
* 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()`](http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html)
*/
close(): void;
/**
* Returns a description for the given error code.
*
* Official libcurl documentation: [`curl_easy_strerror()`](http://curl.haxx.se/libcurl/c/curl_easy_strerror.html)
*/
static strError(errorCode: CurlCode): string;
}
export { Easy };
//# sourceMappingURL=Easy.d.ts.map