Skip to content

Commit 97f7af0

Browse files
committed
added CURLINFO_CONN_ID
1 parent 4c17b9b commit 97f7af0

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

ext/curl/interface.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,11 +2659,6 @@ PHP_FUNCTION(curl_getinfo)
26592659
if (curl_easy_getinfo(ch->cp, CURLINFO_POSTTRANSFER_TIME_T, &co) == CURLE_OK) {
26602660
CAAL("posttransfer_time_us", co);
26612661
}
2662-
#endif
2663-
#if LIBCURL_VERSION_NUM >= 0x080200 /* Available since 8.2.0 */
2664-
if (curl_easy_getinfo(ch->cp, CURLINFO_CONN_ID , &co) == CURLE_OK) {
2665-
CAAL("conn_id", co);
2666-
}
26672662
#endif
26682663
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME_T, &co) == CURLE_OK) {
26692664
CAAL("total_time_us", co);
@@ -2696,6 +2691,11 @@ PHP_FUNCTION(curl_getinfo)
26962691
if (curl_easy_getinfo(ch->cp, CURLINFO_PROXYAUTH_USED, &l_code) == CURLE_OK) {
26972692
CAAL("proxyauth_used", l_code);
26982693
}
2694+
#endif
2695+
#if LIBCURL_VERSION_NUM >= 0x080200 /* Available since 8.2.0 */
2696+
if (curl_easy_getinfo(ch->cp, CURLINFO_CONN_ID , &co) == CURLE_OK) {
2697+
CAAL("conn_id", co);
2698+
}
26992699
#endif
27002700
} else {
27012701
switch (option) {

ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,30 @@ $host = curl_cli_server_start();
1515
$port = (int) (explode(':', $host))[1];
1616

1717
$ch = curl_init();
18-
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
18+
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=get");
1919
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
20-
curl_setopt($ch, CURLOPT_FORBID_REUSE, false);
21-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, false);
22-
curl_setopt($ch, CURLOPT_HTTPHEADER, [
23-
'Connection: Keep-Alive',
24-
'Keep-Alive: 10'
25-
]);
2620

2721
$info = curl_getinfo($ch);
2822
var_dump(isset($info['conn_id']));
29-
var_dump($info['conn_id'] === 0);
30-
var_dump("1. debug");
31-
var_dump($info['conn_id']);
32-
print_r($info);
23+
var_dump($info['conn_id'] === -1);
3324

3425
$result = curl_exec($ch);
3526

3627
$info = curl_getinfo($ch);
3728
var_dump(isset($info['conn_id']));
3829
var_dump(is_int($info['conn_id']));
3930
var_dump(curl_getinfo($ch, CURLINFO_CONN_ID) === $info['conn_id']);
40-
var_dump(curl_getinfo($ch, CURLINFO_CONN_ID) === -1);
41-
var_dump("2. debug");
42-
var_dump($info['conn_id']);
43-
print_r($info);
31+
var_dump(curl_getinfo($ch, CURLINFO_CONN_ID) === 0);
4432

45-
46-
47-
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
33+
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=get");
4834
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4935
$result = curl_exec($ch);
5036

5137
$info = curl_getinfo($ch);
52-
var_dump("3. debug");
53-
var_dump($info['conn_id']);
54-
print_r($info);
38+
var_dump(isset($info['conn_id']));
39+
var_dump(is_int($info['conn_id']));
40+
var_dump(curl_getinfo($ch, CURLINFO_CONN_ID) === $info['conn_id']);
41+
var_dump(curl_getinfo($ch, CURLINFO_CONN_ID) === 1);
5542

5643

5744
?>
@@ -62,4 +49,8 @@ bool(true)
6249
bool(true)
6350
bool(true)
6451
bool(true)
52+
bool(true)
53+
bool(true)
54+
bool(true)
55+
bool(true)
6556

0 commit comments

Comments
 (0)