mirror of
https://github.com/curl/curl.git
synced 2026-04-21 09:52:13 +03:00
url: Add option CURLOPT_RESOLVER_START_FUNCTION
- Add new option CURLOPT_RESOLVER_START_FUNCTION to set a callback that will be called every time before a new resolve request is started (ie before a host is resolved) with a pointer to backend-specific resolver data. Currently this is only useful for ares. - Add new option CURLOPT_RESOLVER_START_DATA to set a user pointer to pass to the resolver start callback. Closes https://github.com/curl/curl/pull/2311
This commit is contained in:
parent
dd027c80fe
commit
23713645d4
16 changed files with 379 additions and 3 deletions
12
lib/hostip.c
12
lib/hostip.c
|
|
@ -58,6 +58,7 @@
|
|||
#include "strerror.h"
|
||||
#include "url.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "multiif.h"
|
||||
#include "warnless.h"
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
|
|
@ -481,6 +482,17 @@ int Curl_resolv(struct connectdata *conn,
|
|||
if(!Curl_ipvalid(conn))
|
||||
return CURLRESOLV_ERROR;
|
||||
|
||||
/* notify the resolver start callback */
|
||||
if(data->set.resolver_start) {
|
||||
int st;
|
||||
Curl_set_in_callback(data, true);
|
||||
st = data->set.resolver_start(data->state.resolver, NULL,
|
||||
data->set.resolver_start_client);
|
||||
Curl_set_in_callback(data, false);
|
||||
if(st)
|
||||
return CURLRESOLV_ERROR;
|
||||
}
|
||||
|
||||
/* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
|
||||
non-zero value indicating that we need to wait for the response to the
|
||||
resolve call */
|
||||
|
|
|
|||
15
lib/setopt.c
15
lib/setopt.c
|
|
@ -2110,6 +2110,21 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
|
|||
data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
|
||||
break;
|
||||
|
||||
case CURLOPT_RESOLVER_START_FUNCTION:
|
||||
/*
|
||||
* resolver start callback function: called before a new resolver request
|
||||
* is started
|
||||
*/
|
||||
data->set.resolver_start = va_arg(param, curl_resolver_start_callback);
|
||||
break;
|
||||
|
||||
case CURLOPT_RESOLVER_START_DATA:
|
||||
/*
|
||||
* resolver start callback data pointer. Might be NULL.
|
||||
*/
|
||||
data->set.resolver_start_client = va_arg(param, void *);
|
||||
break;
|
||||
|
||||
case CURLOPT_CLOSESOCKETDATA:
|
||||
/*
|
||||
* socket callback data pointer. Might be NULL.
|
||||
|
|
|
|||
|
|
@ -1681,6 +1681,10 @@ struct UserDefined {
|
|||
struct Curl_http2_dep *stream_dependents;
|
||||
|
||||
bool abstract_unix_socket;
|
||||
|
||||
curl_resolver_start_callback resolver_start; /* optional callback called
|
||||
before resolver start */
|
||||
void *resolver_start_client; /* pointer to pass to resolver start callback */
|
||||
};
|
||||
|
||||
struct Names {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue