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 rawBufferto a string withutf8encoding) were added. This means that for responses without a matching content-type the rawBufferwill be returned. This is different from the previous behavior where a string would always be returned.
The default parsers can be overwritten by settingcurly.defaultResponseBodyParsersto an object with the format:{ 'content-type': (data: Buffer, headers: HeaderInfo[]) => any }Where
content-typecan 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:
curlyResponseBodyParsersobject that will be merged withdefaultResponseBodyParsers.curlyResponseBodyParsera parser that will be used for all responses.
It's also possible to set
curlyResponseBodyParsertofalseand the data returned will always be the rawBuffer.Of course, it is still possible to use your own
writeFunction(libcurlCURLOPT_WRITEFUNCTIONoption) 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,postandhead. - Errors thrown by the internal
Curlinstance used bycurlynot 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 newcurlyobject that will use the passedoptionsas defaults. #247 - TypeScript:
curly(andcurly.<method>) now accepts a generic type parameter which will be the type of thedatareturned. By default, this is set toany. - Added new options to the
curlyAPI: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
CurlFeatureallowing the use of streams to upload and download data without having to setWRITEFUNCTIONand/orREADFUNCTIONmanually. #237Curl.setUploadStreamCurl.setStreamProgressCurl.setStreamResponseHighWaterMarkCurlFeature.StreamResponse
New options were also added to thecurlyAPI:curlyProgressCallbackcurlyStreamResponsecurlyStreamResponseHighWaterMarkcurlyStreamUpload
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. UseCurlPxfor 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
curlynow has 100% code coverage.
Removed
- Removed prebuilt binaries for: Electron v3, Electron v4, Nwjs v0.42, and Nwjs v0.43