Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ext/curl: Add CURLINFO_{USED_PROXY,HTTPAUTH_USED,PROXYAUTH_USED} #17816

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
merged 1 commit into from
Feb 17, 2025

Conversation

Ayesh
Copy link
Member

@Ayesh Ayesh commented Feb 15, 2025

Adds support for curl_getinfo() info keys and additional array keys:

  • CURLINFO_USED_PROXY - libcurl >= 8.7.9 - Zero if no proxy was used in the previous transfer or a non-zero value if a proxy was used.
  • CURLINFO_HTTPAUTH_USED - libcurl >= 8.7.9 - Bitmask indicating the authentication method that was used in the previous HTTP request.
  • CURLINFO_PROXYAUTH_USED - libcurl >= 8.12.0 - Bitmask indicating the authentication method that was used in the previous request done over an HTTP proxy.
curl_getinfo($ch);
[
	// ...
	"used_proxy" => 0,
	"httpauth_used" => 0,
	"proxyauth_used" => 0,
]

Because the built-in server ext/curl tests use does not support HTTP authentication, there is an online test that uses httpbin. It will be skipped by default unless online tests are run.

@Ayesh Ayesh force-pushed the curl/8-12/auth-used-consts branch from 29a3b7d to f6eccf2 Compare February 15, 2025 13:17
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

Code wise it s very much correct, not entirely sure however how others will think of the online test.

@devnexen devnexen requested a review from cmb69 February 15, 2025 14:00
@Ayesh
Copy link
Member Author

Ayesh commented Feb 15, 2025

Thank you @devnexen - I couldn't think of a way to test it with a local server. That said, we don't seem to be testing a lot of proxy/auth related features, nor any of the HTTP/2, HTTP/3, DoH, etc features either, so the online test is understandably a bit out of place.

If it makes more sense, I can remove the online test.

@cmb69
Copy link
Member

cmb69 commented Feb 15, 2025

Can we use Caddy instead of the online test? Caddy was introduced via #10669, and is used for a couple of tests (some jobs are actually running that).

@Ayesh Ayesh force-pushed the curl/8-12/auth-used-consts branch 2 times, most recently from 1c47f1d to 47a8e73 Compare February 15, 2025 17:10
@Ayesh
Copy link
Member Author

Ayesh commented Feb 15, 2025

Thank you @cmb69. I pushed removing httpbin, and with a new /http-basic-auth Caddy route with HTTP basic auth. I tested it locally with the same Caddyfile, but GH-Actions run will get skipped because the Curl version is older than 8.12.0.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

[…] but GH-Actions run will get skipped because the Curl version is older than 8.12.0.

It would be good to also have a job using recent cURL; possibly on Windows, since we're rather up to date there (at least for the master branch), but this is a separate issue.

Please see my comment below; I guess that should solve the Windows CI failure.

@Ayesh Ayesh force-pushed the curl/8-12/auth-used-consts branch 2 times, most recently from 19b93c4 to 7eebe32 Compare February 17, 2025 05:14
Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you!

Adds support for `curl_getinfo()` info keys and additional array keys:

 - [`CURLINFO_USED_PROXY`](https://curl.se/libcurl/c/CURLINFO_USED_PROXY.html) - `libcurl` >= 8.7.9 -
   Zero if no proxy was used in the previous transfer or a non-zero value if a proxy was used.
 - [`CURLINFO_HTTPAUTH_USED`](https://github.com/curl/curl/blob/curl-8_12_0/docs/libcurl/opts/CURLINFO_HTTPAUTH_USED.md) - `libcurl` >= 8.7.9 -
   Bitmask indicating the authentication method that was used in the previous HTTP request.
 - [`CURLINFO_PROXYAUTH_USED`](https://github.com/curl/curl/blob/curl-8_12_0/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md) - `libcurl` >= 8.12.0 -
   Bitmask indicating the authentication method that was used in the previous request done over an HTTP proxy.

```php
curl_getinfo($ch);
```
```php
[
	// ...
	"used_proxy" => 0,
	"httpauth_used" => 0,
	"proxyauth_used" => 0,
]
```

This also updates the `Caddyfile` for curl tests to add a new route
that supports HTTP basic auth.
@Ayesh Ayesh force-pushed the curl/8-12/auth-used-consts branch from 7eebe32 to 6a31992 Compare February 17, 2025 10:37
@Ayesh Ayesh merged commit d6b1d2e into php:master Feb 17, 2025
8 of 9 checks passed
Ayesh added a commit that referenced this pull request Feb 17, 2025
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.

3 participants