Skip to content

Commit c71a9b2

Browse files
committed
Backport from 8.5:
Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (php#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. php@7fb6afb
1 parent 27f17c3 commit c71a9b2

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

ext/curl/curl.stub.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,13 @@
30293029
* @cvalue CURLAUTH_BEARER
30303030
*/
30313031
const CURLAUTH_BEARER = UNKNOWN;
3032+
#if LIBCURL_VERSION_NUM >= 0x080600 /* Available since 8.6.0 */
3033+
/**
3034+
* @var int
3035+
* @cvalue CURLINFO_QUEUE_TIME_T
3036+
*/
3037+
const CURLINFO_QUEUE_TIME_T = UNKNOWN;
3038+
#endif
30323039
/**
30333040
* @var int
30343041
* @cvalue CURLINFO_APPCONNECT_TIME_T

ext/curl/curl_arginfo.h

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/curl/interface.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,11 @@ PHP_FUNCTION(curl_getinfo)
27482748
if (curl_easy_getinfo(ch->cp, CURLINFO_APPCONNECT_TIME_T, &co) == CURLE_OK) {
27492749
CAAL("appconnect_time_us", co);
27502750
}
2751+
#if LIBCURL_VERSION_NUM >= 0x080600 /* Available since 8.6.0 */
2752+
if (curl_easy_getinfo(ch->cp, CURLINFO_QUEUE_TIME_T , &co) == CURLE_OK) {
2753+
CAAL("queue_time_us", co);
2754+
}
2755+
#endif
27512756
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME_T, &co) == CURLE_OK) {
27522757
CAAL("connect_time_us", co);
27532758
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Curlinfo CURLINFO_QUEUE_TIME_T
3+
--EXTENSIONS--
4+
curl
5+
--SKIPIF--
6+
<?php
7+
$curl_version = curl_version();
8+
if ($curl_version['version_number'] < 0x080600) die("skip: test works only with curl >= 8.6.0");
9+
?>
10+
--FILE--
11+
<?php
12+
include 'server.inc';
13+
14+
$host = curl_cli_server_start();
15+
$port = (int) (explode(':', $host))[1];
16+
17+
$ch = curl_init();
18+
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
19+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
20+
21+
$info = curl_getinfo($ch);
22+
var_dump(isset($info['queue_time_us']));
23+
var_dump($info['queue_time_us'] === 0); // this is always 0 before executing the transfer
24+
25+
$result = curl_exec($ch);
26+
27+
$info = curl_getinfo($ch);
28+
var_dump(isset($info['queue_time_us']));
29+
var_dump(is_int($info['queue_time_us']));
30+
var_dump(curl_getinfo($ch, CURLINFO_QUEUE_TIME_T) === $info['queue_time_us']);
31+
var_dump(curl_getinfo($ch, CURLINFO_QUEUE_TIME_T) > 0);
32+
33+
?>
34+
--EXPECT--
35+
bool(true)
36+
bool(true)
37+
bool(true)
38+
bool(true)
39+
bool(true)
40+
bool(true)
41+

0 commit comments

Comments
 (0)