Skip to content

Commit 33f44af

Browse files
committed
New curl_pause() function
Add the curl_pause function (binding of curl_easy_pause). Using this function, you can explicitly mark a running connection to get paused, and you can unpause a connection that was previously paused.
1 parent 4b4f3db commit 33f44af

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

ext/curl/interface.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,13 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_share_setopt, 0)
396396
ZEND_ARG_INFO(0, option)
397397
ZEND_ARG_INFO(0, value)
398398
ZEND_END_ARG_INFO()
399+
400+
#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
401+
ZEND_BEGIN_ARG_INFO(arginfo_curl_pause, 0)
402+
ZEND_ARG_INFO(0, ch)
403+
ZEND_ARG_INFO(0, bitmask)
404+
ZEND_END_ARG_INFO()
405+
#endif
399406
/* }}} */
400407

401408
/* {{{ curl_functions[]
@@ -421,6 +428,9 @@ const zend_function_entry curl_functions[] = {
421428
#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
422429
PHP_FE(curl_escape, arginfo_curl_escape)
423430
PHP_FE(curl_unescape, arginfo_curl_unescape)
431+
#endif
432+
#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */
433+
PHP_FE(curl_pause, arginfo_curl_pause)
424434
#endif
425435
PHP_FE(curl_multi_init, arginfo_curl_multi_init)
426436
PHP_FE(curl_multi_add_handle, arginfo_curl_multi_add_handle)
@@ -999,6 +1009,14 @@ PHP_MINIT_FUNCTION(curl)
9991009

10001010
#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
10011011
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE);
1012+
REGISTER_CURL_CONSTANT(CURLPAUSE_ALL);
1013+
REGISTER_CURL_CONSTANT(CURLPAUSE_CONT);
1014+
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV);
1015+
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV_CONT);
1016+
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND);
1017+
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND_CONT);
1018+
REGISTER_CURL_CONSTANT(CURL_READFUNC_PAUSE);
1019+
REGISTER_CURL_CONSTANT(CURL_WRITEFUNC_PAUSE);
10021020
#endif
10031021

10041022
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
@@ -3417,8 +3435,29 @@ PHP_FUNCTION(curl_unescape)
34173435
RETURN_FALSE;
34183436
}
34193437
}
3438+
/* }}} */
34203439
#endif
3440+
3441+
#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */
3442+
/* {{{ proto void curl_pause(resource ch, int bitmask)
3443+
pause and unpause a connection */
3444+
PHP_FUNCTION(curl_pause)
3445+
{
3446+
long bitmask;
3447+
zval *zid;
3448+
php_curl *ch;
3449+
3450+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zid, &bitmask) == FAILURE) {
3451+
return;
3452+
}
3453+
3454+
ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
3455+
3456+
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
3457+
}
34213458
/* }}} */
3459+
#endif
3460+
34223461
#endif /* HAVE_CURL */
34233462

34243463
/*

ext/curl/php_curl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ PHP_FUNCTION(curl_unescape);
100100
PHP_FUNCTION(curl_multi_setopt);
101101
#endif
102102

103+
#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */
104+
PHP_FUNCTION(curl_pause);
105+
#endif
106+
103107
void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
104108
void _php_curl_share_close(zend_rsrc_list_entry * TSRMLS_DC);
105109

0 commit comments

Comments
 (0)