Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-libcurl-impersonate

SwapnilSoni199995MIT2.3.5TypeScript support: included

The fastest http(s) client (and much more) for Node.js - Node.js bindings for libcurl (curl-impersonate)

node-curl, curl, libcurl, node-libcurl, axios, request, curl-impersonate

readme

node-libcurl

Buy Me A Coffee
Patreon Logo
Discord Logo

NPM version license Dependencies

Travis CI Status AppVeyor CI Status Code Quality

The fastest URL transfer library for Node.js.

libcurl bindings for Node.js. libcurl official description:

libcurl is a free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more!

Quick Start

Note:

  • This library cannot be used in a browser, it depends on native code.
  • There is no worker threads support at the moment. See #169

Install

npm i node-libcurl --save

or

yarn add node-libcurl

Simple Request - Async / Await using curly

this API is experimental and is subject to changes without a major version bump

const { curly } = require('node-libcurl');

const { statusCode, data, headers } = await curly.get('http://www.google.com')

Any option can be passed using their FULLNAME or a lowerPascalCase format:

const querystring = require('querystring');
const { curly } = require('node-libcurl');

const { statusCode, data, headers } = await curly.post('http://httpbin.com/post', {
  postFields: querystring.stringify({
    field: 'value',
  }),
  // can use `postFields` or `POSTFIELDS`
})

JSON POST example:

const { curly } = require('node-libcurl')
const { data } = await curly.post('http://httpbin.com/post', {
  postFields: JSON.stringify({ field: 'value' }),
  httpHeader: [
    'Content-Type: application/json',
    'Accept: application/json'
  ],
})

console.log(data)

Simple Request - Using Curl class

const { Curl } = require('node-libcurl');

const curl = new Curl();

curl.setOpt('URL', 'www.google.com');
curl.setOpt('FOLLOWLOCATION', true);

curl.on('end', function (statusCode, data, headers) {
  console.info(statusCode);
  console.info('---');
  console.info(data.length);
  console.info('---');
  console.info(this.getInfo( 'TOTAL_TIME'));

  this.close();
});

curl.on('error', curl.close.bind(curl));
curl.perform();

Setting HTTP headers

Pass an array of strings specifying headers

curl.setOpt(Curl.option.HTTPHEADER,
  ['Content-Type: application/x-amz-json-1.1'])

Form Submission (Content-Type: application/x-www-form-urlencoded)

const querystring = require('querystring');
const { Curl } = require('node-libcurl');

const curl = new Curl();
const close = curl.close.bind(curl);

curl.setOpt(Curl.option.URL, '127.0.0.1/upload');
curl.setOpt(Curl.option.POST, true)
curl.setOpt(Curl.option.POSTFIELDS, querystring.stringify({
  field: 'value',
}));

curl.on('end', close);
curl.on('error', close);

MultiPart Upload / HttpPost libcurl Option (Content-Type: multipart/form-data)

const { Curl } = require('node-libcurl');

const curl = new Curl();
const close = curl.close.bind(curl);

curl.setOpt(Curl.option.URL, '127.0.0.1/upload.php');
curl.setOpt(Curl.option.HTTPPOST, [
    { name: 'input-name', file: '/file/path', type: 'text/html' },
    { name: 'input-name2', contents: 'field-contents' }
]);

curl.on('end', close);
curl.on('error', close);

Binary Data

When requesting binary data make sure to do one of these:

The reasoning behind this is that by default, the Curl instance will try to decode the received data and headers to utf8 strings, as can be seen here: https://github.com/JCMais/node-libcurl/blob/b55b13529c9d11fdcdd7959137d8030b39427800/lib/Curl.ts#L391

For more examples check the examples folder.

API

API documentation for the latest stable version is available at https://node-libcurl-docs.netlify.app/modules/libindex_.html.

Develop branch documentation is available at https://develop--node-libcurl-docs.netlify.app/modules/libindex_.html.

This library provides Typescript type definitions.

Almost all CURL options are supported, if you pass one that is not, an error will be thrown.

For more usage examples check the examples folder.

Special Notes

READFUNCTION option

The buffer passed as first parameter to the callback set with the READFUNCTION option is initialized with the size libcurl is using in their upload buffer (which can be set with UPLOAD_BUFFERSIZE), this is initialized using node::Buffer::Data(buf); which is basically the same than Buffer#allocUnsafe and therefore, it has all the implications as to its correct usage: https://nodejs.org/pt-br/docs/guides/buffer-constructor-deprecation/#regarding-buffer-allocunsafe

