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:
Francisco Sedano 2018-02-14 17:20:43 +00:00 committed by Jay Satiro
parent dd027c80fe
commit 23713645d4
16 changed files with 379 additions and 3 deletions

View file

@ -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 */