1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_EARLYDATA_SENT_T
5Section: 3
6Source: libcurl
7See-also:
8  - curl_easy_getinfo (3)
9  - curl_easy_setopt (3)
10Protocol:
11  - TLS
12TLS-backend:
13  - GnuTLS
14Added-in: 8.11.0
15---
16
17# NAME
18
19CURLINFO_EARLYDATA_SENT_T - get the number of bytes sent as TLS early data
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EARLYDATA_SENT_T,
27                           curl_off_t *amount);
28~~~
29
30# DESCRIPTION
31
32Pass a pointer to an *curl_off_t* to receive the total amount of bytes that
33were sent to the server as TLSv1.3 early data. When no TLS early
34data is used, this reports 0.
35
36TLS early data is only attempted when CURLSSLOPT_EARLYDATA is set for the
37transfer. In addition, it is only used by libcurl when a TLS session exists
38that announces support.
39
40The amount is **negative** when the sent data was rejected
41by the server. TLS allows a server that announces support for early data to
42reject any attempt to use it at its own discretion. When for example 127
43bytes had been sent, but were rejected, it reports -127 as the amount "sent".
44
45# %PROTOCOLS%
46
47# EXAMPLE
48
49~~~c
50int main(void)
51{
52  CURL *curl = curl_easy_init();
53  if(curl) {
54    CURLcode res;
55    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
56
57    /* Perform the request */
58    res = curl_easy_perform(curl);
59
60    if(!res) {
61      curl_off_t amount;
62      res = curl_easy_getinfo(curl, CURLINFO_EARLYDATA_SENT_T, &amount);
63      if(!res) {
64        printf("TLS earlydata: %" CURL_FORMAT_CURL_OFF_T " bytes\n", amount);
65      }
66    }
67  }
68}
69~~~
70
71# %AVAILABILITY%
72
73# RETURN VALUE
74
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76