Skip to content

Add support for CURLINFO_CONN_ID in curl_getinfo() #18984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thecaliskan
Copy link

Add support for CURLINFO_CONN_ID in curl_getinfo()

Summary

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

CURLINFO_CONN_ID allows retrieving the unique identifier of the underlying connection used in the most recent transfer. This is useful for advanced features like connection reuse tracking, diagnostics, or connection pooling implementations at the PHP level.


Details

  • Introduced support for curl_getinfo($ch, CURLINFO_CONN_ID) when available.
  • Added "conn_id" key to the associative array returned by curl_getinfo($ch) if applicable.
  • A SKIPIF check ensures that the test is skipped if the libcurl version is too old.
  • Includes a .phpt test file: ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt.

Requirements

  • Requires libcurl version 8.2.0 or higher.
  • PHP runtime will fallback silently if the constant is not available in the underlying libcurl.

Example usage

$ch = curl_init("https://example.com");
curl_exec($ch);
$connId = curl_getinfo($ch, CURLINFO_CONN_ID);
echo "Connection ID: $connId\n";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant