lib: add CURLINFO_SIZE_DELIVERED

This commit is contained in:
Daniel Stenberg 2026-03-02 22:32:56 +01:00
parent d332b9057f
commit fadfa54d86
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 90 additions and 1 deletions

View file

@ -68,6 +68,7 @@ dates. The tool was called `httpget` before 2.0, `urlget` before 4.0 then
`curl` since 4.0. `libcurl` and `curl` are always released in sync, using the
same version numbers.
- 8.20.0: pending
- 8.19.0: pending
- 8.18.0: January 7, 2026
- 8.17.0: November 5, 2025

View file

@ -305,6 +305,10 @@ RTSP session ID. See CURLINFO_RTSP_SESSION_ID(3)
The scheme used for the connection. See CURLINFO_SCHEME(3)
## CURLINFO_SIZE_DELIVERED
Number of bytes passed to the write callback. See CURLINFO_SIZE_DELIVERED(3)
## CURLINFO_SIZE_DOWNLOAD
(**Deprecated**) Number of bytes downloaded. See CURLINFO_SIZE_DOWNLOAD(3)

View file

@ -0,0 +1,78 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SIZE_DELIVERED
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_DOWNLOAD_T (3)
- CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3)
- CURLOPT_MAXFILESIZE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.20.0
---
# NAME
CURLINFO_SIZE_DELIVERED - number of delivered bytes
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DELIVERED,
curl_off_t *dlp);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the total amount of bytes that
were passed on to the write callback in the download. The amount is only for
the latest transfer and gets reset again for each new transfer. This counts
actual payload data, what's also commonly called body. All meta and header
data is excluded from this amount.
The delivered size may differ from the size retrieved with
CURLINFO_SIZE_DOWNLOAD_T(3) when CURLOPT_ACCEPT_ENCODING(3) is used for
automatic data decompression, as this is then the size of the uncompressed
body while CURLINFO_SIZE_DOWNLOAD_T(3) returns the size of the download.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
result = curl_easy_perform(curl);
if(result == CURLE_OK) {
/* check the size */
curl_off_t dl;
result = curl_easy_getinfo(curl, CURLINFO_SIZE_DELIVERED, &dl);
if(result == CURLE_OK) {
printf("Stored %" CURL_FORMAT_CURL_OFF_T " bytes\n", dl);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).

View file

@ -83,6 +83,7 @@ man_MANS = \
CURLINFO_RTSP_SERVER_CSEQ.3 \
CURLINFO_RTSP_SESSION_ID.3 \
CURLINFO_SCHEME.3 \
CURLINFO_SIZE_DELIVERED.3 \
CURLINFO_SIZE_DOWNLOAD.3 \
CURLINFO_SIZE_DOWNLOAD_T.3 \
CURLINFO_SIZE_UPLOAD.3 \

View file

@ -492,6 +492,7 @@ CURLINFO_RTSP_CSEQ_RECV 7.20.0
CURLINFO_RTSP_SERVER_CSEQ 7.20.0
CURLINFO_RTSP_SESSION_ID 7.20.0
CURLINFO_SCHEME 7.52.0
CURLINFO_SIZE_DELIVERED 8.20.0
CURLINFO_SIZE_DOWNLOAD 7.4.1 7.55.0
CURLINFO_SIZE_DOWNLOAD_T 7.55.0
CURLINFO_SIZE_UPLOAD 7.4.1 7.55.0

View file

@ -2991,7 +2991,8 @@ typedef enum {
CURLINFO_EARLYDATA_SENT_T = CURLINFO_OFF_T + 68,
CURLINFO_HTTPAUTH_USED = CURLINFO_LONG + 69,
CURLINFO_PROXYAUTH_USED = CURLINFO_LONG + 70,
CURLINFO_LASTONE = 70
CURLINFO_SIZE_DELIVERED = CURLINFO_OFF_T + 71,
CURLINFO_LASTONE = 71
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as

View file

@ -414,6 +414,9 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
case CURLINFO_FILETIME_T:
*param_offt = (curl_off_t)data->info.filetime;
break;
case CURLINFO_SIZE_DELIVERED:
*param_offt = data->progress.deliver;
break;
case CURLINFO_SIZE_UPLOAD_T:
*param_offt = data->progress.ul.cur_size;
break;