Update networking layer w/ CURL and emscripten impl

This commit is contained in:
2025-11-08 01:50:36 +11:00
parent a17925904d
commit f6874dc55a
4105 changed files with 694617 additions and 179 deletions
+37
View File
@@ -0,0 +1,37 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
# Get man_MANS variable
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
curl_add_manual_pages(man_MANS)
add_custom_target(curl-opts-man DEPENDS ${man_MANS})
add_dependencies(curl-man curl-opts-man)
if(NOT CURL_DISABLE_INSTALL)
set(_src "")
foreach(_file IN LISTS man_MANS)
list(APPEND _src "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
endforeach()
install(FILES ${_src} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
endif()
@@ -0,0 +1,84 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_ACTIVESOCKET
Section: 3
Source: libcurl
See-also:
- CURLINFO_LASTSOCKET (3)
- CURLOPT_CONNECT_ONLY (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.45.0
---
# NAME
CURLINFO_ACTIVESOCKET - get the active socket
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_ACTIVESOCKET,
curl_socket_t *socket);
~~~
# DESCRIPTION
Pass a pointer to a curl_socket_t to receive the most recently active socket
used for the transfer connection by this curl session. If the socket is no
longer valid, *CURL_SOCKET_BAD* is returned. When you are finished working
with the socket, you must call curl_easy_cleanup(3) as usual on the easy
handle and let libcurl close the socket and cleanup other resources associated
with the handle. This option returns the active socket only after the transfer
is complete, and is typically used in combination with
CURLOPT_CONNECT_ONLY(3), which skips the transfer phase.
CURLINFO_ACTIVESOCKET(3) was added as a replacement for
CURLINFO_LASTSOCKET(3) since that one is not working on all platforms.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_socket_t sockfd;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Do not do the transfer - only connect to host */
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
printf("Error: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
return 1;
}
/* Extract the socket from the curl handle */
res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
if(!res && sockfd != CURL_SOCKET_BAD) {
/* operate on sockfd */
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_APPCONNECT_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_APPCONNECT_TIME_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.19.0
---
# NAME
CURLINFO_APPCONNECT_TIME - get the time until the SSL/SSH handshake is completed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_APPCONNECT_TIME,
double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the time, in seconds, it took from the
start until the SSL/SSH connect/handshake to the remote host was completed.
This time is most often close to the CURLINFO_PRETRANSFER_TIME(3) time, except
for cases such as HTTP multiplexing where the pretransfer time can be delayed
due to waits in line for the stream and more.
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;
double connect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &connect);
if(CURLE_OK == res) {
printf("Time: %.1f", connect);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,74 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_APPCONNECT_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_APPCONNECT_TIME (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_APPCONNECT_TIME_T - time until the SSL/SSH handshake completed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_APPCONNECT_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 SSL/SSH connect/handshake to the remote host was
completed. This time is most often close to the CURLINFO_PRETRANSFER_TIME_T(3)
time, except for cases such as HTTP multiplexing where the pretransfer time
can be delayed due to waits in line for the stream and more.
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_off_t connect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME_T, &connect);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
(long)(connect % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,70 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CAINFO
Section: 3
Source: libcurl
See-also:
- CURLINFO_CAPATH (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- All
Added-in: 7.84.0
---
# NAME
CURLINFO_CAINFO - get the default built-in CA certificate path
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CAINFO, char **path);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a null-terminated
string holding the default built-in path used for the CURLOPT_CAINFO(3)
option unless set by the user.
Note that in a situation where libcurl has been built to support multiple TLS
libraries, this option might return a string even if the specific TLS library
currently set to be used does not support CURLOPT_CAINFO(3).
This is a path identifying a single file containing CA certificates.
The **path** pointer is set to NULL if there is no default path.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
char *cainfo = NULL;
curl_easy_getinfo(curl, CURLINFO_CAINFO, &cainfo);
if(cainfo) {
printf("default ca info path: %s\n", cainfo);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CAPATH
Section: 3
Source: libcurl
See-also:
- CURLINFO_CAINFO (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
- GnuTLS
- mbedTLS
- wolfSSL
Added-in: 7.84.0
---
# NAME
CURLINFO_CAPATH - get the default built-in CA path string
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CAPATH, char **path);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a null-terminated
string holding the default built-in path used for the CURLOPT_CAPATH(3)
option unless set by the user.
Note that in a situation where libcurl has been built to support multiple TLS
libraries, this option might return a string even if the specific TLS library
currently set to be used does not support CURLOPT_CAPATH(3).
This is a path identifying a directory.
The **path** pointer is set to NULL if there is no default path.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
char *capath = NULL;
curl_easy_getinfo(curl, CURLINFO_CAPATH, &capath);
if(capath) {
printf("default ca path: %s\n", capath);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,109 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CERTINFO
Section: 3
Source: libcurl
See-also:
- CURLINFO_CAPATH (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
- GnuTLS
- Schannel
- rustls
Added-in: 7.19.1
---
# NAME
CURLINFO_CERTINFO - get the TLS certificate chain
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO,
struct curl_certinfo **chainp);
~~~
# DESCRIPTION
Pass a pointer to a *struct curl_certinfo ** and it is set to point to a
struct that holds info about the server's certificate chain, assuming you had
CURLOPT_CERTINFO(3) enabled when the request was made.
~~~c
struct curl_certinfo {
int num_of_certs;
struct curl_slist **certinfo;
};
~~~
The *certinfo* struct member is an array of linked lists of certificate
information. The *num_of_certs* struct member is the number of certificates
which is the number of elements in the array. Each certificate's list has
items with textual information in the format "name:content" such as
"Subject:Foo", "Issuer:Bar", etc. The items in each list varies depending on
the SSL backend and the certificate.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
/* connect to any HTTPS site, trusted or not */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
res = curl_easy_perform(curl);
if(!res) {
int i;
struct curl_certinfo *ci;
res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
if(!res) {
printf("%d certs!\n", ci->num_of_certs);
for(i = 0; i < ci->num_of_certs; i++) {
struct curl_slist *slist;
for(slist = ci->certinfo[i]; slist; slist = slist->next)
printf("%s\n", slist->data);
}
}
}
curl_easy_cleanup(curl);
}
}
~~~
See also the *certinfo.c* example.
# HISTORY
GnuTLS support added in 7.42.0. Schannel support added in 7.50.0. mbedTLS
support added in 8.9.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,81 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONDITION_UNMET
Section: 3
Source: libcurl
See-also:
- CURLOPT_TIMECONDITION (3)
- CURLOPT_TIMEVALUE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.19.4
---
# NAME
CURLINFO_CONDITION_UNMET - get info on unmet time conditional or 304 HTTP response.
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONDITION_UNMET,
long *unmet);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the number 1 if the condition provided in
the previous request did not match (see CURLOPT_TIMECONDITION(3)). Alas,
if this returns a 1 you know that the reason you did not get data in return is
because it did not fulfill the condition. The long this argument points to
gets a zero stored if the condition instead was met. This can also return 1 if
the server responded with a 304 HTTP status code, for example after sending a
custom "If-Match-*" header.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* January 1, 2020 is 1577833200 */
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
/* If-Modified-Since the above time stamp */
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
/* check the time condition */
long unmet;
res = curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &unmet);
if(!res) {
printf("The time condition was %sfulfilled\n", unmet?"NOT":"");
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONNECT_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONNECT_TIME_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_CONNECT_TIME - get the time until connect
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME, double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total time in seconds from the start
until the connection to the remote host (or proxy) was completed.
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;
double connect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect);
if(CURLE_OK == res) {
printf("Time: %.1f", connect);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONNECT_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONNECT_TIME (3)
- CURLOPT_CONNECTTIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_CONNECT_TIME_T - get the time until connect
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the total time in microseconds from
the start until the connection to the remote host (or proxy) was completed.
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_off_t connect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &connect);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
(long)(connect % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONN_ID
Section: 3
Source: libcurl
See-also:
- CURLINFO_XFER_ID (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.2.0
---
# NAME
CURLINFO_CONN_ID - get the ID of the last connection used by the handle
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONN_ID,
curl_off_t *conn_id);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the connection identifier last
used by the handle. Stores -1 if there was no connection used.
The connection id is unique among all connections using the same
connection cache. This is implicitly the case for all connections in the
same multi handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t conn_id;
res = curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id);
if(!res) {
printf("Connection used: %" CURL_FORMAT_CURL_OFF_T "\n", conn_id);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,76 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONTENT_LENGTH_DOWNLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONTENT_LENGTH_UPLOAD (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.6.1
---
# NAME
CURLINFO_CONTENT_LENGTH_DOWNLOAD - get content-length of download
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
double *content_length);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the content-length of the download. This
is the value read from the Content-Length: field. This returns -1 if the size
is not known.
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3) is a newer replacement that returns a more
sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
double cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
if(!res) {
printf("Size: %.0f\n", cl);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONTENT_LENGTH_UPLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.55.0
---
# NAME
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T - get content-length of download
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
curl_off_t *content_length);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the content-length of the
download. This is the value read from the Content-Length: field. Stores -1 if
the size is not known.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
curl_off_t cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl);
if(!res) {
printf("Download size: %" CURL_FORMAT_CURL_OFF_T "\n", cl);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONTENT_LENGTH_UPLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.6.1
---
# NAME
CURLINFO_CONTENT_LENGTH_UPLOAD - get the specified size of the upload
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD,
double *content_length);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the specified size of the upload. Since
7.19.4, this returns -1 if the size is not known.
CURLINFO_CONTENT_LENGTH_UPLOAD_T(3) is a newer replacement that returns a
more sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the upload */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
double cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &cl);
if(!res) {
printf("Size: %.0f\n", cl);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,68 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONTENT_LENGTH_UPLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.55.0
---
# NAME
CURLINFO_CONTENT_LENGTH_UPLOAD_T - get the specified size of the upload
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD_T,
curl_off_t *content_length);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the specified size of the
upload. Stores -1 if the size is not known.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the upload */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
curl_off_t cl;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &cl);
if(!res) {
printf("Upload size: %" CURL_FORMAT_CURL_OFF_T "\n", cl);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,77 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_CONTENT_TYPE
Section: 3
Source: libcurl
See-also:
- CURLOPT_HEADERFUNCTION (3)
- curl_easy_getinfo (3)
- curl_easy_header (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.9.4
---
# NAME
CURLINFO_CONTENT_TYPE - get Content-Type
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_TYPE, char **ct);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the content-type of the downloaded
object. This is the value read from the Content-Type: field. If you get NULL,
it means that the server did not send a valid Content-Type header or that the
protocol used does not support this.
The **ct** pointer is NULL or points to private memory. You **must not** free
it. It gets freed automatically when you call curl_easy_cleanup(3) on the
corresponding curl handle.
The modern way to get this header from a response is to instead use the
curl_easy_header(3) function.
# %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(!res) {
/* extract the content-type */
char *ct = NULL;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(!res && ct) {
printf("Content-Type: %s\n", ct);
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,84 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_COOKIELIST
Section: 3
Source: libcurl
See-also:
- CURLOPT_COOKIELIST (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.14.1
---
# NAME
CURLINFO_COOKIELIST - get all known cookies
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST,
struct curl_slist **cookies);
~~~
# DESCRIPTION
Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all
cookies curl knows (expired ones, too). Do not forget to call
curl_slist_free_all(3) on the list after it has been used. If there are no
cookies (cookies for the handle have not been enabled or simply none have been
received) the 'struct curl_slist *' is made a NULL pointer.
Since 7.43.0 cookies that were imported in the Set-Cookie format without a
domain name are not exported by this option.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* enable the cookie engine */
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
res = curl_easy_perform(curl);
if(!res) {
/* extract all known cookies */
struct curl_slist *cookies = NULL;
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(!res && cookies) {
/* a linked list of cookies in cookie file format */
struct curl_slist *each = cookies;
while(each) {
printf("%s\n", each->data);
each = each->next;
}
/* we must free these cookies when we are done */
curl_slist_free_all(cookies);
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,78 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_EARLYDATA_SENT_T
Section: 3
Source: libcurl
See-also:
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- GnuTLS
Added-in: 8.11.0
---
# NAME
CURLINFO_EARLYDATA_SENT_T - get the number of bytes sent as TLS early data
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EARLYDATA_SENT_T,
curl_off_t *amount);
~~~
# DESCRIPTION
Pass a pointer to an *curl_off_t* to receive the total amount of bytes that
were sent to the server as TLSv1.3 early data. When no TLS early
data is used, this reports 0.
TLS early data is only attempted when CURLSSLOPT_EARLYDATA is set for the
transfer. In addition, it is only used by libcurl when a TLS session exists
that announces support.
The amount is **negative** when the sent data was rejected
by the server. TLS allows a server that announces support for early data to
reject any attempt to use it at its own discretion. When for example 127
bytes had been sent, but were rejected, it reports -127 as the amount "sent".
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t amount;
res = curl_easy_getinfo(curl, CURLINFO_EARLYDATA_SENT_T, &amount);
if(!res) {
printf("TLS earlydata: %" CURL_FORMAT_CURL_OFF_T " bytes\n", amount);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,74 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_EFFECTIVE_METHOD
Section: 3
Source: libcurl
See-also:
- CURLOPT_CUSTOMREQUEST (3)
- CURLOPT_FOLLOWLOCATION (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.72.0
---
# NAME
CURLINFO_EFFECTIVE_METHOD - get the last used HTTP method
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD,
char **methodp);
~~~
# DESCRIPTION
Pass in a pointer to a char pointer and get the last used effective HTTP
method.
In cases when you have asked libcurl to follow redirects, the method may not be
the same method the first request would use.
The **methodp** pointer is NULL or points to private memory. You
**must not** free it. The memory gets freed automatically when you call
curl_easy_cleanup(3) on the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
char *method = NULL;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_METHOD, &method);
if(method)
printf("Redirected to method: %s\n", method);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,70 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_EFFECTIVE_URL
Section: 3
Source: libcurl
See-also:
- CURLOPT_FOLLOWLOCATION (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.4
---
# NAME
CURLINFO_EFFECTIVE_URL - get the last used URL
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp);
~~~
# DESCRIPTION
Pass in a pointer to a char pointer and get the last used effective URL.
In cases when you have asked libcurl to follow redirects, it may not be the same
value you set with CURLOPT_URL(3).
The **urlp** pointer is NULL or points to private memory. You **must not**
free it. It memory gets freed automatically when you call curl_easy_cleanup(3)
on the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
char *url = NULL;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
if(url)
printf("Redirect to: %s\n", url);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,79 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_FILETIME
Section: 3
Source: libcurl
See-also:
- CURLOPT_FILETIME (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
- FTP
- SFTP
Added-in: 7.5
---
# NAME
CURLINFO_FILETIME - get the remote time of the retrieved document
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the remote time of the retrieved document
in number of seconds since January 1 1970 in the GMT/UTC time zone. If you get
-1, it can be because of many reasons (it might be unknown, the server might
hide it or the server does not support the command that tells document time
etc) and the time of the document is unknown.
You must ask libcurl to collect this information before the transfer is made,
by using the CURLOPT_FILETIME(3) option or you unconditionally get a -1 back.
Consider CURLINFO_FILETIME_T(3) instead to be able to extract dates beyond the
year 2038 on systems using 32-bit longs (Windows).
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Ask for filetime */
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
long filetime = 0;
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if((CURLE_OK == res) && (filetime != -1)) {
time_t file_time = (time_t)filetime;
printf("filetime: %s", ctime(&file_time));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,80 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_FILETIME_T
Section: 3
Source: libcurl
See-also:
- CURLOPT_FILETIME (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
- FTP
- SFTP
Added-in: 7.59.0
---
# NAME
CURLINFO_FILETIME_T - get the remote time of the retrieved document
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the remote time of the retrieved
document in number of seconds since January 1 1970 in the GMT/UTC time zone.
If you get -1, it can be because of many reasons (it might be unknown, the
server might hide it or the server does not support the command that tells
document time etc) and the time of the document is unknown.
You must ask libcurl to collect this information before the transfer is made,
by using the CURLOPT_FILETIME(3) option or you unconditionally get a -1 back.
This option is an alternative to CURLINFO_FILETIME(3) to allow systems with 32
bit long variables to extract dates outside of the 32-bit timestamp range.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
/* Ask for filetime */
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
curl_off_t filetime;
res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
if((CURLE_OK == res) && (filetime != -1)) {
time_t file_time = (time_t)filetime;
printf("filetime: %s", ctime(&file_time));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,77 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_FTP_ENTRY_PATH
Section: 3
Source: libcurl
See-also:
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- FTP
- SFTP
Added-in: 7.15.4
---
# NAME
CURLINFO_FTP_ENTRY_PATH - get entry path in FTP server
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FTP_ENTRY_PATH, char **path);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive a pointer to a string holding the
path of the entry path. That is the initial path libcurl ended up in when
logging on to the remote FTP or SFTP server. This stores a NULL as pointer if
something is wrong.
The **path** pointer is NULL or points to private memory. You **must not**
free it. The memory gets freed automatically when you call
curl_easy_cleanup(3) on the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");
res = curl_easy_perform(curl);
if(!res) {
/* extract the entry path */
char *ep = NULL;
res = curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &ep);
if(!res && ep) {
printf("Entry path was: %s\n", ep);
}
}
curl_easy_cleanup(curl);
}
}
~~~
# HISTORY
Works for SFTP since 7.21.4
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,67 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_HEADER_SIZE
Section: 3
Source: libcurl
See-also:
- CURLINFO_REQUEST_SIZE (3)
- CURLINFO_SIZE_DOWNLOAD (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_HEADER_SIZE - get size of retrieved headers
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HEADER_SIZE, long *sizep);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the total size of all the headers
received. Measured in number of bytes.
The total includes the size of any received headers suppressed by
CURLOPT_SUPPRESS_CONNECT_HEADERS(3).
# %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(res == CURLE_OK) {
long size;
res = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size);
if(!res)
printf("Header size: %ld bytes\n", size);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,77 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_HTTPAUTH_AVAIL
Section: 3
Source: libcurl
See-also:
- CURLINFO_PROXYAUTH_AVAIL (3)
- CURLOPT_HTTPAUTH (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.10.8
---
# NAME
CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive a bitmask indicating the authentication
method(s) available according to the previous response. The meaning of the
bits is explained in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3).
# %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(!res) {
/* extract the available authentication types */
long auth;
res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_AVAIL, &auth);
if(!res) {
if(!auth)
printf("No auth available, perhaps no 401?\n");
else {
printf("%s%s%s%s\n",
auth & CURLAUTH_BASIC ? "Basic ":"",
auth & CURLAUTH_DIGEST ? "Digest ":"",
auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
auth % CURLAUTH_NTLM ? "NTLM ":"");
}
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,79 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_HTTPAUTH_USED
Section: 3
Source: libcurl
See-also:
- CURLINFO_PROXYAUTH_USED (3)
- CURLINFO_HTTPAUTH_AVAIL (3)
- CURLOPT_HTTPAUTH (3)
Protocol:
- HTTP
Added-in: 8.12.0
---
# NAME
CURLINFO_HTTPAUTH_USED - get used HTTP authentication method
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_USED, long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive a bitmask indicating the authentication
method that was used in the previous HTTP request. The meaning of the possible
bits is explained in the CURLOPT_HTTPAUTH(3) option for curl_easy_setopt(3).
The returned value has zero or one bit set.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_USERNAME, "shrek");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "swamp");
res = curl_easy_perform(curl);
if(!res) {
long auth;
res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_USED, &auth);
if(!res) {
if(!auth)
printf("No auth used\n");
else {
if(auth == CURLAUTH_DIGEST)
printf("Used Digest authentication\n");
else
printf("Used Basic authentication\n");
}
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,67 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_HTTP_CONNECTCODE
Section: 3
Source: libcurl
See-also:
- CURLINFO_RESPONSE_CODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.10.7
---
# NAME
CURLINFO_HTTP_CONNECTCODE - get the CONNECT response code
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_CONNECTCODE, long *p);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the last received HTTP proxy response code
to a CONNECT request. The returned value is zero if no such response code was
available.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* typically CONNECT is used to do HTTPS over HTTP proxies */
curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long code;
res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &code);
if(!res && code)
printf("The CONNECT response code: %03ld\n", code);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,63 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_HTTP_VERSION
Section: 3
Source: libcurl
See-also:
- CURLINFO_RESPONSE_CODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.50.0
---
# NAME
CURLINFO_HTTP_VERSION - get the http version used in the connection
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the version used in the last http
connection done using this handle. The returned value is
CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_2_0,
CURL_HTTP_VERSION_3 or 0 if the version cannot be determined.
# %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(res == CURLE_OK) {
long http_version;
curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION, &http_version);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,84 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_LASTSOCKET
Section: 3
Source: libcurl
See-also:
- CURLINFO_ACTIVESOCKET (3)
- CURLOPT_CONNECT_ONLY (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.15.2
---
# NAME
CURLINFO_LASTSOCKET - get the last socket used
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LASTSOCKET, long *socket);
~~~
# DESCRIPTION
Deprecated since 7.45.0. Use CURLINFO_ACTIVESOCKET(3) instead.
Pass a pointer to a long to receive the last socket used by this curl
session. If the socket is no longer valid, -1 is returned. When you finish
working with the socket, you must call curl_easy_cleanup(3) as usual and
let libcurl close the socket and cleanup other resources associated with the
handle. This is typically used in combination with
CURLOPT_CONNECT_ONLY(3).
NOTE: this API is deprecated since it is not working on win64 where the SOCKET
type is 64 bits large while its 'long' is 32 bits. Use the
CURLINFO_ACTIVESOCKET(3) instead, if possible.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
long sockfd; /* does not work on win64 */
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Do not do the transfer - only connect to host */
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
printf("Error: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
return 1;
}
/* Extract the socket from the curl handle */
res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
if(!res && sockfd != -1) {
/* operate on sockfd */
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_LOCAL_IP
Section: 3
Source: libcurl
See-also:
- CURLINFO_LOCAL_PORT (3)
- CURLINFO_PRIMARY_IP (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TCP
- QUIC
Added-in: 7.21.0
---
# NAME
CURLINFO_LOCAL_IP - get local IP address of last connection
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_IP, char **ip);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a null-terminated
string holding the IP address of the local end of most recent connection done
with this **curl** handle. This string may be IPv6 when that is enabled. Note
that you get a pointer to a memory area that is reused at next request so you
need to copy the string if you want to keep the information.
The **ip** pointer is NULL or points to private memory. You **must not** free
it. The memory gets freed automatically when you call curl_easy_cleanup(3) on
the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
char *ip;
CURLcode res;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the transfer */
res = curl_easy_perform(curl);
/* Check for errors */
if((res == CURLE_OK) &&
!curl_easy_getinfo(curl, CURLINFO_LOCAL_IP, &ip) && ip) {
printf("Local IP: %s\n", ip);
}
/* always cleanup */
curl_easy_cleanup(curl);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,74 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_LOCAL_PORT
Section: 3
Source: libcurl
Protocol:
- TCP
- QUIC
See-also:
- CURLINFO_LOCAL_IP (3)
- CURLINFO_PRIMARY_PORT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Added-in: 7.21.0
---
# NAME
CURLINFO_LOCAL_PORT - get the latest local port number
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long *portp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the local port number of the most recent
connection done with this **curl** handle.
If the connection was done using QUIC, the port number is a UDP port number,
otherwise it is a TCP port number.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
long port;
res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
if(CURLE_OK == res) {
printf("We used local port: %ld\n", port);
}
}
curl_easy_cleanup(curl);
}
return 0;
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,70 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_NAMELOOKUP_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_NAMELOOKUP_TIME_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_NAMELOOKUP_TIME - get the name lookup time
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NAMELOOKUP_TIME,
double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total time in seconds from the start
until the name resolving was completed.
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;
double namelookup;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
if(CURLE_OK == res) {
printf("Time: %.1f", namelookup);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,71 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_NAMELOOKUP_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_NAMELOOKUP_TIME (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_NAMELOOKUP_TIME_T - get the name lookup time in microseconds
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NAMELOOKUP_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the total time in microseconds
from the start until the name resolving was completed.
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_off_t namelookup;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &namelookup);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", namelookup / 1000000,
(long)(namelookup % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,67 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_NUM_CONNECTS
Section: 3
Source: libcurl
See-also:
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.12.3
---
# NAME
CURLINFO_NUM_CONNECTS - get number of created connections
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NUM_CONNECTS, long *nump);
~~~
# DESCRIPTION
Pass a pointer to a long to receive how many new connections libcurl had to
create to achieve the previous transfer (only the successful connects are
counted). Combined with CURLINFO_REDIRECT_COUNT(3) you are able to know how
many times libcurl successfully reused existing connection(s) or not. See the
connection options of curl_easy_setopt(3) to see how libcurl tries to make
persistent connections to save time.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long connects;
res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
if(!res)
printf("It needed %ld connects\n", connects);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_OS_ERRNO
Section: 3
Source: libcurl
See-also:
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.12.2
---
# NAME
CURLINFO_OS_ERRNO - get errno number from last connect failure
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the errno variable from a connect failure.
Note that the value is only set on failure, it is not reset upon a successful
operation. The number is OS and system specific.
libcurl network-related errors that may have a saved errno are:
CURLE_COULDNT_CONNECT, CURLE_FAILED_INIT, CURLE_INTERFACE_FAILED,
CURLE_OPERATION_TIMEDOUT, CURLE_RECV_ERROR, CURLE_SEND_ERROR.
Since 8.8.0 libcurl clears the easy handle's saved errno before performing the
transfer. Prior versions did not clear the saved errno, which means if a saved
errno is retrieved it could be from a previous transfer on the same handle.
# %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(res != CURLE_OK) {
long error;
res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
if(!res && error) {
printf("Errno: %ld\n", error);
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
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
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PRETRANSFER_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONNECT_TIME_T (3)
- CURLINFO_PRETRANSFER_TIME_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_PRETRANSFER_TIME - get the time until the file transfer start
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME,
double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the time, in seconds, it took from the
start until the file transfer is just about to begin.
This time-stamp includes all pre-transfer commands and negotiations that are
specific to the particular protocol(s) involved. It includes the sending of
the protocol-specific instructions that trigger a transfer.
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;
double pretransfer;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &pretransfer);
if(CURLE_OK == res) {
printf("Time: %.1f", pretransfer);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,77 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PRETRANSFER_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONNECT_TIME (3)
- CURLINFO_PRETRANSFER_TIME_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_PRETRANSFER_TIME_T - get the time until the file transfer start
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_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 file transfer is just about to begin.
This time-stamp includes all pre-transfer commands and negotiations that are
specific to the particular protocol(s) involved. It includes the sending of
the protocol-specific instructions that trigger a transfer.
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_off_t pretransfer;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, &pretransfer);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
pretransfer / 1000000,
(long)(pretransfer % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PRIMARY_IP
Section: 3
Source: libcurl
See-also:
- CURLINFO_LOCAL_IP (3)
- CURLINFO_LOCAL_PORT (3)
- CURLINFO_PRIMARY_PORT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.19.0
---
# NAME
CURLINFO_PRIMARY_IP - get IP address of last connection
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_IP, char **ip);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a null-terminated
string holding the IP address of the most recent connection done with this
**curl** handle. This string may be IPv6 when that is enabled. Note that you
get a pointer to a memory area that is reused at next request so you need to
copy the string if you want to keep the information.
The **ip** pointer is NULL or points to private memory. You **must not** free
it. The memory gets freed automatically when you call curl_easy_cleanup(3) on
the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
char *ip;
CURLcode res;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the transfer */
res = curl_easy_perform(curl);
/* Check for errors */
if((res == CURLE_OK) &&
!curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip) && ip) {
printf("IP: %s\n", ip);
}
/* always cleanup */
curl_easy_cleanup(curl);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PRIMARY_PORT
Section: 3
Source: libcurl
See-also:
- CURLINFO_LOCAL_PORT (3)
- CURLINFO_PRIMARY_IP (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.21.0
---
# NAME
CURLINFO_PRIMARY_PORT - get the latest destination port number
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_PORT, long *portp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the destination port of the most recent
connection done with this **curl** handle.
This is the destination port of the actual TCP or UDP connection libcurl used.
If a proxy was used for the most recent transfer, this is the port number of
the proxy, if no proxy was used it is the port number of the most recently
accessed URL.
# %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(res == CURLE_OK) {
long port;
res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &port);
if(!res)
printf("Connected to remote port: %ld\n", port);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,70 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PRIVATE
Section: 3
Source: libcurl
See-also:
- CURLOPT_PRIVATE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.10.3
---
# NAME
CURLINFO_PRIVATE - get the private pointer
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIVATE, char **private);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to the private data
associated with the curl handle (set with the CURLOPT_PRIVATE(3)).
Please note that for internal reasons, the value is returned as a char
pointer, although effectively being a 'void *'.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
void *pointer = (void *)0x2345454;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
/* set the private pointer */
curl_easy_setopt(curl, CURLOPT_PRIVATE, pointer);
res = curl_easy_perform(curl);
/* extract the private pointer again */
res = curl_easy_getinfo(curl, CURLINFO_PRIVATE, &pointer);
if(res)
printf("error: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,79 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PROTOCOL
Section: 3
Source: libcurl
See-also:
- CURLINFO_RESPONSE_CODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.52.0
---
# NAME
CURLINFO_PROTOCOL - get the protocol used in the connection
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROTOCOL, long *p);
~~~
# DESCRIPTION
This option is deprecated. We strongly recommend using
CURLINFO_SCHEME(3) instead, because this option cannot return all
possible protocols.
Pass a pointer to a long to receive the version used in the last http
connection. The returned value is set to one of these values:
~~~c
CURLPROTO_DICT, CURLPROTO_FILE, CURLPROTO_FTP, CURLPROTO_FTPS,
CURLPROTO_GOPHER, CURLPROTO_HTTP, CURLPROTO_HTTPS, CURLPROTO_IMAP,
CURLPROTO_IMAPS, CURLPROTO_LDAP, CURLPROTO_LDAPS, CURLPROTO_POP3,
CURLPROTO_POP3S, CURLPROTO_RTMP, CURLPROTO_RTMPE, CURLPROTO_RTMPS,
CURLPROTO_RTMPT, CURLPROTO_RTMPTE, CURLPROTO_RTMPTS, CURLPROTO_RTSP,
CURLPROTO_SCP, CURLPROTO_SFTP, CURLPROTO_SMB, CURLPROTO_SMBS, CURLPROTO_SMTP,
CURLPROTO_SMTPS, CURLPROTO_TELNET, CURLPROTO_TFTP, CURLPROTO_MQTT
~~~
# %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(res == CURLE_OK) {
long protocol;
curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
}
curl_easy_cleanup(curl);
}
}
~~~
# DEPRECATED
Deprecated since 7.85.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,78 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PROXYAUTH_AVAIL
Section: 3
Source: libcurl
See-also:
- CURLINFO_HTTPAUTH_AVAIL (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.10.8
---
# NAME
CURLINFO_PROXYAUTH_AVAIL - get available HTTP proxy authentication methods
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXYAUTH_AVAIL,
long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive a bitmask indicating the authentication
method(s) available according to the previous response. The meaning of the
bits is explained in the CURLOPT_PROXYAUTH(3) option for curl_easy_setopt(3).
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
res = curl_easy_perform(curl);
if(!res) {
/* extract the available proxy authentication types */
long auth;
res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_AVAIL, &auth);
if(!res) {
if(!auth)
printf("No proxy auth available, perhaps no 407?\n");
else {
printf("%s%s%s%s\n",
auth & CURLAUTH_BASIC ? "Basic ":"",
auth & CURLAUTH_DIGEST ? "Digest ":"",
auth & CURLAUTH_NEGOTIATE ? "Negotiate ":"",
auth % CURLAUTH_NTLM ? "NTLM ":"");
}
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,82 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PROXYAUTH_USED
Section: 3
Source: libcurl
See-also:
- CURLINFO_HTTPAUTH_USED (3)
- CURLINFO_PROXYAUTH_AVAIL (3)
- CURLOPT_HTTPAUTH (3)
Protocol:
- HTTP
Added-in: 8.12.0
---
# NAME
CURLINFO_PROXYAUTH_USED - get used HTTP proxy authentication method
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXYAUTH_USED, long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive a bitmask indicating the authentication
method that was used in the previous request done over an HTTP proxy. The
meaning of the possible bits is explained in the CURLOPT_HTTPAUTH(3) option
for curl_easy_setopt(3).
The returned value has zero or one bit set.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com");
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
CURLAUTH_BASIC | CURLAUTH_DIGEST);
curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "shrek");
curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "swamp");
res = curl_easy_perform(curl);
if(!res) {
long auth;
res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_USED, &auth);
if(!res) {
if(!auth)
printf("No auth used\n");
else {
if(auth == CURLAUTH_DIGEST)
printf("Used Digest proxy authentication\n");
else
printf("Used Basic proxy authentication\n");
}
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,107 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PROXY_ERROR
Section: 3
Source: libcurl
See-also:
- CURLINFO_RESPONSE_CODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
- libcurl-errors (3)
Protocol:
- All
Added-in: 7.73.0
---
# NAME
CURLINFO_PROXY_ERROR - get the detailed (SOCKS) proxy error
# SYNOPSIS
~~~c
#include <curl/curl.h>
typedef enum {
CURLPX_OK,
CURLPX_BAD_ADDRESS_TYPE,
CURLPX_BAD_VERSION,
CURLPX_CLOSED,
CURLPX_GSSAPI,
CURLPX_GSSAPI_PERMSG,
CURLPX_GSSAPI_PROTECTION,
CURLPX_IDENTD,
CURLPX_IDENTD_DIFFER,
CURLPX_LONG_HOSTNAME,
CURLPX_LONG_PASSWD,
CURLPX_LONG_USER,
CURLPX_NO_AUTH,
CURLPX_RECV_ADDRESS,
CURLPX_RECV_AUTH,
CURLPX_RECV_CONNECT,
CURLPX_RECV_REQACK,
CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED,
CURLPX_REPLY_COMMAND_NOT_SUPPORTED,
CURLPX_REPLY_CONNECTION_REFUSED,
CURLPX_REPLY_GENERAL_SERVER_FAILURE,
CURLPX_REPLY_HOST_UNREACHABLE,
CURLPX_REPLY_NETWORK_UNREACHABLE,
CURLPX_REPLY_NOT_ALLOWED,
CURLPX_REPLY_TTL_EXPIRED,
CURLPX_REPLY_UNASSIGNED,
CURLPX_REQUEST_FAILED,
CURLPX_RESOLVE_HOST,
CURLPX_SEND_AUTH,
CURLPX_SEND_CONNECT,
CURLPX_SEND_REQUEST,
CURLPX_UNKNOWN_FAIL,
CURLPX_UNKNOWN_MODE,
CURLPX_USER_REJECTED,
CURLPX_LAST /* never use */
} CURLproxycode;
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXY_ERROR, long *detail);
~~~
# DESCRIPTION
Pass a pointer to a long to receive a detailed error code when the most recent
transfer returned a **CURLE_PROXY** error. That error code matches the
**CURLproxycode** set.
The error code is zero (**CURLPX_OK**) if no response code was available.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://127.0.0.1");
res = curl_easy_perform(curl);
if(res == CURLE_PROXY) {
long proxycode;
res = curl_easy_getinfo(curl, CURLINFO_PROXY_ERROR, &proxycode);
if(!res && proxycode)
printf("The detailed proxy error: %ld\n", proxycode);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,80 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_PROXY_SSL_VERIFYRESULT
Section: 3
Source: libcurl
See-also:
- CURLINFO_SSL_VERIFYRESULT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
- GnuTLS
Added-in: 7.52.0
---
# NAME
CURLINFO_PROXY_SSL_VERIFYRESULT - get the result of the proxy certificate verification
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXY_SSL_VERIFYRESULT,
long *result);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the result of the certificate verification
that was requested (using the CURLOPT_PROXY_SSL_VERIFYPEER(3)
option. This is only used for HTTPS proxies.
0 is a positive result. Non-zero is an error.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
long verifyresult;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
res = curl_easy_perform(curl);
if(res) {
printf("error: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
return 1;
}
res = curl_easy_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT,
&verifyresult);
if(!res) {
printf("The peer verification said %s\n",
(verifyresult ? "bad" : "fine"));
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_QUEUE_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_STARTTRANSFER_TIME_T (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.6.0
---
# NAME
CURLINFO_QUEUE_TIME_T - time this transfer was queued
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_QUEUE_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the time, in microseconds, this
transfer was held in a waiting queue before it started "for real". A transfer
might be put in a queue if after getting started, it cannot create a new
connection etc due to set conditions and limits imposed by the application.
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_off_t queue;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_QUEUE_TIME_T, &queue);
if(CURLE_OK == res) {
printf("Queued: %" CURL_FORMAT_CURL_OFF_T ".%06ld us", queue / 1000000,
(long)(queue % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,64 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REDIRECT_COUNT
Section: 3
Source: libcurl
See-also:
- CURLINFO_REDIRECT_URL (3)
- CURLOPT_FOLLOWLOCATION (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.9.7
---
# NAME
CURLINFO_REDIRECT_COUNT - get the number of redirects
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_COUNT,
long *countp);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the total number of redirections that were
actually followed.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long redirects;
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &redirects);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REDIRECT_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_REDIRECT_COUNT (3)
- CURLINFO_REDIRECT_TIME_T (3)
- CURLINFO_REDIRECT_URL (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.9.7
---
# NAME
CURLINFO_REDIRECT_TIME - get the time for all redirection steps
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_TIME,
double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total time, in seconds, it took for
all redirection steps include name lookup, connect, pretransfer and transfer
before final transaction was started. CURLINFO_REDIRECT_TIME(3) contains
the complete execution time for multiple redirections.
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;
double redirect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &redirect);
if(CURLE_OK == res) {
printf("Time: %.1f", redirect);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,74 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REDIRECT_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_REDIRECT_COUNT (3)
- CURLINFO_REDIRECT_TIME (3)
- CURLINFO_REDIRECT_URL (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.61.0
---
# NAME
CURLINFO_REDIRECT_TIME_T - get the time for all redirection steps
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the total time, in microseconds, it
took for all redirection steps include name lookup, connect, pretransfer and
transfer before final transaction was started.
CURLINFO_REDIRECT_TIME_T(3) holds the complete execution time for
multiple redirections.
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_off_t redirect;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME_T, &redirect);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", redirect / 1000000,
(long)(redirect % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,71 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REDIRECT_URL
Section: 3
Source: libcurl
See-also:
- CURLINFO_REDIRECT_COUNT (3)
- CURLINFO_REDIRECT_TIME_T (3)
- CURLOPT_FOLLOWLOCATION (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.18.2
---
# NAME
CURLINFO_REDIRECT_URL - get the URL a redirect would go to
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_URL, char **urlp);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the URL a redirect *would* take
you to if you would enable CURLOPT_FOLLOWLOCATION(3). This can come handy if
you think using the built-in libcurl redirect logic is not good enough for you
but you would still prefer to avoid implementing all the magic of figuring out
the new URL.
This URL is also set if the CURLOPT_MAXREDIRS(3) limit prevented a redirect to
happen (since 7.54.1).
# %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(res == CURLE_OK) {
char *url = NULL;
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &url);
if(url)
printf("Redirect to: %s\n", url);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REFERER
Section: 3
Source: libcurl
See-also:
- CURLOPT_REFERER (3)
- curl_easy_getinfo (3)
- curl_easy_header (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
Added-in: 7.76.0
---
# NAME
CURLINFO_REFERER - get the used referrer request header
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REFERER, char **hdrp);
~~~
# DESCRIPTION
Pass in a pointer to a char pointer and get the referrer header used in the
most recent request.
The **hdrp** pointer is NULL or points to private memory. You **must not**
free it. The memory gets freed automatically when you call
curl_easy_cleanup(3) on the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/referrer");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
char *hdr = NULL;
curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
if(hdr)
printf("Referrer header: %s\n", hdr);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,65 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_REQUEST_SIZE
Section: 3
Source: libcurl
See-also:
- CURLINFO_HEADER_SIZE (3)
- CURLINFO_SIZE_DOWNLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_REQUEST_SIZE - get size of sent request
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REQUEST_SIZE, long *sizep);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the total size of the issued
requests. This is so far only for HTTP requests. Note that this may be more
than one request if CURLOPT_FOLLOWLOCATION(3) is enabled.
# %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(res == CURLE_OK) {
long req;
res = curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &req);
if(!res)
printf("Request size: %ld bytes\n", req);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,74 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RESPONSE_CODE
Section: 3
Source: libcurl
See-also:
- CURLINFO_HTTP_CONNECTCODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- HTTP
- FTP
- SMTP
- LDAP
Added-in: 7.10.8
---
# NAME
CURLINFO_RESPONSE_CODE - get the last response code
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the last received HTTP, FTP, SMTP or LDAP
(OpenLDAP only) response code. This option was previously known as
CURLINFO_HTTP_CODE in libcurl 7.10.7 and earlier. The stored value is zero if
no server response code has been received.
Note that a proxy's CONNECT response should be read with
CURLINFO_HTTP_CONNECTCODE(3) and not this.
# %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(res == CURLE_OK) {
long response_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
}
curl_easy_cleanup(curl);
}
}
~~~
# NOTES
The former name, CURLINFO_HTTP_CODE, was added in 7.4.1. Support for SMTP
responses added in 7.25.0, for OpenLDAP in 7.81.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,78 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RETRY_AFTER
Section: 3
Source: libcurl
See-also:
- CURLOPT_HEADERFUNCTION (3)
- CURLOPT_STDERR (3)
- curl_easy_header (3)
Protocol:
- All
Added-in: 7.66.0
---
# NAME
CURLINFO_RETRY_AFTER - returns the Retry-After retry delay
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RETRY_AFTER,
curl_off_t *retry);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t variable to receive the number of seconds the
HTTP server suggests the client should wait until the next request is
issued. The information from the "Retry-After:" header.
While the HTTP header might contain a fixed date string, the
CURLINFO_RETRY_AFTER(3) always returns the number of seconds to wait -
or zero if there was no header or the header could not be parsed.
This option used to return a negative wait time if the server provided a date
in the past. Since 8.12.0, a negative wait time is returned as zero. In any
case we recommend checking that the wait time is within an acceptable range for
your circumstance.
# DEFAULT
Zero if there was no header.
# %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(res == CURLE_OK) {
curl_off_t wait = 0;
curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &wait);
if(wait)
printf("Wait for %" CURL_FORMAT_CURL_OFF_T " seconds\n", wait);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,63 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RTSP_CLIENT_CSEQ
Section: 3
Source: libcurl
See-also:
- CURLINFO_RTSP_CSEQ_RECV (3)
- CURLINFO_RTSP_SERVER_CSEQ (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- RTSP
Added-in: 7.20.0
---
# NAME
CURLINFO_RTSP_CLIENT_CSEQ - get the next RTSP client CSeq
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_CLIENT_CSEQ,
long *cseq);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the next CSeq that is expected to be used
by the application.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long cseq;
curl_easy_getinfo(curl, CURLINFO_RTSP_CLIENT_CSEQ, &cseq);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,63 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RTSP_CSEQ_RECV
Section: 3
Source: libcurl
See-also:
- CURLINFO_RTSP_SERVER_CSEQ (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- RTSP
Added-in: 7.20.0
---
# NAME
CURLINFO_RTSP_CSEQ_RECV - get the recently received CSeq
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_CSEQ_RECV, long *cseq);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the most recently received CSeq from the
server. If your application encounters a *CURLE_RTSP_CSEQ_ERROR* then you
may wish to troubleshoot and/or fix the CSeq mismatch by peeking at this
value.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long cseq;
curl_easy_getinfo(curl, CURLINFO_RTSP_CSEQ_RECV, &cseq);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,67 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RTSP_SERVER_CSEQ
Section: 3
Source: libcurl
See-also:
- CURLINFO_RTSP_CSEQ_RECV (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- RTSP
Added-in: 7.20.0
---
# NAME
CURLINFO_RTSP_SERVER_CSEQ - get the next RTSP server CSeq
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_SERVER_CSEQ,
long *cseq);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the next CSeq that is expected to be used
by the application.
Listening for server initiated requests is not implemented.
Applications wishing to resume an RTSP session on another connection should
retrieve this info before closing the active connection.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
long cseq;
curl_easy_getinfo(curl, CURLINFO_RTSP_SERVER_CSEQ, &cseq);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,68 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_RTSP_SESSION_ID
Section: 3
Source: libcurl
See-also:
- CURLINFO_RTSP_CSEQ_RECV (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- RTSP
Added-in: 7.20.0
---
# NAME
CURLINFO_RTSP_SESSION_ID - get RTSP session ID
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_SESSION_ID, char **id);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive a pointer to a string holding the
most recent RTSP Session ID.
Applications wishing to resume an RTSP session on another connection should
retrieve this info before closing the active connection.
The **id** pointer is NULL or points to private memory. You **must not** free
it. The memory gets freed automatically when you call curl_easy_cleanup(3) on
the corresponding curl handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "rtsp://rtsp.example.com");
res = curl_easy_perform(curl);
if(res == CURLE_OK) {
char *id;
curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &id);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SCHEME
Section: 3
Source: libcurl
See-also:
- CURLINFO_EFFECTIVE_URL (3)
- CURLINFO_PROTOCOL (3)
- CURLINFO_RESPONSE_CODE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.52.0
---
# NAME
CURLINFO_SCHEME - get the URL scheme (sometimes called protocol) used in the connection
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme);
~~~
# DESCRIPTION
Pass a pointer to a char pointer to receive the pointer to a null-terminated
string holding the URL scheme used for the most recent connection done with
this CURL **handle**.
The **scheme** pointer is NULL or points to private memory. You **must not**
free it. The memory gets freed automatically when you call
curl_easy_cleanup(3) on the corresponding curl handle.
The returned scheme might be upper or lowercase. Do comparisons case
insensitively.
# %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(res == CURLE_OK) {
char *scheme = NULL;
curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(scheme)
printf("scheme: %s\n", scheme); /* scheme: HTTP */
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,79 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SIZE_DOWNLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_DOWNLOAD_T (3)
- CURLINFO_SIZE_UPLOAD_T (3)
- CURLOPT_MAXFILESIZE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_SIZE_DOWNLOAD - get the number of downloaded bytes
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD, double *dlp);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total amount of bytes that were
downloaded. 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 and not included in this
number.
CURLINFO_SIZE_DOWNLOAD_T(3) is a newer replacement that returns a more
sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
double dl;
res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &dl);
if(!res) {
printf("Downloaded %.0f bytes\n", dl);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SIZE_DOWNLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_DOWNLOAD (3)
- CURLINFO_SIZE_UPLOAD_T (3)
- CURLOPT_MAXFILESIZE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.55.0
---
# NAME
CURLINFO_SIZE_DOWNLOAD_T - get the number of downloaded bytes
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD_T,
curl_off_t *dlp);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the total amount of bytes that
were downloaded. 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.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
/* check the size */
curl_off_t dl;
res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &dl);
if(!res) {
printf("Downloaded %" 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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SIZE_UPLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_DOWNLOAD_T (3)
- CURLINFO_SIZE_UPLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_SIZE_UPLOAD - get the number of uploaded bytes
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_UPLOAD,
double *uploadp);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total amount of bytes that were
uploaded.
CURLINFO_SIZE_UPLOAD_T(3) is a newer replacement that returns a more
sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
double ul;
res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &ul);
if(!res) {
printf("Uploaded %.0f bytes\n", ul);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,68 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SIZE_UPLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_DOWNLOAD_T (3)
- CURLINFO_SIZE_UPLOAD (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.55.0
---
# NAME
CURLINFO_SIZE_UPLOAD_T - get the number of uploaded bytes
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_UPLOAD_T,
curl_off_t *uploadp);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the total amount of bytes that
were uploaded.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t ul;
res = curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &ul);
if(!res) {
printf("Uploaded %" CURL_FORMAT_CURL_OFF_T " bytes\n", ul);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SPEED_DOWNLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_UPLOAD_T (3)
- CURLINFO_SPEED_UPLOAD (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_SPEED_DOWNLOAD - get download speed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_DOWNLOAD,
double *speed);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the average download speed that curl
measured for the complete download. Measured in bytes/second.
CURLINFO_SPEED_DOWNLOAD_T(3) is a newer replacement that returns a more
sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
double speed;
res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &speed);
if(!res) {
printf("Download speed %.0f bytes/sec\n", speed);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SPEED_DOWNLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_SIZE_UPLOAD_T (3)
- CURLINFO_SPEED_UPLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.55.0
---
# NAME
CURLINFO_SPEED_DOWNLOAD_T - get download speed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_DOWNLOAD_T,
curl_off_t *speed);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the average download speed
that curl measured for the complete download. Measured in bytes/second.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t speed;
res = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &speed);
if(!res) {
printf("Download speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\n",
speed);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SPEED_UPLOAD
Section: 3
Source: libcurl
See-also:
- CURLINFO_SPEED_DOWNLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_SPEED_UPLOAD - get upload speed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_UPLOAD, double *speed);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the average upload speed that curl
measured for the complete upload. Measured in bytes/second.
CURLINFO_SPEED_UPLOAD_T(3) is a newer replacement that returns a more
sensible variable type.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
double speed;
res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed);
if(!res) {
printf("Upload speed %.0f bytes/sec\n", speed);
}
}
}
}
~~~
# DEPRECATED
Deprecated since 7.55.0.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,67 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SPEED_UPLOAD_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_SPEED_DOWNLOAD_T (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.55.0
---
# NAME
CURLINFO_SPEED_UPLOAD_T - get upload speed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_UPLOAD_T,
curl_off_t *speed);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the average upload speed that
curl measured for the complete upload. Measured in bytes/second.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t speed;
res = curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed);
if(!res) {
printf("Upload speed %" CURL_FORMAT_CURL_OFF_T " bytes/sec\n", speed);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,69 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SSL_ENGINES
Section: 3
Source: libcurl
See-also:
- CURLOPT_SSLENGINE (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
Added-in: 7.12.3
---
# NAME
CURLINFO_SSL_ENGINES - get an slist of OpenSSL crypto-engines
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SSL_ENGINES,
struct curl_slist **engine_list);
~~~
# DESCRIPTION
Pass the address of a 'struct curl_slist *' to receive a linked-list of
OpenSSL crypto-engines supported. Note that engines are normally implemented
in separate dynamic libraries. Hence not all the returned engines may be
available at runtime. **NOTE:** you must call curl_slist_free_all(3)
on the list pointer once you are done with it, as libcurl does not free this
data for you.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
struct curl_slist *engines;
res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
if((res == CURLE_OK) && engines) {
/* we have a list, free it when done using it */
curl_slist_free_all(engines);
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,79 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_SSL_VERIFYRESULT
Section: 3
Source: libcurl
See-also:
- CURLINFO_PROXY_SSL_VERIFYRESULT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
- GnuTLS
Added-in: 7.5
---
# NAME
CURLINFO_SSL_VERIFYRESULT - get the result of the certificate verification
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SSL_VERIFYRESULT,
long *result);
~~~
# DESCRIPTION
Pass a pointer to a long to receive the result of the server SSL certificate
verification that was requested (using the CURLOPT_SSL_VERIFYPEER(3)
option).
0 is a positive result. Non-zero is an error.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
long verifyresult;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(res) {
printf("error: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
return 1;
}
res = curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT,
&verifyresult);
if(!res) {
printf("The peer verification said %s\n",
(verifyresult ? "bad" : "fine"));
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,73 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_STARTTRANSFER_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_STARTTRANSFER_TIME_T (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.9.2
---
# NAME
CURLINFO_STARTTRANSFER_TIME - get the time until the first byte is received
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_STARTTRANSFER_TIME,
double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the time, in seconds, it took from the
start until the first byte is received by libcurl. This includes
CURLINFO_PRETRANSFER_TIME(3) and also the time the server needs to
calculate the result.
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;
double start;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start);
if(CURLE_OK == res) {
printf("Time: %.1f", start);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_STARTTRANSFER_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_STARTTRANSFER_TIME (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_STARTTRANSFER_TIME_T - get the time until the first byte is received
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_STARTTRANSFER_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 first byte is received by libcurl. This includes
CURLINFO_PRETRANSFER_TIME_T(3) and also the time the server needs to
calculate the result.
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_off_t start;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T, &start);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", start / 1000000,
(long)(start % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,94 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_TLS_SESSION
Section: 3
Source: libcurl
See-also:
- CURLINFO_TLS_SSL_PTR (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- OpenSSL
- GnuTLS
Added-in: 7.34.0
---
# NAME
CURLINFO_TLS_SESSION - get TLS session info
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION,
struct curl_tlssessioninfo **session);
~~~
# DESCRIPTION
**This option has been superseded** by CURLINFO_TLS_SSL_PTR(3).
This option is exactly the same as CURLINFO_TLS_SSL_PTR(3) except in the case
of OpenSSL and wolfSSL. If the session *backend* is CURLSSLBACKEND_OPENSSL the
session *internals* pointer varies depending on the option:
## OpenSSL:
CURLINFO_TLS_SESSION(3) OpenSSL session *internals* is **SSL_CTX ***.
CURLINFO_TLS_SSL_PTR(3) OpenSSL session *internals* is **SSL ***.
You can obtain an **SSL_CTX** pointer from an SSL pointer using OpenSSL
function *SSL_get_SSL_CTX(3)*. Therefore unless you need compatibility
with older versions of libcurl use CURLINFO_TLS_SSL_PTR(3). Refer to
that document for more information.
## wolfSSL
CURLINFO_TLS_SESSION(3) wolfSSL session *internals* is **WOLFSSL_CTX ***.
CURLINFO_TLS_SSL_PTR(3) wolfSSL session *internals* is **WOLFSSL ***.
You can obtain an **WOLFSSL_CTX** pointer from an SSL pointer using wolfSSL
function *wolfSSL_get_SSL_CTX(3)*. Therefore unless you need compatibility
with older versions of libcurl use CURLINFO_TLS_SSL_PTR(3). Refer to
that document for more information.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
struct curl_tlssessioninfo *tls;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(res)
printf("error: %s\n", curl_easy_strerror(res));
curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &tls);
curl_easy_cleanup(curl);
}
}
~~~
# DEPRECATED
Deprecated since 7.48.0
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,177 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_TLS_SSL_PTR
Section: 3
Source: libcurl
See-also:
- CURLINFO_TLS_SESSION (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- TLS
TLS-backend:
- GnuTLS
- mbedTLS
- OpenSSL
- Schannel
- wolfSSL
Added-in: 7.48.0
---
# NAME
CURLINFO_TLS_SESSION, CURLINFO_TLS_SSL_PTR - get TLS session info
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SSL_PTR,
struct curl_tlssessioninfo **session);
/* if you need compatibility with libcurl < 7.48.0 use
CURLINFO_TLS_SESSION instead: */
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION,
struct curl_tlssessioninfo **session);
~~~
# DESCRIPTION
Pass a pointer to a *struct curl_tlssessioninfo **. The pointer is initialized
to refer to a *struct curl_tlssessioninfo ** that contains an enum indicating
the SSL library used for the handshake and a pointer to the respective
internal TLS session structure of this underlying SSL library.
This option may be useful for example to extract certificate information in a
format convenient for further processing, such as manual validation. Refer to
the **LIMITATIONS** section.
~~~c
struct curl_tlssessioninfo {
curl_sslbackend backend;
void *internals;
};
~~~
The *backend* struct member is one of these defines: CURLSSLBACKEND_NONE (when
built without TLS support), CURLSSLBACKEND_WOLFSSL,
CURLSSLBACKEND_SECURETRANSPORT, CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_MBEDTLS,
CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL or CURLSSLBACKEND_SCHANNEL. (Note
that the OpenSSL forks are all reported as just OpenSSL here.)
The *internals* struct member points to a TLS library specific pointer for
the active ("in use") SSL connection, with the following underlying types:
## GnuTLS
**gnutls_session_t**
## OpenSSL
CURLINFO_TLS_SESSION(3): **SSL_CTX ***
CURLINFO_TLS_SSL_PTR(3): **SSL ***
Since 7.48.0 the *internals* member can point to these other SSL backends
as well:
## mbedTLS
**mbedTLS_ssl_context ***
## Secure Channel
**CtxtHandle ***
## wolfSSL
**SSL ***
##
If the *internals* pointer is NULL then either the SSL backend is not
supported, an SSL session has not yet been established or the connection is no
longer associated with the easy handle (e.g. curl_easy_perform(3) has
returned).
# LIMITATIONS
This option has some limitations that could make it unsafe when it comes to
the manual verification of certificates.
This option only retrieves the first in-use SSL session pointer for your easy
handle, however your easy handle may have more than one in-use SSL session if
using FTP over SSL. That is because the FTP protocol has a control channel and
a data channel and one or both may be over SSL. Currently there is no way to
retrieve a second in-use SSL session associated with an easy handle.
This option has not been thoroughly tested with clear text protocols that can
be upgraded/downgraded to/from SSL: FTP, SMTP, POP3, IMAP when used with
CURLOPT_USE_SSL(3). Though you can to retrieve the SSL pointer, it is possible
that before you can do that, data (including auth) may have already been sent
over a connection after it was upgraded.
Renegotiation. If unsafe renegotiation or renegotiation in a way that the
certificate is allowed to change is allowed by your SSL library this may occur
and the certificate may change, and data may continue to be sent or received
after renegotiation but before you are able to get the (possibly) changed SSL
pointer, with the (possibly) changed certificate information.
Instead of using this option to poll for certificate changes use
CURLOPT_SSL_CTX_FUNCTION(3) to set a verification callback, if supported.
That is safer and does not suffer from any of the problems above.
How are you using this option? Are you affected by any of these limitations?
Please let us know by making a comment at
https://github.com/curl/curl/issues/685
# %PROTOCOLS%
# EXAMPLE
~~~c
#include <curl/curl.h>
#include <openssl/ssl.h>
CURL *curl;
static size_t wf(void *ptr, size_t size, size_t nmemb, void *stream)
{
const struct curl_tlssessioninfo *info = NULL;
CURLcode res = curl_easy_getinfo(curl, CURLINFO_TLS_SSL_PTR, &info);
if(info && !res) {
if(CURLSSLBACKEND_OPENSSL == info->backend) {
printf("OpenSSL ver. %s\n", SSL_get_version((SSL*)info->internals));
}
}
return size * nmemb;
}
int main(int argc, char **argv)
{
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wf);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return res;
}
~~~
# HISTORY
This option supersedes CURLINFO_TLS_SESSION(3) which was added in 7.34.0.
This option is exactly the same as that option except in the case of OpenSSL.
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,71 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_TOTAL_TIME
Section: 3
Source: libcurl
See-also:
- CURLINFO_TOTAL_TIME_T (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.4.1
---
# NAME
CURLINFO_TOTAL_TIME - get total time of previous transfer
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME, double *timep);
~~~
# DESCRIPTION
Pass a pointer to a double to receive the total time in seconds for the
previous transfer, including name resolving, TCP connect etc. The double
represents the time in seconds, including fractions.
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;
double total;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
if(CURLE_OK == res) {
printf("Time: %.1f", total);
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_TOTAL_TIME_T
Section: 3
Source: libcurl
See-also:
- CURLINFO_TOTAL_TIME (3)
- CURLOPT_TIMEOUT (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 7.61.0
---
# NAME
CURLINFO_TOTAL_TIME_T - get total time of previous transfer in microseconds
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME_T,
curl_off_t *timep);
~~~
# DESCRIPTION
Pass a pointer to a curl_off_t to receive the total time in microseconds
for the previous transfer, including name resolving, TCP connect etc.
The curl_off_t represents the time in microseconds.
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_off_t total;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total);
if(CURLE_OK == res) {
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", total / 1000000,
(long)(total % 1000000));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,71 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_USED_PROXY
Section: 3
Source: libcurl
See-also:
- CURLOPT_NOPROXY (3)
- CURLOPT_PROXY (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.7.0
---
# NAME
CURLINFO_USED_PROXY - whether the transfer used a proxy
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_USED_PROXY,
long *authp);
~~~
# DESCRIPTION
Pass a pointer to a long. It gets set to zero set if no proxy was used in the
previous transfer or a non-zero value if a proxy was used.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(int argc, char *argv[])
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80");
curl_easy_setopt(curl, CURLOPT_NOPROXY, "example.com");
res = curl_easy_perform(curl);
if(!res) {
/* extract the available proxy authentication types */
long used;
res = curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &used);
if(!res) {
printf("The proxy was %sused\n", used ? "": "NOT ");
}
}
curl_easy_cleanup(curl);
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLINFO_XFER_ID
Section: 3
Source: libcurl
See-also:
- CURLINFO_CONN_ID (3)
- curl_easy_getinfo (3)
- curl_easy_setopt (3)
Protocol:
- All
Added-in: 8.2.0
---
# NAME
CURLINFO_XFER_ID - get the ID of a transfer
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_XFER_ID,
curl_off_t *xfer_id);
~~~
# DESCRIPTION
Pass a pointer to a *curl_off_t* to receive the identifier of the
current/last transfer done with the handle. Stores -1 if no transfer
has been started yet for the handle.
The transfer id is unique among all transfers performed using the same
connection cache. This is implicitly the case for all transfers in the
same multi handle.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
res = curl_easy_perform(curl);
if(!res) {
curl_off_t xfer_id;
res = curl_easy_getinfo(curl, CURLINFO_XFER_ID, &xfer_id);
if(!res) {
printf("Transfer ID: %" CURL_FORMAT_CURL_OFF_T "\n", xfer_id);
}
}
}
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_easy_getinfo(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).
@@ -0,0 +1,63 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMINFO_XFERS_ADDED
Section: 3
Source: libcurl
See-also:
- CURLMINFO_XFERS_CURRENT (3)
- CURLMINFO_XFERS_RUNNING (3)
- CURLMINFO_XFERS_DONE (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMINFO_XFERS_ADDED - Cumulative number of all easy handles added
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_get_offt(CURLM *handle, CURLMINFO_XFERS_ADDED,
curl_off_t *pvalue);
~~~
# DESCRIPTION
The cumulative number of all easy handles added to the multi, ever. This
includes internal handles added for tasks (like resolving via DoH, for
example).
For the current number of easy handles managed by the multi, use
CURLMINFO_XFERS_CURRENT(3).
# DEFAULT
n/a
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
curl_off_t value;
curl_multi_get_offt(m, CURLMINFO_XFERS_ADDED, &value);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_get_offt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,62 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMINFO_XFERS_CURRENT
Section: 3
Source: libcurl
See-also:
- CURLMINFO_XFERS_RUNNING (3)
- CURLMINFO_XFERS_PENDING (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMINFO_XFERS_CURRENT - Number of easy handles currently added
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_get_offt(CURLM *handle, CURLMINFO_XFERS_CURRENT,
curl_off_t *pvalue);
~~~
# DESCRIPTION
Returns the number of easy handles currently added to the multi handle. This
does not include already removed handles. It does include internal handles
that get added for tasks (like resolving via DoH, for example).
For the total number of easy handles ever added to the multi, see
CURLMINFO_XFERS_ADDED(3).
# DEFAULT
n/a
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
curl_off_t value;
curl_multi_get_offt(m, CURLMINFO_XFERS_CURRENT, &value);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_get_offt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,58 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMINFO_XFERS_DONE
Section: 3
Source: libcurl
See-also:
- CURLMINFO_XFERS_CURRENT (3)
- CURLMINFO_XFERS_RUNNING (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMINFO_XFERS_DONE - Number of finished unprocessed easy handles
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_get_offt(CURLM *handle, CURLMINFO_XFERS_DONE,
curl_off_t *pvalue);
~~~
# DESCRIPTION
The number of easy handles currently finished, but not yet processed via
curl_multi_info_read(3).
# DEFAULT
n/a
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
curl_off_t value;
curl_multi_get_offt(m, CURLMINFO_XFERS_DONE, &value);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_get_offt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,60 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMINFO_XFERS_PENDING
Section: 3
Source: libcurl
See-also:
- CURLMINFO_XFERS_CURRENT (3)
- CURLMINFO_XFERS_RUNNING (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMINFO_XFERS_PENDING - Number of easy handles waiting to start
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_get_offt(CURLM *handle, CURLMINFO_XFERS_PENDING,
curl_off_t *pvalue);
~~~
# DESCRIPTION
The number of current easy handles waiting to start. An added transfer might
become pending for various reasons: a connection limit forces it to wait,
resolving DNS is not finished or it is not clear if an existing, matching
connection may allow multiplexing (HTTP/2 or HTTP/3).
# DEFAULT
n/a
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
curl_off_t value;
curl_multi_get_offt(m, CURLMINFO_XFERS_PENDING, &value);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_get_offt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,58 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMINFO_XFERS_RUNNING
Section: 3
Source: libcurl
See-also:
- CURLMINFO_XFERS_CURRENT (3)
- CURLMINFO_XFERS_PENDING (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMINFO_XFERS_RUNNING - Number of easy handles currently running
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_get_offt(CURLM *handle, CURLMINFO_XFERS_RUNNING,
curl_off_t *pvalue);
~~~
# DESCRIPTION
The number of easy handles currently running, e.g. where the transfer has
started but not finished yet.
# DEFAULT
n/a
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
curl_off_t value;
curl_multi_get_offt(m, CURLMINFO_XFERS_RUNNING, &value);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_get_offt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,63 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE
Section: 3
Source: libcurl
See-also:
- CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE (3)
- CURLMOPT_MAX_PIPELINE_LENGTH (3)
- CURLMOPT_PIPELINING (3)
Protocol:
- HTTP
Added-in: 7.30.0
---
# NAME
CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE - chunk length threshold for pipelining
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE,
long size);
~~~
# DESCRIPTION
No function since pipelining was removed in 7.62.0.
Pass a long with a **size** in bytes. If a transfer in a pipeline is
currently processing a chunked (Transfer-encoding: chunked) request with a
current chunk length larger than CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE(3),
that pipeline is not considered for additional requests, even if it is shorter
than CURLMOPT_MAX_PIPELINE_LENGTH(3).
# DEFAULT
0, which means that penalization is inactive.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
long maxchunk = 10000;
curl_multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, maxchunk);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,62 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE
Section: 3
Source: libcurl
See-also:
- CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE (3)
- CURLMOPT_PIPELINING (3)
Protocol:
- HTTP
Added-in: 7.30.0
---
# NAME
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE - size threshold for pipelining penalty
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE,
long size);
~~~
# DESCRIPTION
No function since pipelining was removed in 7.62.0.
Pass a long with a **size** in bytes. If a transfer in a pipeline is
currently processing a request with a Content-Length larger than this
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE(3), that pipeline is not considered
for additional requests, even if it is shorter than
CURLMOPT_MAX_PIPELINE_LENGTH(3).
# DEFAULT
0, which means that the size penalization is inactive.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
long maxlength = 10000;
curl_multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, maxlength);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,75 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAXCONNECTS
Section: 3
Source: libcurl
See-also:
- CURLMOPT_MAX_HOST_CONNECTIONS (3)
- CURLOPT_MAXCONNECTS (3)
Protocol:
- All
Added-in: 7.16.3
---
# NAME
CURLMOPT_MAXCONNECTS - size of connection cache
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max);
~~~
# DESCRIPTION
Pass a long indicating the **max**, the maximum amount of connections that
libcurl may keep alive in its connection cache after use. By default libcurl
enlarges the size for each added easy handle to make it fit 4 times the number
of added easy handles.
By setting this option, you prevent the cache size from growing beyond the
limit set by you.
When the cache is full, curl closes the oldest connection present in the cache
to prevent the number of connections from increasing.
This option is for the multi handle's use only, when using the easy interface
you should instead use the CURLOPT_MAXCONNECTS(3) option.
See CURLMOPT_MAX_TOTAL_CONNECTIONS(3) for limiting the number of active
connections.
Changing this value when there are transfers in progress is possible, and the
new value is then used the next time checks are performed. Lowering the value
does not close down any active transfers, it simply does not allow new ones to
get made.
# DEFAULT
See DESCRIPTION
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* only keep 10 connections in the cache */
curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,61 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAX_CONCURRENT_STREAMS
Section: 3
Source: libcurl
See-also:
- CURLMOPT_MAXCONNECTS (3)
- CURLOPT_MAXCONNECTS (3)
Protocol:
- HTTP
Added-in: 7.67.0
---
# NAME
CURLMOPT_MAX_CONCURRENT_STREAMS - max concurrent streams for http2
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_CONCURRENT_STREAMS,
long max);
~~~
# DESCRIPTION
Pass a long indicating the **max**. The set number is used as the maximum
number of concurrent streams libcurl should support on connections done using
HTTP/2 or HTTP/3.
Valid values range from 1 to 2147483647 (2^31 - 1) and defaults to 100. The
value passed here would be honored based on other system resources properties.
# DEFAULT
100
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* max concurrent streams 200 */
curl_multi_setopt(m, CURLMOPT_MAX_CONCURRENT_STREAMS, 200L);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,80 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAX_HOST_CONNECTIONS
Section: 3
Source: libcurl
See-also:
- CURLMOPT_MAXCONNECTS (3)
- CURLMOPT_MAX_TOTAL_CONNECTIONS (3)
Protocol:
- All
Added-in: 7.30.0
---
# NAME
CURLMOPT_MAX_HOST_CONNECTIONS - max number of connections to a single host
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_HOST_CONNECTIONS,
long max);
~~~
# DESCRIPTION
Pass a long to indicate **max**, the maximum amount of simultaneously open
connections libcurl may hold a single host (a host being the same as a
hostname + port number pair). For each new transfer to the same host, libcurl
might open a new connection up to the limit set by
CURLMOPT_MAX_HOST_CONNECTIONS(3). When the limit is reached, new sessions are
kept pending until a connection becomes available.
The default **max** value is 0, unlimited. This set limit is also used for
proxy connections, and then the proxy is considered to be the host for which
this limit counts.
When more transfers are added to the multi handle than what can be performed
due to the set limit, they are queued up waiting for their chance.
While a transfer is queued up internally waiting for a connection, the
CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the waiting time,
meaning that if you set a too narrow timeout the transfer might never even
start before it times out. The CURLOPT_CONNECTTIMEOUT_MS(3) time is also
similarly still treated as a per-connect timeout and might expire even before
making a new connection is permitted.
Changing this value while there are transfers in progress is possible. The new
value is then used the next time checks are performed. Lowering the value does
not close down any active transfers, it simply does not allow new ones to get
made.
# DEFAULT
0
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* do no more than 2 connections per host */
curl_multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,66 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAX_PIPELINE_LENGTH
Section: 3
Source: libcurl
See-also:
- CURLMOPT_MAX_HOST_CONNECTIONS (3)
- CURLMOPT_PIPELINING (3)
Protocol:
- All
Added-in: 7.30.0
---
# NAME
CURLMOPT_MAX_PIPELINE_LENGTH - maximum number of requests in a pipeline
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_PIPELINE_LENGTH,
long max);
~~~
# DESCRIPTION
No function since pipelining was removed in 7.62.0.
Pass a long. The set **max** number is used as the maximum amount of
outstanding requests in an HTTP/1.1 pipeline. This option is only used for
HTTP/1.1 pipelining, not for HTTP/2 multiplexing.
When this limit is reached, libcurl creates another connection to the same
host (see CURLMOPT_MAX_HOST_CONNECTIONS(3)), or queue the request until one
of the pipelines to the host is ready to accept a request. Thus, the total
number of requests in-flight is CURLMOPT_MAX_HOST_CONNECTIONS(3) *
CURLMOPT_MAX_PIPELINE_LENGTH(3).
# DEFAULT
5
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* set a more conservative pipe length */
curl_multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,77 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_MAX_TOTAL_CONNECTIONS
Section: 3
Source: libcurl
See-also:
- CURLMOPT_MAXCONNECTS (3)
- CURLMOPT_MAX_HOST_CONNECTIONS (3)
Protocol:
- All
Added-in: 7.30.0
---
# NAME
CURLMOPT_MAX_TOTAL_CONNECTIONS - max simultaneously open connections
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_TOTAL_CONNECTIONS,
long amount);
~~~
# DESCRIPTION
Pass a long for the **amount**. The set number is used as the maximum number
of simultaneously open connections in total using this multi handle. For each
new session, libcurl might open a new connection up to the limit set by
CURLMOPT_MAX_TOTAL_CONNECTIONS(3). If CURLMOPT_PIPELINING(3) is enabled,
libcurl can try multiplexing if the host is capable of it.
When more transfers are added to the multi handle than what can be performed
due to the set limit, they get queued up waiting for their chance.
While a transfer is queued up internally waiting for a connection, the
CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the waiting time,
meaning that if you set a too narrow timeout the transfer might never even
start before it times out. The CURLOPT_CONNECTTIMEOUT_MS(3) time is also
similarly still treated as a per-connect timeout and might expire even before
making a new connection is permitted.
Changing this value while there are transfers in progress is possible. The new
value is then used the next time checks are performed. Lowering the value does
not close down any active transfers, it simply does not allow new ones to get
made.
# DEFAULT
0, which means that there is no limit. It is then simply controlled by the
number of easy handles added concurrently and how much multiplexing is being
done.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* never do more than 15 connections */
curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,80 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_NETWORK_CHANGED
Section: 3
Source: libcurl
See-also:
- CURLOPT_FRESH_CONNECT (3)
- CURLOPT_FORBID_REUSE (3)
Protocol:
- All
Added-in: 8.16.0
---
# NAME
CURLMOPT_NETWORK_CHANGED - signal network changed
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NETWORK_CHANGED,
long value);
~~~
# DESCRIPTION
Pass a long with a bitmask to tell libcurl how the multi
handle should react. The following values in the mask are
defined. All bits not mentioned are reserved for future
extensions.
This option can be set at any time and repeatedly. Each call only
affects the *currently* cached connections and DNS information.
Any connection created or DNS information added afterwards is
cached the usual way again. Phrasing it another way: the option is
not persisted but setting it serves as a "trigger"
to clear the caches.
The call affects only the connection and DNS cache of the multi handle
itself and not the ones owned by SHARE handles.
## CURLMNWC_CLEAR_CONNS
No longer reuse any existing connection in the multi handle's
connection cache. This closes all connections that are not in use.
Ongoing transfers continue on the connections they operate on.
## CURLMNWC_CLEAR_DNS
Clear the multi handle's DNS cache.
# DEFAULT
0, which has no effect.
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* do transfers on the multi handle */
/* do not reuse existing connections */
curl_multi_setopt(m, CURLMOPT_NETWORK_CHANGED, CURLMNWC_CLEAR_CONNS);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_NOTIFYDATA
Section: 3
Source: libcurl
See-also:
- CURLMOPT_NOTIFYFUNCTION (3)
- curl_multi_notify_disable (3)
- curl_multi_notify_enable (3)
Protocol:
- All
Added-in: 8.17.0
---
# NAME
CURLMOPT_NOTIFYDATA - custom pointer passed to the notification callback
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NOTIFYDATA, void *pointer);
~~~
# DESCRIPTION
A data *pointer* to pass to the notification callback set with the
CURLMOPT_NOTIFYFUNCTION(3) option.
This pointer is not touched by libcurl but is only passed in as the
notification callback's **clientp** argument.
# DEFAULT
NULL
# %PROTOCOLS%
# EXAMPLE
~~~c
struct priv {
void *ours;
};
static void notify_cb(CURLM *multi, unsigned int notification,
CURL *easy, void *notifyp)
{
struct priv *p = notifyp;
printf("my ptr: %p\n", p->ours);
/* ... */
}
int main(void)
{
struct priv setup;
CURLM *multi = curl_multi_init();
/* ... use socket callback and custom pointer */
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, notify_cb);
curl_multi_setopt(multi, CURLMOPT_NOTIFYDATA, &setup);
curl_multi_notify_enable(multi, CURLMNOTIFY_INFO_READ);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
Returns CURLM_OK.
@@ -0,0 +1,130 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_NOTIFYFUNCTION
Section: 3
Source: libcurl
See-also:
- CURLMOPT_NOTIFYDATA (3)
- curl_multi_socket_action (3)
- curl_multi_notify_disable (3)
- curl_multi_notify_enable (3)
Protocol:
- All
Added-in: 8.17.0
---
# NAME
CURLMOPT_NOTIFYFUNCTION - callback receiving notifications
# SYNOPSIS
~~~c
#include <curl/curl.h>
void notify_callback(CURLM *multi, /* multi handle */
unsigned int notification, /* notification type */
CURL *easy, /* easy handle */
void *notifyp); /* private notify pointer */
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NOTIFYFUNCTION, notify_callback);
~~~
# DESCRIPTION
Pass a pointer to your callback function, which should match the prototype
shown above.
When the multi handle processes transfers, changes can be observed
by receiving notifications about them. This can eliminate the need to
constantly interrogate the multi handle to observe such changes to
act on them.
Notifications are collected and dispatched to the application's callback
function at an appropriate time.
The notify callback is different from other callbacks in that it
can use more libcurl API functions. Apart from curl_multi_perform(3),
curl_multi_socket(3), curl_multi_socket_action(3), curl_multi_socket_all(3)
and curl_multi_cleanup(3) it may call all other methods on the
multi and easy handles. This includes adding and removing easy
handles to/from the multi handle.
This callback may get invoked at any time when interacting with libcurl.
This may even happen after all transfers are done and *may also*
happen *during* a call to curl_multi_cleanup(3) when cached connections
are shut down.
# CALLBACK ARGUMENTS
*multi* identifies the multi handle that triggered the notification.
**notification** is the type of notification, e.g. what happened. The
following types are available right now. In the future, new ones might be
added.
## CURLMNOTIFY_INFO_READ
When enabled via curl_multi_notify_enable(3), this informs the application
that there are new messages to be processed via curl_multi_info_read(3).
This notification happens whenever a message is added to an empty
message stack in the multi handle and not for subsequent additions. The
notification callback is then expected to read all available message,
emptying the stack, so a subsequent addition triggers the notification
again.
The *easy* handle passed is an internal handle.
## CURLMNOTIFY_EASY_DONE
When enabled via curl_multi_notify_enable(3), this notification is triggered
when an easy handle has finished. This happens both for successful and failed
transfers.
The *easy* handle passed is the transfer that is done. This *may* be
an internal handle when DoH or other features are used.
*easy* identifies the transfer involved. This may be one of the
application's own easy handle or an internal handle.
**notifyp** is set with CURLMOPT_NOTIFYDATA(3).
# DEFAULT
NULL (no callback)
# %PROTOCOLS%
# EXAMPLE
~~~c
struct priv {
void *ours;
};
static void notify_cb(CURLM *multi, unsigned int notification,
CURL *easy, void *notifyp)
{
struct priv *p = notifyp;
printf("my ptr: %p\n", p->ours);
/* ... */
}
int main(void)
{
struct priv setup;
CURLM *multi = curl_multi_init();
/* ... use socket callback and custom pointer */
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, notify_cb);
curl_multi_setopt(multi, CURLMOPT_NOTIFYDATA, &setup);
curl_multi_notify_enable(multi, CURLMNOTIFY_INFO_READ);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
Returns CURLM_OK.
@@ -0,0 +1,85 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_PIPELINING
Section: 3
Source: libcurl
See-also:
- CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE (3)
- CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE (3)
- CURLMOPT_MAXCONNECTS (3)
- CURLMOPT_MAX_HOST_CONNECTIONS (3)
- CURLMOPT_MAX_PIPELINE_LENGTH (3)
- CURLMOPT_PIPELINING_SITE_BL (3)
Protocol:
- HTTP
Added-in: 7.16.0
---
# NAME
CURLMOPT_PIPELINING - enable HTTP multiplexing
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING, long bitmask);
~~~
# DESCRIPTION
Pass in the correct value in the **bitmask** parameter to instruct libcurl to
enable multiplexing for this multi handle.
With multiplexing enabled, libcurl attempts to do multiple transfers over the
same connection when doing parallel transfers to the same hosts.
## CURLPIPE_NOTHING (0)
Make no attempts at multiplexing.
## CURLPIPE_HTTP1 (1)
This bit is deprecated and has no effect since version 7.62.0.
## CURLPIPE_MULTIPLEX (2)
If this bit is set, libcurl tries to multiplex the new transfer over an
existing connection if possible. This requires HTTP/2 or HTTP/3.
# DEFAULT
**CURLPIPE_MULTIPLEX**
# %PROTOCOLS%
# EXAMPLE
~~~c
int main(void)
{
CURLM *m = curl_multi_init();
/* try HTTP/2 multiplexing */
curl_multi_setopt(m, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
}
~~~
# HISTORY
The multiplex support bit was added in 7.43.0. HTTP/1 Pipelining support was
disabled in 7.62.0.
Since 7.62.0, **CURLPIPE_MULTIPLEX** is enabled by default.
Before that, default was **CURLPIPE_NOTHING**.
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,72 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_PIPELINING_SERVER_BL
Section: 3
Source: libcurl
See-also:
- CURLMOPT_PIPELINING (3)
- CURLMOPT_PIPELINING_SITE_BL (3)
Protocol:
- HTTP
Added-in: 7.30.0
---
# NAME
CURLMOPT_PIPELINING_SERVER_BL - pipelining server block list
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING_SERVER_BL,
char **servers);
~~~
# DESCRIPTION
No function since pipelining was removed in 7.62.0.
Pass a **servers** array of char *, ending with a NULL entry. This is a list
of server types prefixes (in the Server: HTTP header) that are blocked from
pipelining, i.e server types that are known to not support HTTP
pipelining. The array is copied by libcurl.
Note that the comparison matches if the Server: header begins with the string
in the block list, i.e "Server: Ninja 1.2.3" and "Server: Ninja 1.4.0" can
both be blocked by having "Ninja" in the list.
Pass a NULL pointer to clear the block list.
# DEFAULT
NULL, which means that there is no block list.
# %PROTOCOLS%
# EXAMPLE
~~~c
static char *server_block_list[] =
{
"Microsoft-IIS/6.0",
"nginx/0.8.54",
NULL
};
int main(void)
{
CURLM *m = curl_multi_init();
curl_multi_setopt(m, CURLMOPT_PIPELINING_SERVER_BL, server_block_list);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,68 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_PIPELINING_SITE_BL
Section: 3
Source: libcurl
See-also:
- CURLMOPT_PIPELINING (3)
- CURLMOPT_PIPELINING_SERVER_BL (3)
Protocol:
- HTTP
Added-in: 7.30.0
---
# NAME
CURLMOPT_PIPELINING_SITE_BL - pipelining host block list
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING_SITE_BL,
char **hosts);
~~~
# DESCRIPTION
No function since pipelining was removed in 7.62.0.
Pass a **hosts** array of char *, ending with a NULL entry. This is a list
of sites that are blocked from pipelining, i.e sites that are known to not
support HTTP pipelining. The array is copied by libcurl.
Pass a NULL pointer to clear the block list.
# DEFAULT
NULL, which means that there is no block list.
# %PROTOCOLS%
# EXAMPLE
~~~c
static char *site_block_list[] =
{
"www.haxx.se",
"www.example.com:1234",
NULL
};
int main(void)
{
CURLM *m = curl_multi_init();
curl_multi_setopt(m, CURLMOPT_PIPELINING_SITE_BL, site_block_list);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,89 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_PUSHDATA
Section: 3
Source: libcurl
See-also:
- CURLMOPT_PIPELINING (3)
- CURLMOPT_PUSHFUNCTION (3)
- CURLOPT_PIPEWAIT (3)
- RFC 7540
Protocol:
- HTTP
Added-in: 7.44.0
---
# NAME
CURLMOPT_PUSHDATA - pointer to pass to push callback
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer);
~~~
# DESCRIPTION
Set a *pointer* to pass as the last argument to the
CURLMOPT_PUSHFUNCTION(3) callback. The pointer is not touched or used by
libcurl itself, only passed on to the callback function.
# DEFAULT
NULL
# %PROTOCOLS%
# EXAMPLE
~~~c
#include <string.h>
/* only allow pushes for filenames starting with "push-" */
int push_callback(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *clientp)
{
char *headp;
int *transfers = (int *)clientp;
FILE *out;
headp = curl_pushheader_byname(headers, ":path");
if(headp && !strncmp(headp, "/push-", 6)) {
fprintf(stderr, "The PATH is %s\n", headp);
/* save the push here */
out = fopen("pushed-stream", "wb");
/* write to this file */
curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
(*transfers)++; /* one more */
return CURL_PUSH_OK;
}
return CURL_PUSH_DENY;
}
int main(void)
{
int counter;
CURLM *multi = curl_multi_init();
curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,150 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_PUSHFUNCTION
Section: 3
Source: libcurl
See-also:
- CURLMOPT_PIPELINING (3)
- CURLMOPT_PUSHDATA (3)
- CURLOPT_PIPEWAIT (3)
- RFC 7540
Protocol:
- HTTP
Added-in: 7.44.0
---
# NAME
CURLMOPT_PUSHFUNCTION - callback that approves or denies server pushes
# SYNOPSIS
~~~c
#include <curl/curl.h>
int curl_push_callback(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *clientp);
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHFUNCTION,
curl_push_callback func);
~~~
# DESCRIPTION
This callback gets called when a new HTTP/2 stream is being pushed by the
server (using the PUSH_PROMISE frame). If no push callback is set, all offered
pushes are denied automatically.
# CALLBACK DESCRIPTION
The callback gets its arguments like this:
*parent* is the handle of the stream on which this push arrives. The new
handle has been duplicated from the parent, meaning that it has gotten all its
options inherited. It is then up to the application to alter any options if
desired.
*easy* is a newly created handle that represents this upcoming transfer.
*num_headers* is the number of name+value pairs that was received and can
be accessed
*headers* is a handle used to access push headers using the accessor
functions described below. This only accesses and provides the PUSH_PROMISE
headers, the normal response headers are provided in the header callback as
usual.
*clientp* is the pointer set with CURLMOPT_PUSHDATA(3)
If the callback returns CURL_PUSH_OK, the new easy handle is added to the
multi handle, the callback must not do that by itself.
The callback can access PUSH_PROMISE headers with two accessor
functions. These functions can only be used from within this callback and they
can only access the PUSH_PROMISE headers: curl_pushheader_byname(3) and
curl_pushheader_bynum(3). The normal response headers are passed to the
header callback for pushed streams just as for normal streams.
The header fields can also be accessed with curl_easy_header(3),
introduced in later libcurl versions.
# CALLBACK RETURN VALUE
## CURL_PUSH_OK (0)
The application has accepted the stream and it can now start receiving data,
the ownership of the curl handle has been taken over by the application.
## CURL_PUSH_DENY (1)
The callback denies the stream and no data reaches the application, the easy
handle is destroyed by libcurl.
## CURL_PUSH_ERROROUT (2)
Returning this code rejects the pushed stream and returns an error back on the
parent stream making it get closed with an error. (Added in 7.72.0)
## *
All other return codes are reserved for future use.
# DEFAULT
NULL, no callback
# %PROTOCOLS%
# EXAMPLE
~~~c
#include <string.h>
/* only allow pushes for filenames starting with "push-" */
int push_callback(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *clientp)
{
char *headp;
int *transfers = (int *)clientp;
FILE *out;
headp = curl_pushheader_byname(headers, ":path");
if(headp && !strncmp(headp, "/push-", 6)) {
fprintf(stderr, "The PATH is %s\n", headp);
/* save the push here */
out = fopen("pushed-stream", "wb");
/* write to this file */
curl_easy_setopt(easy, CURLOPT_WRITEDATA, out);
(*transfers)++; /* one more */
return CURL_PUSH_OK;
}
return CURL_PUSH_DENY;
}
int main(void)
{
int counter;
CURLM *multi = curl_multi_init();
curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_callback);
curl_multi_setopt(multi, CURLMOPT_PUSHDATA, &counter);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see
libcurl-errors(3).
@@ -0,0 +1,81 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_SOCKETDATA
Section: 3
Source: libcurl
See-also:
- CURLMOPT_SOCKETFUNCTION (3)
- CURLMOPT_TIMERFUNCTION (3)
- curl_multi_socket_action (3)
Protocol:
- All
Added-in: 7.15.4
---
# NAME
CURLMOPT_SOCKETDATA - custom pointer passed to the socket callback
# SYNOPSIS
~~~c
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETDATA, void *pointer);
~~~
# DESCRIPTION
A data *pointer* to pass to the socket callback set with the
CURLMOPT_SOCKETFUNCTION(3) option.
This pointer is not touched by libcurl but is only passed in as the socket
callback's **clientp** argument.
# DEFAULT
NULL
# %PROTOCOLS%
# EXAMPLE
~~~c
struct priv {
void *ours;
};
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
struct priv *p = sockp;
printf("my ptr: %p\n", p->ours);
if(what == CURL_POLL_REMOVE) {
/* remove the socket from our collection */
}
if(what & CURL_POLL_IN) {
/* wait for read on this socket */
}
if(what & CURL_POLL_OUT) {
/* wait for write on this socket */
}
return 0;
}
int main(void)
{
struct priv setup;
CURLM *multi = curl_multi_init();
/* ... use socket callback and custom pointer */
curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
Returns CURLM_OK.
@@ -0,0 +1,142 @@
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Title: CURLMOPT_SOCKETFUNCTION
Section: 3
Source: libcurl
See-also:
- CURLMOPT_SOCKETDATA (3)
- CURLMOPT_TIMERFUNCTION (3)
- curl_multi_socket_action (3)
Protocol:
- All
Added-in: 7.15.4
---
# NAME
CURLMOPT_SOCKETFUNCTION - callback informed about what to wait for
# SYNOPSIS
~~~c
#include <curl/curl.h>
int socket_callback(CURL *easy, /* easy handle */
curl_socket_t s, /* socket */
int what, /* describes the socket */
void *clientp, /* private callback pointer */
void *socketp); /* private socket pointer */
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
~~~
# DESCRIPTION
Pass a pointer to your callback function, which should match the prototype
shown above.
When the curl_multi_socket_action(3) function is called, it uses this
callback to inform the application about updates in the socket (file
descriptor) status by doing none, one, or multiple calls to the
**socket_callback**. The callback function gets status updates with changes
since the previous time the callback was called. If the given callback pointer
is set to NULL, no callback is called.
libcurl then expects the application to monitor the sockets for the specific
activities and tell libcurl again when something happens on one of them. Tell
libcurl by calling curl_multi_socket_action(3).
This callback may get invoked at any time when interacting with libcurl.
This may even happen after all transfers are done and is *likely* to
happen *during* a call to curl_multi_cleanup(3) when cached connections
are shut down.
# CALLBACK ARGUMENTS
*easy* identifies the specific transfer for which this update is related.
Since this callback manages a whole multi handle, an application should not
make assumptions about which particular handle that is passed here. It might
even be an internal easy handle that the application did not add itself.
*s* is the specific socket this function invocation concerns. If the
**what** argument is not CURL_POLL_REMOVE then it holds information about
what activity on this socket the application is supposed to
monitor. Subsequent calls to this callback might update the **what** bits
for a socket that is already monitored.
The socket callback should return 0 on success, and -1 on error. If this
callback returns error, **all** transfers currently in progress in this
multi handle are aborted and made to fail.
**clientp** is set with CURLMOPT_SOCKETDATA(3).
**socketp** is set with curl_multi_assign(3) or NULL.
The **what** parameter informs the callback on the status of the given
socket. It can hold one of these values:
## CURL_POLL_IN
Wait for incoming data. For the socket to become readable.
## CURL_POLL_OUT
Wait for outgoing data. For the socket to become writable.
## CURL_POLL_INOUT
Wait for incoming and outgoing data. For the socket to become readable or
writable.
## CURL_POLL_REMOVE
The specified socket/file descriptor is no longer used by libcurl for any
active transfer. It might soon be added again.
# DEFAULT
NULL (no callback)
# %PROTOCOLS%
# EXAMPLE
~~~c
struct priv {
void *ours;
};
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
struct priv *p = sockp;
printf("our ptr: %p\n", p->ours);
if(what == CURL_POLL_REMOVE) {
/* remove the socket from our collection */
}
if(what & CURL_POLL_IN) {
/* wait for read on this socket */
}
if(what & CURL_POLL_OUT) {
/* wait for write on this socket */
}
return 0;
}
int main(void)
{
struct priv setup;
CURLM *multi = curl_multi_init();
/* ... use socket callback and custom pointer */
curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
}
~~~
# %AVAILABILITY%
# RETURN VALUE
Returns CURLM_OK.

Some files were not shown because too many files have changed in this diff Show More