/// <reference types="node" />
/**
 * 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 { EventEmitter } from 'events';
import { EasyNativeBinding, FileInfo, HttpPostField } from './types';
import { Share } from './Share';
import { HeaderInfo } from './parseHeaders';
import { DataCallbackOptions, ProgressCallbackOptions, StringListOptions, CurlOptionName, SpecificOptions } from './generated/CurlOption';
import { CurlInfoName } from './generated/CurlInfo';
import { CurlCode } from './enum/CurlCode';
import { CurlFeature } from './enum/CurlFeature';
import { CurlGlobalInit } from './enum/CurlGlobalInit';
import { CurlGssApi } from './enum/CurlGssApi';
import { CurlPause } from './enum/CurlPause';
import { CurlProgressFunc } from './enum/CurlProgressFunc';
import { CurlSslOpt } from './enum/CurlSslOpt';
/**
 * Wrapper around {@link Easy} class with a more *nodejs-friendly* interface.
 *
 * @remarks
 *
 * Also see the Curl Interface definition for some overloaded methods.
 * The `setOpt` method here has `(never, never)` as type for their arguments because
 *  the overloaded methods are the ones with the correct signatures.
 *
 * @public
 */
declare class Curl extends EventEmitter {
    /**
     * Calls [curl_global_init()](http://curl.haxx.se/libcurl/c/curl_global_init.html)
     * For **flags** see the the enum `CurlGlobalInit`
     *
     * This is automatically called when the addon is loaded, to disable this, set the environment variable
     *  `NODE_LIBCURL_DISABLE_GLOBAL_INIT_CALL=false`
     */
    static globalInit: (flags: CurlGlobalInit) => number;
    /**
     * Calls [curl_global_cleanup()](http://curl.haxx.se/libcurl/c/curl_global_cleanup.html)
     *
     * This is automatically called when the process is exiting
     */
    static globalCleanup: () => void;
    /**
     * Returns libcurl version string.
     * The string shows which features are enabled,
     *  and the version of the libraries that libcurl was built with.
     */
    static getVersion: () => string;
    /**
     * Returns an object with a representation of the current libcurl version and their features/protocols.
     *
     * This is basically [curl_version_info()](https://curl.haxx.se/libcurl/c/curl_version_info.html)
     */
    static getVersionInfo: () => import("./types").CurlVersionInfoNativeBindingObject;
    /**
     * Returns a string that looks like the one returned by
     * ```
     * curl -V
     * ```
     */
    static getVersionInfoString: () => string;
    static isVersionGreaterOrEqualThan: (x: number, y: number, z?: number) => boolean;
    static defaultUserAgent: string;
    /**
     * Returns the number of handles currently open in the internal multi handle being used.
     */
    static getCount: () => number;
    /**
     * Current libcurl version
     */
    static VERSION_NUM: number;
    /**
     * Options to be used with `Easy.getInfo` or `Curl.getInfo`
     *
     * See the official documentation of [curl_easy_getinfo()](http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html)
     *  for reference.
     *
     * `CURLINFO_EFFECTIVE_URL` becomes `Curl.info.EFFECTIVE_URL`
     */
    static info: import("./generated/CurlInfo").CurlInfo;
    /**
     * Options to be used with `Easy.setOpt` or `Curl.setOpt`
     *
     * See the official documentation of [curl_easy_setopt()](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
     *  for reference.
     *
     * `CURLOPT_URL` becomes `Curl.option.URL`
     */
    static option: import("./generated/CurlOption").CurlOption;
    /**
     * Internal Easy handle being used
     */
    protected handle: EasyNativeBinding;
    /**
     * Stores current response payload
     * This will not store anything in case the NO_DATA_STORAGE flag is enabled
     */
    protected chunks: Buffer[];
    protected chunksLength: number;
    /**
     * Stores current headers payload
     * This will not store anything in case the NO_DATA_STORAGE flag is enabled
     */
    protected headerChunks: Buffer[];
    protected headerChunksLength: number;
    protected features: CurlFeature;
    /**
     * Whether this instance is running or not (called perform())
     */
    isRunning: boolean;
    constructor(cloneHandle?: EasyNativeBinding);
    protected defaultWriteFunction(chunk: Buffer, size: number, nmemb: number): number;
    protected defaultHeaderFunction(chunk: Buffer, size: number, nmemb: number): number;
    /**
     * Event called when an error is thrown on this handle.
     */
    onError(error: Error, errorCode: CurlCode): void;
    /**
     * Called when this handle has finished the request.
     */
    onEnd(): void;
    /**
     * Enables a feature, should not be used while a request is running.
     * Use `Curl.feature` for predefined constants.
     */
    enable(bitmask: CurlFeature): this;
    /**
     * Disables a feature, should not be used while a request is running.
     * Use `Curl.feature` for predefined constants.
     */
    disable(bitmask: CurlFeature): this;
    /**
     * Use `Curl.info` for predefined constants.
     * Official libcurl documentation: [curl_easy_getinfo()](http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html)
     */
    getInfo(infoNameOrId: CurlInfoName): string | number | null;
    /**
     * The option XFERINFOFUNCTION was introduced in curl version 7.32.0,
     *  versions older than that should use PROGRESSFUNCTION.
     * If you don't want to mess with version numbers you can use this method,
     * instead of directly calling `Curl.setOpt`
     *
     * NOPROGRESS should be set to false to make this function actually get called.
     */
    setProgressCallback(cb: ((dltotal: number, dlnow: number, ultotal: number, ulnow: number) => number) | null): this;
    /**
     * Add this instance to the processing queue.
     * This method should be called only one time per request,
     *  otherwise it will throw an exception.
     */
    perform(): this;
    /**
     * Perform any connection upkeep checks.
     */
    upkeep(): this;
    /**
     * Using this function, you can explicitly mark a running connection to get paused, and you can unpause a connection that was previously paused.
     *
     * The bitmask argument is a set of bits that sets the new state of the connection.
     *
     * Use `Curl.pause` for predefined constants.
     */
    pause(bitmask: CurlPause): this;
    /**
     * Reset this handle options to their defaults.
     */
    reset(): this;
    /**
     * Duplicate this handle with all their options.
     * Keep in mind that, by default, this also means all event listeners.
     *
     * Use the argument to change that behaviour.
     */
    dupHandle(shouldCopyEventListeners?: boolean): Curl;
    /**
     * Close this handle.
     *
     * **NOTE:** After closing the handle, it should not be used anymore! Doing so will throw an exception.
     */
    close(): void;
}
/**
 * Overloaded methods for the Curl class.
 */
