add CURLINFO_RETRY_AFTER
authorMichael Wallner <mike@php.net>
Mon, 8 Mar 2021 11:07:27 +0000 (12:07 +0100)
committerMichael Wallner <mike@php.net>
Mon, 8 Mar 2021 11:07:27 +0000 (12:07 +0100)
scripts/gen_curlinfo.php
src/php_http_client_curl.c

index bc4a683b05f63a2010fabc31500a97a999343221..92ff65e42859bb64b732498eff4158e76e65a0c3 100755 (executable)
@@ -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)',
        '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)',
 );
        '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);
        }
 ',
                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);
 '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;
 
 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");
        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");
index ee3a2b432353635b9fc48ce9328d1306b2897d63..82db05332944a140b01dc2e54af6d5fce296915c 100644 (file)
@@ -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;
        char *c = NULL;
        long l = 0;
        double d = 0;
+       curl_off_t o = 0;
        struct curl_slist *s = NULL, *p = NULL;
        zval tmp;
 
        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
                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));
 #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));