curl: update CURLINFO
authorMichael Wallner <mike@php.net>
Wed, 31 May 2023 15:27:39 +0000 (17:27 +0200)
committerMichael Wallner <mike@php.net>
Mon, 5 Feb 2024 19:17:07 +0000 (20:17 +0100)
BUGS
scripts/gen_curlinfo.php
src/php_http_client_curl.c

diff --git a/BUGS b/BUGS
index 4c2ad80b6025a49554ce2b2c54e6b02063385c26..0b981790dbeb4ba2cc836b1072de46cf178918ac 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -2,15 +2,13 @@ Known Issues
 ============
 
 Windows:
-       If you keep getting "SSL connect error" when trying to issue 
+       If you keep getting "SSL connect error" when trying to issue
                requests, try another (newer) libeay32.dll/ssleay32.dll pair.
 
 Internals:
        Inflating raw deflated data causes a re-initialization of the inflate
                stream where the corresponding window bits are modified to tell libz
                to not check for zlib header bytes.  This is not preventable AFAICS.
-       LFS dependant parts of libcurl are left out because of off_t,
-               respectively off64_t confusion.
        Persistent handles and "cookiestore" request option do interfere,
                as libcurl saves the cookies to the file on curl_easy_destroy(),
                cookies are not saved until the CURL handle will be recycled.
index 92ff65e42859bb64b732498eff4158e76e65a0c3..ab4391dccef9eb2b09463cbbcf9e35b619551ef8 100755 (executable)
@@ -42,6 +42,9 @@ $ifdefs = array(
        '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)',
+       'REFERER' => 'PHP_HTTP_CURL_VERSION(7,76,0)',
+       'CAINFO' => 'PHP_HTTP_CURL_VERSION(7,84,0)',
+       'CAPATH' => 'PHP_HTTP_CURL_VERSION(7,84,0)',
 );
 $exclude = array(
        'ACTIVESOCKET',
@@ -102,12 +105,12 @@ $templates = array(
 ',
 );
 
-$infos = file_re('curl.h', '/^\s*(CURLINFO_(\w+))\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST|OFF_T)\s*\+\s*\d+\s*,?\s*$/m');
-
+$infos = file_re('curl.h', '/\s*(CURLINFO_(\w+))\s*(?:CURL_DEPRECATED\(\d+\.\d+\.\d+,\s*"[\w _-]+"\))?\s*=\s*CURLINFO_(STRING|LONG|DOUBLE|SLIST|OFF_T)\s*\+\s*\d+\s*,?\s*/m');
+var_dump($infos);
 ob_start();
 foreach ($infos as $info) {
        list(, $full, $short, $type) = $info;
-       if (in_array($short, $exclude) || substr($short, -2) === "_T") continue;
+       if (in_array($short, $exclude)) 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");
index 156c569ec1393b586a4fc76d8c61e2dfc3570122..4decc7af20c8e7a234ab9492a775fa5f97a6cac1 100644 (file)
@@ -367,18 +367,34 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "size_upload", lenof("size_upload"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SIZE_UPLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "size_upload_t", lenof("size_upload_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SIZE_DOWNLOAD, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "size_download", lenof("size_download"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SIZE_DOWNLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "size_download_t", lenof("size_download_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_DOWNLOAD, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "speed_download", lenof("speed_download"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_DOWNLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "speed_download_t", lenof("speed_download_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_UPLOAD, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "speed_upload", lenof("speed_upload"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_SPEED_UPLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "speed_upload_t", lenof("speed_upload_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HEADER_SIZE, &l)) {
                ZVAL_LONG(&tmp, l);
                zend_hash_str_update(info, "header_size", lenof("header_size"), &tmp);
@@ -395,14 +411,26 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
                ZVAL_LONG(&tmp, l);
                zend_hash_str_update(info, "filetime", lenof("filetime"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_FILETIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "filetime_t", lenof("filetime_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "content_length_download", lenof("content_length_download"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "content_length_download_t", lenof("content_length_download_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_UPLOAD, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "content_length_upload", lenof("content_length_upload"), &tmp);
        }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "content_length_upload_t", lenof("content_length_upload_t"), &tmp);
+       }
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_STARTTRANSFER_TIME, &d)) {
                ZVAL_DOUBLE(&tmp, d);
                zend_hash_str_update(info, "starttransfer_time", lenof("starttransfer_time"), &tmp);
@@ -513,6 +541,34 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
                zend_hash_str_update(info, "scheme", lenof("scheme"), &tmp);
        }
 #endif
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_TOTAL_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "total_time_t", lenof("total_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_NAMELOOKUP_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "namelookup_time_t", lenof("namelookup_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CONNECT_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "connect_time_t", lenof("connect_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_PRETRANSFER_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "pretransfer_time_t", lenof("pretransfer_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_STARTTRANSFER_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "starttransfer_time_t", lenof("starttransfer_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REDIRECT_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "redirect_time_t", lenof("redirect_time_t"), &tmp);
+       }
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_APPCONNECT_TIME_T, &o)) {
+               ZVAL_LONG(&tmp, o);
+               zend_hash_str_update(info, "appconnect_time_t", lenof("appconnect_time_t"), &tmp);
+       }
 #if PHP_HTTP_CURL_VERSION(7,66,0)
        if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_RETRY_AFTER, &o)) {
                ZVAL_LONG(&tmp, o);
@@ -531,6 +587,24 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
                zend_hash_str_update(info, "proxy_error", lenof("proxy_error"), &tmp);
        }
 #endif
+#if PHP_HTTP_CURL_VERSION(7,76,0)
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_REFERER, &c)) {
+               ZVAL_STRING(&tmp, STR_PTR(c));
+               zend_hash_str_update(info, "referer", lenof("referer"), &tmp);
+       }
+#endif
+#if PHP_HTTP_CURL_VERSION(7,84,0)
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CAINFO, &c)) {
+               ZVAL_STRING(&tmp, STR_PTR(c));
+               zend_hash_str_update(info, "cainfo", lenof("cainfo"), &tmp);
+       }
+#endif
+#if PHP_HTTP_CURL_VERSION(7,84,0)
+       if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_CAPATH, &c)) {
+               ZVAL_STRING(&tmp, STR_PTR(c));
+               zend_hash_str_update(info, "capath", lenof("capath"), &tmp);
+       }
+#endif
 
        /* END::CURLINFO */
 
@@ -630,8 +704,9 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
 
 #if (PHP_HTTP_CURL_VERSION(7,19,1) && PHP_HTTP_HAVE_LIBCURL_OPENSSL) || \
        (PHP_HTTP_CURL_VERSION(7,34,0) && PHP_HTTP_HAVE_LIBCURL_NSS) || \
+       (PHP_HTTP_CURL_VERSION(7,39,0) && PHP_HTTP_HAVE_LIBCURL_GSKIT) || \
        (PHP_HTTP_CURL_VERSION(7,42,0) && PHP_HTTP_HAVE_LIBCURL_GNUTLS) || \
-       (PHP_HTTP_CURL_VERSION(7,39,0) && PHP_HTTP_HAVE_LIBCURL_GSKIT)
+       (PHP_HTTP_CURL_VERSION(7,79,0) && PHP_HTTP_HAVE_LIBCURL_SECURETRANSPORT)
        {
                int i;
                zval ci_array, subarray;