v2.3.0
Probably the last release that curly
is considered experimental.
Breaking Change
-
curly
(andcurly.<method>
) is now able to automatically parse the response body based on the content-type header of the response. #240
Default parsers forapplication/json
(callsJSON.parse
) andtext/*
(converts the rawBuffer
to a string withutf8
encoding) were added. This means that for responses without a matching content-type the rawBuffer
will be returned. This is different from the previous behavior where a string would always be returned.
The default parsers can be overwritten by settingcurly.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, liketext/*
. - a catch-all pattern: just
*
.
You can also override the parsers using the following options:
curlyResponseBodyParsers
object that will be merged withdefaultResponseBodyParsers
.curlyResponseBodyParser
a parser that will be used for all responses.
It's also possible to set
curlyResponseBodyParser
tofalse
and the data returned will always be the rawBuffer
.Of course, it is still possible to use your own
writeFunction
(libcurlCURLOPT_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 notget
,post
andhead
. - Errors thrown by the internal
Curl
instance used bycurly
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 newcurly
object that will use the passedoptions
as defaults. #247 - TypeScript:
curly
(andcurly.<method>
) now accepts a generic type parameter which will be the type of thedata
returned. By default, this is set toany
. - 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 setWRITEFUNCTION
and/orREADFUNCTION
manually. #237Curl.setUploadStream
Curl.setStreamProgress
Curl.setStreamResponseHighWaterMark
CurlFeature.StreamResponse
New options were also added to thecurly
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 usinggetInfo("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
. UseCurlPx
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