Compare commits

...

7 commits

Author SHA1 Message Date
Daniel Stenberg
84333580d4
fixup JSON tests for the new -w variable 2026-03-02 22:49:27 +01:00
Daniel Stenberg
54c1106507
fixup wording 2026-03-02 22:45:24 +01:00
Daniel Stenberg
87eae5ec2d
VERSIONS: 8.20.0 is pending 2026-03-02 22:42:21 +01:00
Daniel Stenberg
e289dc733e
fixup curl_easy_getinfo.md 2026-03-02 22:41:38 +01:00
Daniel Stenberg
a70f289dfa
fixup symbols-in-versions 2026-03-02 22:37:29 +01:00
Daniel Stenberg
af9417ddfc
src: add 'size_delivered' as a write-out variable
Verify in test 220
2026-03-02 22:33:10 +01:00
Daniel Stenberg
69c6cda944
lib: add CURLINFO_SIZE_DELIVERED 2026-03-02 22:32:56 +01:00
13 changed files with 103 additions and 4 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

@ -193,6 +193,10 @@ known as "http_code"). (Added in 7.18.2)
## `scheme`
The URL scheme (sometimes called protocol) that was effectively used. (Added in 7.52.0)
## `size_delivered`
The total amount of data that were saved or written to stdout. When
--compressed is used, this is likely different than `size_download`.
## `size_download`
The total amount of bytes that were downloaded. This is the size of the
body/data that was transferred, excluding headers.

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;

View file

