Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (#19147)

This patch adds support for the CURLINFO_QUEUE_TIME_T constant in the
curl_getinfo() function when compiled with libcurl >= 8.6.0.

CURLINFO_QUEUE_TIME_T This constant allows retrieving the time (in
microseconds) that the request spent in libcurl’s connection queue
before it was sent.
This commit is contained in:
Emre Çalışkan 2025-07-17 15:56:07 +03:00 committed by GitHub
parent 0e80be83b3
commit 7fb6afbe9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 63 additions and 1 deletions

View file

@ -193,6 +193,11 @@ PHP 8.5 UPGRADE NOTES
used by a cURL transfer. It is primarily useful when connection reuse or
connection pooling logic is needed in PHP-level applications. When
curl_getinfo() returns an array, this value is available as the "conn_id" key.
. Added support for CURLINFO_QUEUE_TIME_T (libcurl >= 8.6.0) to the curl_getinfo()
function. This constant allows retrieving the time (in microseconds) that the
request spent in libcurls connection queue before it was sent.
This value can also be retrieved by passing CURLINFO_QUEUE_TIME_T to the
curl_getinfo() $option parameter.
- DOM:
. Added Dom\Element::$outerHTML.
@ -526,6 +531,7 @@ PHP 8.5 UPGRADE NOTES
. CURLINFO_HTTPAUTH_USED.
. CURLINFO_PROXYAUTH_USED.
. CURLINFO_CONN_ID.
. CURLINFO_QUEUE_TIME_T.
. CURLOPT_INFILESIZE_LARGE.
. CURLFOLLOW_ALL.
. CURLFOLLOW_OBEYCODE.

View file

@ -3054,6 +3054,13 @@ const CURL_LOCK_DATA_PSL = UNKNOWN;
* @cvalue CURLAUTH_BEARER
*/
const CURLAUTH_BEARER = UNKNOWN;
#if LIBCURL_VERSION_NUM >= 0x080600 /* Available since 8.6.0 */
/**
* @var int
* @cvalue CURLINFO_QUEUE_TIME_T
*/
const CURLINFO_QUEUE_TIME_T = UNKNOWN;
#endif
/**
* @var int
* @cvalue CURLINFO_APPCONNECT_TIME_T

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 533884c442ca1146a61c0824a4f8c9628c31aae3 */
* Stub hash: c2245ec496551980ca17ff4472cc1790653e41bd */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_close, 0, 1, IS_VOID, 0)
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
@ -812,6 +812,9 @@ static void register_curl_symbols(int module_number)
REGISTER_LONG_CONSTANT("CURLOPT_HAPROXYPROTOCOL", CURLOPT_HAPROXYPROTOCOL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CURL_LOCK_DATA_PSL", CURL_LOCK_DATA_PSL, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CURLAUTH_BEARER", CURLAUTH_BEARER, CONST_PERSISTENT);
#if LIBCURL_VERSION_NUM >= 0x080600 /* Available since 8.6.0 */
REGISTER_LONG_CONSTANT("CURLINFO_QUEUE_TIME_T", CURLINFO_QUEUE_TIME_T, CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("CURLINFO_APPCONNECT_TIME_T", CURLINFO_APPCONNECT_TIME_T, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CURLINFO_CONNECT_TIME_T", CURLINFO_CONNECT_TIME_T, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CURLINFO_NAMELOOKUP_TIME_T", CURLINFO_NAMELOOKUP_TIME_T, CONST_PERSISTENT);

View file

@ -2571,6 +2571,11 @@ PHP_FUNCTION(curl_getinfo)
if (curl_easy_getinfo(ch->cp, CURLINFO_APPCONNECT_TIME_T, &co) == CURLE_OK) {
CAAL("appconnect_time_us", co);
}
#if LIBCURL_VERSION_NUM >= 0x080600 /* Available since 8.6.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_QUEUE_TIME_T , &co) == CURLE_OK) {
CAAL("queue_time_us", co);
}
#endif
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME_T, &co) == CURLE_OK) {
CAAL("connect_time_us", co);
}

View file

@ -0,0 +1,41 @@
--TEST--
Curlinfo CURLINFO_QUEUE_TIME_T
--EXTENSIONS--
curl
--SKIPIF--
<?php
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x080600) die("skip: test works only with curl >= 8.6.0");
?>
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$port = (int) (explode(':', $host))[1];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$info = curl_getinfo($ch);
var_dump(isset($info['queue_time_us']));
var_dump($info['queue_time_us'] === 0); // this is always 0 before executing the transfer
$result = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump(isset($info['queue_time_us']));
var_dump(is_int($info['queue_time_us']));
var_dump(curl_getinfo($ch, CURLINFO_QUEUE_TIME_T) === $info['queue_time_us']);
var_dump(curl_getinfo($ch, CURLINFO_QUEUE_TIME_T) > 0);
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)