Skip to content

Commit 2e44fa5

Browse files
committed
Add new curl_upkeep() function
1 parent deb328b commit 2e44fa5

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

ext/curl/curl.stub.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ function curl_getinfo(CurlHandle $handle, ?int $option = null): mixed {}
5454
/** @refcount 1 */
5555
function curl_init(?string $url = null): CurlHandle|false {}
5656

57+
#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
58+
function curl_upkeep(CurlHandle $handle): bool {}
59+
#endif
60+
5761
function curl_multi_add_handle(CurlMultiHandle $multi_handle, CurlHandle $handle): int {}
5862

5963
function curl_multi_close(CurlMultiHandle $multi_handle): void {}

ext/curl/curl_arginfo.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3abf3f6d5dfb14d2e22ebf5730a869e2c17c7958 */
2+
* Stub hash: 1bd8a84a4aa80912463ea76d08f64d3c2cf4c0db */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_close, 0, 1, IS_VOID, 0)
55
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
@@ -49,6 +49,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_curl_init, 0, 0, CurlHandle,
4949
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, url, IS_STRING, 1, "null")
5050
ZEND_END_ARG_INFO()
5151

52+
#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
53+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_upkeep, 0, 1, _IS_BOOL, 0)
54+
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
55+
ZEND_END_ARG_INFO()
56+
#endif
57+
5258
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_multi_add_handle, 0, 2, IS_LONG, 0)
5359
ZEND_ARG_OBJ_INFO(0, multi_handle, CurlMultiHandle, 0)
5460
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
@@ -144,6 +150,9 @@ ZEND_FUNCTION(curl_exec);
144150
ZEND_FUNCTION(curl_file_create);
145151
ZEND_FUNCTION(curl_getinfo);
146152
ZEND_FUNCTION(curl_init);
153+
#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
154+
ZEND_FUNCTION(curl_upkeep);
155+
#endif
147156
ZEND_FUNCTION(curl_multi_add_handle);
148157
ZEND_FUNCTION(curl_multi_close);
149158
ZEND_FUNCTION(curl_multi_errno);
@@ -179,6 +188,9 @@ static const zend_function_entry ext_functions[] = {
179188
ZEND_FE(curl_file_create, arginfo_curl_file_create)
180189
ZEND_FE(curl_getinfo, arginfo_curl_getinfo)
181190
ZEND_FE(curl_init, arginfo_curl_init)
191+
#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
192+
ZEND_FE(curl_upkeep, arginfo_curl_upkeep)
193+
#endif
182194
ZEND_FE(curl_multi_add_handle, arginfo_curl_multi_add_handle)
183195
ZEND_FE(curl_multi_close, arginfo_curl_multi_close)
184196
ZEND_FE(curl_multi_errno, arginfo_curl_multi_errno)

ext/curl/interface.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,3 +3954,29 @@ PHP_FUNCTION(curl_pause)
39543954
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
39553955
}
39563956
/* }}} */
3957+
3958+
#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
3959+
/* {{{ perform connection upkeep checks */
3960+
PHP_FUNCTION(curl_upkeep)
3961+
{
3962+
CURLcode error;
3963+
zval *zid;
3964+
php_curl *ch;
3965+
3966+
ZEND_PARSE_PARAMETERS_START(1, 1)
3967+
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
3968+
ZEND_PARSE_PARAMETERS_END();
3969+
3970+
ch = Z_CURL_P(zid);
3971+
3972+
error = curl_easy_upkeep(ch->cp);
3973+
SAVE_CURL_ERROR(ch, error);
3974+
3975+
if (error != CURLE_OK) {
3976+
RETURN_FALSE;
3977+
} else {
3978+
RETURN_TRUE;
3979+
}
3980+
}
3981+
/*}}} */
3982+
#endif

0 commit comments

Comments
 (0)