Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
bukka merged 9 commits into php:master from thecaliskan:master
Jul 16, 2025
Merged

Conversation

Copy link
Contributor

@thecaliskan thecaliskan commented Jun 30, 2025

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";

ilyasozkurt and ddevsr reacted with heart emoji
Copy link
Member

Ayesh commented Jul 2, 2025

PR looks good to me. I would have really liked it if there was a test for curl_multi_* (because all requests should return same connection ID), but we this is a straight forward addition either way. Nice job!

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks reasonable. Agree that the multi test would be good.

Copy link
Contributor Author

Hi @Ayesh and @bukka

I added curl multi and share init tests, but since the local server is used, the connection closes every time.

@Ayesh Ayesh self-requested a review July 8, 2025 09:09
@bukka bukka merged commit e84320a into php:master Jul 16, 2025
9 checks passed
Copy link
Member

bukka commented Jul 17, 2025

Thanks for the contribution! For the record the NEWS updated in a8a3c81

thecaliskan reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@bukka bukka bukka approved these changes

@Ayesh Ayesh Ayesh approved these changes

@kocsismate kocsismate Awaiting requested review from kocsismate kocsismate is a code owner

@adoy adoy Awaiting requested review from adoy adoy is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /