getinfo: add CURLINFO_POSTTRANSFER_TIME_T

Returns the time, in microseconds, from the start until the last byte is
sent by libcurl (i.e. the request is sent off).

Closes #14189
This commit is contained in:
Alex Snast 2024-07-15 11:52:50 +03:00 committed by Daniel Stenberg
parent c0233a35da
commit 136504195a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
18 changed files with 123 additions and 9 deletions

View file

@ -221,6 +221,10 @@ remote host (or proxy) was completed.
The time, in seconds, it took from the start until the name resolving was
completed.
## `time_posttransfer`
The time it took from the start until the last byte is sent by libcurl.
In microseconds. (Added in 8.10.0)
## `time_pretransfer`
The time, in seconds, it took from the start until the file transfer was just
about to begin. This includes all pre-transfer commands and negotiations that

View file

@ -180,6 +180,11 @@ See CURLINFO_NUM_CONNECTS(3)
The errno from the last failure to connect. See CURLINFO_OS_ERRNO(3)
## CURLINFO_POSTTRANSFER_TIME_T
The time it took from the start until the last byte is sent by libcurl.
In microseconds. (Added in 8.10.0) See CURLINFO_POSTTRANSFER_TIME_T(3)
## CURLINFO_PRETRANSFER_TIME
The time it took from the start until the file transfer is just about to
@ -375,15 +380,17 @@ An overview of the time values available from curl_easy_getinfo(3)
|--|--|--CONNECT
|--|--|--|--APPCONNECT
|--|--|--|--|--PRETRANSFER
|--|--|--|--|--|--STARTTRANSFER
|--|--|--|--|--|--|--TOTAL
|--|--|--|--|--|--|--REDIRECT
|--|--|--|--|--|--POSTTRANSFER
|--|--|--|--|--|--|--STARTTRANSFER
|--|--|--|--|--|--|--|--TOTAL
|--|--|--|--|--|--|--|--REDIRECT
CURLINFO_QUEUE_TIME_T(3), CURLINFO_NAMELOOKUP_TIME_T(3),
CURLINFO_CONNECT_TIME_T(3), CURLINFO_APPCONNECT_TIME_T(3),
CURLINFO_PRETRANSFER_TIME_T(3), CURLINFO_STARTTRANSFER_TIME_T(3),
CURLINFO_TOTAL_TIME_T(3), CURLINFO_REDIRECT_TIME_T(3)
CURLINFO_PRETRANSFER_TIME_T(3), CURLINFO_POSTTRANSFER_TIME_T(3),
CURLINFO_STARTTRANSFER_TIME_T(3), CURLINFO_TOTAL_TIME_T(3),
CURLINFO_REDIRECT_TIME_T(3)
# %PROTOCOLS%

View file

@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_POSTTRANSFER_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_PRETRANSFER_TIME_T (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.10.0
---
# NAME
CURLINFO_POSTTRANSFER_TIME_T - get the time until the last byte is sent
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_POSTTRANSFER_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the time, in microseconds,
it took from the start until the last byte is sent by libcurl.
When a redirect is followed, the time from each request is added together.
See also the TIMES overview in the curl_easy_getinfo(3) man page.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
curl_off_t posttransfer;
res = curl_easy_getinfo(curl, CURLINFO_POSTTRANSFER_TIME_T, &posttransfer);
if(CURLE_OK == res) {
printf("Request sent after: %" CURL_FORMAT_CURL_OFF_T ".%06ld us", posttransfer / 1000000,
(long)(posttransfer % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.

View file

@ -58,6 +58,7 @@ man_MANS = \
CURLINFO_OS_ERRNO.3 \
CURLINFO_PRETRANSFER_TIME.3 \
CURLINFO_PRETRANSFER_TIME_T.3 \
CURLINFO_POSTTRANSFER_TIME_T.3 \
CURLINFO_PRIMARY_IP.3 \
CURLINFO_PRIMARY_PORT.3 \
CURLINFO_PRIVATE.3 \

View file

@ -462,6 +462,7 @@ CURLINFO_OFF_T 7.55.0
CURLINFO_OS_ERRNO 7.12.2
CURLINFO_PRETRANSFER_TIME 7.4.1
CURLINFO_PRETRANSFER_TIME_T 7.61.0
CURLINFO_POSTTRANSFER_TIME_T 8.10.0
CURLINFO_PRIMARY_IP 7.19.0
CURLINFO_PRIMARY_PORT 7.21.0
CURLINFO_PRIVATE 7.10.3