Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ PHP NEWS
- Curl:
. Added curl_multi_get_handles(). (timwolla)
. Added curl_share_init_persistent(). (enorris)
. Added CURLINFO_USED_PROXY, CURLINFO_HTTPAUTH_USED, and CURLINFO_PROXYAUTH_USED
support to curl_getinfo. (Ayesh Karunaratne)

- Date:
. Fix undefined behaviour problems regarding integer overflow in extreme edge
Expand Down
17 changes: 17 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ PHP 8.5 UPGRADE NOTES
. Added support for share handles that are persisted across multiple PHP
requests, safely allowing for more effective connection reuse.
RFC: https://wiki.php.net/rfc/curl_share_persistence_improvement
. Added support for CURLINFO_USED_PROXY (libcurl >= 8.7.0),
CURLINFO_HTTPAUTH_USED, and CURLINFO_PROXYAUTH_USED
(libcurl >= 8.12.0) to the curl_getinfo() function.
When curl_getinfo() returns an array, the same information
is available as "used_proxy", "httpauth_used", and "proxyauth_used"
keys.
CURLINFO_USED_PROXY gets zero set if no proxy was used in the
previous transfer or a non-zero value if a proxy was used.
CURLINFO_HTTPAUTH_USED and CURLINFO_PROXYAUTH_USED get bitmasks
indicating the http and proxy authentication methods that were
used in the previous request. See CURLAUTH_* constants for
possible values.

- DOM:
. Added Dom\Element::$outerHTML.
Expand Down Expand Up @@ -262,6 +274,11 @@ PHP 8.5 UPGRADE NOTES
- Core:
. PHP_BUILD_DATE.

- Curl:
. CURLINFO_USED_PROXY.
. CURLINFO_HTTPAUTH_USED.
. CURLINFO_PROXYAUTH_USED.

- POSIX:
. POSIX_SC_OPEN_MAX.

Expand Down
19 changes: 19 additions & 0 deletions ext/curl/curl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,18 @@
*/
const CURLINFO_CAINFO = UNKNOWN;
#endif
#if LIBCURL_VERSION_NUM >= 0x080c00 /* Available since 8.12.0 */
/**
* @var int
* @cvalue CURLINFO_HTTPAUTH_USED
*/
const CURLINFO_HTTPAUTH_USED = UNKNOWN;
/**
* @var int
* @cvalue CURLINFO_PROXYAUTH_USED
*/
const CURLINFO_PROXYAUTH_USED = UNKNOWN;
#endif

