X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_curl_client.c;h=bf04651d00ccec16dbe0530ce724e46f433de357;hb=5df3bfd0128ebd48de13c95fc459110eb0463c30;hp=97b04a229200e6bf70bc0d4a1e96dc93ae77c864;hpb=5913db177b07398233cb00d2357aba595eab8371;p=m6w6%2Fext-http diff --git a/php_http_curl_client.c b/php_http_curl_client.c index 97b04a2..bf04651 100644 --- a/php_http_curl_client.c +++ b/php_http_curl_client.c @@ -574,6 +574,19 @@ static STATUS set_options(php_http_client_t *h, HashTable *options) if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("connecttimeout"), IS_DOUBLE))) { curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT_MS, (long)(Z_DVAL_P(zoption)*1000)); } + +#if PHP_HTTP_CURL_VERSION(7,25,0) + /* tcp */ + if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepalive"), IS_BOOL))) { + curl_easy_setopt(ch, CURLOPT_TCP_KEEPALIVE, (long)Z_BVAL_P(zoption)); + } + if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepidle"), IS_LONG))) { + curl_easy_setopt(ch, CURLOPT_TCP_KEEPIDLE, Z_LVAL_P(zoption)); + } + if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("tcp_keepintvl"), IS_LONG))) { + curl_easy_setopt(ch, CURLOPT_TCP_KEEPINTVL, Z_LVAL_P(zoption)); + } +#endif /* ssl */ if ((zoption = get_option(&curl->options.cache, options, ZEND_STRS("ssl"), IS_ARRAY))) { @@ -971,7 +984,12 @@ static STATUS php_http_curl_client_reset(php_http_client_t *h) curl_easy_setopt(ch, CURLOPT_TIMECONDITION, 0L); curl_easy_setopt(ch, CURLOPT_TIMEVALUE, 0L); curl_easy_setopt(ch, CURLOPT_TIMEOUT, 0L); - curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3); + curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, 3L); +#if PHP_HTTP_CURL_VERSION(7,25,0) + curl_easy_setopt(ch, CURLOPT_TCP_KEEPALIVE, 0L); + curl_easy_setopt(ch, CURLOPT_TCP_KEEPIDLE, 60L); + curl_easy_setopt(ch, CURLOPT_TCP_KEEPINTVL, 60L); +#endif curl_easy_setopt(ch, CURLOPT_SSLCERT, NULL); curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, NULL); curl_easy_setopt(ch, CURLOPT_SSLCERTPASSWD, NULL); @@ -1279,7 +1297,7 @@ PHP_HTTP_API php_http_client_ops_t *php_http_curl_client_get_ops(void) #define PHP_HTTP_CURL_CLIENT_ME(method, visibility) PHP_ME(HttpClientCURL, method, PHP_HTTP_ARGS(HttpClientCURL, method), visibility) #define PHP_HTTP_CURL_CLIENT_CLIENT_MALIAS(me, vis) ZEND_FENTRY(me, ZEND_MN(HttpClient_##me), PHP_HTTP_ARGS(HttpClientCURL, me), vis) -PHP_HTTP_BEGIN_ARGS(send, 1) +PHP_HTTP_BEGIN_ARGS(send, 0) PHP_HTTP_ARG_VAL(request, 0) PHP_HTTP_END_ARGS;