Skip to content

feat: add support for the CURLOPT_PREREQFUNCTION option #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- The prebuilt binaries on musl Linux (Alpine) are now built on Alpine 3.16.
- The prebuilt binaries on Windows are now built with Visual Studio 2019.
- There are no prebuilt binaries for NW.js anymore. This is because nw-gyp does not support Python 3 currently.
- Option types for `CURLOPT_FTP_RESPONSE_TIMEOUT` has been removed, since libcurl 7.20 it was the same as `CURLOPT_SERVER_RESPONSE_TIMEOUT`.

### Fixed
### Added
- Add support for the [`CURLOPT_PREREQFUNCTION`](https://curl.haxx.se/libcurl/c/CURLOPT_MAIL_RCPT_ALLLOWFAILS) option.

### Changed
### Removed

Expand Down
22 changes: 21 additions & 1 deletion lib/Curl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { CurlInfoDebug } from './enum/CurlInfoDebug'
import { CurlIpResolve } from './enum/CurlIpResolve'
import { CurlNetrc } from './enum/CurlNetrc'
import { CurlPause } from './enum/CurlPause'
import { CurlPreReqFunc } from './enum/CurlPreReqFunc'
import { CurlProgressFunc } from './enum/CurlProgressFunc'
import { CurlProtocol } from './enum/CurlProtocol'
import { CurlProxy } from './enum/CurlProxy'
Expand Down Expand Up @@ -269,7 +270,8 @@ class Curl extends EventEmitter {
protected streamPauseNext = false
protected streamContinueNext = false
protected streamError: false | Error = false
protected streamUserSuppliedProgressFunction: CurlOptionValueType['xferInfoFunction'] = null
protected streamUserSuppliedProgressFunction: CurlOptionValueType['xferInfoFunction'] =
null

/**
* @param cloneHandle {@link "Easy".Easy | `Easy`} handle that should be used instead of creating a new one.
Expand Down Expand Up @@ -1337,6 +1339,24 @@ interface Curl {
) => any)
| null,
): this
/**
* Use {@link "Curl".Curl.option|`Curl.option`} for predefined constants.
*
*
* Official libcurl documentation: [`curl_easy_setopt()`](http://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
*/
setOpt(
option: 'PREREQFUNCTION',
value:
| ((
this: EasyNativeBinding,
connPrimaryIp: string,
connLocalIp: string,
connPrimaryPort: number,
conLocalPort: number,
) => CurlPreReqFunc)
| null,
): this
/**
* Use {@link "Curl".Curl.option|`Curl.option`} for predefined constants.
*
Expand Down
18 changes: 18 additions & 0 deletions lib/enum/CurlPreReqFunc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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.
*/
// https://github.com/curl/curl/blob/e1be8254534898fccafc5d6cd04f6235f283cfbd/include/curl/curl.h#L342
/**
* Object to be used as the return value for the callback set with the option `PREREQFUNCTION`
*
* `CURL_PREREQFUNC_OK` becomes `CurlPreReqFunc.Ok`
*
* @public
*/
export enum CurlPreReqFunc {
Ok,
Abort,
}
Loading