So, be careful, make sure to return exactly the amount of data you have written to the buffer on this callback. Only that specific amount is going to be copied and handed over to libcurl.

Common Issues

See COMMON_ISSUES.md

Benchmarks

See ./benchmark

Security

See SECURITY.md

Supported Libcurl Versions

The addon is only tested against libcurl version 7.50.0 and the latest one available.

The code itself is made to compile with any version greater than 7.32.0, any libcurl version lower than that is not supported.

For Enterprise

node-libcurl is available as part of the Tidelift Subscription.

The maintainers of node-libcurl and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Detailed Installation

The latest version of this package has prebuilt binaries (thanks to node-pre-gyp) available for:

  • Node.js: Latest two versions on active LTS (see https://github.com/nodejs/Release)
  • Electron: Latest 3 major versions
  • NW.js (node-webkit): Latest 3 major (minor for nw.js case) versions

And on the following platforms:

  • Linux 64 bits
  • Mac OS X 64 bits
  • Windows 32 and 64 bits

Installing with yarn add node-libcurl or npm install node-libcurl should download a prebuilt binary and no compilation will be needed. However if you are trying to install on nw.js or electron additional steps will be required, check their corresponding section below.

The prebuilt binary is statically built with the following library versions, features and protocols (library versions may change between Node.js versions):

Version: libcurl/7.73.0 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 zstd/1.4.9 c-ares/1.16.1 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.41.0
Protocols: dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Features: AsynchDNS, IDN, IPv6, Largefile, NTLM, NTLM_WB, SSL, libz, brotli, TLS-SRP, HTTP2, UnixSockets, HTTPS-proxy

If there is no prebuilt binary available that matches your system, or if the installation fails, then you will need an environment capable of compiling Node.js addons, which means:

If you don't want to use the prebuilt binary even if it works on your system, you can pass a flag when installing:

With npm

npm install node-libcurl --build-from-source

With yarn

npm_config_build_from_source=true yarn add node-libcurl

Important Notes on Prebuilt Binaries / Direct Installation

Those notes are not important when building on Windows

The prebuilt binaries are statically linked with brotli, libidn2, libssh2, openLDAP, OpenSSL nghttp2, zstd and zlib.

The brotli, nghttp2, OpenSSL and zlib versions must match the version Node.js uses, this is necessary to avoid any possible issues by mixing library symbols of different versions, since Node.js also exports some of the symbols of their deps.

In case you are building the addon yourself with the libraries mentioned above, you must make sure their version is ABI compatible with the one Node.js uses, otherwise you are probably going to hit a Segmentation Fault.

If you want to build a statically linked version of the addon yourself, you need to pass the curl_static_build=true flag when calling install.

If using npm:

npm install node-libcurl --build-from-source --curl_static_build=true

If using yarn:

npm_config_build_from_source=true npm_config_curl_static_build=true yarn add node-libcurl

The build process will use curl-config available on path, if you want to overwrite it to your own libcurl installation one, you can set the curl_config_bin variable, like mentioned above for curl_static_build.

And if you don't want to use curl-config, you can pass two extra variables to control the build process:

  • curl_include_dirs Space separated list of directories to search for header files
  • curl_libraries Space separated list of flags to pass to the linker

Missing Packages

The statically linked version currently does not have support for GSS-API, SPNEGO, KERBEROS, RTMP, Metalink, PSL and Alt-svc.

The scripts to build Kerberos exists on the ./scripts/ci folder, but it was removed for two reasons:

  • If built with Heimdal, the addon becomes too big
  • If built with MIT Kerberos, the addon would be bound to their licensing terms.

Electron / NW.js

If building for a Electron or NW.js you need to pass additional parameters to the install command.

If you do not want to use the prebuilt binary, pass the npm_config_build_from_source=true / --build-from-source flag to the install command.

NW.js (aka node-webkit)

For building from source on NW.js you first need to make sure you have nw-gyp installed globally: yarn global add nw-gyp or npm i -g nw-gyp

If on Windows, you also need addition steps, currently the available win_delay_load_hook.cc on nw-gyp is not working with this addon, so it's necessary to apply a patch to it. The patch can be found on ./scripts/ci/patches/win_delay_load_hook.cc.patch, and should be applied to the file on <nw-gyp-folder>/src/win_delay_load_hook.cc.

Then:

yarn

npm_config_runtime=node-webkit npm_config_target=0.38.2 yarn add node-libcurl

npm

npm install node-libcurl --runtime=node-webkit --target=0.38.2 --save

where --target is the current version of NW.js you are using

Electron (aka atom-shell)

yarn

npm_config_runtime=electron npm_config_target=$(yarn --silent electron --version) npm_config_disturl=https://www.electronjs.org/headers yarn add node-libcurl

npm

npm install node-libcurl --runtime=electron --target=$(yarn --silent electron --version) --disturl=https://www.electronjs.org/headers --save

Where --target is the version of electron you are using, in our case, we are just using the version returned by the locally installed electron binary.

You can also put those args in a .npmrc file, like so:

runtime = electron
target = 5.0.1
target_arch = x64
dist_url = https://atom.io/download/atom-shell

Electron >= 11 / NW.js >= 0.50

If you are building for Electron >= 11 or NW.js >= 0.50 you need to set the build process to use the C++17 std, you can do that by passing the variable node_libcurl_cpp_std=c++17. The way you do that depends if you are using npm or yarn:

If using npm:

npm install node-libcurl --node_libcurl_cpp_std=c++17 <...other args...>

If using yarn:

npm_config_node_libcurl_cpp_std=c++17 <...other args...> yarn add node-libcurl

Building on Linux

To build the addon on linux based systems you must have:

  • gcc >= 4.8
  • libcurl dev files
  • python 2.7

If you are on a debian based system, you can get those by running:

sudo apt-get install python libcurl4-openssl-dev build-essential

If you don't want to use the libcurl version shipped with your system, since it's probably very old, you can install libcurl from source, for the addon to use that libcurl version you can use the variable mentioned above, curl_config_bin.

In case you want some examples check the CI configuration files (.travis.yml, .circleci/config.yml) and the scripts/ci/ folder.

Building on macOS

On macOS you must have:

  • macOS >= 10.12 (Sierra)
  • Xcode Command Line Tools

You can check if you have Xcode Command Line Tools be running:

xcode-select -p

It should return their path, in case it returns nothing, you must install it by running:

xcode-select --install

Xcode >= 10 | macOS >= Mojave

In case you have errors installing the addon from source, and you are using macOS version >= Mojave, check if the error you are receiving is the following one:

  CXX(target) Release/obj.target/node_libcurl/src/node_libcurl.o
  clang: error: no such file or directory: '/usr/include'

If that is the case, it's because newer versions of the Command Line Tools does not add the /usr/include folder by default. Check Xcode 10 release notes for details.

The /usr/include is now available on $(xcrun --show-sdk-path)/usr/include. To correctly build libcurl you then need to pass that path to the npm_config_curl_include_dirs environment variable:

npm_config_curl_include_dirs="$(xcrun --show-sdk-path)/usr/include" yarn add node-libcurl

Building on Windows

If installing using a prebuilt binary you only need to have the visual c++ 2017 runtime library.

If building from source, you must have:

Python 2.7 and the Visual Studio compiler can be installed by running:

npm install --global --production windows-build-tools

nasm can be obtained from their website, which is linked above, or using chocolatey:

cinst nasm

Currently there is no support to use other libcurl version than the one provided by the curl-for-windows submodule (help is appreciated on adding this feature).

An important note about building the addon on Windows is that we have to do some "hacks" with the header files included by node-gyp/nw-gyp. The reason for that is because as we are using a standalone version of OpenSSL, we don't want to use the OpenSSL headers provided by Node.js, which are by default added to <nw-gyp-or-node-gyp-folder>/include/node/openssl, so what we do is that before compilation that folder is renamed to openssl.disabled. After a successful installation the folder is renamed back to their original name, however if any error happens during compilation the folder will stay renamed until the addon is compiled successfully. More info on why that was needed and some context can be found on issue #164.

Getting Help

If your question is directly related to the addon or their usage, you can get help the following ways:

  • Post a question on stack-overflow and use the node-libcurl tag.
  • Join our Discord server and send your question there.

Contributing

Read CONTRIBUTING.md

Donations / Patreon

Some people have been asking if there are any means to support my work, I've created a patreon page for that: https://www.patreon.com/jonathancardoso

If you want to donate via PayPal, use the same e-mail that is available on my GitHub profile: https://github.com/JCMais

And thanks for reading till here! 😄

Originally this addon was based on the work from jiangmiao/node-curl, things have changed and most if not all code has been rewritten.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

Breaking Change

Fixed

Added

Changed

Removed

2.3.4 - 2022-01-29

Added

  • support curl_blob options #300 by @johnwchadwick
  • added arm64 builds for macOS #312 by @johnwchadwick
  • added most options that were missing up to libcurl version 7.79.1, including HSTS support.
  • added prebuilt binaries for Node.js v17.

Changed

  • Upgraded prebuild binaries to use libcurl 7.79.1. On Windows, OpenSSL 3.0.0 will be used.
  • The only Electron versions with prebuilt binaries are: 16, 15, 14, 13, 12, and 11.
  • The only Nwjs versions with prebuilt binaries are: 0.58, 0.57, and 0.56.

2.3.3 - 2021-05-09

Fixed

  • Fix support for Node.js v16

2.3.2 - 2021-03-24

Changed

  • The prebuilt binaries are not build with c-ares anymore, for reasoning see issue #280. c-ares was included in the prebuilt binaries starting with 2.3.0.

2.3.1 - 2021-03-09

The yes, curly is still experimental release. 😅

If you are using curly in your project, and you want to share any feedback about it, please post them in our Discord. I would love to read and discuss it!

Fixed

  • Fixed not building zstd lib statically. #274
  • Fixed download streams not working with responses that did not include a body. #271

Added

  • Added prebuilt binaries for: Node.js 15, Electron v11, Electron v12, Nwjs 0.49.2, Nwjs 0.51.2, and Nwjs 0.52.0.

Changed

  • Building the addon from source now requires a C++ compiler with support for c++1z (c++17).

Removed

  • Removed prebuilt binaries for: Node.js 10, Electron v5, Electron v6, Electron v7, Nwjs v0.43, and Nwjs v0.44.

2.3.0 - 2020-11-15

Probably the last release that curly is considered experimental.

Breaking Change

  • curly (and curly.<method>) is now able to automatically parse the response body based on the content-type header of the response. #240
    Default parsers for application/json (calls JSON.parse) and text/* (converts the raw Buffer to a string with utf8 encoding) were added. This means that for responses without a matching content-type the raw Buffer will be returned. This is different from the previous behavior where a string would always be returned. The default parsers can be overwritten by setting curly.defaultResponseBodyParsers to an object with the format:

    {
      'content-type': (data: Buffer, headers: HeaderInfo[]) => any
    }

    Where content-type can be one of these:

    • the exact content-type.
    • a pattern using * to match specific parts of the content-type, like text/*.
    • a catch-all pattern: just *.

    You can also override the parsers using the following options:

    • curlyResponseBodyParsers object that will be merged with defaultResponseBodyParsers.
    • curlyResponseBodyParser a parser that will be used for all responses.

    It's also possible to set curlyResponseBodyParser to false and the data returned will always be the raw Buffer.

    Of course, it is still possible to use your own writeFunction (libcurl CURLOPT_WRITEFUNCTION option) to set your own write callback and not rely on this default handling of the response.

As curly is marked as experimental, this allows us to do a breaking change in a minor version bump. This release should make the curly API more stable and provide a better developer experience, however, the API remains experimental.

Fixed

  • Some curly.<method> calls not working correctly, to be more specific, all calls that were not get, post and head.
  • Errors thrown by the internal Curl instance used by curly not being re-thrown correctly.
  • Progress callbacks were not allowing to use default libcurl progress meter (by returning CurlProgressFunc.Continue).

Added

  • Calling curly.create(options) will now return a new curly object that will use the passed options as defaults. #247
  • TypeScript: curly (and curly.<method>) now accepts a generic type parameter which will be the type of the data returned. By default, this is set to any.
  • Added new options to the curly API:
    • curlyBaseUrl: string, if set, their value will always be added as the prefix for the URL.
    • curlyLowerCaseHeaders: boolean, if set to true, headers will be returned in lower case. Defaults to false. #240
  • Added new methods and CurlFeature allowing the use of streams to upload and download data without having to set WRITEFUNCTION and/or READFUNCTION manually. #237
    • Curl.setUploadStream
    • Curl.setStreamProgress
    • Curl.setStreamResponseHighWaterMark
    • CurlFeature.StreamResponse
      New options were also added to the curly API:
    • curlyProgressCallback
    • curlyStreamResponse
    • curlyStreamResponseHighWaterMark
    • curlyStreamUpload
      These new features related to streams are only reliable when using a libcurl version >= 7.69.1.
  • Support libcurl info CURLINFO_CERTINFO. Can be retrieved using getInfo("CERTINFO"). Thanks to @Sergey-Mityukov for most of the work on this.
  • Support libcurl info CURLINFO_EFFECTIVE_METHOD. Requires libcurl >= 7.72.0.
  • Support libcurl info CURLINFO_PROXY_ERROR. Use CurlPx for constants. Requires libcurl >= 7.73.0.
  • Support libcurl option CURLOPT_SSL_EC_CURVES. Requires libcurl >= 7.73.0.
  • Added prebuilt binaries for Electron v10.1
  • The libcurl version being used by prebuilt binaries is now 7.73.0 and it's now built with c-ares.

Changed

  • curly now has 100% code coverage.

Removed

  • Removed prebuilt binaries for: Electron v3, Electron v4, Nwjs v0.42, and Nwjs v0.43

2.2.0 - 2020-07-14

Fixed

  • Fix curly.get not working correctly (#230)
  • Fix not resetting CURLOPT_TRAILERDATA when duplicating an Easy instance (7bf3a51)

    Added

  • Added initial support to the CURLMOPT_PUSHFUNCTION libcurl multi option. (#232) (b8d0fac)
  • Added private member to the EasyNativeBinding typescript class, you can set this value on the Easy instances to anything, and Typescript should not complain.
  • Adde prebuilt binaries for Electron v9

    Changed

  • Improved Typescript types / documentation for some libcurl options. (63a71b7)

2.1.3 - 2020-06-02

Fixed

  • v2.1.2 had a caching issue on during the dist files generation, which caused it to not build some required files.

2.1.2 - 2020-06-01

Fixed

  • Fix curly.post and curly.head using wrong libcurl options to set the HTTP Method.
  • Fix postinstall script not working properly.
  • Setting the HTTPPOST option to nullwould, wrongly, throw an Error.
  • Setting any string option to null would, wrongly, throw an Error.

    Added

  • We now have API docs! 🥳 http://jcmais.github.io/node-libcurl/modules/_index_.html Thanks to typedoc
  • Added back prebuilt binaries for:
    • Electron v3, v4 and v5
  • Added isMonitoringSockets boolean readonly property to Easy instances, it is true when monitorSocketEvents has been called on that Easy instance.
  • Added CurlVersion enum to be used with the rawFeatures property returned from Curl.getVersionInfo.

2.1.1 - 2020-04-28

Fixed

  • Remove benchmark folder from the distributed npm package (reducing the package size)

2.1.0 - 2020-04-12

Fixed

  • Fix retrieve-win-deps Windows build script not working correctly
  • Fix context switches between addon callbacks not causing Node.js to drain microtasks - (#177)
  • Fix some curl_off_t getinfo values corrupting the stack
  • WRITEFUNCTION, HEADERFUNCTION and READFUNCTION callbacks now correctly rethrow JS errors thrown inside of them. The return value of both callbacks is now also checked to be an integer, any other type will cause an error. This is considered a fix because previously the return value was being cast to an integer, which means the method would already fail, as there are remote chances (aka impossible) casting something else to an integer would yield the length of the data passed by libcurl.

Added

  • Added missing CURLOPT_SASL_AUTHZID option - libcurl 7.66.0
  • Added missing CURLE_AUTH_ERROR error code added with libcurl 7.66.0
  • Added missing CURLINFO_RETRY_AFTER info field - libcurl 7.66.0
  • Added missing CURL_HTTP_VERSION_3 constant related http version to the CurlHttpVersion enum - libcurl 7.66.0
  • Added missing CURLMOPT_MAX_CONCURRENT_STREAMS option - libcurl 7.67.0
  • Added missing CurlProgressFunc enum to reflect the new CURL_PROGRESSFUNC_CONTINUE constant - libcurl 7.68.0
  • Added missing CurlSslOpt enum member NoPartialChain - libcurl 7.68.0
  • Added missing CURLE_HTTP3 error code - An HTTP/3 layer problem - libcurl 7.68.0
  • Added missing CURLM_WAKEUP_FAILURE error code - wakeup is unavailable or failed - libcurl 7.68.0
  • Added missing CURLM_BAD_FUNCTION_ARGUMENT error code - function called with a bad parameter - libcurl 7.69.0
  • Added missing CURLE_QUIC_CONNECT_ERROR error code - QUIC connection error - libcurl 7.69.0
  • Added missing CURLOPT_MAIL_RCPT_ALLLOWFAILS option - libcurl 7.69.0

Changed

  • Prebuilt binaries are now compiled with libcurl 7.69.1 and, when possible, latest version of other related dependencies:
    • OpenSSL 1.1.1d
    • nghttp2 1.4.0
    • libssh2 1.9.0
  • Added prebuilt binaries for:
    • Electron v8
    • NW.js v0.44, v0.43 and v0.42
  • Dropped prebuilt binaries for:
    • Node.js 8
    • Electron v3, v4 and v5
    • NW.js v0.38 and v0.39
  • Remove dynamic require (#204)
  • The C++ implementation for the previously removed onData and onHeader Curl/Easy instance fields has been removed - If you were still using those internal fields your code is going to break. Use WRITEFUNCTION and HEADERFUNCTION options instead.

2.0.3 - 2019-12-11

Fixed

  • Updated return type of DEBUGFUNCTION (#202)
  • Fixed issues when building with newer versions of v8 (Node.js >= 13 and Electron >= 7) (#203)

Added

  • Type for this added to event listeners callbacks
  • Build on Node.js 13 and Electron 7

2.0.2 - 2019-09-20

Added

  • Build on Electron v6

    Changed

  • Improved build scripts
  • bump libssh2 to 1.9.0

2.0.1 - 2019-06-06

Fixed

  • Fixed problem when building with libcurl <= 7.38

2.0.0 - 2019-06-02

Breaking Change

  • Dropped support for Node.js 4 and 6
  • Prebuilt binary is now statically built with brotli, libssh2, nghttp2, OpenSSL and zlib. brotli, OpenSSL, nghttp2 and zlib versions match their respective versions used by Node.js.
  • The minimum libcurl version being tested is now 7.50.0, which itself is almost 3 years old.
    The addon will still try to be compatible with old versions up to 7.32.0, but there are no guarantees.
  • Curl.reset now correctly resets their instance (#141)
  • Previously Curl.code had all Curl codes into a single enum like object, that is, it included properties for each CURLMCode, CURLcode and CURLSHcode libcurl enums.
    Now they are separated, each on their own object:
    CURLMCode -> CurlMultiCode
    CURLcode -> CurlCode
    CURLSHCode -> CurlShareCode
  • DEBUGFUNCTION now receives a Buffer as the data argument, instead of a string.
  • Easy.send and Easy.recv now return an object, { code: CurlCode, bytesSent: number } and { code: CurlCode, bytesReceived: number } respectively.
  • Curl class: removed _ prefix from their private members.
    Only a breaking change in case you were using internal methods.
  • Curl class: methods onData and onHeader renamed to defaultWriteFunction and defaultHeaderFunction.
    Only a breaking change in case you were using internal methods.
  • Curl class: deprecated instance fields onData and onHeader were removed.
    Use options WRITEFUNCTION and HEADERFUNCTION respectively.
  • Curl.dupHandle, argument shouldCopyCallbacks was removed, it was the first one.
    This is not needed anymore because the previously set callbacks (onData and onHeader) can now only be set using their respective libcurl options, which is always copied when duplicating a handle.
  • Curl.multi moved to Multi.option
  • Curl.share moved to Share.option
  • Following members were moved to their own export:
    Curl.auth -> CurlAuth
    Curl.pause -> CurlPause
    Curl.http -> CurlHttpversion
    Curl.feature -> CurlFeature
    Curl.lock -> CurlShareLock
    Curl.header -> CurlHeader
    Curl.info.debug -> CurlInfoDebug
    Curl.netrc -> CurlNetrc
    Curl.chunk -> CurlChunk
    Curl.filetype -> CurlFileType
    Curl.fnmatchfunc -> CurlFnMatchFunc
    Curl.ftpauth -> CurlFtpAuth
    Curl.ftpssl -> CurlFtpSsl
    Curl.ftpmethod -> CurlFtpMethod
    Curl.rtspreq -> CurlRtspRequest
    Curl.ipresolve -> CurlIpResolve
    Curl.proxy -> CurlProxy
    Curl.pipe -> CurlPipe
    Curl.usessl -> CurlUseSsl
    Curl.sslversion -> CurlSslVersion
    Curl.sslversion.max -> CurlSslVersionMax
    Curl.ssh_auth -> CurlSshAuth
    Curl.timecond -> CurlTimeCond
    Easy.socket -> SocketState
    And their fields were changed from SNAKE_CASE to PascalCase.
    The change in casing was to follow Typescript's Enum naming convention.
  • Curl.protocol also moved to their own export CurlProtocol, no changes were made to fields casing in this case.
  • Passing non-integer option value to Multi.setOpt will now throw an error.
    Previously the value was converted to 1 if it was a truthy value, or 0 if otherwise.

    Fixed

  • Fix SigAbort caused by calling v8 AsFunction on null value at Easy::SetOpt
  • Fix SegFault during gargage collection after process.exit (#165)
  • Using curl_socket_t without libcurl version guard on Easy::GetInfo

    Added

  • Support Node.js 12
  • Added missing options:
    • CURLOPT_DISALLOW_USERNAME_IN_URL
    • CURLOPT_DNS_SHUFFLE_ADDRESSES
    • CURLOPT_DOH_URL
    • CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS
    • CURLOPT_HAPROXYPROTOCOL
    • CURLOPT_HTTP09_ALLOWED
    • CURLOPT_REQUEST_TARGET
    • CURLOPT_FTP_FILEMETHOD (#148)
    • CURLOPT_MAXAGE_CONN
    • CURLOPT_PROXY_*
    • CURLOPT_RTSPHEADER
    • CURLOPT_RTSP_REQUEST
    • CURLOPT_SOCKS5_AUTH
    • CURLOPT_SSH_COMPRESSION
    • CURLOPT_TLS13_CIPHERS
    • CURLOPT_TIMEVALUE_LARGE
    • CURLOPT_TRAILERFUNCTION
    • CURLOPT_UPKEEP_INTERVAL_MS
  • Add missing info fields:
    • CURLINFO_*_{DOWNLOAD,UPLOAD}_T
    • CURLINFO_*_TIME_T
    • CURLINFO_FILETIME_T
  • Add Curl.getVersionInfo() which returns an object that represents the struct returned from curl_version_info().
    See their type definition for details: [./lib/types/CurlVersionInfoNativeBinding.ts](./lib/types/
  • Add Curl.getVersionInfoString() which returns a string representation of the above function.
    It should be almost identical to the one returned from curl -V.
  • Add Curl.isVersionGreaterOrEqualThan(x, y, z) to help test if the libcurl version the addon was built against is greater or equal than x.y.z.
  • Add upkeep function to Easy and Curl classes. This is a binding for the curl_easy_upkeep() function.
  • Errors thrown inside callbacks are correctly caught / passed forward (if using multi interface)
  • All Curl instances now set their USERAGENT to node-libcurl/${packageVersion} during creation.
    You change the default user agent string by changing Curl.defaultUserAgent, and disable it by setting their value to null.
  • CurlWriteFunc and CurlReadFunc enums with special return codes for their respective options, WRITEFUNCTION and READFUNCTION.
  • Added experimental curly(url: string, options: {}) / curly.<http-verb>(url: string, options: {}) async api.
    This API can change between minor releases.

    Changed

  • Migrated project to Typescript and added type definitions
  • Bumped libcurl version used on Windows to 7.64.1, which has nghttp2 support
  • Added the Curl instance that emitted the event as the last param passed to events, can be useful if using anonymous functions as callback for the events. Example:
      // ...
      curl.on('end', (statusCode, data, headers, curlInstance) => {
         // ...
      })
  • Fix erratic condition when setting option HEADERFUNCTION (#142)
  • macOS libs should be linked against @rpath (#145)

Special Thanks to @koskokos2 for their contributions to this release.

1.3.3

Added

  • Node.js 10 on CI and respective prebuilt binaries

    Changed

  • Removed deprecated NAN method calls

1.3.2 - 2018-05-24

Fixed

  • Curl multi integer options being wrongly tested (#126)

1.3.1 - 2018-05-04

Added

  • Changelog file (finally)

    Changed

  • Improved code style, started using prettier

    1.2.0 - 2017-08-28