node-libcurl v2.3.0-0 Release Notes

Release Date: 2020-10-30 // over 1 year ago
  • ๐Ÿ’ฅ 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
    0๏ธโƒฃ 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.
    0๏ธโƒฃ 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.

    0๏ธโƒฃ 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.
    • 0๏ธโƒฃ Progress callbacks were not allowing to use default libcurl progress meter (by returning CurlProgressFunc.Continue).

    โž• Added

    • 0๏ธโƒฃ Calling curly.create(options) will now return a new curly object that will use the passed options as defaults. #247
    • 0๏ธโƒฃ 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 not 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