Skip to content
Merged
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
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ PHP NEWS
- BZ2:
. Reject oversized input in bzdecompress(). (arshidkv12)

- Curl:
. Add support for CURLINFO_SIZE_DELIVERED (libcurl >= 8.20.0). (Ayesh)

- Date:
. Update timelib to 2022.16. (Derick)

Expand Down
10 changes: 10 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ PHP 8.6 UPGRADE NOTES
. It is now possible to define the `__debugInfo()` magic method on enums.
RFC: https://wiki.php.net/rfc/debugable-enums

- Curl:
. curl_getinfo() return array now includes a new size_delivered key,
which indicates the total number of bytes passed to the download
write callback. This value can also be obtained by passing
CURLINFO_SIZE_DELIVERED as the $option parameter.
Requires libcurl 8.20.0 or later.

- Fileinfo:
. finfo_file() now works with remote streams.

Expand Down Expand Up @@ -399,6 +406,9 @@ PHP 8.6 UPGRADE NOTES
10. New Global Constants
========================================

- Curl:
. CURLINFO_SIZE_DELIVERED (libcurl >= 8.20.0).

- Sockets:
. TCP_USER_TIMEOUT (Linux only).
. AF_UNSPEC.
Expand Down
7 changes: 7 additions & 0 deletions ext/curl/curl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3117,6 +3117,13 @@
*/
const CURLINFO_CONN_ID = UNKNOWN;
#endif
#if LIBCURL_VERSION_NUM >= 0x081400 /* Available since 8.20.0 */
/**
* @var int
* @cvalue CURLINFO_SIZE_DELIVERED
*/
const CURLINFO_SIZE_DELIVERED = UNKNOWN;
#endif
/**
* @var int
* @cvalue CURLOPT_DISALLOW_USERNAME_IN_URL
Expand Down
5 changes: 4 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.

5 changes: 5 additions & 0 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,11 @@ PHP_FUNCTION(curl_getinfo)
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("size_download", d_code);
}
#if LIBCURL_VERSION_NUM >= 0x081400 /* Available since 8.20.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DELIVERED , &l_code) == CURLE_OK) {
CAAL("size_delivered", l_code);
}
#endif
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("speed_download", d_code);
}
Expand Down
40 changes: 40 additions & 0 deletions ext/curl/tests/curl_getinfo_CURLINFO_SIZE_DELIVERED.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Curlinfo CURLINFO_SIZE_DELIVERED
--EXTENSIONS--
curl
--SKIPIF--
<?php
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x081400) die("skip: test works only with curl >= 8.20.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");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

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

$result = curl_exec($ch);

$info = curl_getinfo($ch);
var_dump(isset($info['size_delivered']));
var_dump(is_int($info['size_delivered']));
var_dump(curl_getinfo($ch, CURLINFO_SIZE_DELIVERED) === $info['size_delivered']);
var_dump(curl_getinfo($ch, CURLINFO_SIZE_DELIVERED) > 0);
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)