@ -461,6 +461,8 @@ static const struct writeoutvar variables[] = {
{ "remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong },
{ "response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong },
{ "scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString },
{ "size_delivered", VAR_SIZE_DELIVERED, CURLINFO_SIZE_DELIVERED,
writeOffset },
{ "size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T,
writeOffset },
{ "size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong },

View file

@ -90,6 +90,7 @@ typedef enum {
VAR_REFERER,
VAR_REQUEST_SIZE,
VAR_SCHEME,
VAR_SIZE_DELIVERED,
VAR_SIZE_DOWNLOAD,
VAR_SIZE_UPLOAD,
VAR_SPEED_DOWNLOAD,

View file

@ -50,7 +50,7 @@ http
HTTP GET gzip compressed content
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --compressed
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --compressed -s -w '%{stderr}%{size_delivered}\n'
</command>
</client>
@ -67,5 +67,8 @@ Accept: */*
Accept-Encoding: xxx
</protocol>
<stderr>
24
</stderr>
</verify>
</testcase>

View file

@ -57,7 +57,7 @@ Accept: */*
</protocol>
<stdout nonewline="yes">
{"certs":"","conn_id":0,"content_type":"text/html","errormsg":null,"exitcode":0,"filename_effective":"%LOGDIR/out%TESTNUMBER","ftp_entry_path":null,"http_code":200,"http_connect":0,"http_version":"1.1","local_ip":"127.0.0.1","local_port":13,"method":"GET","num_certs":0,"num_connects":1,"num_headers":9,"num_redirects":0,"num_retries":0,"proxy_ssl_verify_result":0,"proxy_used":0,"redirect_url":null,"referer":null,"remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"response_code":200,"scheme":"http","size_download":445,"size_header":4019,"size_request":4019,"size_upload":0,"speed_download":13,"speed_upload":13,"ssl_verify_result":0,"time_appconnect":0.000013,"time_connect":0.000013,"time_namelookup":0.000013,"time_posttransfer":0.000013,"time_pretransfer":0.000013,"time_queue":0.000013,"time_redirect":0.000013,"time_starttransfer":0.000013,"time_total":0.000013,"tls_earlydata":0,"url":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","url.fragment":null,"url.host":"127.0.0.1","url.options":null,"url.password":null,"url.path":"/%TESTNUMBER","url.port":"%HTTPPORT","url.query":null,"url.scheme":"http","url.user":null,"url.zoneid":null,"url_effective":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","urle.fragment":null,"urle.host":"127.0.0.1","urle.options":null,"urle.password":null,"urle.path":"/%TESTNUMBER","urle.port":"%HTTPPORT","urle.query":null,"urle.scheme":"http","urle.user":null,"urle.zoneid":null,"urlnum":0,"xfer_id":0,"curl_version":"curl-unit-test-fake-version"}
{"certs":"","conn_id":0,"content_type":"text/html","errormsg":null,"exitcode":0,"filename_effective":"%LOGDIR/out%TESTNUMBER","ftp_entry_path":null,"http_code":200,"http_connect":0,"http_version":"1.1","local_ip":"127.0.0.1","local_port":13,"method":"GET","num_certs":0,"num_connects":1,"num_headers":9,"num_redirects":0,"num_retries":0,"proxy_ssl_verify_result":0,"proxy_used":0,"redirect_url":null,"referer":null,"remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"response_code":200,"scheme":"http","size_delivered":445,"size_download":445,"size_header":4019,"size_request":4019,"size_upload":0,"speed_download":13,"speed_upload":13,"ssl_verify_result":0,"time_appconnect":0.000013,"time_connect":0.000013,"time_namelookup":0.000013,"time_posttransfer":0.000013,"time_pretransfer":0.000013,"time_queue":0.000013,"time_redirect":0.000013,"time_starttransfer":0.000013,"time_total":0.000013,"tls_earlydata":0,"url":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","url.fragment":null,"url.host":"127.0.0.1","url.options":null,"url.password":null,"url.path":"/%TESTNUMBER","url.port":"%HTTPPORT","url.query":null,"url.scheme":"http","url.user":null,"url.zoneid":null,"url_effective":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","urle.fragment":null,"urle.host":"127.0.0.1","urle.options":null,"urle.password":null,"urle.path":"/%TESTNUMBER","urle.port":"%HTTPPORT","urle.query":null,"urle.scheme":"http","urle.user":null,"urle.zoneid":null,"urlnum":0,"xfer_id":0,"curl_version":"curl-unit-test-fake-version"}
</stdout>
</verify>
</testcase>

View file

@ -58,7 +58,7 @@ Accept: */*
</protocol>
<stdout mode="text">
{"certs":"","conn_id":0,"content_type":"text/html","errormsg":null,"exitcode":0,"filename_effective":"%LOGDIR/out%TESTNUMBER","ftp_entry_path":null,"http_code":200,"http_connect":0,"http_version":"1.1","local_ip":"127.0.0.1","local_port":13,"method":"GET","num_certs":0,"num_connects":1,"num_headers":9,"num_redirects":0,"num_retries":0,"proxy_ssl_verify_result":0,"proxy_used":0,"redirect_url":null,"referer":null,"remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"response_code":200,"scheme":"http","size_download":445,"size_header":4019,"size_request":4019,"size_upload":0,"speed_download":13,"speed_upload":13,"ssl_verify_result":0,"time_appconnect":0.000013,"time_connect":0.000013,"time_namelookup":0.000013,"time_posttransfer":0.000013,"time_pretransfer":0.000013,"time_queue":0.000013,"time_redirect":0.000013,"time_starttransfer":0.000013,"time_total":0.000013,"tls_earlydata":0,"url":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","url.fragment":null,"url.host":"127.0.0.1","url.options":null,"url.password":null,"url.path":"/%TESTNUMBER","url.port":"%HTTPPORT","url.query":null,"url.scheme":"http","url.user":null,"url.zoneid":null,"url_effective":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","urle.fragment":null,"urle.host":"127.0.0.1","urle.options":null,"urle.password":null,"urle.path":"/%TESTNUMBER","urle.port":"%HTTPPORT","urle.query":null,"urle.scheme":"http","urle.user":null,"urle.zoneid":null,"urlnum":0,"xfer_id":0,"curl_version":"curl-unit-test-fake-version"}
{"certs":"","conn_id":0,"content_type":"text/html","errormsg":null,"exitcode":0,"filename_effective":"%LOGDIR/out%TESTNUMBER","ftp_entry_path":null,"http_code":200,"http_connect":0,"http_version":"1.1","local_ip":"127.0.0.1","local_port":13,"method":"GET","num_certs":0,"num_connects":1,"num_headers":9,"num_redirects":0,"num_retries":0,"proxy_ssl_verify_result":0,"proxy_used":0,"redirect_url":null,"referer":null,"remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"response_code":200,"scheme":"http","size_delivered":445,"size_download":445,"size_header":4019,"size_request":4019,"size_upload":0,"speed_download":13,"speed_upload":13,"ssl_verify_result":0,"time_appconnect":0.000013,"time_connect":0.000013,"time_namelookup":0.000013,"time_posttransfer":0.000013,"time_pretransfer":0.000013,"time_queue":0.000013,"time_redirect":0.000013,"time_starttransfer":0.000013,"time_total":0.000013,"tls_earlydata":0,"url":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","url.fragment":null,"url.host":"127.0.0.1","url.options":null,"url.password":null,"url.path":"/%TESTNUMBER","url.port":"%HTTPPORT","url.query":null,"url.scheme":"http","url.user":null,"url.zoneid":null,"url_effective":"http://%HOSTIP:%HTTPPORT/%TESTNUMBER","urle.fragment":null,"urle.host":"127.0.0.1","urle.options":null,"urle.password":null,"urle.path":"/%TESTNUMBER","urle.port":"%HTTPPORT","urle.query":null,"urle.scheme":"http","urle.user":null,"urle.zoneid":null,"urlnum":0,"xfer_id":0,"curl_version":"curl-unit-test-fake-version"}
</stdout>
</verify>
</testcase>