Skip to content

Add CURLINFO_PRIMARY_IP and CURLINFO_PRIMARY_PORT to cpr::Response #1222

@gitpaladin

Description

@gitpaladin

Is your feature request related to a problem?

No response

Possible Solution

Feature Request: Add CURLINFO_PRIMARY_IP and CURLINFO_PRIMARY_PORT to cpr::Response

What

As a developer using CPR for HTTP requests, I need to access the resolved IP address and port of the target endpoint after making a request. This capability is crucial for monitoring, logging, and reporting purposes. Currently, CPR does not expose these details in the cpr::Response object.

Why

Having access to the resolved IP and port is highly valuable for:

  • Accurate monitoring of network traffic
  • Detailed logging for debugging and auditing
  • Proper reporting in distributed systems
  • Security compliance and tracking

This feature is commonly required in production environments and would significantly enhance CPR's utility for enterprise and large-scale applications.

Possible Solution

Extend the cpr::Response object to include the resolved IP and port by retrieving them during response creation:

std::string ip;
long port;
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);

These values should be stored in the cpr::Response object and made accessible via new member functions like GetPrimaryIP() and GetPrimaryPort().

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions