CURLOPT_PREREQFUNCTION: add new callback

Triggered before a request is made but after a connection is set up

Changes:

- callback: Update docs and callback for pre-request callback
- Add documentation for CURLOPT_PREREQDATA and CURLOPT_PREREQFUNCTION,
- Add redirect test and callback failure test
- Note that the function may be called multiple times on a redirection
- Disable new 2086 test due to Windows weirdness

Closes #7477
This commit is contained in:
Max Dymond 2021-07-22 15:32:30 +01:00 committed by Daniel Stenberg
parent 06981ba7f6
commit a517378de5
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
21 changed files with 602 additions and 4 deletions

View file

@ -470,6 +470,20 @@ typedef int (*curl_debug_callback)
size_t size, /* size of the data pointed to */
void *userptr); /* whatever the user please */
/* This is the CURLOPT_PREREQFUNCTION callback prototype. */
typedef int (*curl_prereq_callback)(void *clientp,
char *conn_primary_ip,
char *conn_local_ip,
int conn_primary_port,
int conn_local_port);
/* Return code for when the pre-request callback has terminated without
any errors */
#define CURL_PREREQFUNC_OK 0
/* Return code for when the pre-request callback wants to abort the
request */
#define CURL_PREREQFUNC_ABORT 1
/* All possible error codes from all sorts of curl functions. Future versions
may return other values, stay prepared.
@ -2105,6 +2119,13 @@ typedef enum {
/* used by scp/sftp to verify the host's public key */
CURLOPT(CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, CURLOPTTYPE_STRINGPOINT, 311),
/* Function that will be called immediately before the initial request
is made on a connection (after any protocol negotiation step). */
CURLOPT(CURLOPT_PREREQFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 312),
/* Data passed to the CURLOPT_PREREQFUNCTION callback */
CURLOPT(CURLOPT_PREREQDATA, CURLOPTTYPE_CBPOINT, 313),
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;