/* Other */
/**
Expand Down Expand Up @@ -3054,6 +3066,13 @@
* @cvalue CURLINFO_TOTAL_TIME_T
*/
const CURLINFO_TOTAL_TIME_T = UNKNOWN;
#if LIBCURL_VERSION_NUM >= 0x080700 /* Available since 8.7.0 */
/**
* @var int
* @cvalue CURLINFO_USED_PROXY
*/
const CURLINFO_USED_PROXY = UNKNOWN;
#endif
#if LIBCURL_VERSION_NUM >= 0x080a00 /* Available since 8.10.0 */
/**
* @var int
Expand Down
11 changes: 10 additions & 1 deletion ext/curl/curl_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2662,6 +2662,19 @@ PHP_FUNCTION(curl_getinfo)
if (curl_easy_getinfo(ch->cp, CURLINFO_CAINFO, &s_code) == CURLE_OK) {
CAAS("cainfo", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x080700 /* Available since 8.7.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_USED_PROXY, &l_code) == CURLE_OK) {
CAAL("used_proxy", l_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x080c00 /* Available since 8.12.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTPAUTH_USED, &l_code) == CURLE_OK) {
CAAL("httpauth_used", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PROXYAUTH_USED, &l_code) == CURLE_OK) {
CAAL("proxyauth_used", l_code);
}
#endif
} else {
switch (option) {
Expand Down
5 changes: 5 additions & 0 deletions ext/curl/tests/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ respond / "Caddy is up and running"
respond /serverpush "main response"
respond /serverpush/pushed "pushed response"
push /serverpush /serverpush/pushed

basicauth /http-basic-auth {
# bcrypt password hash for "password", calculated with 'caddy hash-password'
user $2a$14$yUKl9SGqVTAAqPTzLup.DefsbXXx3kfreNnzpJOUHcIrKnr5lgef2
}
34 changes: 34 additions & 0 deletions ext/curl/tests/curl_getinfo_CURLINFO_HTTPAUTH_USED-caddy.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
curl_getinfo - CURLINFO_HTTPAUTH_USED - online test
--EXTENSIONS--
curl
--SKIPIF--
<?php
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x080c00) die("skip: test works only with curl >= 8.12.0");
?>
--FILE--
<?php

include 'skipif-nocaddy.inc';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://localhost/http-basic-auth");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$info = curl_getinfo($ch);
var_dump($info['httpauth_used'] === 0); // this is always 0 before executing the transfer

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERNAME, "foo");
curl_setopt($ch, CURLOPT_PASSWORD, "bar");

$result = curl_exec($ch);
$info = curl_getinfo($ch);

var_dump($info['httpauth_used'] === CURLAUTH_BASIC);

?>
--EXPECT--
bool(true)
bool(true)
66 changes: 66 additions & 0 deletions ext/curl/tests/curl_getinfo_CURLINFO_HTTPAUTH_USED.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
--TEST--
curl_getinfo - CURLINFO_HTTPAUTH_USED
--EXTENSIONS--
curl
--SKIPIF--
<?php
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x080c00) die("skip: test works only with curl >= 8.12.0");
?>
--FILE--
<?php
include 'server.inc';

$host = curl_cli_server_start();
$port = (int) (explode(':', $host))[1];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

echo "httpauth_used and proxyauth_used empty\n";

$info = curl_getinfo($ch);
var_dump(isset($info['httpauth_used']));
var_dump(isset($info['proxyauth_used']));
var_dump($info['httpauth_used'] === 0); // this is always 0 before executing the transfer
var_dump($info['proxyauth_used'] === 0); // this is always 0 before executing the transfer

$result = curl_exec($ch);
echo "httpauth_used and proxyauth_used empty after request\n";
$info = curl_getinfo($ch);
var_dump(isset($info['httpauth_used']));
var_dump(isset($info['proxyauth_used']));
var_dump($info['httpauth_used'] === 0);
var_dump($info['proxyauth_used'] === 0);
var_dump(curl_getinfo($ch, CURLINFO_HTTPAUTH_USED) === $info['used_proxy']);
var_dump(curl_getinfo($ch, CURLINFO_PROXYAUTH_USED) === $info['proxyauth_used']);

echo "httpauth_used set after request\n";

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERNAME, "foo");
curl_setopt($ch, CURLOPT_PASSWORD, "bar");

$result = curl_exec($ch);
$info = curl_getinfo($ch);

var_dump($info['httpauth_used']); // Built-in server does not support auth

?>
--EXPECT--
httpauth_used and proxyauth_used empty
bool(true)
bool(true)
bool(true)
bool(true)
httpauth_used and proxyauth_used empty after request
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
httpauth_used set after request
int(0)
38 changes: 38 additions & 0 deletions ext/curl/tests/curl_getinfo_CURLINFO_USED_PROXY.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
curl_getinfo - CURLINFO_USED_PROXY
--EXTENSIONS--
curl
--SKIPIF--
<?php
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x080700) die("skip: test works only with curl >= 8.7.0");
?>
--FILE--
<?php
include 'server.inc';

$host = curl_cli_server_start();
$port = (int) (explode(':', $host))[1];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$info = curl_getinfo($ch);
var_dump(isset($info['used_proxy']));
var_dump($info['used_proxy'] === 0); // this is always 0 before executing the transfer

$result = curl_exec($ch);

$info = curl_getinfo($ch);
var_dump(isset($info['used_proxy']));
var_dump($info['used_proxy'] === 0);
var_dump(curl_getinfo($ch, CURLINFO_USED_PROXY) === $info['used_proxy']);

?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Loading