diff options
-rw-r--r-- | http.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -233,7 +233,13 @@ static int has_cert_password(void) return 0; } -/* curl 7.25.0 has CURLOPT_TCP_KEEPALIVE, too, but we support older curl */ +#if LIBCURL_VERSION_NUM >= 0x071900 +static void set_curl_keepalive(CURL *c) +{ + curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1); +} + +#elif LIBCURL_VERSION_NUM >= 0x071000 static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type) { int ka = 1; @@ -251,6 +257,18 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type) return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */ } +static void set_curl_keepalive(CURL *c) +{ + curl_easy_setopt(c, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); +} + +#else +static void set_curl_keepalive(CURL *c) +{ + /* not supported on older curl versions */ +} +#endif + static CURL *get_curl_handle(void) { CURL *result = curl_easy_init(); @@ -316,9 +334,7 @@ static CURL *get_curl_handle(void) if (curl_http_proxy) curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy); -#if LIBCURL_VERSION_NUM >= 0x071000 - curl_easy_setopt(result, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); -#endif + set_curl_keepalive(result); return result; } |