interface Curl {
    on(event: 'data', listener: (this: Curl, chunk: Buffer, curlInstance: Curl) => void): this;
    on(event: 'header', listener: (this: Curl, chunk: Buffer, curlInstance: Curl) => void): this;
    on(event: 'error', listener: (this: Curl, error: Error, errorCode: CurlCode, curlInstance: Curl) => void): this;
    on(event: 'end', listener: (this: Curl, status: number, data: string | Buffer, headers: Buffer | HeaderInfo[], curlInstance: Curl) => void): this;
    on(event: string, listener: Function): this;
    /**
     * Use `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: ((data: Buffer, size: number, nmemb: number) => number) | null): this;
    /**
     * Use `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: ((dltotal: number, dlnow: number, ultotal: number, ulnow: number) => number | CurlProgressFunc) | null): this;
    /**
     * Use `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): this;
    /**
     * Use `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: ((fileInfo: FileInfo, remains: number) => number) | null): this;
    /**
     * Use `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: (() => number) | null): this;
    /**
     * Use `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: ((type: number, data: Buffer) => 0) | null): this;
    /**
     * Use `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: ((pattern: string, value: string) => number) | null): this;
    /**
     * Use `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: ((offset: number, origin: number) => number) | null): this;
    /**
     * Use `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: (() => string[] | false) | null): this;
    /**
     * Use `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): this;
    /**
     * Use `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): this;
    /**
     * Use `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): this;
    /**
     * Use `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): this;
    /**
     * Use `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): this;
    /**
     * Use `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): this;
}
export { Curl };
//# sourceMappingURL=Curl.d.ts.map