summaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
authorMax Dymond <max.dymond@microsoft.com>2021-07-22 15:32:30 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-09-27 17:16:43 +0200
commita517378de58358a85b7cfe9efecb56051268f629 (patch)
tree8b8b43685911d3cbc6450b8d7255f5a10d2b8795 /lib/multi.c
parent06981ba7f620364eba253f5afcd7ebfaefcc8694 (diff)
downloadcurl-a517378de58358a85b7cfe9efecb56051268f629.tar.gz
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
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/multi.c b/lib/multi.c
index 68c1a64d5..f31b25262 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -2028,6 +2028,28 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
case MSTATE_DO:
+ if(data->set.fprereq) {
+ int prereq_rc;
+
+ /* call the prerequest callback function */
+ Curl_set_in_callback(data, true);
+ prereq_rc = data->set.fprereq(data->set.prereq_userp,
+ data->info.conn_primary_ip,
+ data->info.conn_local_ip,
+ data->info.conn_primary_port,
+ data->info.conn_local_port);
+ Curl_set_in_callback(data, false);
+ if(prereq_rc != CURL_PREREQFUNC_OK) {
+ failf(data, "operation aborted by pre-request callback");
+ /* failure in pre-request callback - don't do any other processing */
+ result = CURLE_ABORTED_BY_CALLBACK;
+ Curl_posttransfer(data);
+ multi_done(data, result, FALSE);
+ stream_error = TRUE;
+ break;
+ }
+ }
+
if(data->set.connect_only) {
/* keep connection open for application to use the socket */
connkeep(data->conn, "CONNECT_ONLY");