From: Michael Wallner Date: Mon, 8 Mar 2021 11:07:27 +0000 (+0100) Subject: add CURLINFO_RETRY_AFTER X-Git-Tag: v4.1.0~11 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=640b762aa5a5fdf571e44f7a66725c097b7dc0f1;ds=sidebyside add CURLINFO_RETRY_AFTER --- diff --git a/scripts/gen_curlinfo.php b/scripts/gen_curlinfo.php index bc4a683..92ff65e 100755 --- a/scripts/gen_curlinfo.php +++ b/scripts/gen_curlinfo.php @@ -39,6 +39,7 @@ $ifdefs = array( 'PROXY_SSL_VERIFYRESULT' => 'PHP_HTTP_CURL_VERSION(7,52,0)', 'PROTOCOL' => 'PHP_HTTP_CURL_VERSION(7,52,0)', 'SCHEME' => 'PHP_HTTP_CURL_VERSION(7,52,0)', + 'RETRY_AFTER' => 'PHP_HTTP_CURL_VERSION(7,66,0)', 'EFFECTIVE_METHOD' => 'PHP_HTTP_CURL_VERSION(7,72,0)', 'PROXY_ERROR' => 'PHP_HTTP_CURL_VERSION(7,73,0)', ); @@ -81,6 +82,12 @@ $templates = array( zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); } ', +'OFF_T' => +' if (CURLE_OK == curl_easy_getinfo(ch, %s, &o)) { + ZVAL_LONG(&tmp, o); + zend_hash_str_update(info, "%s", lenof("%2$s"), &tmp); + } +', 'SLIST' => ' if (CURLE_OK == curl_easy_getinfo(ch, %s, &s)) { array_init(&tmp); @@ -95,12 +102,12 @@ $templates = array( ', ); -$infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST)\s*\+\s*\d+\s*,?\s*$/m'); +$infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST|OFF_T)\s*\+\s*\d+\s*,?\s*$/m'); ob_start(); foreach ($infos as $info) { list(, $full, $short, $type) = $info; - if (in_array($short, $exclude)) continue; + if (in_array($short, $exclude) || substr($short, -2) === "_T") continue; if (isset($ifdefs[$short])) printf("#if %s\n", $ifdefs[$short]); printf($templates[$type], $full, strtolower((isset($translate[$short])) ? $translate[$short] : $short)); if (isset($ifdefs[$short])) printf("#endif\n"); diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index ee3a2b4..82db053 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -330,6 +330,7 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) char *c = NULL; long l = 0; double d = 0; + curl_off_t o = 0; struct curl_slist *s = NULL, *p = NULL; zval tmp; @@ -510,6 +511,12 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) zend_hash_str_update(info, "scheme", lenof("scheme"), &tmp); } #endif +#if PHP_HTTP_CURL_VERSION(7,66,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_RETRY_AFTER, &o)) { + ZVAL_LONG(&tmp, o); + zend_hash_str_update(info, "retry_after", lenof("retry_after"), &tmp); + } +#endif #if PHP_HTTP_CURL_VERSION(7,72,0) if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_EFFECTIVE_METHOD, &c)) { ZVAL_STRING(&tmp, STR_PTR(c));