diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..5ace4600a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/labeler.yml b/.github/labeler.yml index be585a690..cef2789d8 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -13,481 +13,246 @@ # PR is all about that one topic, like HTTP/3), while the second ones are # "addendums" that give useful information about a PR that's really mostly # something else (e.g. CI if the PR also touches CI jobs). +# +# N.B. any-glob-to-all-files is misnamed; it acts like one-glob-to-all-files. +# Therefore, to get any-glob-to-all-files semantics, there must be a single glob +# with all matching patterns within braces. +# +# See https://github.com/actions/labeler/ for documentation on this file. appleOS: -- all: - - changed-files: - - any-glob-to-all-files: - - '.github/workflows/macos.yml' - - 'lib/config-mac.h' - - 'lib/macos*' - - 'lib/vtls/sectransp*' - - 'm4/curl-sectransp.m4' - - 'MacOSX-Framework' + - all: + - changed-files: + - any-glob-to-all-files: + - '{.github/workflows/macos.yml,lib/config-mac.h,lib/macos*,lib/vtls/sectransp*,m4/curl-sectransp.m4,MacOSX-Framework}' authentication: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/mk-ca-bundle.1' - - 'docs/libcurl/opts/CURLINFO_HTTPAUTH*' - - 'docs/libcurl/opts/CURLINFO_PROXYAUTH*' - - 'docs/libcurl/opts/CURLOPT_KRB*' - - 'docs/libcurl/opts/CURLOPT_SASL*' - - 'docs/libcurl/opts/CURLOPT_SERVICE_NAME*' - - 'docs/libcurl/opts/CURLOPT_USERNAME*' - - 'docs/libcurl/opts/CURLOPT_USERPWD*' - - 'docs/libcurl/opts/CURLOPT_XOAUTH*' - - 'lib/*gssapi*' - - 'lib/*krb5*' - - 'lib/*ntlm*' - - 'lib/curl_sasl.*' - - 'lib/http_aws*' - - 'lib/http_digest.*' - - 'lib/http_negotiate.*' - - 'lib/vauth/**' - - 'tests/server/fake_ntlm.c' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/mk-ca-bundle.1,docs/libcurl/opts/CURLINFO_HTTPAUTH*,docs/libcurl/opts/CURLINFO_PROXYAUTH*,docs/libcurl/opts/CURLOPT_KRB*,docs/libcurl/opts/CURLOPT_SASL*,docs/libcurl/opts/CURLOPT_SERVICE_NAME*,docs/libcurl/opts/CURLOPT_USERNAME*,docs/libcurl/opts/CURLOPT_USERPWD*,docs/libcurl/opts/CURLOPT_XOAUTH*,lib/*gssapi*,lib/*krb5*,lib/*ntlm*,lib/curl_sasl.*,lib/http_aws*,lib/http_digest.*,lib/http_negotiate.*,lib/vauth/**,tests/server/fake_ntlm.c}' build: -- all: - - changed-files: - - any-glob-to-all-files: - - '**/CMakeLists.txt' - - '**/Makefile.am' - - '**/Makefile.inc' - - '**/Makefile.mk' - - '**/*.m4' - - '**/*.mk' - - '*.m4' - - 'docs/INSTALL.cmake' - - 'lib/curl_config.h.cmake' - - 'lib/libcurl*.in' - - 'CMake/**' - - 'CMakeLists.txt' - - 'configure.ac' - - 'm4/**' - - 'MacOSX-Framework' - - 'Makefile.*' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' - - 'libcurl.def' + - all: + - changed-files: + - any-glob-to-all-files: + - '{**/CMakeLists.txt,**/Makefile.am,**/Makefile.inc,**/Makefile.mk,**/*.m4,**/*.mk,*.m4,docs/INSTALL.cmake,lib/curl_config.h.cmake,lib/libcurl*.in,CMake/**,CMakeLists.txt,configure.ac,m4/**,MacOSX-Framework,Makefile.*,packages/**,plan9/**,projects/**,winbuild/**,libcurl.def}' CI: -- all: - - changed-files: - - any-glob-to-any-file: - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - '.github/**' - - 'appveyor.yml' - - 'scripts/ci*' - - 'tests/azure.pm' - - 'tests/appveyor.pm' - - 'tests/CI.md' + - all: + - changed-files: + - any-glob-to-any-file: + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - '.github/**' + - 'appveyor.*' + - 'scripts/ci*' + - 'tests/azure.pm' + - 'tests/appveyor.pm' + - 'tests/CI.md' cmake: -- all: - - changed-files: - - any-glob-to-all-files: - - '**/CMakeLists.txt' - - 'CMake/**' - - 'docs/INSTALL.cmake' - - 'lib/curl_config.h.cmake' + - all: + - changed-files: + - any-glob-to-all-files: + - '{**/CMakeLists.txt,CMake/**,docs/INSTALL.cmake,lib/curl_config.h.cmake}' cmdline tool: -- all: - - changed-files: - - any-glob-to-any-file: - - 'docs/cmdline-opts/**' - - 'src/**' + - all: + - changed-files: + - any-glob-to-any-file: + - 'docs/cmdline-opts/**' + - 'src/**' connecting & proxies: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/CONNECTION-FILTERS.md' - - 'docs/examples/ipv6.c' - - 'docs/libcurl/opts/CURLINFO_CONNECT*' - - 'docs/libcurl/opts/CURLINFO_PROXY*' - - 'docs/libcurl/opts/CURLOPT_ADDRESS*' - - 'docs/libcurl/opts/CURLOPT_CONNECT*' - - 'docs/libcurl/opts/CURLOPT_HAPROXY*' - - 'docs/libcurl/opts/CURLOPT_OPENSOCKET*' - - 'docs/libcurl/opts/CURLOPT_PRE_PROXY*' - - 'docs/libcurl/opts/CURLOPT_PROXY*' - - 'docs/libcurl/opts/CURLOPT_SOCKOPT*' - - 'docs/libcurl/opts/CURLOPT_SOCKS*' - - 'docs/libcurl/opts/CURLOPT_TCP*' - - 'docs/libcurl/opts/CURLOPT_TIMEOUT*' - - 'lib/cf-*proxy.*' - - 'lib/cf-socket.*' - - 'lib/cfilters.*' - - 'lib/conncache.*' - - 'lib/connect.*' - - 'lib/http_proxy.*' - - 'lib/if2ip.*' - - 'lib/noproxy.*' - - 'lib/socks.*' - - 'tests/server/socksd.c' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/CONNECTION-FILTERS.md,docs/examples/ipv6.c,docs/libcurl/opts/CURLINFO_CONNECT*,docs/libcurl/opts/CURLINFO_PROXY*,docs/libcurl/opts/CURLOPT_ADDRESS*,docs/libcurl/opts/CURLOPT_CONNECT*,docs/libcurl/opts/CURLOPT_HAPROXY*,docs/libcurl/opts/CURLOPT_OPENSOCKET*,docs/libcurl/opts/CURLOPT_PRE_PROXY*,docs/libcurl/opts/CURLOPT_PROXY*,docs/libcurl/opts/CURLOPT_SOCKOPT*,docs/libcurl/opts/CURLOPT_SOCKS*,docs/libcurl/opts/CURLOPT_TCP*,docs/libcurl/opts/CURLOPT_TIMEOUT*,lib/cf-*proxy.*,lib/cf-socket.*,lib/cfilters.*,lib/conncache.*,lib/connect.*,lib/http_proxy.*,lib/if2ip.*,lib/noproxy.*,lib/socks.*,tests/server/socksd.c}' cookies: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/HTTP-COOKIES.md' - - 'docs/cmdline-opts/cookie*' - - 'docs/cmdline-opts/junk-session-cookies.d' - - 'docs/libcurl/opts/CURLINFO_COOKIE*' - - 'docs/libcurl/opts/CURLOPT_COOKIE*' - - 'docs/examples/cookie_interface.c' - - 'lib/cookie.*' - - 'lib/psl.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/HTTP-COOKIES.md,docs/cmdline-opts/cookie*,docs/cmdline-opts/junk-session-cookies.d,docs/libcurl/opts/CURLINFO_COOKIE*,docs/libcurl/opts/CURLOPT_COOKIE*,docs/examples/cookie_interface.c,lib/cookie.*,lib/psl.*}' cryptography: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/CIPHERS.md' - - 'docs/RUSTLS.md' - - 'docs/libcurl/opts/CURLOPT_EGDSOCKET*' - - 'lib/*sha256*' - - 'lib/curl_des.*' - - 'lib/curl_hmac.*' - - 'lib/curl_md?.*' - - 'lib/md?.*' - - 'lib/rand.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/CIPHERS.md,docs/RUSTLS.md,docs/libcurl/opts/CURLOPT_EGDSOCKET*,lib/*sha256*,lib/curl_des.*,lib/curl_hmac.*,lib/curl_md?.*,lib/md?.*,lib/rand.*}' DICT: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/dict.*' - - 'tests/dictserver.py' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/dict.*,tests/dictserver.py}' documentation: -- all: - - changed-files: - - any-glob-to-all-files: - - '**/*.md' - - '**/*.txt' - - '**/*.1' - - '**/*.3' - - 'CHANGES' - - 'docs/**' - - 'GIT-INFO' - - 'LICENSES/**' - - 'README' - - 'RELEASE-NOTES' - - AllGlobsToAllFiles: - # negative matches - - '!**/CMakeLists.txt' - - '!**/Makefile.am' + - all: + - changed-files: + - any-glob-to-all-files: + - '{**/*.md,**/*.txt,**/*.1,**/*.3,CHANGES,docs/**,GIT-INFO,LICENSES/**,README,RELEASE-NOTES}' + - all-globs-to-all-files: + # negative matches + - '!**/CMakeLists.txt' + - '!**/Makefile.am' FTP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/libcurl/opts/CURLINFO_FTP*' - - 'docs/libcurl/opts/CURLOPT_FTP*' - - 'docs/libcurl/opts/CURLOPT_WILDCARDMATCH*' - - 'docs/examples/ftp*' - - 'lib/curl_fnmatch.*' - - 'lib/curl_range.*' - - 'lib/ftp*' - - 'tests/ftp*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/libcurl/opts/CURLINFO_FTP*,docs/libcurl/opts/CURLOPT_FTP*,docs/libcurl/opts/CURLOPT_WILDCARDMATCH*,docs/examples/ftp*,lib/curl_fnmatch.*,lib/curl_range.*,lib/ftp*,tests/ftp*' GOPHER: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/gopher*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/gopher*}' HTTP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/examples/hsts*' - - 'docs/examples/http-*' - - 'docs/examples/httpput*' - - 'docs/examples/https*' - - 'docs/examples/*post*' - - 'docs/HSTS.md' - - 'docs/HTTP-COOKIES.md' - - 'docs/libcurl/opts/CURLINFO_COOKIE*' - - 'docs/libcurl/opts/CURLOPT_COOKIE*' - - 'docs/libcurl/opts/CURLINFO_HTTP_**' - - 'docs/libcurl/opts/CURLINFO_REDIRECT*' - - 'docs/libcurl/opts/CURLINFO_REFER*' - - 'docs/libcurl/opts/CURLOPT_FOLLOWLOCATION*' - - 'docs/libcurl/opts/CURLOPT_HSTS*' - - 'docs/libcurl/opts/CURLOPT_HTTP*' - - 'docs/libcurl/opts/CURLOPT_POST.*' - - 'docs/libcurl/opts/CURLOPT_POSTFIELD*' - - 'docs/libcurl/opts/CURLOPT_POSTREDIR*' - - 'docs/libcurl/opts/CURLOPT_REDIR*' - - 'docs/libcurl/opts/CURLOPT_REFER*' - - 'docs/libcurl/opts/CURLOPT_TRAILER*' - - 'docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING*' - - 'lib/cf-https*' - - 'lib/cf-h1*' - - 'lib/cf-h2*' - - 'lib/cookie.*' - - 'lib/http*' - - 'tests/http*' - - 'tests/http-server.pl' - - 'tests/http/*' - - 'tests/nghttp*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/examples/hsts*,docs/examples/http-*,docs/examples/httpput*,docs/examples/https*,docs/examples/*post*,docs/HSTS.md,docs/HTTP-COOKIES.md,docs/libcurl/opts/CURLINFO_COOKIE*,docs/libcurl/opts/CURLOPT_COOKIE*,docs/libcurl/opts/CURLINFO_HTTP_**,docs/libcurl/opts/CURLINFO_REDIRECT*,docs/libcurl/opts/CURLINFO_REFER*,docs/libcurl/opts/CURLOPT_FOLLOWLOCATION*,docs/libcurl/opts/CURLOPT_HSTS*,docs/libcurl/opts/CURLOPT_HTTP*,docs/libcurl/opts/CURLOPT_POST.*,docs/libcurl/opts/CURLOPT_POSTFIELD*,docs/libcurl/opts/CURLOPT_POSTREDIR*,docs/libcurl/opts/CURLOPT_REDIR*,docs/libcurl/opts/CURLOPT_REFER*,docs/libcurl/opts/CURLOPT_TRAILER*,docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING*,lib/cf-https*,lib/cf-h1*,lib/cf-h2*,lib/cookie.*,lib/http*,tests/http*,tests/http-server.pl,tests/http/*,tests/nghttp*}' HTTP/2: -- all: - - changed-files: - - any-glob-to-all-files: - - 'CMake/FindNGHTTP2.cmake' - - 'CMake/FindQUICHE.cmake' - - 'docs/HTTP2.md' - - 'docs/libcurl/opts/CURLOPT_STREAM*' - - 'docs/examples/http2*' - - 'lib/http2*' - - 'tests/http2-server.pl' + - all: + - changed-files: + - any-glob-to-all-files: + - '{CMake/FindNGHTTP2.cmake,CMake/FindQUICHE.cmake,docs/HTTP2.md,docs/libcurl/opts/CURLOPT_STREAM*,docs/examples/http2*,lib/http2*,tests/http2-server.pl}' HTTP/3: -- all: - - changed-files: - - any-glob-to-all-files: - - '.github/workflows/ngtcp2*' - - '.github/workflows/quiche*' - - 'CMake/FindMSH3.cmake' - - 'CMake/FindNGHTTP3.cmake' - - 'CMake/FindNGTCP2.cmake' - - 'docs/HTTP3.md' - - 'docs/examples/http3*' - - 'lib/vquic/**' - - 'tests/http3-server.pl' - - 'tests/nghttpx.conf' + - all: + - changed-files: + - any-glob-to-all-files: + - '{.github/workflows/ngtcp2*,.github/workflows/quiche*,CMake/FindMSH3.cmake,CMake/FindNGHTTP3.cmake,CMake/FindNGTCP2.cmake,docs/HTTP3.md,docs/examples/http3*,lib/vquic/**,tests/http3-server.pl,tests/nghttpx.conf}' Hyper: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/HYPER.md' - - 'lib/c-hyper.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/HYPER.md,lib/c-hyper.*}' IMAP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/imap*' - - 'docs/examples/imap*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/imap*,docs/examples/imap*}' LDAP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/*ldap*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/*ldap*}' libcurl API: -- all: - - changed-files: - - any-glob-to-any-file: - - 'docs/libcurl/ABI.md' - - 'docs/libcurl/curl_*.3' - - 'include/curl/**' + - all: + - changed-files: + - any-glob-to-any-file: + - 'docs/libcurl/ABI.md' + - 'docs/libcurl/curl_*.3' + - 'include/curl/**' logging: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/cmdline-opts/trace*' - - 'docs/libcurl/curl_global_trace*' - - 'lib/curl_trc*' - - 'tests/http/test_15_tracing.py' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/cmdline-opts/trace*,docs/libcurl/curl_global_trace*,lib/curl_trc*,tests/http/test_15_tracing.py}' MIME: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/libcurl/curl_form*' - - 'docs/libcurl/curl_mime_*' - - 'docs/libcurl/opts/CURLOPT_MIME*' - - 'docs/libcurl/opts/CURLOPT_HTTPPOST*' - - 'lib/formdata*' - - 'lib/mime*' - - 'src/tool_formparse.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/libcurl/curl_form*,docs/libcurl/curl_mime_*,docs/libcurl/opts/CURLOPT_MIME*,docs/libcurl/opts/CURLOPT_HTTPPOST*,lib/formdata*,lib/mime*,src/tool_formparse.*}' MQTT: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/MQTT.md' - - 'lib/mqtt*' - - 'tests/server/mqttd.c' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/MQTT.md,lib/mqtt*,tests/server/mqttd.c}' name lookup: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/examples/resolve.c' - - 'docs/libcurl/opts/CURLINFO_NAMELOOKUP*' - - 'docs/libcurl/opts/CURLOPT_DNS*' - - 'docs/libcurl/opts/CURLOPT_DOH*' - - 'docs/libcurl/opts/CURLOPT_RESOLVE*' - - 'lib/asyn*' - - 'lib/curl_gethostname.*' - - 'lib/doh*' - - 'lib/host*' - - 'lib/idn*' - - 'lib/inet_pton.*' - - 'lib/socketpair*' - - 'tests/server/resolve.c' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/examples/resolve.c,docs/libcurl/opts/CURLINFO_NAMELOOKUP*,docs/libcurl/opts/CURLOPT_DNS*,docs/libcurl/opts/CURLOPT_DOH*,docs/libcurl/opts/CURLOPT_RESOLVE*,lib/asyn*,lib/curl_gethostname.*,lib/doh*,lib/host*,lib/idn*,lib/inet_pton.*,lib/socketpair*,tests/server/resolve.c}' POP3: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/examples/pop3*' - - 'lib/pop3.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/examples/pop3*,lib/pop3.*}' RTMP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/curl_rtmp.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/curl_rtmp.*}' RTSP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/libcurl/opts/CURLINFO_RTSP*' - - 'docs/libcurl/opts/CURLOPT_RTSP*' - - 'lib/rtsp.*' - - 'tests/rtspserver.pl' - - 'tests/server/rtspd.c' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/libcurl/opts/CURLINFO_RTSP*,docs/libcurl/opts/CURLOPT_RTSP*,lib/rtsp.*,tests/rtspserver.pl,tests/server/rtspd.c}' SCP/SFTP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'CMake/FindLibSSH2.cmake' - - 'docs/libcurl/opts/CURLOPT_SSH*' - - 'docs/examples/sftp*' - - 'lib/vssh/**' - - 'tests/sshhelp.pm' - - 'tests/sshserver.pl' + - all: + - changed-files: + - any-glob-to-all-files: + - '{CMake/FindLibSSH2.cmake,docs/libcurl/opts/CURLOPT_SSH*,docs/examples/sftp*,lib/vssh/**,tests/sshhelp.pm,tests/sshserver.pl}' script: -- all: - - changed-files: - - any-glob-to-all-files: - - '**/*.pl' - - '**/*.sh' - - 'curl-config.in' - - 'docs/curl-config.1' - - 'docs/mk-ca-bundle.1' - - 'docs/THANKS-filter' - - 'scripts/**' + - all: + - changed-files: + - any-glob-to-all-files: + - '{**/*.pl,**/*.sh,curl-config.in,docs/curl-config.1,docs/mk-ca-bundle.1,docs/THANKS-filter,scripts/**}' SMB: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/smb.*' - - 'tests/smbserver.py' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/smb.*,tests/smbserver.py}' SMTP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/examples/smtp-*' - - 'docs/libcurl/opts/CURLOPT_MAIL*' - - 'lib/smtp.*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/examples/smtp-*,docs/libcurl/opts/CURLOPT_MAIL*,lib/smtp.*}' tests: -- all: - - changed-files: - - any-glob-to-any-file: - - 'tests/**' + - all: + - changed-files: + - any-glob-to-any-file: + - 'tests/**' TFTP: -- all: - - changed-files: - - any-glob-to-all-files: - - 'lib/tftp.*' - - 'tests/tftpserver.pl' - - 'tests/server/tftp*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{lib/tftp.*,tests/tftpserver.pl,tests/server/tftp*}' TLS: -- all: - - changed-files: - - any-glob-to-all-files: - - 'CMake/FindBearSSL.cmake' - - 'CMake/FindMbedTLS.cmake' - - 'CMake/FindWolfSSL.cmake' - - 'docs/examples/ssl*' - - 'docs/examples/*ssl.*' - - 'docs/examples/*tls.*' - - 'docs/SSL*' - - 'docs/libcurl/curl_global_sslset*' - - 'docs/libcurl/opts/CURLINFO_CA*' - - 'docs/libcurl/opts/CURLINFO_CERT*' - - 'docs/libcurl/opts/CURLINFO_SSL*' - - 'docs/libcurl/opts/CURLINFO_TLS*' - - 'docs/libcurl/opts/CURLOPT_CA*' - - 'docs/libcurl/opts/CURLOPT_CERT*' - - 'docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY*' - - 'docs/libcurl/opts/CURLOPT_SSL*' - - 'docs/libcurl/opts/CURLOPT_TLS*' - - 'docs/libcurl/opts/CURLOPT_USE_SSL*' - - 'lib/vtls/**' - - 'm4/curl-bearssl.m4' - - 'm4/curl-gnutls.m4' - - 'm4/curl-mbedtls.m4' - - 'm4/curl-openssl.m4' - - 'm4/curl-rustls.m4' - - 'm4/curl-schannel.m4' - - 'm4/curl-sectransp.m4' - - 'm4/curl-wolfssl.m4' + - all: + - changed-files: + - any-glob-to-all-files: + - '{CMake/FindBearSSL.cmake,CMake/FindMbedTLS.cmake,CMake/FindWolfSSL.cmake,docs/examples/ssl*,docs/examples/*ssl.*,docs/examples/*tls.*,docs/SSL*,docs/libcurl/curl_global_sslset*,docs/libcurl/opts/CURLINFO_CA*,docs/libcurl/opts/CURLINFO_CERT*,docs/libcurl/opts/CURLINFO_SSL*,docs/libcurl/opts/CURLINFO_TLS*,docs/libcurl/opts/CURLOPT_CA*,docs/libcurl/opts/CURLOPT_CERT*,docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY*,docs/libcurl/opts/CURLOPT_SSL*,docs/libcurl/opts/CURLOPT_TLS*,docs/libcurl/opts/CURLOPT_USE_SSL*,lib/vtls/**,m4/curl-bearssl.m4,m4/curl-gnutls.m4,m4/curl-mbedtls.m4,m4/curl-openssl.m4,m4/curl-rustls.m4,m4/curl-schannel.m4,m4/curl-sectransp.m4,m4/curl-wolfssl.m4}' URL: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/libcurl/curl_url*' - - 'docs/URL-SYNTAX.md' - - 'docs/examples/parseurl*' - - 'include/curl/urlapi.h' - - 'lib/urlapi*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/libcurl/curl_url*,docs/URL-SYNTAX.md,docs/examples/parseurl*,include/curl/urlapi.h,lib/urlapi*}' WebSocket: -- all: - - changed-files: - - any-glob-to-all-files: - - 'docs/WEBSOCKET.md*' - - 'docs/examples/websocket*' - - 'docs/libcurl/curl_ws_*' - - 'docs/libcurl/libcurl-ws*' - - 'docs/libcurl/opts/CURLOPT_WS_*' - - 'include/curl/websockets.h' - - 'lib/ws.*' - - 'tests/http/clients/ws*' - - 'tests/http/test_20_websockets.py' - - 'tests/http/testenv/ws*' + - all: + - changed-files: + - any-glob-to-all-files: + - '{docs/WEBSOCKET.md*,docs/examples/websocket*,docs/libcurl/curl_ws_*,docs/libcurl/libcurl-ws*,docs/libcurl/opts/CURLOPT_WS_*,include/curl/websockets.h,lib/ws.*,tests/http/clients/ws*,tests/http/test_20_websockets.py,tests/http/testenv/ws*}' Windows: -- all: - - changed-files: - - any-glob-to-all-files: - - '**/Makefile.mk' - - 'appveyor.yml' - - 'CMake/Platforms/WindowsCache.cmake' - - 'lib/*win32*' - - 'lib/curl_multibyte.*' - - 'lib/rename.*' - - 'lib/vtls/schannel*' - - 'm4/curl-schannel.m4' - - 'projects/**' - - 'src/tool_doswin.c' - - 'winbuild/**' - - 'libcurl.def' + - all: + - changed-files: + - any-glob-to-all-files: + - '{appveyor.*,CMake/Platforms/WindowsCache.cmake,lib/*win32*,lib/curl_multibyte.*,lib/rename.*,lib/vtls/schannel*,m4/curl-schannel.m4,projects/**,src/tool_doswin.c,winbuild/**,libcurl.def}' diff --git a/.github/scripts/badwords.pl b/.github/scripts/badwords.pl new file mode 100755 index 000000000..ffebad94e --- /dev/null +++ b/.github/scripts/badwords.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl +# +# bad[:=]correct +# +# If separator is '=', the string will be compared case sensitively. +# If separator is ':', the check is done case insensitively. +# +my $w; +while() { + chomp; + if($_ =~ /^#/) { + next; + } + if($_ =~ /^([^:=]*)([:=])(.*)/) { + my ($bad, $sep, $better)=($1, $2, $3); + push @w, $bad; + $alt{$bad} = $better; + if($sep eq "=") { + $exactcase{$bad} = 1; + } + } +} + +my $errors; + +sub file { + my ($f) = @_; + my $l = 0; + open(F, "<$f"); + while() { + my $in = $_; + $l++; + chomp $in; + if($in =~ /^ /) { + next; + } + # remove the link part + $in =~ s/(\[.*\])\(.*\)/$1/g; + # remove backticked texts + $in =~ s/\`.*\`//g; + foreach my $w (@w) { + my $case = $exactcase{$w}; + if(($in =~ /^(.*)$w/i && !$case) || + ($in =~ /^(.*)$w/ && $case) ) { + my $p = $1; + my $c = length($p)+1; + print STDERR "$f:$l:$c: error: found bad word \"$w\"\n"; + printf STDERR " %4d | $in\n", $l; + printf STDERR " | %*s^%s\n", length($p), " ", + "~" x (length($w)-1); + printf STDERR " maybe use \"%s\" instead?\n", $alt{$w}; + $errors++; + } + } + } + close(F); +} + +my @files = @ARGV; + +foreach my $each (@files) { + file($each); +} +exit $errors; diff --git a/.github/scripts/badwords.txt b/.github/scripts/badwords.txt new file mode 100644 index 000000000..0e6be76c6 --- /dev/null +++ b/.github/scripts/badwords.txt @@ -0,0 +1,46 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl +# +back-end:backend +e-mail:email +run-time:runtime +set-up:setup +tool chain:toolchain +tool-chain:toolchain +wild-card:wildcard +wild card:wildcard +i'm:I am +you've:You have +they've:They have +they're:They are +should've:should have +don't:do not +could've:could have +doesn't:does not +isn't:is not + a html: an html + a http: an http + a ftp: an ftp + url =URL +internet\W=Internet +isation:ization +it's:it is +there's:there is +[^.]\. And: Rewrite it somehow? +^(And|So|But) = Rewrite it somehow? +\. But: Rewrite it somehow? +file name :filename +\. So : Rewrite without "so" ? + dir :directory +you'd:you would +you'll:you will +can't:cannot +that's:that is +web page:webpage +host name\W:hostname +file name\W:filename +didn't:did not +doesn't:does not +won't:will not +couldn't:could not diff --git a/.github/scripts/cleancmd.pl b/.github/scripts/cleancmd.pl new file mode 100755 index 000000000..5d0fe2b2f --- /dev/null +++ b/.github/scripts/cleancmd.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl +# +# Input: a cmdline docs markdown, it gets modfied *in place* +# +# The main purpose is to strip off the leading meta-data part, but also to +# clean up whatever else the spell checker might have a problem with that we +# still deem is fine. + +my $header = 1; +while(1) { + # set this if the markdown has no meta-data header to skip + if($ARGV[0] eq "--no-header") { + shift @ARGV; + $header = 0; + } + else { + last; + } +} + +my $f = $ARGV[0]; + +open(F, "<$f") or die; + +my $ignore = $header; +my $sepcount = 0; +my @out; +while() { + if(/^---/ && $header) { + if(++$sepcount == 2) { + $ignore = 0; + } + next; + } + next if($ignore); + + # strip out all long command line options + $_ =~ s/--[a-z0-9-]+//g; + + # strip out https URLs, we don't want them spellchecked + $_ =~ s!https://[a-z0-9\#_/.-]+!!gi; + + push @out, $_; +} +close(F); + +open(O, ">$f") or die; +print O @out; +close(O); diff --git a/.github/scripts/verify-examples.pl b/.github/scripts/verify-examples.pl index ff275569e..28d24595f 100755 --- a/.github/scripts/verify-examples.pl +++ b/.github/scripts/verify-examples.pl @@ -26,6 +26,7 @@ my @files = @ARGV; my $cfile = "test.c"; my $check = "./scripts/checksrc.pl"; +my $error; if($files[0] eq "-h") { print "Usage: verify-synopsis [man pages]\n"; @@ -47,8 +48,9 @@ sub extract { my $syn = 0; my $l = 0; my $iline = 0; - open(F, "<$f"); - open(O, ">$cfile"); + my $fail = 0; + open(F, "<$f") or die "failed opening input file $f : $!"; + open(O, ">$cfile") or die "failed opening output file $cfile : $!"; print O "#include \n"; while() { $iline++; @@ -68,6 +70,15 @@ sub extract { if(/^.fi/) { last; } + if(/(?, et al. +# +# SPDX-License-Identifier: curl + +name: badwords + +on: + # Trigger the workflow on push or pull requests, but only for the + # master branch + push: + branches: + - master + - '*/ci' + pull_request: + branches: + - master + +jobs: + check: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: check + run: ./.github/scripts/badwords.pl < .github/scripts/badwords.txt docs/*.md docs/libcurl/*.md docs/libcurl/opts/*.md diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index 405d63915..2b095dae7 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -7,25 +7,25 @@ name: Codespell on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths: - - 'lib/**' - - 'src/**' - - 'include/**' + - 'lib/**' + - 'src/**' + - 'include/**' pull_request: branches: - - master - - 'lib/**' - - 'src/**' - - 'include/**' + - master + - 'lib/**' + - 'src/**' + - 'include/**' jobs: codespell: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install run: | diff --git a/.github/workflows/configure-vs-cmake.yml b/.github/workflows/configure-vs-cmake.yml index 3131bc128..dc2273f73 100644 --- a/.github/workflows/configure-vs-cmake.yml +++ b/.github/workflows/configure-vs-cmake.yml @@ -6,23 +6,23 @@ name: configure-vs-cmake on: push: branches: - - master + - master paths: - - '*.ac' - - '**/*.m4' - - '**/CMakeLists.txt' - - 'lib/curl_config.h.cmake' - - 'scripts/cmp-config.pl' + - '*.ac' + - '**/*.m4' + - '**/CMakeLists.txt' + - 'lib/curl_config.h.cmake' + - 'scripts/cmp-config.pl' pull_request: branches: - - master + - master paths: - - '*.ac' - - '**/*.m4' - - '**/CMakeLists.txt' - - 'lib/curl_config.h.cmake' - - 'scripts/cmp-config.pl' + - '*.ac' + - '**/*.m4' + - '**/CMakeLists.txt' + - 'lib/curl_config.h.cmake' + - 'scripts/cmp-config.pl' permissions: {} @@ -30,16 +30,16 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: run configure --with-openssl - run: | - autoreconf -fi - ./configure --with-openssl + - name: run configure --with-openssl + run: | + autoreconf -fi + ./configure --with-openssl --without-libpsl - - name: run cmake - run: | - mkdir build && cd build && cmake .. + - name: run cmake + run: | + mkdir build && cd build && cmake .. - - name: compare generated curl_config.h files - run: ./scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h + - name: compare generated curl_config.h files + run: ./scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml index 26c4da2b8..15068b640 100644 --- a/.github/workflows/distcheck.yml +++ b/.github/workflows/distcheck.yml @@ -7,11 +7,11 @@ name: dist on: push: branches: - - master - - '*/ci' + - master + - '*/ci' pull_request: branches: - - master + - master concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} @@ -22,101 +22,101 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@v4 - - - run: sudo apt-get purge -y curl libcurl4 libcurl4-doc - name: 'remove preinstalled curl libcurl4{-doc}' - - - run: autoreconf -fi - name: 'autoreconf' - - - run: ./configure --without-ssl - name: 'configure' - - - run: make V=1 && make V=1 clean - name: 'make and clean' - - - run: ./maketgz 99.98.97 - name: 'maketgz' - - - uses: actions/upload-artifact@v3 - with: - name: 'release-tgz' - path: 'curl-99.98.97.tar.gz' - - - run: | - echo "::stop-commands::$(uuidgen)" - tar xvf curl-99.98.97.tar.gz - pushd curl-99.98.97 - ./configure --prefix=$HOME/temp --without-ssl - make - make TFLAGS=1 test - make install - popd - # basic check of the installed files - bash scripts/installcheck.sh $HOME/temp - rm -rf curl-99.98.97 - name: 'verify in-tree configure build including install' + - uses: actions/checkout@v4 + + - run: sudo apt-get purge -y curl libcurl4 libcurl4-doc + name: 'remove preinstalled curl libcurl4{-doc}' + + - run: autoreconf -fi + name: 'autoreconf' + + - run: ./configure --without-ssl --without-libpsl + name: 'configure' + + - run: make V=1 && make V=1 clean + name: 'make and clean' + + - run: ./maketgz 99.98.97 + name: 'maketgz' + + - uses: actions/upload-artifact@v4 + with: + name: 'release-tgz' + path: 'curl-99.98.97.tar.gz' + + - run: | + echo "::stop-commands::$(uuidgen)" + tar xvf curl-99.98.97.tar.gz + pushd curl-99.98.97 + ./configure --prefix=$HOME/temp --without-ssl --without-libpsl + make + make test-ci + make install + popd + # basic check of the installed files + bash scripts/installcheck.sh $HOME/temp + rm -rf curl-99.98.97 + name: 'verify in-tree configure build including install' verify-out-of-tree-docs: runs-on: ubuntu-latest timeout-minutes: 30 needs: maketgz-and-verify-in-tree steps: - - uses: actions/download-artifact@v3 - with: - name: 'release-tgz' - - - run: | - echo "::stop-commands::$(uuidgen)" - tar xvf curl-99.98.97.tar.gz - touch curl-99.98.97/docs/{cmdline-opts,libcurl}/Makefile.inc - mkdir build - pushd build - ../curl-99.98.97/configure --without-ssl - make - make TFLAGS='-p 1 1139' test - popd - rm -rf build - rm -rf curl-99.98.97 - name: 'verify out-of-tree configure build including docs' + - uses: actions/download-artifact@v4 + with: + name: 'release-tgz' + + - run: | + echo "::stop-commands::$(uuidgen)" + tar xvf curl-99.98.97.tar.gz + touch curl-99.98.97/docs/{cmdline-opts,libcurl}/Makefile.inc + mkdir build + pushd build + ../curl-99.98.97/configure --without-ssl --without-libpsl + make + make test-ci + popd + rm -rf build + rm -rf curl-99.98.97 + name: 'verify out-of-tree configure build including docs' verify-out-of-tree-autotools-debug: runs-on: ubuntu-latest timeout-minutes: 30 needs: maketgz-and-verify-in-tree steps: - - uses: actions/download-artifact@v3 - with: - name: 'release-tgz' - - - run: | - echo "::stop-commands::$(uuidgen)" - tar xvf curl-99.98.97.tar.gz - pushd curl-99.98.97 - mkdir build - pushd build - ../configure --without-ssl --enable-debug "--prefix=${PWD}/pkg" - make -j3 - make -j3 TFLAGS=1279 test - make -j3 install - name: 'verify out-of-tree autotools debug build' + - uses: actions/download-artifact@v4 + with: + name: 'release-tgz' + + - run: | + echo "::stop-commands::$(uuidgen)" + tar xvf curl-99.98.97.tar.gz + pushd curl-99.98.97 + mkdir build + pushd build + ../configure --without-ssl --enable-debug "--prefix=${PWD}/pkg" --without-libpsl + make -j3 + make -j3 test-ci + make -j3 install + name: 'verify out-of-tree autotools debug build' verify-out-of-tree-cmake: runs-on: ubuntu-latest timeout-minutes: 30 needs: maketgz-and-verify-in-tree steps: - - uses: actions/download-artifact@v3 - with: - name: 'release-tgz' - - - run: | - echo "::stop-commands::$(uuidgen)" - tar xvf curl-99.98.97.tar.gz - pushd curl-99.98.97 - mkdir build - pushd build - cmake .. - make - name: 'verify out-of-tree cmake build' + - uses: actions/download-artifact@v4 + with: + name: 'release-tgz' + + - run: | + echo "::stop-commands::$(uuidgen)" + tar xvf curl-99.98.97.tar.gz + pushd curl-99.98.97 + mkdir build + pushd build + cmake .. + make + name: 'verify out-of-tree cmake build' diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index df841cf88..b874c31b5 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -21,6 +21,6 @@ jobs: pull-requests: write steps: - - uses: actions/labeler@v5 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/labeler@v5 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/linux32.yml b/.github/workflows/linux32.yml index 7c2d4cbf6..e3fca3d1d 100644 --- a/.github/workflows/linux32.yml +++ b/.github/workflows/linux32.yml @@ -7,35 +7,35 @@ name: Linux 32-bit on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' pull_request: branches: - - master + - master paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} @@ -55,39 +55,39 @@ jobs: fail-fast: false matrix: build: - - name: Linux i686 - install_packages: gcc-11-i686-linux-gnu libssl-dev:i386 zlib1g-dev:i386 libpsl-dev:i386 libbrotli-dev:i386 libzstd-dev:i386 - configure: --enable-debug --enable-websockets --with-openssl --host=i686-linux-gnu CC=i686-linux-gnu-gcc-11 PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CPPFLAGS=-I/usr/include/i386-linux-gnu LDFLAGS=-L/usr/lib/i386-linux-gnu + - name: Linux i686 + install_packages: gcc-11-i686-linux-gnu libssl-dev:i386 zlib1g-dev:i386 libpsl-dev:i386 libbrotli-dev:i386 libzstd-dev:i386 + configure: --enable-debug --enable-websockets --with-openssl --host=i686-linux-gnu CC=i686-linux-gnu-gcc-11 PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CPPFLAGS=-I/usr/include/i386-linux-gnu LDFLAGS=-L/usr/lib/i386-linux-gnu steps: - - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -y - sudo apt-get install -y --no-install-suggests --no-install-recommends libtool autoconf automake pkg-config stunnel4 ${{ matrix.build.install_packages }} - sudo python3 -m pip install impacket - name: 'install prereqs' + - run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -y + sudo apt-get install -y --no-install-suggests --no-install-recommends libtool autoconf automake pkg-config stunnel4 ${{ matrix.build.install_packages }} + sudo python3 -m pip install impacket + name: 'install prereqs' - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - run: autoreconf -fi - name: 'autoreconf' + - run: autoreconf -fi + name: 'autoreconf' - - run: ./configure --enable-warnings --enable-werror ${{ matrix.build.configure }} - name: 'configure' + - run: ./configure --enable-warnings --enable-werror ${{ matrix.build.configure }} + name: 'configure' - - run: make V=1 - name: 'make' + - run: make V=1 + name: 'make' - - run: ./src/curl -V - name: 'check curl -V output' + - run: ./src/curl -V + name: 'check curl -V output' - - run: make V=1 examples - name: 'make examples' + - run: make V=1 examples + name: 'make examples' - - run: make V=1 -C tests - name: 'make tests' + - run: make V=1 -C tests + name: 'make tests' - - run: make V=1 test-ci - name: 'run tests' - env: - TFLAGS: "${{ matrix.build.tflags }}" + - run: make V=1 test-ci + name: 'run tests' + env: + TFLAGS: "${{ matrix.build.tflags }}" diff --git a/.github/workflows/man-examples.yml b/.github/workflows/man-examples.yml index 126e989dc..6f0d1e8ae 100644 --- a/.github/workflows/man-examples.yml +++ b/.github/workflows/man-examples.yml @@ -7,24 +7,29 @@ name: manpage examples on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths: - - 'docs/libcurl/curl_*.3' - - 'docs/libcurl/opts/*.3' + - 'docs/libcurl/curl_*.3' + - 'docs/libcurl/opts/*.3' + - '.github/scripts/verify-examples.pl' pull_request: branches: - - master + - master paths: - - 'docs/libcurl/curl_*.3' - - 'docs/libcurl/opts/*.3' + - 'docs/libcurl/curl_*.3' + - 'docs/libcurl/opts/*.3' + - '.github/scripts/verify-examples.pl' jobs: verify: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: render nroff versions + run: autoreconf -fi && ./configure --without-ssl --without-libpsl && make -C docs - name: verify examples run: ./.github/scripts/verify-examples.pl docs/libcurl/curl*.3 docs/libcurl/opts/*.3 diff --git a/.github/workflows/ngtcp2-linux.yml b/.github/workflows/ngtcp2-linux.yml index e73eba8c1..19172b48f 100644 --- a/.github/workflows/ngtcp2-linux.yml +++ b/.github/workflows/ngtcp2-linux.yml @@ -7,35 +7,35 @@ name: ngtcp2-linux on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' pull_request: branches: - - master + - master paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' concurrency: # Hardcoded workflow filename as workflow name above is just Linux again @@ -47,12 +47,12 @@ permissions: {} env: MAKEFLAGS: -j 3 quictls-version: 3.1.4+quic - gnutls-version: 3.8.0 + gnutls-version: 3.8.3 wolfssl-version: master nghttp3-version: v1.1.0 - ngtcp2-version: v1.1.0 - nghttp2-version: v1.58.0 - mod_h2-version: v2.0.25 + ngtcp2-version: v1.2.0 + nghttp2-version: v1.59.0 + mod_h2-version: v2.0.26 jobs: autotools: @@ -63,208 +63,208 @@ jobs: fail-fast: false matrix: build: - - name: quictls - configure: >- - PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" - --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug --disable-ntlm - --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" - --with-openssl=$HOME/nghttpx - - name: gnutls - configure: >- - PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" - --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug - --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" - --with-gnutls=$HOME/nghttpx - - name: wolfssl - configure: >- - PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" - --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug - --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" - --with-wolfssl=$HOME/nghttpx + - name: quictls + configure: >- + PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" + --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug --disable-ntlm + --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" + --with-openssl=$HOME/nghttpx + - name: gnutls + configure: >- + PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" + --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug + --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" + --with-gnutls=$HOME/nghttpx + - name: wolfssl + configure: >- + PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib" + --with-ngtcp2=$HOME/nghttpx --enable-warnings --enable-werror --enable-debug + --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" + --with-wolfssl=$HOME/nghttpx steps: - - run: | - sudo apt-get update - sudo apt-get install libtool autoconf automake pkg-config stunnel4 \ - libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libev-dev libc-ares-dev \ - nettle-dev libp11-kit-dev libtspi-dev libunistring-dev guile-2.2-dev libtasn1-bin \ - libtasn1-6-dev libidn2-0-dev gawk gperf libtss2-dev dns-root-data bison gtk-doc-tools \ - texinfo texlive texlive-extra-utils autopoint libev-dev \ - apache2 apache2-dev libnghttp2-dev - name: 'install prereqs and impacket, pytest, crypto, apache2' - - - name: cache quictls - uses: actions/cache@v3 - id: cache-quictls-no-deprecated - env: - cache-name: cache-quictls-no-deprecated - with: - path: /home/runner/quictls - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.quictls-version }} - - - if: steps.cache-quictls-no-deprecated.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b openssl-${{ env.quictls-version }} https://github.com/quictls/openssl quictls - cd quictls - ./config no-deprecated --prefix=$HOME/nghttpx --libdir=$HOME/nghttpx/lib - make - name: 'build quictls' - - - run: | - cd $HOME/quictls - make -j1 install_sw - name: 'install quictls' - - - - name: cache gnutls - uses: actions/cache@v3 - id: cache-gnutls - env: - cache-name: cache-gnutls - with: - path: /home/runner/gnutls - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.gnutls-version }} - - - if: steps.cache-gnutls.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b ${{ env.gnutls-version }} https://github.com/gnutls/gnutls.git - cd gnutls - ./bootstrap - ./configure --prefix=$HOME/nghttpx \ - PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib -L$HOME/nghttpx/lib" \ - --with-included-libtasn1 --with-included-unistring \ - --disable-guile --disable-doc --disable-tests --disable-tools - make - name: 'build gnutls' - - - run: | - cd $HOME/gnutls - make install - name: 'install gnutls' - - - - name: cache wolfssl - uses: actions/cache@v3 - id: cache-wolfssl - env: - cache-name: cache-wolfssl - with: - path: /home/runner/wolfssl - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.wolfssl-version }} - - - if: steps.cache-wolfssl.outputs.cache-hit != 'true' || ${{ env.wolfssl-version }} == 'master' - run: | - cd $HOME - rm -rf wolfssl - git clone --quiet --depth=1 -b ${{ env.wolfssl-version }} https://github.com/wolfSSL/wolfssl.git - cd wolfssl - ./autogen.sh - ./configure --enable-all --enable-quic --prefix=$HOME/nghttpx - make - name: 'build wolfssl' - - - run: | - cd $HOME/wolfssl - make install - name: 'install wolfssl' - - - - name: cache nghttp3 - uses: actions/cache@v3 - id: cache-nghttp3 - env: - cache-name: cache-nghttp3 - with: - path: /home/runner/nghttp3 - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.nghttp3-version }} - - - if: steps.cache-nghttp3.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b ${{ env.nghttp3-version }} https://github.com/ngtcp2/nghttp3 - cd nghttp3 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only - make - name: 'build nghttp3' - - - run: | - cd $HOME/nghttp3 - make install - name: 'install nghttp3' - - # depends on all other cached libs built so far - - run: | - git clone --quiet --depth=1 -b ${{ env.ngtcp2-version }} https://github.com/ngtcp2/ngtcp2 - cd ngtcp2 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only --with-openssl --with-gnutls --with-wolfssl - make install - name: 'install ngtcp2' - - # depends on all other cached libs built so far - - run: | - git clone --quiet --depth=1 -b ${{ env.nghttp2-version }} https://github.com/nghttp2/nghttp2 - cd nghttp2 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-http3 - make install - name: 'install nghttp2' - - - name: cache mod_h2 - uses: actions/cache@v3 - id: cache-mod_h2 - env: - cache-name: cache-mod_h2 - with: - path: /home/runner/mod_h2 - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }} - - - if: steps.cache-mod_h2.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b ${{ env.mod_h2-version }} https://github.com/icing/mod_h2 - cd mod_h2 - autoreconf -fi - ./configure - make - name: 'build mod_h2' - - - run: | - cd $HOME/mod_h2 - sudo make install - name: 'install mod_h2' - - - uses: actions/checkout@v4 - - - run: | - sudo python3 -m pip install -r tests/requirements.txt -r tests/http/requirements.txt - name: 'install python test prereqs' - - - run: autoreconf -fi - name: 'autoreconf' - - - run: ./configure ${{ matrix.build.configure }} - name: 'configure' - - - run: make V=1 - name: 'make' - - - run: make V=1 examples - name: 'make examples' - - - run: make V=1 -C tests - name: 'make tests' - - - run: make V=1 test-ci - name: 'run tests' - env: - TFLAGS: "${{ matrix.build.tflags }}" - - - run: pytest -v tests - name: 'run pytest' - env: - TFLAGS: "${{ matrix.build.tflags }}" - CURL_CI: github + - run: | + sudo apt-get update + sudo apt-get install libtool autoconf automake pkg-config stunnel4 \ + libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libev-dev libc-ares-dev \ + nettle-dev libp11-kit-dev libtspi-dev libunistring-dev guile-2.2-dev libtasn1-bin \ + libtasn1-6-dev libidn2-0-dev gawk gperf libtss2-dev dns-root-data bison gtk-doc-tools \ + texinfo texlive texlive-extra-utils autopoint libev-dev \ + apache2 apache2-dev libnghttp2-dev + name: 'install prereqs and impacket, pytest, crypto, apache2' + + - name: cache quictls + uses: actions/cache@v4 + id: cache-quictls-no-deprecated + env: + cache-name: cache-quictls-no-deprecated + with: + path: /home/runner/quictls + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.quictls-version }} + + - if: steps.cache-quictls-no-deprecated.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b openssl-${{ env.quictls-version }} https://github.com/quictls/openssl quictls + cd quictls + ./config no-deprecated --prefix=$HOME/nghttpx --libdir=$HOME/nghttpx/lib + make + name: 'build quictls' + + - run: | + cd $HOME/quictls + make -j1 install_sw + name: 'install quictls' + + + - name: cache gnutls + uses: actions/cache@v4 + id: cache-gnutls + env: + cache-name: cache-gnutls + with: + path: /home/runner/gnutls + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.gnutls-version }} + + - if: steps.cache-gnutls.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.gnutls-version }} https://github.com/gnutls/gnutls.git + cd gnutls + ./bootstrap + ./configure --prefix=$HOME/nghttpx \ + PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/nghttpx/lib -L$HOME/nghttpx/lib" \ + --with-included-libtasn1 --with-included-unistring \ + --disable-guile --disable-doc --disable-tests --disable-tools + make + name: 'build gnutls' + + - run: | + cd $HOME/gnutls + make install + name: 'install gnutls' + + + - name: cache wolfssl + uses: actions/cache@v4 + id: cache-wolfssl + env: + cache-name: cache-wolfssl + with: + path: /home/runner/wolfssl + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.wolfssl-version }} + + - if: steps.cache-wolfssl.outputs.cache-hit != 'true' || ${{ env.wolfssl-version }} == 'master' + run: | + cd $HOME + rm -rf wolfssl + git clone --quiet --depth=1 -b ${{ env.wolfssl-version }} https://github.com/wolfSSL/wolfssl.git + cd wolfssl + ./autogen.sh + ./configure --enable-all --enable-quic --prefix=$HOME/nghttpx + make + name: 'build wolfssl' + + - run: | + cd $HOME/wolfssl + make install + name: 'install wolfssl' + + + - name: cache nghttp3 + uses: actions/cache@v4 + id: cache-nghttp3 + env: + cache-name: cache-nghttp3 + with: + path: /home/runner/nghttp3 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.nghttp3-version }} + + - if: steps.cache-nghttp3.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.nghttp3-version }} https://github.com/ngtcp2/nghttp3 + cd nghttp3 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only + make + name: 'build nghttp3' + + - run: | + cd $HOME/nghttp3 + make install + name: 'install nghttp3' + + # depends on all other cached libs built so far + - run: | + git clone --quiet --depth=1 -b ${{ env.ngtcp2-version }} https://github.com/ngtcp2/ngtcp2 + cd ngtcp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only --with-openssl --with-gnutls --with-wolfssl + make install + name: 'install ngtcp2' + + # depends on all other cached libs built so far + - run: | + git clone --quiet --depth=1 -b ${{ env.nghttp2-version }} https://github.com/nghttp2/nghttp2 + cd nghttp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-http3 + make install + name: 'install nghttp2' + + - name: cache mod_h2 + uses: actions/cache@v4 + id: cache-mod_h2 + env: + cache-name: cache-mod_h2 + with: + path: /home/runner/mod_h2 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }} + + - if: steps.cache-mod_h2.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.mod_h2-version }} https://github.com/icing/mod_h2 + cd mod_h2 + autoreconf -fi + ./configure + make + name: 'build mod_h2' + + - run: | + cd $HOME/mod_h2 + sudo make install + name: 'install mod_h2' + + - uses: actions/checkout@v4 + + - run: | + sudo python3 -m pip install -r tests/requirements.txt -r tests/http/requirements.txt + name: 'install python test prereqs' + + - run: autoreconf -fi + name: 'autoreconf' + + - run: ./configure ${{ matrix.build.configure }} + name: 'configure' + + - run: make V=1 + name: 'make' + + - run: make V=1 examples + name: 'make examples' + + - run: make V=1 -C tests + name: 'make tests' + + - run: make V=1 test-ci + name: 'run tests' + env: + TFLAGS: "${{ matrix.build.tflags }}" + + - run: pytest -v tests + name: 'run pytest' + env: + TFLAGS: "${{ matrix.build.tflags }}" + CURL_CI: github diff --git a/.github/workflows/osslq-linux.yml b/.github/workflows/osslq-linux.yml new file mode 100644 index 000000000..997e35bab --- /dev/null +++ b/.github/workflows/osslq-linux.yml @@ -0,0 +1,233 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl + +name: osslq-linux + +on: + push: + branches: + - master + - '*/ci' + paths-ignore: + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' + pull_request: + branches: + - master + paths-ignore: + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' + +concurrency: + # Hardcoded workflow filename as workflow name above is just Linux again + group: osslq-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +permissions: {} + +env: + MAKEFLAGS: -j 3 + openssl3-version: openssl-3.2.0 + quictls-version: 3.1.4+quic + nghttp3-version: v1.1.0 + ngtcp2-version: v1.2.0 + nghttp2-version: v1.59.0 + mod_h2-version: v2.0.26 + +jobs: + autotools: + name: ${{ matrix.build.name }} + runs-on: 'ubuntu-latest' + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + build: + - name: openssl-quic + configure: >- + PKG_CONFIG_PATH="$HOME/openssl3/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" + --enable-warnings --enable-werror --enable-debug --disable-ntlm + --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" + --with-openssl=$HOME/openssl3 --with-openssl-quic + --with-nghttp3=$HOME/nghttpx + + steps: + - run: | + sudo apt-get update + sudo apt-get install libtool autoconf automake pkg-config stunnel4 \ + libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libev-dev libc-ares-dev \ + nettle-dev libp11-kit-dev libtspi-dev libunistring-dev guile-2.2-dev libtasn1-bin \ + libtasn1-6-dev libidn2-0-dev gawk gperf libtss2-dev dns-root-data bison gtk-doc-tools \ + texinfo texlive texlive-extra-utils autopoint libev-dev \ + apache2 apache2-dev libnghttp2-dev + name: 'install prereqs and impacket, pytest, crypto, apache2' + + - name: cache openssl3 + if: contains(matrix.build.install_steps, 'openssl3') + uses: actions/cache@v3 + id: cache-openssl3 + env: + cache-name: cache-openssl3 + with: + path: /home/runner/openssl3 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.openssl3-version }} + + - name: 'install openssl3' + if: steps.cache-openssl3.outputs.cache-hit != 'true' + run: | + git clone --quiet --depth=1 -b ${{ env.openssl3-version }} https://github.com/openssl/openssl + cd openssl + ./config --prefix=$HOME/openssl3 --libdir=$HOME/openssl3/lib + make -j1 install_sw + + - name: cache quictls + if: contains(matrix.build.install_steps, 'quictls') + uses: actions/cache@v3 + id: cache-quictls + env: + cache-name: cache-quictls + with: + path: /home/runner/quictls + key: ${{ runner.os }}-build-${{ env.cache-name }}-quictls-${{ env.quictls-version }} + + - name: cache quictls + uses: actions/cache@v3 + id: cache-quictls-no-deprecated + env: + cache-name: cache-quictls-no-deprecated + with: + path: /home/runner/quictls + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.quictls-version }} + + - if: steps.cache-quictls-no-deprecated.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b openssl-${{ env.quictls-version }} https://github.com/quictls/openssl quictls + cd quictls + ./config no-deprecated --prefix=$HOME/nghttpx --libdir=$HOME/nghttpx/lib + make + name: 'build quictls' + + - run: | + cd $HOME/quictls + make -j1 install_sw + name: 'install quictls' + + + - name: cache nghttp3 + uses: actions/cache@v3 + id: cache-nghttp3 + env: + cache-name: cache-nghttp3 + with: + path: /home/runner/nghttp3 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.nghttp3-version }} + + - if: steps.cache-nghttp3.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.nghttp3-version }} https://github.com/ngtcp2/nghttp3 + cd nghttp3 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only + make + name: 'build nghttp3' + + - run: | + cd $HOME/nghttp3 + make install + name: 'install nghttp3' + + # depends on all other cached libs built so far + - run: | + git clone --quiet --depth=1 -b ${{ env.ngtcp2-version }} https://github.com/ngtcp2/ngtcp2 + cd ngtcp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only --with-openssl + make install + name: 'install ngtcp2' + + # depends on all other cached libs built so far + - run: | + git clone --quiet --depth=1 -b ${{ env.nghttp2-version }} https://github.com/nghttp2/nghttp2 + cd nghttp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-http3 + make install + name: 'install nghttp2' + + - name: cache mod_h2 + uses: actions/cache@v3 + id: cache-mod_h2 + env: + cache-name: cache-mod_h2 + with: + path: /home/runner/mod_h2 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }} + + - if: steps.cache-mod_h2.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.mod_h2-version }} https://github.com/icing/mod_h2 + cd mod_h2 + autoreconf -fi + ./configure + make + name: 'build mod_h2' + + - run: | + cd $HOME/mod_h2 + sudo make install + name: 'install mod_h2' + + - uses: actions/checkout@v4 + + - run: | + sudo python3 -m pip install -r tests/requirements.txt -r tests/http/requirements.txt + name: 'install python test prereqs' + + - run: autoreconf -fi + name: 'autoreconf' + + - run: ./configure ${{ matrix.build.configure }} + name: 'configure' + + - run: make V=1 + name: 'make' + + - run: make V=1 examples + name: 'make examples' + + - run: make V=1 -C tests + name: 'make tests' + + - run: make V=1 test-ci + name: 'run tests' + env: + # 2500 and 25002 fail atm due to fin handling + TFLAGS: "!http/3" + + - run: pytest -v tests + name: 'run pytest' + env: + TFLAGS: "${{ matrix.build.tflags }}" + CURL_CI: github diff --git a/.github/workflows/quiche-linux.yml b/.github/workflows/quiche-linux.yml index 9d43d42df..40fc4d580 100644 --- a/.github/workflows/quiche-linux.yml +++ b/.github/workflows/quiche-linux.yml @@ -7,35 +7,35 @@ name: quiche on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' pull_request: branches: - - master + - master paths-ignore: - - '**/*.md' - - '**/CMakeLists.txt' - - '.azure-pipelines.yml' - - '.circleci/**' - - '.cirrus.yml' - - 'appveyor.yml' - - 'CMake/**' - - 'packages/**' - - 'plan9/**' - - 'projects/**' - - 'winbuild/**' + - '**/*.md' + - '**/CMakeLists.txt' + - '.azure-pipelines.yml' + - '.circleci/**' + - '.cirrus.yml' + - 'appveyor.*' + - 'CMake/**' + - 'packages/**' + - 'plan9/**' + - 'projects/**' + - 'winbuild/**' concurrency: # Hardcoded workflow filename as workflow name above is just Linux again @@ -48,10 +48,10 @@ env: MAKEFLAGS: -j 3 openssl-version: 3.1.4+quic nghttp3-version: v1.1.0 - ngtcp2-version: v1.1.0 - nghttp2-version: v1.58.0 - quiche-version: 0.19.0 - mod_h2-version: v2.0.25 + ngtcp2-version: v1.2.0 + nghttp2-version: v1.59.0 + quiche-version: 0.20.0 + mod_h2-version: v2.0.26 jobs: autotools: @@ -62,149 +62,149 @@ jobs: fail-fast: false matrix: build: - - name: quiche - install: >- - libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libev-dev libc-ares-dev - install_steps: pytest - configure: >- - LDFLAGS="-Wl,-rpath,/home/runner/quiche/target/release" - --with-openssl=/home/runner/quiche/quiche/deps/boringssl/src - --enable-debug - --with-quiche=/home/runner/quiche/target/release - --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" - --with-ca-fallback + - name: quiche + install: >- + libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libev-dev libc-ares-dev + install_steps: pytest + configure: >- + LDFLAGS="-Wl,-rpath,/home/runner/quiche/target/release" + --with-openssl=/home/runner/quiche/quiche/deps/boringssl/src + --enable-debug + --with-quiche=/home/runner/quiche/target/release + --with-test-nghttpx="$HOME/nghttpx/bin/nghttpx" + --with-ca-fallback steps: - - run: | - sudo apt-get update - sudo apt-get install libtool autoconf automake pkg-config stunnel4 ${{ matrix.build.install }} - sudo apt-get install apache2 apache2-dev libnghttp2-dev - name: 'install prereqs and impacket, pytest, crypto' - - - name: cache nghttpx - uses: actions/cache@v3 - id: cache-nghttpx - env: - cache-name: cache-nghttpx - with: - path: /home/runner/nghttpx - key: ${{ runner.os }}-build-${{ env.cache-name }}-openssl-${{ env.openssl-version }}-nghttp3-${{ env.nghttp3-version }}-ngtcp2-${{ env.ngtcp2-version }}-nghttp2-${{ env.nghttp2-version }} - - - if: steps.cache-nghttpx.outputs.cache-hit != 'true' - run: | - git clone --quiet --depth=1 -b openssl-${{ env.openssl-version }} https://github.com/quictls/openssl - cd openssl - ./config --prefix=$HOME/nghttpx --libdir=$HOME/nghttpx/lib - make -j1 install_sw - name: 'install quictls' - - - if: steps.cache-nghttpx.outputs.cache-hit != 'true' - run: | - git clone --quiet --depth=1 -b ${{ env.nghttp3-version }} https://github.com/ngtcp2/nghttp3 - cd nghttp3 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only - make install - name: 'install nghttp3' - - - if: steps.cache-nghttpx.outputs.cache-hit != 'true' - run: | - git clone --quiet --depth=1 -b ${{ env.ngtcp2-version }} https://github.com/ngtcp2/ngtcp2 - cd ngtcp2 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only --with-openssl - make install - name: 'install ngtcp2' - - - if: steps.cache-nghttpx.outputs.cache-hit != 'true' - run: | - git clone --quiet --depth=1 -b ${{ env.nghttp2-version }} https://github.com/nghttp2/nghttp2 - cd nghttp2 - autoreconf -fi - ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-http3 - make install - name: 'install nghttp2' - - - name: cache quiche - uses: actions/cache@v3 - id: cache-quiche - env: - cache-name: cache-quiche - with: - path: /home/runner/quiche - key: ${{ runner.os }}-build-${{ env.cache-name }}-quiche-${{ env.quiche-version }} - - - if: steps.cache-quiche.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b ${{ env.quiche-version }} --recursive https://github.com/cloudflare/quiche.git - cd quiche - #### Work-around https://github.com/curl/curl/issues/7927 ####### - #### See https://github.com/alexcrichton/cmake-rs/issues/131 #### - sed -i -e 's/cmake = "0.1"/cmake = "=0.1.45"/' quiche/Cargo.toml - - cargo build -v --package quiche --release --features ffi,pkg-config-meta,qlog --verbose - mkdir -v quiche/deps/boringssl/src/lib - ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) quiche/deps/boringssl/src/lib/ - - # include dir - # /home/runner/quiche/quiche/deps/boringssl/src/include - # lib dir - # /home/runner/quiche/quiche/deps/boringssl/src/lib - name: 'build quiche and boringssl' - - - name: cache mod_h2 - uses: actions/cache@v3 - id: cache-mod_h2 - env: - cache-name: cache-mod_h2 - with: - path: /home/runner/mod_h2 - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }} - - - if: steps.cache-mod_h2.outputs.cache-hit != 'true' - run: | - cd $HOME - git clone --quiet --depth=1 -b ${{ env.mod_h2-version }} https://github.com/icing/mod_h2 - cd mod_h2 - autoreconf -fi - ./configure - make - name: 'build mod_h2' - - - run: | - cd $HOME/mod_h2 - sudo make install - name: 'install mod_h2' - - - uses: actions/checkout@v4 - - - run: | - sudo python3 -m pip install -r tests/requirements.txt -r tests/http/requirements.txt - name: 'install python test prereqs' - - - run: autoreconf -fi - name: 'autoreconf' - - - run: ./configure ${{ matrix.build.configure }} - name: 'configure' - - - run: make V=1 - name: 'make' - - - run: make V=1 examples - name: 'make examples' - - - run: make V=1 -C tests - name: 'make tests' - - - run: make V=1 test-ci - name: 'run tests' - env: - TFLAGS: "${{ matrix.build.tflags }}" - - - run: pytest -v tests - name: 'run pytest' - env: - TFLAGS: "${{ matrix.build.tflags }}" - CURL_CI: github + - run: | + sudo apt-get update + sudo apt-get install libtool autoconf automake pkg-config stunnel4 ${{ matrix.build.install }} + sudo apt-get install apache2 apache2-dev libnghttp2-dev + name: 'install prereqs and impacket, pytest, crypto' + + - name: cache nghttpx + uses: actions/cache@v4 + id: cache-nghttpx + env: + cache-name: cache-nghttpx + with: + path: /home/runner/nghttpx + key: ${{ runner.os }}-build-${{ env.cache-name }}-openssl-${{ env.openssl-version }}-nghttp3-${{ env.nghttp3-version }}-ngtcp2-${{ env.ngtcp2-version }}-nghttp2-${{ env.nghttp2-version }} + + - if: steps.cache-nghttpx.outputs.cache-hit != 'true' + run: | + git clone --quiet --depth=1 -b openssl-${{ env.openssl-version }} https://github.com/quictls/openssl + cd openssl + ./config --prefix=$HOME/nghttpx --libdir=$HOME/nghttpx/lib + make -j1 install_sw + name: 'install quictls' + + - if: steps.cache-nghttpx.outputs.cache-hit != 'true' + run: | + git clone --quiet --depth=1 -b ${{ env.nghttp3-version }} https://github.com/ngtcp2/nghttp3 + cd nghttp3 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only + make install + name: 'install nghttp3' + + - if: steps.cache-nghttpx.outputs.cache-hit != 'true' + run: | + git clone --quiet --depth=1 -b ${{ env.ngtcp2-version }} https://github.com/ngtcp2/ngtcp2 + cd ngtcp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-lib-only --with-openssl + make install + name: 'install ngtcp2' + + - if: steps.cache-nghttpx.outputs.cache-hit != 'true' + run: | + git clone --quiet --depth=1 -b ${{ env.nghttp2-version }} https://github.com/nghttp2/nghttp2 + cd nghttp2 + autoreconf -fi + ./configure --prefix=$HOME/nghttpx PKG_CONFIG_PATH="$HOME/nghttpx/lib/pkgconfig" --enable-http3 + make install + name: 'install nghttp2' + + - name: cache quiche + uses: actions/cache@v4 + id: cache-quiche + env: + cache-name: cache-quiche + with: + path: /home/runner/quiche + key: ${{ runner.os }}-build-${{ env.cache-name }}-quiche-${{ env.quiche-version }} + + - if: steps.cache-quiche.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.quiche-version }} --recursive https://github.com/cloudflare/quiche.git + cd quiche + #### Work-around https://github.com/curl/curl/issues/7927 ####### + #### See https://github.com/alexcrichton/cmake-rs/issues/131 #### + sed -i -e 's/cmake = "0.1"/cmake = "=0.1.45"/' quiche/Cargo.toml + + cargo build -v --package quiche --release --features ffi,pkg-config-meta,qlog --verbose + mkdir -v quiche/deps/boringssl/src/lib + ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) quiche/deps/boringssl/src/lib/ + + # include dir + # /home/runner/quiche/quiche/deps/boringssl/src/include + # lib dir + # /home/runner/quiche/quiche/deps/boringssl/src/lib + name: 'build quiche and boringssl' + + - name: cache mod_h2 + uses: actions/cache@v4 + id: cache-mod_h2 + env: + cache-name: cache-mod_h2 + with: + path: /home/runner/mod_h2 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.mod_h2-version }} + + - if: steps.cache-mod_h2.outputs.cache-hit != 'true' + run: | + cd $HOME + git clone --quiet --depth=1 -b ${{ env.mod_h2-version }} https://github.com/icing/mod_h2 + cd mod_h2 + autoreconf -fi + ./configure + make + name: 'build mod_h2' + + - run: | + cd $HOME/mod_h2 + sudo make install + name: 'install mod_h2' + + - uses: actions/checkout@v4 + + - run: | + sudo python3 -m pip install -r tests/requirements.txt -r tests/http/requirements.txt + name: 'install python test prereqs' + + - run: autoreconf -fi + name: 'autoreconf' + + - run: ./configure ${{ matrix.build.configure }} + name: 'configure' + + - run: make V=1 + name: 'make' + + - run: make V=1 examples + name: 'make examples' + + - run: make V=1 -C tests + name: 'make tests' + + - run: make V=1 test-ci + name: 'run tests' + env: + TFLAGS: "${{ matrix.build.tflags }}" + + - run: pytest -v tests + name: 'run pytest' + env: + TFLAGS: "${{ matrix.build.tflags }}" + CURL_CI: github diff --git a/.github/workflows/synopsis.yml b/.github/workflows/synopsis.yml index 948a83acb..0938f4bfc 100644 --- a/.github/workflows/synopsis.yml +++ b/.github/workflows/synopsis.yml @@ -7,22 +7,22 @@ name: SYNOPSIS on: push: branches: - - master - - '*/ci' + - master + - '*/ci' paths: - - 'docs/libcurl/curl_*.3' + - 'docs/libcurl/curl_*.3' pull_request: branches: - - master + - master paths: - - 'docs/libcurl/curl_*.3' + - 'docs/libcurl/curl_*.3' jobs: verify: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: verify-synopsis run: ./.github/scripts/verify-synopsis.pl docs/libcurl/curl*.3 diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index e54628626..83d743d34 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -164,14 +164,11 @@ int main(void) { ; return 0; } #ifdef HAVE_IOCTLSOCKET /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif int main(void) { @@ -186,14 +183,11 @@ int main(void) #ifdef HAVE_IOCTLSOCKET_CAMEL /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif int main(void) { @@ -207,14 +201,11 @@ int main(void) #ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif int main(void) { @@ -229,14 +220,11 @@ int main(void) #ifdef HAVE_IOCTLSOCKET_FIONBIO /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif int main(void) { @@ -307,14 +295,11 @@ int main(void) #ifdef HAVE_SETSOCKOPT_SO_NONBLOCK /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif /* includes start */ #ifdef HAVE_SYS_TYPES_H diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake index 7ad2f5c40..9ff62ea72 100644 --- a/CMake/Macros.cmake +++ b/CMake/Macros.cmake @@ -45,7 +45,7 @@ macro(curl_internal_test CURL_TEST) "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") endif() - message(STATUS "Performing Curl Test ${CURL_TEST}") + message(STATUS "Performing Test ${CURL_TEST}") try_compile(${CURL_TEST} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c @@ -54,15 +54,15 @@ macro(curl_internal_test CURL_TEST) OUTPUT_VARIABLE OUTPUT) if(${CURL_TEST}) set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}") - message(STATUS "Performing Curl Test ${CURL_TEST} - Success") + message(STATUS "Performing Test ${CURL_TEST} - Success") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing Curl Test ${CURL_TEST} passed with the following output:\n" + "Performing Test ${CURL_TEST} passed with the following output:\n" "${OUTPUT}\n") else() - message(STATUS "Performing Curl Test ${CURL_TEST} - Failed") + message(STATUS "Performing Test ${CURL_TEST} - Failed") set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing Curl Test ${CURL_TEST} failed with the following output:\n" + "Performing Test ${CURL_TEST} failed with the following output:\n" "${OUTPUT}\n") endif() endif() diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index a613f6ecd..7701c0ee9 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -23,115 +23,89 @@ ########################################################################### include(CheckCSourceCompiles) include(CheckCSourceRuns) - -# The begin of the sources (macros and includes) -set(_source_epilogue "#undef inline") +include(CheckTypeSize) macro(add_header_include check header) if(${check}) - set(_source_epilogue "${_source_epilogue}\n#include <${header}>") + set(_source_epilogue "${_source_epilogue} + #include <${header}>") endif() endmacro() -set(signature_call_conv) -if(HAVE_WINDOWS_H) - set(_source_epilogue - "${_source_epilogue}\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif") - add_header_include(HAVE_WINSOCK2_H "winsock2.h") - add_header_include(HAVE_WINDOWS_H "windows.h") - set(signature_call_conv "PASCAL") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +if(NOT DEFINED HAVE_STRUCT_SOCKADDR_STORAGE) + set(CMAKE_EXTRA_INCLUDE_FILES) if(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h") + set(CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN") set(CMAKE_REQUIRED_LIBRARIES "ws2_32") + elseif(HAVE_SYS_SOCKET_H) + set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") endif() -else() + check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE) + set(HAVE_STRUCT_SOCKADDR_STORAGE ${HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE}) +endif() + +if(NOT WIN32) + set(_source_epilogue "#undef inline") add_header_include(HAVE_SYS_TYPES_H "sys/types.h") add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h") + check_c_source_compiles("${_source_epilogue} + int main(void) + { + int flag = MSG_NOSIGNAL; + (void)flag; + return 0; + }" HAVE_MSG_NOSIGNAL) endif() -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - +set(_source_epilogue "#undef inline") +add_header_include(HAVE_SYS_TIME_H "sys/time.h") check_c_source_compiles("${_source_epilogue} - int main(void) { - int flag = MSG_NOSIGNAL; - (void)flag; + #include + int main(void) + { + struct timeval ts; + ts.tv_sec = 0; + ts.tv_usec = 0; + (void)ts; return 0; - }" HAVE_MSG_NOSIGNAL) - -if(NOT HAVE_WINDOWS_H) - add_header_include(HAVE_SYS_TIME_H "sys/time.h") -endif() -check_c_source_compiles("${_source_epilogue} -#include -int main(void) { - struct timeval ts; - ts.tv_sec = 0; - ts.tv_usec = 0; - (void)ts; - return 0; -}" HAVE_STRUCT_TIMEVAL) - -if(HAVE_WINDOWS_H) - set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h") -else() - set(CMAKE_EXTRA_INCLUDE_FILES) - if(HAVE_SYS_SOCKET_H) - set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") - endif() -endif() - -check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE) -if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE) - set(HAVE_STRUCT_SOCKADDR_STORAGE 1) -endif() + }" HAVE_STRUCT_TIMEVAL) unset(CMAKE_TRY_COMPILE_TARGET_TYPE) -if(NOT CMAKE_CROSSCOMPILING) - if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "iOS") - # only try this on non-apple platforms - - # if not cross-compilation... - set(CMAKE_REQUIRED_FLAGS "") - if(HAVE_SYS_POLL_H) - set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H") - elseif(HAVE_POLL_H) - set(CMAKE_REQUIRED_FLAGS "-DHAVE_POLL_H") - endif() - check_c_source_runs(" - #include - #include - - #ifdef HAVE_SYS_POLL_H - # include - #elif HAVE_POLL_H - # include - #endif - - int main(void) - { - if(0 != poll(0, 0, 10)) { - return 1; /* fail */ - } - else { - /* detect the 10.12 poll() breakage */ - struct timeval before, after; - int rc; - size_t us; - - gettimeofday(&before, NULL); - rc = poll(NULL, 0, 500); - gettimeofday(&after, NULL); - - us = (after.tv_sec - before.tv_sec) * 1000000 + - (after.tv_usec - before.tv_usec); - - if(us < 400000) { - return 1; - } - } - return 0; +if(NOT CMAKE_CROSSCOMPILING AND NOT APPLE) + set(_source_epilogue "#undef inline") + add_header_include(HAVE_SYS_POLL_H "sys/poll.h") + add_header_include(HAVE_POLL_H "poll.h") + check_c_source_runs("${_source_epilogue} + #include + #include + int main(void) + { + if(0 != poll(0, 0, 10)) { + return 1; /* fail */ + } + else { + /* detect the 10.12 poll() breakage */ + struct timeval before, after; + int rc; + size_t us; + + gettimeofday(&before, NULL); + rc = poll(NULL, 0, 500); + gettimeofday(&after, NULL); + + us = (after.tv_sec - before.tv_sec) * 1000000 + + (after.tv_usec - before.tv_usec); + + if(us < 400000) { + return 1; + } + } + return 0; }" HAVE_POLL_FINE) - endif() endif() # Detect HAVE_GETADDRINFO_THREADSAFE @@ -140,8 +114,8 @@ if(WIN32) set(HAVE_GETADDRINFO_THREADSAFE ${HAVE_GETADDRINFO}) elseif(NOT HAVE_GETADDRINFO) set(HAVE_GETADDRINFO_THREADSAFE FALSE) -elseif(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR - CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR +elseif(APPLE OR + CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "HP-UX" OR CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD" OR @@ -153,14 +127,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "BSD") endif() if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE) - - set(_save_epilogue "${_source_epilogue}") set(_source_epilogue "#undef inline") - add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h") add_header_include(HAVE_SYS_TIME_H "sys/time.h") add_header_include(HAVE_NETDB_H "netdb.h") - check_c_source_compiles("${_source_epilogue} int main(void) { @@ -197,17 +167,12 @@ if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE) if(HAVE_H_ERRNO OR HAVE_H_ERRNO_ASSIGNABLE OR HAVE_H_ERRNO_SBS_ISSUE_7) set(HAVE_GETADDRINFO_THREADSAFE TRUE) endif() - - set(_source_epilogue "${_save_epilogue}") endif() if(NOT WIN32 AND NOT DEFINED HAVE_CLOCK_GETTIME_MONOTONIC_RAW) - set(_save_epilogue "${_source_epilogue}") set(_source_epilogue "#undef inline") - add_header_include(HAVE_SYS_TYPES_H "sys/types.h") add_header_include(HAVE_SYS_TIME_H "sys/time.h") - check_c_source_compiles("${_source_epilogue} #include int main(void) @@ -216,6 +181,4 @@ if(NOT WIN32 AND NOT DEFINED HAVE_CLOCK_GETTIME_MONOTONIC_RAW) (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); return 0; }" HAVE_CLOCK_GETTIME_MONOTONIC_RAW) - - set(_source_epilogue "${_save_epilogue}") endif() diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index 5a0d15604..d82bbb1d6 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -23,6 +23,12 @@ ########################################################################### include(CheckCCompilerFlag) +unset(WPICKY) + +if(CURL_WERROR AND CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) + set(WPICKY "${WPICKY} -pedantic-errors") +endif() + if(PICKY_COMPILER) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") @@ -83,11 +89,12 @@ if(PICKY_COMPILER) -Wmissing-field-initializers # clang 2.7 gcc 4.1 -Wmissing-noreturn # clang 2.7 gcc 4.1 -Wno-format-nonliteral # clang 1.0 gcc 2.96 (3.0) - -Wno-sign-conversion # clang 2.9 gcc 4.3 -Wno-system-headers # clang 1.0 gcc 3.0 # -Wpadded # clang 2.9 gcc 4.1 # Not used because we cannot change public structs - -Wredundant-decls # clang 2.7 gcc 4.1 -Wold-style-definition # clang 2.7 gcc 3.4 + -Wredundant-decls # clang 2.7 gcc 4.1 + -Wsign-conversion # clang 2.9 gcc 4.3 + -Wno-error=sign-conversion # FIXME -Wstrict-prototypes # clang 1.0 gcc 3.3 # -Wswitch-enum # clang 2.7 gcc 4.1 # Not used because this basically disallows default case -Wtype-limits # clang 2.7 gcc 4.3 @@ -110,6 +117,7 @@ if(PICKY_COMPILER) -Wshift-sign-overflow # clang 2.9 -Wshorten-64-to-32 # clang 1.0 -Wlanguage-extension-token # clang 3.0 + -Wformat=2 # clang 3.0 gcc 4.8 ) # Enable based on compiler version if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) OR @@ -135,6 +143,12 @@ if(PICKY_COMPILER) -Wextra-semi-stmt # clang 7.0 appleclang 10.3 ) endif() + if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0) OR + (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.4)) + list(APPEND WPICKY_ENABLE + -Wimplicit-fallthrough # clang 4.0 gcc 7.0 appleclang 12.4 # we have silencing markup for clang 10.0 and above only + ) + endif() else() # gcc list(APPEND WPICKY_DETECT ${WPICKY_COMMON} @@ -147,6 +161,7 @@ if(PICKY_COMPILER) -Wmissing-parameter-type # gcc 4.3 -Wold-style-declaration # gcc 4.3 -Wstrict-aliasing=3 # gcc 4.0 + -Wtrampolines # gcc 4.3 ) endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND MINGW) @@ -156,7 +171,7 @@ if(PICKY_COMPILER) endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8) list(APPEND WPICKY_ENABLE - -Wformat=2 # clang 3.0 gcc 4.8 (clang part-default, enabling it fully causes -Wformat-nonliteral warnings) + -Wformat=2 # clang 3.0 gcc 4.8 ) endif() if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) @@ -179,6 +194,7 @@ if(PICKY_COMPILER) -Wduplicated-branches # gcc 7.0 -Wformat-overflow=2 # gcc 7.0 -Wformat-truncation=2 # gcc 7.0 + -Wimplicit-fallthrough # clang 4.0 gcc 7.0 -Wrestrict # gcc 7.0 ) endif() @@ -191,8 +207,6 @@ if(PICKY_COMPILER) # - unset(WPICKY) - foreach(_CCOPT IN LISTS WPICKY_ENABLE) set(WPICKY "${WPICKY} ${_CCOPT}") endforeach() @@ -209,8 +223,10 @@ if(PICKY_COMPILER) set(WPICKY "${WPICKY} ${_CCOPT}") endif() endforeach() - - message(STATUS "Picky compiler options:${WPICKY}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WPICKY}") endif() endif() + +if(WPICKY) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WPICKY}") + message(STATUS "Picky compiler options:${WPICKY}") +endif() diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index ec09fd4bd..d3391d92f 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -171,6 +171,7 @@ set(HAVE_POSIX_STRERROR_R 0) set(HAVE_BUILTIN_AVAILABLE 0) set(HAVE_MSG_NOSIGNAL 0) set(HAVE_STRUCT_TIMEVAL 1) +set(HAVE_STRUCT_SOCKADDR_STORAGE 1) set(HAVE_GETHOSTBYNAME_R_3 0) set(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index a54c2fff9..1b5ea67c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,25 +21,8 @@ # SPDX-License-Identifier: curl # ########################################################################### -# curl/libcurl CMake script # by Tetetest and Sukender (Benoit Neil) -# TODO: -# The output .so file lacks the soname number which we currently have within the lib/Makefile.am file -# Add full (4 or 5 libs) SSL support -# Add INSTALL target (EXTRA_DIST variables in Makefile.am may be moved to Makefile.inc so that CMake/CPack is aware of what's to include). -# Check on all possible platforms -# Test with as many configurations possible (With or without any option) -# Create scripts that help keeping the CMake build system up to date (to reduce maintenance). According to Tetetest: -# - lists of headers that 'configure' checks for; -# - curl-specific tests (the ones that are in m4/curl-*.m4 files); -# - (most obvious thing:) curl version numbers. -# Add documentation subproject -# -# To check: -# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. -# (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options. - # Note: By default this CMake build script detects the version of some # dependencies using `check_symbol_exists`. Those checks do not work # in the case that both CURL and its dependency are included as @@ -105,7 +88,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(BUILD_STATIC_LIBS "Build static libraries" OFF) option(BUILD_STATIC_CURL "Build curl executable with static libcurl" OFF) option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) -option(CURL_DISABLE_INSTALL "Set to ON to disable instalation targets" OFF) +option(CURL_DISABLE_INSTALL "Set to ON to disable installation targets" OFF) if(WIN32) option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF) @@ -321,18 +304,22 @@ if(ENABLE_IPV6 AND NOT WIN32) endif() endif() -if(USE_MANUAL) - #nroff is currently only used when USE_MANUAL is set, so we can prevent the warning of no *NROFF if USE_MANUAL is OFF (or not defined), by not even looking for NROFF.. - curl_nroff_check() -endif() find_package(Perl) -cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual" - ON "NROFF_USEFUL;PERL_FOUND" - OFF) +option(BUILD_LIBCURL_DOCS "to build libcurl man pages" ON) +# curl source release tarballs come with the curl man page pre-built. +option(ENABLE_CURL_MANUAL "to build the man page for curl and enable its -M/--manual option" OFF) -if(ENABLE_MANUAL) - set(USE_MANUAL ON) +if(ENABLE_CURL_MANUAL OR BUILD_LIBCURL_DOCS) + if(PERL_FOUND) + curl_nroff_check() + if(NROFF_USEFUL) + set(HAVE_MANUAL_TOOLS ON) + endif() + endif() + if(NOT HAVE_MANUAL_TOOLS) + message(WARNING "Perl not found, or nroff not useful. Will not build manuals.") + endif() endif() if(CURL_STATIC_CRT) @@ -368,9 +355,6 @@ include(CheckCSourceCompiles) # On windows preload settings if(WIN32) - set(HAVE_WINDOWS_H 1) - set(HAVE_WS2TCPIP_H 1) - set(HAVE_WINSOCK2_H 1) include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) endif() @@ -736,6 +720,10 @@ if(USE_MSH3) list(APPEND CURL_LIBS ${MSH3_LIBRARIES}) endif() +if(CURL_WITH_MULTI_SSL AND (USE_NGTCP2 OR USE_QUICHE OR USE_MSH3)) + message(FATAL_ERROR "MultiSSL cannot be enabled with HTTP/3 and vice versa.") +endif() + if(NOT CURL_DISABLE_SRP AND (HAVE_GNUTLS_SRP OR HAVE_OPENSSL_SRP)) set(USE_TLS_SRP 1) endif() @@ -787,7 +775,7 @@ if(NOT CURL_DISABLE_LDAP) endif() set(NEED_LBER_H ON) set(_HEADER_LIST) - if(HAVE_WINDOWS_H) + if(WIN32) list(APPEND _HEADER_LIST "windows.h") endif() if(HAVE_SYS_TYPES_H) @@ -927,10 +915,8 @@ if(CURL_USE_GSSAPI) check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) - if(GSS_FLAVOUR STREQUAL "Heimdal") - set(HAVE_GSSHEIMDAL ON) - else() # MIT - set(HAVE_GSSMIT ON) + if(NOT GSS_FLAVOUR STREQUAL "Heimdal") + # MIT set(_INCLUDE_LIST "") if(HAVE_GSSAPI_GSSAPI_H) list(APPEND _INCLUDE_LIST "gssapi/gssapi.h") @@ -1070,9 +1056,9 @@ endif() # Check for header files if(WIN32) - check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) - check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) - check_include_file_concat("windows.h" HAVE_WINDOWS_H) + set(CURL_INCLUDES ${CURL_INCLUDES} "winsock2.h") + set(CURL_INCLUDES ${CURL_INCLUDES} "ws2tcpip.h") + set(CURL_INCLUDES ${CURL_INCLUDES} "windows.h") endif() if(WIN32) @@ -1266,7 +1252,7 @@ set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T}) set(CMAKE_EXTRA_INCLUDE_FILES "") if(WIN32) - set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h") + set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h") check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY) set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY}) set(CMAKE_EXTRA_INCLUDE_FILES "") @@ -1406,15 +1392,6 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE) endif() endif() -# TODO test which of these headers are required -if(WIN32) - set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H}) -else() - set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H}) - set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H}) - set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H}) -endif() - include(CMake/OtherTests.cmake) add_definitions(-DHAVE_CONFIG_H) @@ -1504,7 +1481,7 @@ set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") -if(USE_MANUAL) +if(HAVE_MANUAL_TOOLS) add_subdirectory(docs) endif() @@ -1533,7 +1510,6 @@ if(NOT CURL_DISABLE_INSTALL) endmacro() # NTLM support requires crypto function adaptions from various SSL libs - # TODO alternative SSL libs tests for SSP1, GnuTLS, NSS if(NOT (CURL_DISABLE_NTLM) AND (USE_OPENSSL OR USE_MBEDTLS OR USE_DARWINSSL OR USE_WIN32_CRYPTO OR USE_GNUTLS)) set(use_curl_ntlm_core ON) @@ -1551,26 +1527,20 @@ if(NOT CURL_DISABLE_INSTALL) _add_if("IDN" HAVE_LIBIDN2 OR USE_WIN32_IDN) _add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) - # TODO SSP1 (Schannel) check is missing _add_if("SSPI" USE_WINDOWS_SSPI) _add_if("GSS-API" HAVE_GSSAPI) _add_if("alt-svc" NOT CURL_DISABLE_ALTSVC) _add_if("HSTS" NOT CURL_DISABLE_HSTS) - # TODO SSP1 missing for SPNEGO _add_if("SPNEGO" NOT CURL_DISABLE_NEGOTIATE_AUTH AND (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) _add_if("Kerberos" NOT CURL_DISABLE_KERBEROS_AUTH AND (HAVE_GSSAPI OR USE_WINDOWS_SSPI)) - # NTLM support requires crypto function adaptions from various SSL libs - # TODO alternative SSL libs tests for SSP1, GnuTLS, NSS _add_if("NTLM" NOT (CURL_DISABLE_NTLM) AND (use_curl_ntlm_core OR USE_WINDOWS_SSPI)) - # TODO missing option (autoconf: --enable-ntlm-wb) _add_if("NTLM_WB" NOT (CURL_DISABLE_NTLM) AND (use_curl_ntlm_core OR USE_WINDOWS_SSPI) AND NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED) _add_if("TLS-SRP" USE_TLS_SRP) - # TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header _add_if("HTTP2" USE_NGHTTP2) _add_if("HTTP3" USE_NGTCP2 OR USE_QUICHE) _add_if("MultiSSL" CURL_WITH_MULTI_SSL) @@ -1589,6 +1559,8 @@ if(NOT CURL_DISABLE_INSTALL) # Clear list and try to detect available protocols set(_items) _add_if("HTTP" NOT CURL_DISABLE_HTTP) + _add_if("IPFS" NOT CURL_DISABLE_HTTP) + _add_if("IPNS" NOT CURL_DISABLE_HTTP) _add_if("HTTPS" NOT CURL_DISABLE_HTTP AND SSL_ENABLED) _add_if("FTP" NOT CURL_DISABLE_FTP) _add_if("FTPS" NOT CURL_DISABLE_FTP AND SSL_ENABLED) diff --git a/COPYING b/COPYING index d1eab3eb9..d9e7e0bef 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2023, Daniel Stenberg, , and many +Copyright (c) 1996 - 2024, Daniel Stenberg, , and many contributors, see the THANKS file. All rights reserved. diff --git a/Makefile.am b/Makefile.am index c8afcb505..b56ca1a1e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -127,8 +127,9 @@ EXTRA_DIST = CHANGES COPYING maketgz Makefile.dist curl-config.in \ $(VC_DIST) $(WINBUILD_DIST) $(PLAN9_DIST) lib/libcurl.vers.in buildconf.bat \ libcurl.def -CLEANFILES = $(VC14_LIBVCXPROJ) \ - $(VC14_SRCVCXPROJ) $(VC14_10_LIBVCXPROJ) $(VC14_10_SRCVCXPROJ) \ +CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) \ + $(VC14_10_LIBVCXPROJ) $(VC14_10_SRCVCXPROJ) \ + $(VC14_20_LIBVCXPROJ) $(VC14_20_SRCVCXPROJ) \ $(VC14_30_LIBVCXPROJ) $(VC14_30_SRCVCXPROJ) bin_SCRIPTS = curl-config @@ -152,12 +153,6 @@ dist-hook: cp -p $$file $(distdir)$$strip; \ done) -html: - cd docs && $(MAKE) html - -pdf: - cd docs && $(MAKE) pdf - check: test examples check-docs if CROSSCOMPILING @@ -509,7 +504,8 @@ function gen_element(type, dir, file)\ -v src_rc="$$win32_src_rc" \ -v src_x_srcs="$$sorted_src_x_srcs" \ -v src_x_hdrs="$$sorted_src_x_hdrs" \ - "$$awk_code" $(srcdir)/$(VC14_20_SRCTMPL) > $(VC14_20_SRCVCXPROJ) || { exit 1; };) \ + "$$awk_code" $(srcdir)/$(VC14_20_SRCTMPL) > $(VC14_20_SRCVCXPROJ) || { exit 1; }; \ + \ echo "generating '$(VC14_30_LIBVCXPROJ)'"; \ awk -v proj_type=vcxproj \ -v lib_srcs="$$sorted_lib_srcs" \ diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3f7dc99f6..0bb5a8d43 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,206 +1,178 @@ -curl and libcurl 8.5.0 +curl and libcurl 8.6.0 - Public curl releases: 253 + Public curl releases: 254 Command line options: 258 - curl_easy_setopt() options: 303 + curl_easy_setopt() options: 304 Public functions in libcurl: 93 - Contributors: 3039 + Contributors: 3078 This release includes the following changes: - o gnutls: support CURLSSLOPT_NATIVE_CA [31] - o HTTP3: ngtcp2 builds are no longer experimental [77] + o add CURLE_TOO_LARGE [48] + o add CURLINFO_QUEUE_TIME_T [76] + o add CURLOPT_SERVER_RESPONSE_TIMEOUT_MS: add [39] + o asyn-thread: use GetAddrInfoExW on >= Windows 8 [55] + o configure: make libpsl detection failure cause error [109] + o docs/cmdline: change to .md for cmdline docs [77] + o docs: introduce "curldown" for libcurl man page format [102] + o runtests: support -gl. Like -g but for lldb. [47] This release includes the following bugfixes: - o appveyor: make VS2008-built curl tool runnable [93] - o asyn-thread: use pipe instead of socketpair for IPC when available [4] - o autotools: accept linker flags via `CURL_LDFLAGS_{LIB,BIN}` [128] - o autotools: avoid passing `LDFLAGS` twice to libcurl [127] - o autotools: delete LCC compiler support bits [137] - o autotools: fix/improve gcc and Apple clang version detection [136] - o autotools: stop setting `-std=gnu89` with `--enable-warnings` [135] - o autotools: update references to deleted `crypt-auth` option [46] - o BINDINGS: add V binding [54] - o build: add `src/.checksrc` to source tarball [1] - o build: add more picky warnings and fix them [172] - o build: always revert `#pragma GCC diagnostic` after use [143] - o build: delete `HAVE_STDINT_H` and `HAVE_INTTYPES_H` [107] - o build: delete support bits for obsolete Windows compilers [106] - o build: fix 'threadsafe' feature detection for older gcc [19] - o build: fix builds that disable protocols but not digest auth [174] - o build: fix compiler warning with auths disabled [85] - o build: fix libssh2 + `CURL_DISABLE_DIGEST_AUTH` + `CURL_DISABLE_AWS` [120] - o build: picky warning updates [125] - o build: require Windows XP or newer [86] - o cfilter: provide call to tell connection to forget a socket [65] - o checksrc.pl: support #line instructions - o CI: add autotools, out-of-tree, debug build to distro check job [14] - o CI: ignore test 286 on Appveyor gcc 9 build [6] - o cmake: add `CURL_DISABLE_BINDLOCAL` option [146] - o cmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API` [138] - o cmake: dedupe Windows system libs [114] - o cmake: fix `HAVE_H_ERRNO_ASSIGNABLE` detection [2] - o cmake: fix CURL_DISABLE_GETOPTIONS [12] - o cmake: fix multiple include of CURL package [96] - o cmake: fix OpenSSL quic detection in quiche builds [56] - o cmake: option to disable install & drop `curlu` target when unused [72] - o cmake: pre-fill rest of detection values for Windows [50] - o cmake: replace `check_library_exists_concat()` [23] - o cmake: speed up threads setup for Windows [68] - o cmake: speed up zstd detection [69] - o config-win32: set `HAVE_SNPRINTF` for mingw-w64 [123] - o configure: better --disable-http [80] - o configure: check for the fseeko declaration too [55] - o conncache: use the closure handle when disconnecting surplus connections [173] - o content_encoding: make Curl_all_content_encodings allocless [101] - o cookie: lowercase the domain names before PSL checks [160] - o curl.h: delete Symbian OS references [162] - o curl.h: on FreeBSD include sys/param.h instead of osreldate.h [21] - o curl.rc: switch out the copyright symbol for plain ASCII [167] - o curl: improved IPFS and IPNS URL support [87] - o curl_easy_duphandle.3: clarify how HSTS and alt-svc are duped [99] - o Curl_http_body: cleanup properly when Curl_getformdata errors [152] - o curl_setup: disallow Windows IPv6 builds missing getaddrinfo [57] - o curl_sspi: support more revocation error names in error messages [95] - o CURLINFO_PRETRANSFER_TIME_T.3: fix time explanation [181] - o CURLMOPT_MAX_CONCURRENT_STREAMS: make sure the set value is within range [165] - o CURLOPT_CAINFO_BLOB.3: explain what CURL_BLOB_COPY does [113] - o CURLOPT_WRITEFUNCTION.3: clarify libcurl returns for CURL_WRITEFUNC_ERROR [45] - o CURPOST_POSTFIELDS.3: add CURLOPT_COPYPOSTFIELDS in SEE ALSO - o docs/example/keepalive.c: show TCP keep-alive options [73] - o docs/example/localport.c: show off CURLOPT_LOCALPORT [83] - o docs/examples/interface.c: show CURLOPT_INTERFACE use [84] - o docs/libcurl: fix three minor man page format mistakes [26] - o docs/libcurl: SYNSOPSIS cleanup [150] - o docs: add supported version for the json write-out [92] - o docs: clarify that curl passes on input unfiltered [47] - o docs: fix function typo in curl_easy_option_next.3 [36] - o docs: KNOWN_BUGS cleanup - o docs: make all examples in all libcurl man pages compile [175] - o docs: preserve the modification date when copying the prebuilt man page [89] - o docs: remove bold from some man page SYNOPSIS sections [90] - o docs: use SOURCE_DATE_EPOCH for generated manpages [16] - o doh: provide better return code for responses w/o addresses [133] - o doh: use PIPEWAIT when HTTP/2 is attempted [63] - o duphandle: also free 'outcurl->cookies' in error path [122] - o duphandle: make dupset() not return with pointers to old alloced data [109] - o duphandle: use strdup to clone *COPYPOSTFIELDS if size is not set [132] - o easy: in duphandle, init the cookies for the new handle [131] - o easy: remove duplicate wolfSSH init call [37] - o easy_lock: add a pthread_mutex_t fallback [13] - o examples/rtsp-options.c: add [157] - o fopen: create new file using old file's mode [153] - o fopen: create short(er) temporary file name [155] - o getenv: PlayStation doesn't have getenv() [41] - o GHA: move mod_h2 version in CI to v2.0.25 [43] - o hostip: show the list of IPs when resolving is done [35] - o hostip: silence compiler warning `-Wparentheses-equality` [62] - o hsts: skip single-dot hostname [67] - o HTTP/2, HTTP/3: handle detach of onoing transfers [134] - o http2: header conversion tightening [33] - o http2: provide an error callback and failf the message [53] - o http2: safer invocation of populate_binsettings [8] - o http: allow longer HTTP/2 request method names [112] - o http: avoid Expect: 100-continue if Upgrade: is used [15] - o http: consider resume with CURLOPT_FAILONERRROR and 416 to be fine [81] - o http: fix `-Wunused-parameter` with no auth and no proxy [149] - o http: fix `-Wunused-variable` compiler warning [115] - o http: fix empty-body warning [76] - o http_aws_sigv4: canonicalise valueless query params [88] - o hyper: temporarily remove HTTP/2 support [139] - o INSTALL: update list of ports and CPU archs - o IPFS: fix IPFS_PATH and file parsing [119] - o keylog: disable if unused [145] - o lib: add and use Curl_strndup() [97] - o lib: apache style infof and trace macros/functions [71] - o lib: fix gcc warning in printf call [7] - o libcurl-errors.3: sync with current public headers [156] - o libcurl-thread.3: simplify the TLS section [79] - o Makefile.am: drop vc10, vc11 and vc12 projects from dist [103] - o Makefile.mk: fix `-rtmp` option for non-Windows - o mime: store "form escape" as a single bit [170] - o misc: fix -Walloc-size warnings [118] - o msh3: error when built with CURL_DISABLE_SOCKETPAIR set [61] - o multi: during ratelimit multi_getsock should return no sockets [182] - o multi: use pipe instead of socketpair to *wakeup() [18] - o ngtcp2: fix races in stream handling [178] - o ngtcp2: ignore errors on unknown streams [158] - o ntlm_wb: use pipe instead of socketpair when possible [44] - o openldap: move the alloc of ldapconninfo to *connect() [29] - o openldap: set the callback argument in oldap_do [30] - o openssl: avoid BN_num_bits() NULL pointer derefs [9] - o openssl: fix building with v3 `no-deprecated` + add CI test [161] - o openssl: fix infof() to avoid compiler warning for %s with null [70] - o openssl: identify the "quictls" backend correctly [82] - o openssl: include SIG and KEM algorithms in verbose [52] - o openssl: make CURLSSLOPT_NATIVE_CA import Windows intermediate CAs [58] - o openssl: two multi pointer checks should probably rather be asserts [91] - o openssl: when a session-ID is reused, skip OCSP stapling [142] - o page-footer: clarify exit code 25 [51] - o projects: add VC14.20 project files [104] - o pytest: use lower count in repeat tests [98] - o quic: make eyeballers connect retries stop at weird replies [140] - o quic: manage connection idle timeouts [5] - o quiche: use quiche_conn_peer_transport_params() [116] - o rand: fix build error with autotools + LibreSSL [111] - o resolve.d: drop a multi use-sentence [100] - o RTSP: improved RTP parser [32] - o rustls: implement connect_blocking [154] - o sasl: fix `-Wunused-function` compiler warning [124] - o schannel: add CA cache support for files and memory blobs [121] - o setopt: check CURLOPT_TFTP_BLKSIZE range on set [171] - o setopt: remove outdated cookie comment [64] - o setopt: remove superfluous use of ternary expressions [169] - o socks: better buffer size checks for socks4a user and hostname [20] - o socks: make SOCKS5 use the CURLOPT_IPRESOLVE choice [38] - o symbols-in-versions: the CLOSEPOLICY options are deprecated - o test1683: remove commented-out check alternatives - o test3103: add missing quotes around a test tag attribute - o test613: stop showing an error on missing output file - o tests/README: SOCKS tests are not using OpenSSH, it has its own server [48] - o tests/server: add more SOCKS5 handshake error checking [27] - o tests: Fix Windows test helper tool search & use it for handle64 [17] - o tidy-up: casing typos, delete unused Windows version aliases [144] - o tool: fix --capath when proxy support is disabled [28] - o tool: support bold headers in Windows [117] - o tool_cb_hdr: add an additional parsing check [129] - o tool_cb_prg: make the carriage return fit for wide progress bars [159] - o tool_cb_wrt: fix write output for very old Windows versions [24] - o tool_getparam: limit --rate to be smaller than number of ms [3] - o tool_operate: do not mix memory models [108] - o tool_operate: fix links in ipfs errors [22] - o tool_parsecfg: make warning output propose double-quoting [164] - o tool_urlglob: fix build for old gcc versions [25] - o tool_urlglob: make multiply() bail out on negative values [11] - o tool_writeout_json: fix JSON encoding of non-ascii bytes [179] - o transfer: abort pause send when connection is marked for closing [183] - o transfer: avoid calling the read callback again after EOF [130] - o transfer: only reset the FTP wildcard engine in CLEAR state [42] - o url: don't touch the multi handle when closing internal handles [40] - o url: find scheme with a "perfect hash" [141] - o url: fix `-Wzero-length-array` with no protocols [147] - o url: fix builds with `CURL_DISABLE_HTTP` [148] - o url: protocol handler lookup tidy-up [66] - o url: proxy ssl connection reuse fix [94] - o urlapi: avoid null deref if setting blank host to url encode [75] - o urlapi: skip appending NULL pointer query [74] - o urlapi: when URL encoding the fragment, pass in the right length [59] - o urldata: make maxconnects a 32 bit value [166] - o urldata: move async resolver state from easy handle to connectdata [34] - o urldata: move cookielist from UserDefined to UrlState [126] - o urldata: move hstslist from 'set' to 'state' [105] - o urldata: move the 'internal' boolean to the state struct [39] - o vssh: remove the #ifdef for Curl_ssh_init, use empty macro - o vtls: cleanup SSL config management [78] - o vtls: consistently use typedef names for OpenSSL structs [176] - o vtls: late clone of connection ssl config [60] - o vtls: use ALPN "http/1.1" for HTTP/1.x, including HTTP/1.0 [102] - o VULN-DISCLOSURE-POLICY: escape sequences are not a security flaw [110] - o windows: use built-in `_WIN32` macro to detect Windows [163] - o wolfssh: remove redundant static prototypes [168] - o wolfssl: add default case for wolfssl_connect_step1 switch [49] - o wolfssl: require WOLFSSL_SYS_CA_CERTS for loading system CA [10] + o altsvc: free 'as' when returning error [23] + o appveyor: replace PowerShell with bash + parallel autotools [54] + o appveyor: switch to out-of-tree builds [29] + o asyn-ares: with modern c-ares, use its default timeout [127] + o build: delete unused `HAVE_{GSSHEIMDAL,GSSMIT,HEIMDAL}` [4] + o build: delete/replace clang warning pragmas [111] + o build: enable missing OpenSSF-recommended warnings, with fixes [11] + o build: fix `-Wconversion`/`-Wsign-conversion` warnings [26] + o build: fix Windows ADDRESS_FAMILY detection [35] + o build: more `-Wformat` fixes [40] + o build: remove redundant `CURL_PULL_*` settings [8] + o cf-h1-proxy: no CURLOPT_USERAGENT in CONNECT with hyper [133] + o cf-socket: show errno in tcpkeepalive error messages [120] + o CI/distcheck: run full tests [31] + o cmake: add option to disable building docs + o cmake: fix generation for system name iOS [53] + o cmake: fix typo [5] + o cmake: freshen up docs/INSTALL.cmake [101] + o cmake: prefill/cache `HAVE_STRUCT_SOCKADDR_STORAGE` [45] + o cmake: rework options to enable curl and libcurl docs [161] + o cmake: when USE_MANUAL=YES, build the curl.1 man page [113] + o cmdline-opts/write-out.d: remove spurious double quotes + o cmdline-opts: update availability for the *-ca-native options [66] + o cmdline/gen: fix the sorting of the man page options [33] + o configure: add libngtcp2_crypto_boringssl detection [155] + o configure: fix no default int compile error in ipv6 detection [69] + o configure: when enabling QUIC, check that TLS supports QUIC [87] + o connect: remove margin from eyeballer alloc [79] + o content_encoding: change return code to typedef'ed enum [94] + o cookie.d: document use of empty string to enable cookie engine [106] + o cookie: avoid fopen with empty file name [24] + o curl.h: CURLOPT_DNS_SERVERS is only available with c-ares [131] + o curl: show ipfs and ipns as supported "protocols" [15] + o curl_easy_getinfo.3: remove the wrong time value count [116] + o curl_multi_fdset.3: remove mention of null pointer support [134] + o CURLINFO_REFERER.3: clarify that it is the *request* header [70] + o CURLOPT_AUTOREFERER.3: mention CURLINFO_REFERER + o CURLOPT_POSTFIELDS.3: fix incorrect C string escape in example [27] + o CURLOPT_SSH_*_KEYFILE: clarify [57] + o dist: add tests/errorcodes.pl to the tarball [6] + o docs: clean up Protocols: for cmdline options [32] + o docs: describe and highlight super cookies [80] + o docs: do not start lines/sentences with So, But nor And [140] + o docs: install curl.1 with cmake [166] + o docs: mention env vars not used by schannel [124] + o doh: remove unused local variable [34] + o examples: add four new examples [99] + o file+ftp: use stack buffers instead of data->state.buffer [138] + o ftp: handle the PORT parsing without allocation [44] + o ftp: use dynbuf to store entrypath [83] + o ftp: use memdup0 to store the OS from a SYST 215 response [82] + o ftpserver.pl: send 213 SIZE response without spurious newline + o gen.pl: support ## for doing .IP in table-like lists [105] + o gen: do italics/bold for a range of letters, not just single word [78] + o GHA: add a job scanning for "bad words" in markdown [164] + o GHA: bump ngtcp2, gnutls, mod_h2, quiche [158] + o gnutls: fix build with --disable-verbose [3] + o haproxy-clientip.d: document the arg [68] + o headers: make sure the trailing newline is not stored [97] + o headers: remove assert from Curl_headers_push [115] + o hostip: return error immediately when Curl_ip2addr() fails [19] + o hsts: remove assert for zero length domain [96] + o http2: improved on_stream_close/data_done handling [49] + o http3/quiche: fix result code on a stream reset [91] + o http3: initial support for OpenSSL 3.2 QUIC stack [110] + o http: adjust_pollset fix [85] + o http: check for "Host:" case insensitively [154] + o http: fix off-by-one error in request method length check [14] + o http: only act on 101 responses when they are HTTP/1.1 [98] + o http: remove comment reference to a removed solution [156] + o http: use stack scratch buffer [150] + o http_proxy: a blank CURLOPT_USERAGENT should not be used in CONNECT [90] + o krb5: add prototype to silence clang warnings on mvsnprintf() [119] + o lib: add debug log outputs for CURLE_BAD_FUNCTION_ARGUMENT [62] + o lib: error out on multissl + http3 [13] + o lib: fix variable undeclared error caused by `infof` changes [2] + o lib: reduce use of strncpy [30] + o lib: rename Curl_strndup to Curl_memdup0 to avoid misunderstanding [36] + o lib: replace readwrite with write_resp [137] + o lib: strndup/memdup instead of malloc, memcpy and null-terminate [42] + o libssh2: use `libssh2_session_callback_set2()` with v1.11.1 [103] + o libssh: improve the deprecation warning dismissal [20] + o libssh: supress warnings without version check [18] + o Makefile.am: fix the MSVC project generation [22] + o Makefile.mk: drop Windows support [12] + o mbedtls: fix `-Wnull-dereference` and `-Wredundant-decls` [117] + o mbedtls: free the entropy when threaded [46] + o mime: use memdup0 instead of malloc + memcpy [63] + o mksymbolsmanpage.pl: provide references to where the symbol is used + o mprintf: overhaul and bugfixes [52] + o mqtt: use stack scratch buffer for recv+publish [148] + o multi: remove total timer reset in file_do() while fetching file:// [89] + o ngtcp2: put h3 at the front of alpn [58] + o ntlm_wb: do not use data->state.buffer any longer [151] + o openldap: fix an LDAP crash [75] + o openldap: fix STARTTLS [67] + o openssl: re-match LibreSSL deinit with init [17] + o openssl: when verifystatus fails, remove session id from cache [100] + o OS400: sync ILE/RPG binding [114] + o pingpong: stop using the download buffer [159] + o pop3: replace calloc + memcpy with memdup0 [60] + o pytest: scorecard tracking CPU and RSS [157] + o quiche: return CURLE_HTTP3 on send to invalid stream [65] + o readwrite_data: loop less [21] + o Revert "urldata: move async resolver state from easy handle to connectdata" [16] + o rtsp: deal with borked server responses [129] + o runtests: for mode="text" on , fix newlines on both parts [64] + o sasl: make login option string override http auth [142] + o schannel: fix `-Warith-conversion` gcc 13 warning [28] + o sectransp: do verify_cert without memdup for blobs [93] + o sectransp_ make TLSCipherNameForNumber() available in non-verbose config [1] + o sendf: fix compiler warning with CURL_DISABLE_HEADERS_API [38] + o setopt: clear mimepost when formp is freed [92] + o setopt: use memdup0 when cloning COPYPOSTFIELDS [107] + o socks: fix generic output string to say SOCKS instead of SOCKS4 [144] + o socks: use own buffer instead of data->state.buffer [143] + o ssh: fix namespace of two local macros [51] + o ssh: use stack scratch buffer for seeks [146] + o strerror: repair get_winsock_error() [56] + o system.h: sync mingw `CURL_TYPEOF_CURL_SOCKLEN_T` with other compilers [9] + o system_win32: fix a function pointer assignment warning [71] + o telnet: use dynbuf instad of malloc for escape buffer [108] + o telnet: use stack scratch buffer for do [149] + o tests/server: delete workaround for old-mingw [25] + o tests: avoid int/size_t conversion size/sign warnings [163] + o tests: respect $TMPDIR when creating unix domain sockets [50] + o tool: make parser reject blank arguments if not supported [86] + o tool: prepend output_dir in header callback [95] + o tool_getparam: bsearch cmdline options [74] + o tool_getparam: do not try to expand without an argument [59] + o tool_getparam: stop supporting `@filename` style for --cookie [121] + o tool_listhelp: regenerate after recent .d updates [61] + o tool_operate: make --remove-on-error only remove "real" files [125] + o tool_operate: stop setting the file comment on Amiga [128] + o transfer: adjust_pollset improvements [81] + o transfer: fix upload rate limiting, add test cases [37] + o transfer: make the select_bits_paused condition check both directions [104] + o transfer: remove warning: Value stored to 'blen' is never read [136] + o url: don't set default CA paths for Secure Transport backend [126] + o url: for disabled protocols, mention if found in redirect [7] + o urlapi: remove assert [162] + o verify-examples.pl: fail verification on unescaped backslash [72] + o version: show only the libpsl version, not its dependencies [130] + o vquic: extract TLS setup into own source [88] + o vtls: fix missing multissl version info [73] + o vtls: receive max buffer [139] + o vtls: remove the Curl_cft_ssl_proxy object if CURL_DISABLE_PROXY [41] + o websockets: check for negative payload lengths [123] + o websockets: refactor decode chain [122] + o windows: delete redundant headers [43] + o windows: simplify detecting and using system headers [10] + o wolfssl: load certificate *chain* for PEM client certs [84] + o x509asn1: remove code for WANT_VERIFYHOST [132] + o x509asn1: switch from malloc to dynbuf [112] This release includes the following known bugs: @@ -215,204 +187,179 @@ Planned upcoming removals include: This release would not have looked like this without help, code, reports and advice from friends like these: - 12932 on github, Alex Bozarth, Alexey Larikov, Alex Klyubin, Ammar Faizi, - Andrew Kurushin, Anubhav Rai, boilingoden, calvin2021y on github, - Carlos Henrique Lima Melara, Casey Bodley, Charlie C, Dan Fandrich, - Daniel Jeliński, Daniel Stenberg, David Benjamin, David Suter, Dmitry Karpov, - eeverettrbx on github, Emanuele Torre, Enno Boland, enWILLYado on github, - Faraz Fallahi, Gisle Vanem, Goro FUJI, Graham Campbell, Harry Mallon, - Harry Sintonen, iconoclasthero, icy17 on github, Jacob Hoffman-Andrews, - Jan Alexander Steffens, Jeroen Ooms, Jiehong on github, Jiri Hruska, - Junho Choi, Kai Pastor, Kareem, Kartatz on Github, kirbyn17 on hackerone, - Lau, lkordos on github, Loïc Yhuel, LoRd_MuldeR, lRoccoon on github, - Maksymilian Arciemowicz, Manfred Schwarb, Marcel Raad, Marcin Rataj, - Mark Gaiser, Martin Schmatz, Michael Kaufmann, Michał Antoniak, Nico Rieck, - Niracler Li, ohyeaah on github, Ophir Lojkine, Paweł Wegner, Philip Heiduck, - Ray Satiro, rilysh, Robert Southee, Romain Geissler, Sam James, - Samuel Henrique, sd0 on hackerone, Smackd0wn, Sohom Datta, Stefan Eissing, - Steven Allen, Tim Hill, Torben Dury, Turiiya, Viktor Szakats, - yushicheng7788 on github, z2_, zhengqwe on github, 積丹尼 Dan Jacobson - (78 contributors) + Andy Alt, annalee, Baruch Siach, Ben, Boris Verkhovskiy, Brad Harder, + bubbleguuum on github, Cajus Pollmeier, calvin2021y on github, Chara White, + Chris Sauer, Dan Fandrich, Daniel Gustafsson, Daniel Stenberg, + dependabot[bot], Dmitry Karpov, Gabe, Geeknik Labs, Gisle Vanem, + Graham Campbell, Hans-Christian Egtvedt, Harry Sintonen, Haydar Alaidrus, + hgdagon on github, Hiroki Kurosawa, iAroc on github, ivanfywang, + janko-js on github, Jay Wu, Jess Lowe, Karthikdasari0423 on github, + Lealem Amedie, Lin Sun, Marcel Raad, Mark Huang, Mark Sinkovics, + Mauricio Scheffer, Michał Antoniak, Mike Hommey, Mohammadreza Hendiani, + Ozan Cansel, Patrick Monnerat, Pavel Pavlov, promptfuzz_ on hackerone, + Ray Satiro, RevaliQaQ on github, Richard Levitte, Scarlett McAllister, + Sergey Bronnikov, Sergey Markelov, sfan5 on github, Stefan Eissing, + Tatsuhiko Miyagawa, Tatsuhiro Tsujikawa, Theo, Thomas Ferguson, + Viktor Szakats, Xi Ruoyao, Yadhu Krishna M, Yedaya Katsman, Yifei Kong, + YX Hao, zengwei, zengwei2000, ウさん + (65 contributors) References to bug reports and discussions on issues: - [1] = https://curl.se/bug/?i=12084 - [2] = https://curl.se/bug/?i=12093 - [3] = https://curl.se/bug/?i=12116 - [4] = https://curl.se/bug/?i=12146 - [5] = https://curl.se/bug/?i=12064 - [6] = https://curl.se/bug/?i=12040 - [7] = https://curl.se/bug/?i=12082 - [8] = https://curl.se/bug/?i=12101 - [9] = https://curl.se/bug/?i=12099 - [10] = https://curl.se/bug/?i=12108 - [11] = https://curl.se/bug/?i=12102 - [12] = https://curl.se/bug/?i=12091 - [13] = https://curl.se/bug/?i=12090 - [14] = https://curl.se/bug/?i=12088 - [15] = https://curl.se/bug/?i=12022 - [16] = https://curl.se/bug/?i=12092 - [17] = https://curl.se/bug/?i=12115 - [18] = https://curl.se/bug/?i=12142 - [19] = https://curl.se/bug/?i=12125 - [20] = https://curl.se/bug/?i=12139 - [21] = https://curl.se/bug/?i=12107 - [22] = https://curl.se/bug/?i=12133 - [23] = https://curl.se/bug/?i=11285 - [24] = https://curl.se/bug/?i=12131 - [25] = https://curl.se/bug/?i=12124 - [26] = https://curl.se/bug/?i=12126 - [27] = https://curl.se/bug/?i=12117 - [28] = https://curl.se/bug/?i=12089 - [29] = https://curl.se/bug/?i=12166 - [30] = https://curl.se/bug/?i=12166 - [31] = https://curl.se/bug/?i=12137 - [32] = https://curl.se/bug/?i=12052 - [33] = https://curl.se/bug/?i=12097 - [34] = https://curl.se/bug/?i=12198 - [35] = https://curl.se/bug/?i=12145 - [36] = https://curl.se/bug/?i=12170 - [37] = https://curl.se/bug/?i=12168 - [38] = https://curl.se/bug/?i=11949 - [39] = https://curl.se/bug/?i=12165 - [40] = https://curl.se/bug/?i=12165 - [41] = https://curl.se/bug/?i=12140 - [42] = https://curl.se/bug/?i=11775 - [43] = https://curl.se/bug/?i=12157 - [44] = https://curl.se/bug/?i=12149 - [45] = https://curl.se/bug/?i=12201 - [46] = https://curl.se/bug/?i=12194 - [47] = https://curl.se/bug/?i=12249 - [48] = https://curl.se/bug/?i=12195 - [49] = https://curl.se/bug/?i=12218 - [50] = https://curl.se/bug/?i=12044 - [51] = https://curl.se/bug/?i=12189 - [52] = https://curl.se/bug/?i=12030 - [53] = https://curl.se/bug/?i=12179 - [54] = https://curl.se/bug/?i=12182 - [55] = https://curl.se/bug/?i=12086 - [56] = https://curl.se/bug/?i=12160 - [57] = https://curl.se/bug/?i=12221 - [58] = https://curl.se/bug/?i=12155 - [59] = https://curl.se/bug/?i=12250 - [60] = https://curl.se/bug/?i=12237 - [61] = https://curl.se/bug/?i=12213 - [62] = https://curl.se/bug/?i=12215 - [63] = https://curl.se/bug/?i=12214 - [64] = https://curl.se/bug/?i=12206 - [65] = https://curl.se/bug/?i=12207 - [66] = https://curl.se/bug/?i=12216 - [67] = https://curl.se/bug/?i=12247 - [68] = https://curl.se/bug/?i=12202 - [69] = https://curl.se/bug/?i=12200 - [70] = https://curl.se/bug/?i=12196 - [71] = https://curl.se/bug/?i=12083 - [72] = https://curl.se/bug/?i=12287 - [73] = https://curl.se/bug/?i=12242 - [74] = https://curl.se/bug/?i=12240 - [75] = https://curl.se/bug/?i=12240 - [76] = https://curl.se/bug/?i=12262 - [77] = https://curl.se/bug/?i=12235 - [78] = https://curl.se/bug/?i=12204 - [79] = https://curl.se/bug/?i=12233 - [80] = https://curl.se/bug/?i=12223 - [81] = https://curl.se/bug/?i=10521 - [82] = https://curl.se/bug/?i=12270 - [83] = https://curl.se/bug/?i=12230 - [84] = https://curl.se/bug/?i=12229 - [85] = https://curl.se/bug/?i=12227 - [86] = https://curl.se/bug/?i=12225 - [87] = https://curl.se/bug/?i=12148 - [88] = https://curl.se/bug/?i=8107 - [89] = https://curl.se/bug/?i=12199 - [90] = https://curl.se/bug/?i=12267 - [91] = https://curl.se/bug/?i=12264 - [92] = https://curl.se/bug/?i=12266 - [93] = https://curl.se/bug/?i=12263 - [94] = https://curl.se/bug/?i=12255 - [95] = https://curl.se/bug/?i=12239 - [96] = https://curl.se/bug/?i=11913 - [97] = https://curl.se/bug/?i=12251 - [98] = https://curl.se/bug/?i=12248 - [99] = https://curl.se/bug/?i=12315 - [100] = https://curl.se/bug/?i=12294 - [101] = https://curl.se/bug/?i=12289 - [102] = https://curl.se/bug/?i=12259 - [103] = https://curl.se/bug/?i=12288 - [104] = https://curl.se/bug/?i=12282 - [105] = https://curl.se/bug/?i=12315 - [106] = https://curl.se/bug/?i=12222 - [107] = https://curl.se/bug/?i=12275 - [108] = https://curl.se/bug/?i=12280 - [109] = https://curl.se/bug/?i=12337 - [110] = https://curl.se/bug/?i=12278 - [111] = https://curl.se/bug/?i=12257 - [112] = https://curl.se/bug/?i=12311 - [113] = https://curl.se/bug/?i=12277 - [114] = https://curl.se/bug/?i=12307 - [115] = https://curl.se/bug/?i=12228 - [116] = https://curl.se/bug/?i=12180 - [117] = https://curl.se/bug/?i=12321 - [118] = https://curl.se/bug/?i=12292 - [119] = https://curl.se/bug/?i=12152 - [120] = https://curl.se/bug/?i=12273 - [121] = https://curl.se/bug/?i=12261 - [122] = https://curl.se/bug/?i=12329 - [123] = https://curl.se/bug/?i=12325 - [124] = https://curl.se/bug/?i=12326 - [125] = https://curl.se/bug/?i=12324 - [126] = https://curl.se/bug/?i=12323 - [127] = https://curl.se/bug/?i=12310 - [128] = https://curl.se/bug/?i=12312 - [129] = https://curl.se/bug/?i=12320 - [130] = https://curl.se/mail/lib-2023-11/0017.html - [131] = https://curl.se/bug/?i=12318 - [132] = https://curl.se/bug/?i=12317 - [133] = https://curl.se/bug/?i=12365 - [134] = https://curl.se/bug/?i=12356 - [135] = https://curl.se/bug/?i=12346 - [136] = https://curl.se/bug/?i=12362 - [137] = https://curl.se/bug/?i=12357 - [138] = https://curl.se/bug/?i=12353 - [139] = https://curl.se/bug/?i=12191 - [140] = https://curl.se/bug/?i=12400 - [141] = https://curl.se/bug/?i=12347 - [142] = https://curl.se/bug/?i=12399 - [143] = https://curl.se/bug/?i=12352 - [144] = https://curl.se/bug/?i=12351 - [145] = https://curl.se/bug/?i=12350 - [146] = https://curl.se/bug/?i=12345 - [147] = https://curl.se/bug/?i=12344 - [148] = https://curl.se/bug/?i=12343 - [149] = https://curl.se/bug/?i=12338 - [150] = https://curl.se/bug/?i=12402 - [152] = https://curl.se/bug/?i=12410 - [153] = https://curl.se/bug/?i=12299 - [154] = https://curl.se/bug/?i=11647 - [155] = https://curl.se/bug/?i=12388 - [156] = https://curl.se/bug/?i=12424 - [157] = https://curl.se/bug/?i=12452 - [158] = https://curl.se/bug/?i=12449 - [159] = https://curl.se/bug/?i=12407 - [160] = https://curl.se/bug/?i=12387 - [161] = https://curl.se/bug/?i=12384 - [162] = https://curl.se/bug/?i=12378 - [163] = https://curl.se/bug/?i=12376 - [164] = https://curl.se/bug/?i=12409 - [165] = https://curl.se/bug/?i=12382 - [166] = https://curl.se/bug/?i=12375 - [167] = https://curl.se/bug/?i=12403 - [168] = https://curl.se/bug/?i=12381 - [169] = https://curl.se/bug/?i=12374 - [170] = https://curl.se/bug/?i=12374 - [171] = https://curl.se/bug/?i=12374 - [172] = https://curl.se/bug/?i=12331 - [173] = https://curl.se/bug/?i=12367 - [174] = https://curl.se/bug/?i=12440 - [175] = https://curl.se/bug/?i=12448 - [176] = https://curl.se/bug/?i=12439 - [178] = https://curl.se/bug/?i=12435 - [179] = https://curl.se/bug/?i=12434 - [181] = https://curl.se/bug/?i=12431 - [182] = https://curl.se/bug/?i=12430 - [183] = https://curl.se/bug/?i=12428 + [1] = https://curl.se/bug/?i=12474 + [2] = https://curl.se/bug/?i=12470 + [3] = https://curl.se/bug/?i=12505 + [4] = https://curl.se/bug/?i=12506 + [5] = https://curl.se/bug/?i=12464 + [6] = https://curl.se/bug/?i=12462 + [7] = https://curl.se/bug/?i=12466 + [8] = https://curl.se/bug/?i=12502 + [9] = https://curl.se/bug/?i=12501 + [10] = https://curl.se/bug/?i=12495 + [11] = https://curl.se/bug/?i=12489 + [12] = https://curl.se/bug/?i=12224 + [13] = https://curl.se/bug/?i=12807 + [14] = https://curl.se/bug/?i=12534 + [15] = https://curl.se/mail/archive-2023-12/0026.html + [16] = https://curl.se/bug/?i=12524 + [17] = https://curl.se/bug/?i=12525 + [18] = https://curl.se/bug/?i=12523 + [19] = https://curl.se/bug/?i=12522 + [20] = https://curl.se/bug/?i=12519 + [21] = https://curl.se/bug/?i=12504 + [22] = https://curl.se/bug/?i=12564 + [23] = https://curl.se/bug/?i=12570 + [24] = https://curl.se/bug/?i=12514 + [25] = https://curl.se/bug/?i=12510 + [26] = https://curl.se/bug/?i=12557 + [27] = https://curl.se/bug/?i=12588 + [28] = https://curl.se/bug/?i=12616 + [29] = https://curl.se/bug/?i=12550 + [30] = https://curl.se/bug/?i=12499 + [31] = https://curl.se/bug/?i=12503 + [32] = https://curl.se/bug/?i=12496 + [33] = https://curl.se/mail/archive-2023-12/0014.html + [34] = https://curl.se/bug/?i=12491 + [35] = https://curl.se/bug/?i=12441 + [36] = https://curl.se/bug/?i=12490 + [37] = https://curl.se/bug/?i=12559 + [38] = https://curl.se/bug/?i=12485 + [39] = https://curl.se/bug/?i=12369 + [40] = https://curl.se/bug/?i=12540 + [41] = https://curl.se/bug/?i=12459 + [42] = https://curl.se/bug/?i=12453 + [43] = https://curl.se/bug/?i=12539 + [44] = https://curl.se/bug/?i=12456 + [45] = https://curl.se/bug/?i=12537 + [46] = https://curl.se/bug/?i=12584 + [47] = https://curl.se/bug/?i=12547 + [48] = https://curl.se/bug/?i=12269 + [49] = https://curl.se/bug/?i=10936 + [50] = https://curl.se/bug/?i=12545 + [51] = https://curl.se/bug/?i=12544 + [52] = https://curl.se/bug/?i=12561 + [53] = https://curl.se/bug/?i=12515 + [54] = https://curl.se/bug/?i=12560 + [55] = https://curl.se/bug/?i=12481 + [56] = https://curl.se/bug/?i=12578 + [57] = https://curl.se/bug/?i=12554 + [58] = https://curl.se/bug/?i=12576 + [59] = https://curl.se/bug/?i=12565 + [60] = https://curl.se/bug/?i=12650 + [61] = https://curl.se/bug/?i=12612 + [62] = https://curl.se/bug/?i=12658 + [63] = https://curl.se/bug/?i=12649 + [64] = https://curl.se/bug/?i=12612 + [65] = https://curl.se/bug/?i=12590 + [66] = https://curl.se/bug/?i=12613 + [67] = https://curl.se/bug/?i=12610 + [68] = https://curl.se/bug/?i=12611 + [69] = https://curl.se/bug/?i=12607 + [70] = https://curl.se/bug/?i=12605 + [71] = https://curl.se/bug/?i=12581 + [72] = https://curl.se/bug/?i=12589 + [73] = https://curl.se/bug/?i=12599 + [74] = https://curl.se/bug/?i=12631 + [75] = https://curl.se/bug/?i=12593 + [76] = https://curl.se/bug/?i=12368 + [77] = https://curl.se/bug/?i=12751 + [78] = https://curl.se/bug/?i=12689 + [79] = https://curl.se/bug/?i=12647 + [80] = https://curl.se/bug/?i=12687 + [81] = https://curl.se/bug/?i=12640 + [82] = https://curl.se/bug/?i=12639 + [83] = https://curl.se/bug/?i=12638 + [84] = https://curl.se/bug/?i=12634 + [85] = https://curl.se/bug/?i=12632 + [86] = https://curl.se/bug/?i=12620 + [87] = https://curl.se/bug/?i=12683 + [88] = https://curl.se/bug/?i=12678 + [89] = https://curl.se/bug/?i=12682 + [90] = https://curl.se/bug/?i=12680 + [91] = https://curl.se/bug/?i=12629 + [92] = https://curl.se/bug/?i=12608 + [93] = https://curl.se/bug/?i=12679 + [94] = https://curl.se/bug/?i=12618 + [95] = https://curl.se/bug/?i=12614 + [96] = https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65661 + [97] = https://curl.se/mail/lib-2024-01/0019.html + [98] = https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66184 + [99] = https://curl.se/bug/?i=12671 + [100] = https://curl.se/bug/?i=12760 + [101] = https://curl.se/bug/?i=12772 + [102] = https://curl.se/bug/?i=12730 + [103] = https://curl.se/bug/?i=12754 + [104] = https://curl.se/mail/lib-2024-01/0049.html + [105] = https://curl.se/bug/?i=12667 + [106] = https://curl.se/bug/?i=12643 + [107] = https://curl.se/bug/?i=12651 + [108] = https://curl.se/bug/?i=12652 + [109] = https://curl.se/bug/?i=12661 + [110] = https://curl.se/bug/?i=12734 + [111] = https://curl.se/bug/?i=12812 + [112] = https://curl.se/bug/?i=12808 + [113] = https://curl.se/bug/?i=12742 + [114] = https://curl.se/bug/?i=12815 + [115] = https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65839 + [116] = https://curl.se/bug/?i=12727 + [117] = https://curl.se/bug/?i=12720 + [119] = https://curl.se/bug/?i=12803 + [120] = https://curl.se/bug/?i=12726 + [121] = https://curl.se/bug/?i=12645 + [122] = https://curl.se/bug/?i=12713 + [123] = https://curl.se/bug/?i=12707 + [124] = https://curl.se/bug/?i=12711 + [125] = https://curl.se/bug/?i=12710 + [126] = https://curl.se/bug/?i=12704 + [127] = https://curl.se/bug/?i=12703 + [128] = https://curl.se/bug/?i=12709 + [129] = https://curl.se/bug/?i=12701 + [130] = https://curl.se/bug/?i=12700 + [131] = https://curl.se/bug/?i=12695 + [132] = https://curl.se/bug/?i=12804 + [133] = https://curl.se/bug/?i=12697 + [134] = https://curl.se/bug/?i=12691 + [136] = https://curl.se/bug/?i=12693 + [137] = https://curl.se/bug/?i=12480 + [138] = https://curl.se/bug/?i=12789 + [139] = https://curl.se/bug/?i=12801 + [140] = https://curl.se/bug/?i=12802 + [142] = https://curl.se/bug/?i=10259 + [143] = https://curl.se/bug/?i=12788 + [144] = https://curl.se/bug/?i=12797 + [146] = https://curl.se/bug/?i=12794 + [148] = https://curl.se/bug/?i=12792 + [149] = https://curl.se/bug/?i=12793 + [150] = https://curl.se/bug/?i=12791 + [151] = https://curl.se/bug/?i=12787 + [154] = https://curl.se/bug/?i=12784 + [155] = https://curl.se/bug/?i=12724 + [156] = https://curl.se/bug/?i=12785 + [157] = https://curl.se/bug/?i=12765 + [158] = https://curl.se/bug/?i=12778 + [159] = https://curl.se/bug/?i=12757 + [161] = https://curl.se/bug/?i=12773 + [162] = https://curl.se/bug/?i=12775 + [163] = https://curl.se/bug/?i=12768 + [164] = https://curl.se/bug/?i=12764 + [166] = https://curl.se/bug/?i=12759 diff --git a/acinclude.m4 b/acinclude.m4 index ac026e39d..a44ae350e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -156,7 +156,6 @@ AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [ #endif]) AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl AC_BEFORE([$0], [CURL_CONFIGURE_REENTRANT])dnl - AC_BEFORE([$0], [CURL_CONFIGURE_PULL_SYS_POLL])dnl AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)]) AC_EGREP_CPP([yes_this_is_aix],[ #ifdef _AIX @@ -171,144 +170,28 @@ AC_DEFUN([CURL_CHECK_AIX_ALL_SOURCE], [ ]) -dnl CURL_CHECK_HEADER_WINDOWS -dnl ------------------------------------------------- -dnl Check for compilable and valid windows.h header - -AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [ - AC_CACHE_CHECK([for windows.h], [curl_cv_header_windows_h], [ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#undef inline -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include - ]],[[ -#if defined(__CYGWIN__) || defined(__CEGCC__) - HAVE_WINDOWS_H shall not be defined. -#else - int dummy=2*WINVER; -#endif - ]]) - ],[ - curl_cv_header_windows_h="yes" - ],[ - curl_cv_header_windows_h="no" - ]) - ]) - case "$curl_cv_header_windows_h" in - yes) - AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1, - [Define to 1 if you have the windows.h header file.]) - ;; - esac -]) - - dnl CURL_CHECK_NATIVE_WINDOWS dnl ------------------------------------------------- dnl Check if building a native Windows target AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl AC_CACHE_CHECK([whether build target is a native Windows one], [curl_cv_native_windows], [ - if test "$curl_cv_header_windows_h" = "no"; then - curl_cv_native_windows="no" - else - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - ]],[[ -#if defined(__MINGW32__) || defined(__MINGW32CE__) || \ - (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))) - int dummy=1; -#else - Not a native Windows build target. -#endif - ]]) - ],[ - curl_cv_native_windows="yes" - ],[ - curl_cv_native_windows="no" - ]) - fi - ]) - AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes) -]) - - -dnl CURL_CHECK_HEADER_WINSOCK2 -dnl ------------------------------------------------- -dnl Check for compilable and valid winsock2.h header - -AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl - AC_CACHE_CHECK([for winsock2.h], [curl_cv_header_winsock2_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ -#undef inline -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#include ]],[[ -#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) - HAVE_WINSOCK2_H shall not be defined. +#ifdef _WIN32 + int dummy=1; #else - int dummy=2*IPPROTO_ESP; + Not a native Windows build target. #endif ]]) ],[ - curl_cv_header_winsock2_h="yes" + curl_cv_native_windows="yes" ],[ - curl_cv_header_winsock2_h="no" - ]) - ]) - case "$curl_cv_header_winsock2_h" in - yes) - AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, - [Define to 1 if you have the winsock2.h header file.]) - ;; - esac -]) - - -dnl CURL_CHECK_HEADER_WS2TCPIP -dnl ------------------------------------------------- -dnl Check for compilable and valid ws2tcpip.h header - -AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl - AC_CACHE_CHECK([for ws2tcpip.h], [curl_cv_header_ws2tcpip_h], [ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#undef inline -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#include -#include - ]],[[ -#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) - HAVE_WS2TCPIP_H shall not be defined. -#else - int dummy=2*IP_PKTINFO; -#endif - ]]) - ],[ - curl_cv_header_ws2tcpip_h="yes" - ],[ - curl_cv_header_ws2tcpip_h="no" + curl_cv_native_windows="no" ]) ]) - case "$curl_cv_header_ws2tcpip_h" in - yes) - AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1, - [Define to 1 if you have the ws2tcpip.h header file.]) - ;; - esac + AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes) ]) @@ -318,12 +201,12 @@ dnl Check for compilable and valid lber.h header, dnl and check if it is needed even with ldap.h AC_DEFUN([CURL_CHECK_HEADER_LBER], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_CACHE_CHECK([for lber.h], [curl_cv_header_lber_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -355,7 +238,7 @@ AC_DEFUN([CURL_CHECK_HEADER_LBER], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -403,7 +286,7 @@ AC_DEFUN([CURL_CHECK_HEADER_LDAP], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -449,7 +332,7 @@ AC_DEFUN([CURL_CHECK_HEADER_LDAP_SSL], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -534,7 +417,7 @@ AC_DEFUN([CURL_CHECK_LIBS_WINLDAP], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -632,7 +515,7 @@ AC_DEFUN([CURL_CHECK_LIBS_LDAP], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -701,14 +584,11 @@ AC_DEFUN([TYPE_SOCKADDR_STORAGE], [if struct sockaddr_storage is defined]), , [ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -731,7 +611,7 @@ dnl ------------------------------------------------- dnl Test if the socket recv() function is available, AC_DEFUN([CURL_CHECK_FUNC_RECV], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl AC_CHECK_HEADERS(sys/types.h sys/socket.h) # @@ -739,14 +619,11 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else $curl_includes_bsdsocket #ifdef HAVE_SYS_TYPES_H @@ -782,7 +659,7 @@ dnl ------------------------------------------------- dnl Test if the socket send() function is available, AC_DEFUN([CURL_CHECK_FUNC_SEND], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl AC_CHECK_HEADERS(sys/types.h sys/socket.h) # @@ -790,14 +667,11 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else $curl_includes_bsdsocket #ifdef HAVE_SYS_TYPES_H @@ -837,14 +711,11 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -876,21 +747,18 @@ dnl ------------------------------------------------- dnl Check for timeval struct AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h) AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include #endif -#include -#endif #ifdef HAVE_SYS_TYPES_H #include #endif @@ -937,14 +805,11 @@ AC_DEFUN([TYPE_IN_ADDR_T], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -979,14 +844,11 @@ AC_DEFUN([TYPE_IN_ADDR_T], [ esac ],[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -1197,7 +1059,7 @@ AC_DEFUN([CURL_CHECK_LIBS_CONNECT], [ AC_LANG_PROGRAM([[ $curl_includes_winsock2 $curl_includes_bsdsocket - #if !defined(HAVE_WINDOWS_H) && !defined(HAVE_PROTO_BSDSOCKET_H) + #if !defined(_WIN32) && !defined(HAVE_PROTO_BSDSOCKET_H) int connect(int, void*, int); #endif ]],[[ @@ -1246,40 +1108,6 @@ cat >>confdefs.h <<_EOF _EOF ]) -dnl CURL_CONFIGURE_PULL_SYS_POLL -dnl ------------------------------------------------- -dnl The need for the sys/poll.h inclusion arises mainly to properly -dnl interface AIX systems which define macros 'events' and 'revents'. - -AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [ - AC_REQUIRE([CURL_INCLUDES_POLL])dnl - # - tst_poll_events_macro_defined="unknown" - # - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - $curl_includes_poll - ]],[[ -#if defined(events) || defined(revents) - return 0; -#else - force compilation error -#endif - ]]) - ],[ - tst_poll_events_macro_defined="yes" - ],[ - tst_poll_events_macro_defined="no" - ]) - # - if test "$tst_poll_events_macro_defined" = "yes"; then - if test "x$ac_cv_header_sys_poll_h" = "xyes"; then - CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_POLL_H]) - fi - fi - # -]) - dnl CURL_CHECK_FUNC_SELECT dnl ------------------------------------------------- @@ -1294,15 +1122,12 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #undef inline -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include #endif -#include -#endif #ifdef HAVE_SYS_TYPES_H #include #endif @@ -1310,7 +1135,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [ #include #endif #include -#ifndef HAVE_WINDOWS_H +#ifndef _WIN32 #ifdef HAVE_SYS_SELECT_H #include #elif defined(HAVE_UNISTD_H) @@ -1547,17 +1372,15 @@ dnl ------------------------------------------------- dnl Check if curl's WIN32 large file will be used AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_MSG_CHECKING([whether build target supports WIN32 file API]) curl_win32_file_api="no" - if test "$curl_cv_header_windows_h" = "yes"; then + if test "$curl_cv_native_windows" = "yes"; then if test x"$enable_largefile" != "xno"; then AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ ]],[[ -#if !defined(_WIN32_WCE) && \ - (defined(__MINGW32__) || \ - (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))) +#if !defined(_WIN32_WCE) && (defined(__MINGW32__) || defined(_MSC_VER)) int dummy=1; #else WIN32 large file API not supported. @@ -1606,10 +1429,10 @@ dnl ------------------------------------------------- dnl Check if curl's WIN32 crypto lib can be used AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [ - AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl + AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_MSG_CHECKING([whether build target supports WIN32 crypto API]) curl_win32_crypto_api="no" - if test "$curl_cv_header_windows_h" = "yes"; then + if test "$curl_cv_native_windows" = "yes"; then AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline diff --git a/appveyor.sh b/appveyor.sh new file mode 100644 index 000000000..87c9d572a --- /dev/null +++ b/appveyor.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +# shellcheck disable=SC3040,SC2039 +set -eux; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail + +# build + +if [ "${APPVEYOR_BUILD_WORKER_IMAGE}" = 'Visual Studio 2022' ]; then + openssl_root_win='C:/OpenSSL-v30-Win64' +else + openssl_root_win='C:/OpenSSL-v111-Win64' +fi +openssl_root="$(cygpath -u "${openssl_root_win}")" + +if [ "${BUILD_SYSTEM}" = 'CMake' ]; then + options='' + [[ "${TARGET:-}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture' + [ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}" + [ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}" + [ "${PRJ_CFG}" = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=' + [ "${PRJ_CFG}" = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=' + [[ "${PRJ_GEN}" = *'Visual Studio'* ]] && options+=' -DCMAKE_VS_GLOBALS=TrackFileAccess=false' + # Fails to run without this run due to missing MSVCR90.dll + [ "${PRJ_GEN}" = 'Visual Studio 9 2008' ] && options+=' -DCURL_STATIC_CRT=ON' + # shellcheck disable=SC2086 + cmake -B _bld "-G${PRJ_GEN}" ${TARGET:-} ${options} \ + "-DCURL_USE_OPENSSL=${OPENSSL}" \ + "-DCURL_USE_SCHANNEL=${SCHANNEL}" \ + "-DHTTP_ONLY=${HTTP_ONLY}" \ + "-DBUILD_SHARED_LIBS=${SHARED}" \ + "-DBUILD_TESTING=${TESTING}" \ + "-DENABLE_WEBSOCKETS=${WEBSOCKETS:-}" \ + "-DCMAKE_UNITY_BUILD=${UNITY}" \ + '-DCURL_WERROR=ON' \ + "-DENABLE_DEBUG=${DEBUG}" \ + "-DENABLE_UNICODE=${ENABLE_UNICODE}" \ + '-DCMAKE_INSTALL_PREFIX=C:/CURL' \ + "-DCMAKE_BUILD_TYPE=${PRJ_CFG}" + # shellcheck disable=SC2086 + cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --clean-first -- ${BUILD_OPT:-} + if [ "${SHARED}" = 'ON' ]; then + cp -f -p _bld/lib/*.dll _bld/src/ + fi + if [ "${OPENSSL}" = 'ON' ]; then + cp -f -p "${openssl_root}"/*.dll _bld/src/ + fi + curl='_bld/src/curl.exe' +elif [ "${BUILD_SYSTEM}" = 'VisualStudioSolution' ]; then + ( + cd projects + ./generate.bat "${VC_VERSION}" + msbuild.exe -maxcpucount "-property:Configuration=${PRJ_CFG}" "Windows/${VC_VERSION}/curl-all.sln" + ) + curl="build/Win32/${VC_VERSION}/${PRJ_CFG}/curld.exe" +elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2015' ]; then + ./buildconf.bat + ( + cd winbuild + cat << EOF > _make.bat + call "C:/Program Files/Microsoft SDKs/Windows/v7.1/Bin/SetEnv.cmd" /x64 + call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" x86_amd64 + nmake -f Makefile.vc mode=dll VC=14 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE} +EOF + ./_make.bat + rm _make.bat + ) + curl="builds/libcurl-vc14-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" +elif [ "${BUILD_SYSTEM}" = 'winbuild_vs2017' ]; then + ./buildconf.bat + ( + cd winbuild + cat << EOF > _make.bat + call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat" + nmake -f Makefile.vc mode=dll VC=14.10 "SSL_PATH=${openssl_root_win}" WITH_SSL=dll MACHINE=x64 DEBUG=${DEBUG} ENABLE_UNICODE=${ENABLE_UNICODE} +EOF + ./_make.bat + rm _make.bat + ) + curl="builds/libcurl-vc14.10-x64-${PATHPART}-dll-ssl-dll-ipv6-sspi/bin/curl.exe" +elif [ "${BUILD_SYSTEM}" = 'autotools' ]; then + autoreconf -fi + ( + mkdir _bld + cd _bld + # shellcheck disable=SC2086 + ../configure ${CONFIG_ARGS:-} + make -j2 V=1 + make -j2 V=1 examples + cd tests + make -j2 V=1 + ) + curl='_bld/src/curl.exe' +fi + +find . -name '*.exe' -o -name '*.dll' +if [ -z "${SKIP_RUN:-}" ]; then + "${curl}" --version +else + echo "Skip running curl.exe. Reason: ${SKIP_RUN}" +fi + +if false; then + for log in CMakeFiles/CMakeConfigureLog.yaml CMakeFiles/CMakeOutput.log CMakeFiles/CMakeError.log; do + [ -r "_bld/${log}" ] && cat "_bld/${log}" + done +fi + +if [ "${TESTING}" = 'ON' ] && [ "${BUILD_SYSTEM}" = 'CMake' ]; then + cmake --build _bld --config "${PRJ_CFG}" --parallel 2 --target testdeps +fi + +# test + +if [ "${TESTING}" = 'ON' ]; then + export TFLAGS='' + if [ -x "$(cygpath -u "${WINDIR}/System32/curl.exe")" ]; then + TFLAGS+=" -ac $(cygpath -u "${WINDIR}/System32/curl.exe")" + elif [ -x "$(cygpath -u "C:/msys64/usr/bin/curl.exe")" ]; then + TFLAGS+=" -ac $(cygpath -u "C:/msys64/usr/bin/curl.exe")" + fi + TFLAGS+=" ${DISABLED_TESTS:-}" + if [ "${BUILD_SYSTEM}" = 'CMake' ]; then + ls _bld/lib/*.dll >/dev/null 2>&1 && cp -f -p _bld/lib/*.dll _bld/tests/libtest/ + cmake --build _bld --config "${PRJ_CFG}" --target test-ci + elif [ "${BUILD_SYSTEM}" = 'autotools' ]; then + ( + cd _bld + make -j2 V=1 test-ci + ) + else + ( + TFLAGS="-a -p !flaky -r -rm ${TFLAGS}" + cd _bld/tests + ./runtests.pl + ) + fi +fi diff --git a/configure.ac b/configure.ac index d9b396376..be66be9e9 100644 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,7 @@ curl_headers_msg="enabled (--disable-headers-api)" ssl_backends= curl_h1_msg="enabled (internal)" curl_h2_msg="no (--with-nghttp2)" - curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-msh3)" + curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic, --with-msh3)" enable_altsvc="yes" hsts="yes" @@ -503,6 +503,7 @@ dnl platform/compiler/architecture specific checks/flags dnl ********************************************************************** CURL_CHECK_COMPILER +CURL_CHECK_NATIVE_WINDOWS CURL_SET_COMPILER_BASIC_OPTS CURL_SET_COMPILER_DEBUG_OPTS CURL_SET_COMPILER_OPTIMIZE_OPTS @@ -583,25 +584,6 @@ dnl ********************************************************************** dnl Compilation based checks should not be done before this point. dnl ********************************************************************** -dnl ********************************************************************** -dnl Make sure that our checks for headers windows.h winsock2.h -dnl and ws2tcpip.h take precedence over any other further checks which -dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for -dnl this specific header files. And do them before its results are used. -dnl ********************************************************************** - -CURL_CHECK_HEADER_WINDOWS -CURL_CHECK_NATIVE_WINDOWS -case X-"$curl_cv_native_windows" in - X-yes) - CURL_CHECK_HEADER_WINSOCK2 - CURL_CHECK_HEADER_WS2TCPIP - ;; - *) - curl_cv_header_winsock2_h="no" - curl_cv_header_ws2tcpip_h="no" - ;; -esac CURL_CHECK_WIN32_LARGEFILE CURL_CHECK_WIN32_CRYPTO @@ -1130,24 +1112,19 @@ fi if test "$HAVE_GETHOSTBYNAME" != "1" then dnl This is for winsock systems - if test "$curl_cv_header_windows_h" = "yes"; then - if test "$curl_cv_header_winsock2_h" = "yes"; then - winsock_LIB="-lws2_32" - fi + if test "$curl_cv_native_windows" = "yes"; then + winsock_LIB="-lws2_32" if test ! -z "$winsock_LIB"; then my_ac_save_LIBS=$LIBS LIBS="$winsock_LIB $LIBS" AC_MSG_CHECKING([for gethostbyname in $winsock_LIB]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifdef HAVE_WINSOCK2_H #include -#endif -#include #endif ]],[[ gethostbyname("localhost"); @@ -1668,7 +1645,7 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]), AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* are AF_INET6 and sockaddr_in6 available? */ #include -#ifdef HAVE_WINSOCK2_H +#ifdef _WIN32 #include #include #else @@ -1678,15 +1655,12 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]), # include #endif #endif -#include /* for exit() */ -main() + +int main(void) { struct sockaddr_in6 s; (void)s; - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); + return socket(AF_INET6, SOCK_STREAM, 0) < 0; } ]]) ], @@ -1707,7 +1681,7 @@ if test "$ipv6" = yes; then AC_MSG_CHECKING([if struct sockaddr_in6 has sin6_scope_id member]) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #include -#ifdef HAVE_WINSOCK2_H +#ifdef _WIN32 #include #include #else @@ -1850,10 +1824,7 @@ AC_INCLUDES_DEFAULT if test "x$not_mit" = "x1"; then dnl MIT not found, check for Heimdal AC_CHECK_HEADER(gssapi.h, - [ - dnl found - AC_DEFINE(HAVE_GSSHEIMDAL, 1, [if you have Heimdal]) - ], + [], [ dnl no header found, disabling GSS want_gss=no @@ -1862,7 +1833,6 @@ AC_INCLUDES_DEFAULT ) else dnl MIT found - AC_DEFINE(HAVE_GSSMIT, 1, [if you have MIT Kerberos]) dnl check if we have a really old MIT Kerberos version (<= 1.2) AC_MSG_CHECKING([if GSS-API headers declare GSS_C_NT_HOSTBASED_SERVICE]) AC_COMPILE_IFELSE([ @@ -2084,17 +2054,16 @@ dnl ********************************************************************** AC_ARG_WITH(libpsl, AS_HELP_STRING([--without-libpsl], - [disable support for libpsl cookie checking]), + [disable support for libpsl]), with_libpsl=$withval, with_libpsl=yes) +curl_psl_msg="no (libpsl disabled)" if test $with_libpsl != "no"; then AC_SEARCH_LIBS(psl_builtin, psl, [curl_psl_msg="enabled"; AC_DEFINE([USE_LIBPSL], [1], [PSL support enabled]) ], - [curl_psl_msg="no (libpsl not found)"; - AC_MSG_WARN([libpsl was not found]) - ] + [AC_MSG_ERROR([libpsl was not found]) ] ) fi AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "enabled"]) @@ -2807,6 +2776,11 @@ esac curl_tcp2_msg="no (--with-ngtcp2)" if test X"$want_tcp2" != Xno; then + + if test "$QUIC_ENABLED" != "yes"; then + AC_MSG_ERROR([the detected TLS library does not support QUIC, making --with-ngtcp2 a no-no]) + fi + dnl backup the pre-ngtcp2 variables CLEANLDFLAGS="$LDFLAGS" CLEANCPPFLAGS="$CPPFLAGS" @@ -2862,7 +2836,7 @@ if test X"$want_tcp2" != Xno; then fi -if test "x$NGTCP2_ENABLED" = "x1" -a "x$OPENSSL_ENABLED" = "x1"; then +if test "x$NGTCP2_ENABLED" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BORINGSSL" != "x1"; then dnl backup the pre-ngtcp2_crypto_quictls variables CLEANLDFLAGS="$LDFLAGS" CLEANCPPFLAGS="$CPPFLAGS" @@ -2917,6 +2891,61 @@ if test "x$NGTCP2_ENABLED" = "x1" -a "x$OPENSSL_ENABLED" = "x1"; then fi fi +if test "x$NGTCP2_ENABLED" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BORINGSSL" = "x1"; then + dnl backup the pre-ngtcp2_crypto_boringssl variables + CLEANLDFLAGS="$LDFLAGS" + CLEANCPPFLAGS="$CPPFLAGS" + CLEANLIBS="$LIBS" + + CURL_CHECK_PKGCONFIG(libngtcp2_crypto_boringssl, $want_tcp2_path) + + if test "$PKGCONFIG" != "no" ; then + LIB_NGTCP2_CRYPTO_BORINGSSL=`CURL_EXPORT_PCDIR([$want_tcp2_path]) + $PKGCONFIG --libs-only-l libngtcp2_crypto_boringssl` + AC_MSG_NOTICE([-l is $LIB_NGTCP2_CRYPTO_BORINGSSL]) + + CPP_NGTCP2_CRYPTO_BORINGSSL=`CURL_EXPORT_PCDIR([$want_tcp2_path]) dnl + $PKGCONFIG --cflags-only-I libngtcp2_crypto_boringssl` + AC_MSG_NOTICE([-I is $CPP_NGTCP2_CRYPTO_BORINGSSL]) + + LD_NGTCP2_CRYPTO_BORINGSSL=`CURL_EXPORT_PCDIR([$want_tcp2_path]) + $PKGCONFIG --libs-only-L libngtcp2_crypto_boringssl` + AC_MSG_NOTICE([-L is $LD_NGTCP2_CRYPTO_BORINGSSL]) + + LDFLAGS="$LDFLAGS $LD_NGTCP2_CRYPTO_BORINGSSL" + CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_BORINGSSL" + LIBS="$LIB_NGTCP2_CRYPTO_BORINGSSL $LIBS" + + if test "x$cross_compiling" != "xyes"; then + DIR_NGTCP2_CRYPTO_BORINGSSL=`echo $LD_NGTCP2_CRYPTO_BORINGSSL | $SED -e 's/^-L//'` + fi + AC_CHECK_LIB(ngtcp2_crypto_boringssl, ngtcp2_crypto_recv_client_initial_cb, + [ + AC_CHECK_HEADERS(ngtcp2/ngtcp2_crypto.h, + NGTCP2_ENABLED=1 + AC_DEFINE(USE_NGTCP2_CRYPTO_BORINGSSL, 1, [if ngtcp2_crypto_boringssl is in use]) + AC_SUBST(USE_NGTCP2_CRYPTO_BORINGSSL, [1]) + CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_NGTCP2_CRYPTO_BORINGSSL" + export CURL_LIBRARY_PATH + AC_MSG_NOTICE([Added $DIR_NGTCP2_CRYPTO_BORINGSSL to CURL_LIBRARY_PATH]) + ) + ], + dnl not found, revert back to clean variables + LDFLAGS=$CLEANLDFLAGS + CPPFLAGS=$CLEANCPPFLAGS + LIBS=$CLEANLIBS + ) + + else + dnl no ngtcp2_crypto_boringssl pkg-config found, deal with it + if test X"$want_tcp2" != Xdefault; then + dnl To avoid link errors, we do not allow --with-ngtcp2 without + dnl a pkgconfig file + AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_boringssl pkg-config file.]) + fi + fi +fi + if test "x$NGTCP2_ENABLED" = "x1" -a "x$GNUTLS_ENABLED" = "x1"; then dnl backup the pre-ngtcp2_crypto_gnutls variables CLEANLDFLAGS="$LDFLAGS" @@ -3027,14 +3056,53 @@ if test "x$NGTCP2_ENABLED" = "x1" -a "x$WOLFSSL_ENABLED" = "x1"; then fi fi +dnl ********************************************************************** +dnl Check for OpenSSL QUIC +dnl ********************************************************************** + +OPT_OPENSSL_QUIC="no" + +if test "x$disable_http" = "xyes" -o "x$OPENSSL_ENABLED" != "x1"; then + # without HTTP or without openssl, no use + OPT_OPENSSL_QUIC="no" +fi + +AC_ARG_WITH(openssl-quic, +AS_HELP_STRING([--with-openssl-quic],[Enable OpenSSL QUIC usage]) +AS_HELP_STRING([--without-openssl-quic],[Disable OpenSSL QUIC usage]), + [OPT_OPENSSL_QUIC=$withval]) +case "$OPT_OPENSSL_QUIC" in + no) + dnl --without-openssl-quic option used + want_openssl_quic="no" + ;; + yes) + dnl --with-openssl-quic option used + want_openssl_quic="yes" + ;; +esac + +curl_openssl_quic_msg="no (--with-openssl-quic)" +if test "x$want_openssl_quic" = "xyes"; then + + if test "$NGTCP2_ENABLED" = 1; then + AC_MSG_ERROR([--with-openssl-quic and --with-ngtcp2 are mutually exclusive]) + fi + if test "$HAVE_OPENSSL_QUIC" != 1; then + AC_MSG_ERROR([--with-openssl-quic requires quic support in OpenSSL]) + fi + AC_DEFINE(USE_OPENSSL_QUIC, 1, [if openssl QUIC is in use]) + AC_SUBST(USE_OPENSSL_QUIC, [1]) +fi + dnl ********************************************************************** dnl Check for nghttp3 (HTTP/3 with ngtcp2) dnl ********************************************************************** OPT_NGHTTP3="yes" -if test "x$NGTCP2_ENABLED" = "x"; then - # without ngtcp2, nghttp3 is of no use for us +if test "x$USE_NGTCP2" = "x" -a "$USE_OPENSSL_QUIC" = "x"; then + # without ngtcp2 or openssl quic, nghttp3 is of no use for us OPT_NGHTTP3="no" fi @@ -3061,6 +3129,7 @@ esac curl_http3_msg="no (--with-nghttp3)" if test X"$want_nghttp3" != Xno; then + dnl backup the pre-nghttp3 variables CLEANLDFLAGS="$LDFLAGS" CLEANCPPFLAGS="$CPPFLAGS" @@ -3091,8 +3160,6 @@ if test X"$want_nghttp3" != Xno; then AC_CHECK_LIB(nghttp3, nghttp3_conn_client_new_versioned, [ AC_CHECK_HEADERS(nghttp3/nghttp3.h, - curl_h3_msg="enabled (ngtcp2 + nghttp3)" - NGHTTP3_ENABLED=1 AC_DEFINE(USE_NGHTTP3, 1, [if nghttp3 is in use]) AC_SUBST(USE_NGHTTP3, [1]) CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_NGHTTP3" @@ -3117,6 +3184,29 @@ if test X"$want_nghttp3" != Xno; then fi +dnl ********************************************************************** +dnl Check for ngtcp2 and nghttp3 (HTTP/3 with ngtcp2 + nghttp3) +dnl ********************************************************************** + +if test "x$NGTCP2_ENABLED" = "x1" -a "x$USE_NGHTTP3" = "x1"; then + AC_DEFINE(USE_NGTCP2_H3, 1, [if ngtcp2 + nghttp3 is in use]) + AC_SUBST(USE_NGTCP2_H3, [1]) + AC_MSG_NOTICE([HTTP3 support is experimental]) + curl_h3_msg="enabled (ngtcp2 + nghttp3)" +fi + +dnl ********************************************************************** +dnl Check for OpenSSL and nghttp3 (HTTP/3 with nghttp3 using OpenSSL QUIC) +dnl ********************************************************************** + +if test "x$USE_OPENSSL_QUIC" = "x1" -a "x$USE_NGHTTP3" = "x1"; then + experimental="$experimental HTTP3" + AC_DEFINE(USE_OPENSSL_H3, 1, [if openssl quic + nghttp3 is in use]) + AC_SUBST(USE_OPENSSL_H3, [1]) + AC_MSG_NOTICE([HTTP3 support is experimental]) + curl_h3_msg="enabled (openssl + nghttp3)" +fi + dnl ********************************************************************** dnl Check for quiche (QUIC) dnl ********************************************************************** @@ -3151,6 +3241,10 @@ esac if test X"$want_quiche" != Xno; then + if test "$QUIC_ENABLED" != "yes"; then + AC_MSG_ERROR([the detected TLS library does not support QUIC, making --with-quiche a no-no]) + fi + if test "$NGHTTP3_ENABLED" = 1; then AC_MSG_ERROR([--with-quiche and --with-ngtcp2 are mutually exclusive]) fi @@ -3249,9 +3343,22 @@ esac if test X"$want_msh3" != Xno; then + dnl msh3 on non-Windows needs an OpenSSL with the QUIC API + if test "$curl_cv_native_windows" != "yes"; then + if test "$QUIC_ENABLED" != "yes"; then + AC_MSG_ERROR([the detected TLS library does not support QUIC, making --with-msh3 a no-no]) + fi + if test "$OPENSSL_ENABLED" != "1"; then + AC_MSG_ERROR([msh3 requires OpenSSL]) + fi + fi + if test "$NGHTTP3_ENABLED" = 1; then AC_MSG_ERROR([--with-msh3 and --with-ngtcp2 are mutually exclusive]) fi + if test "$QUICHE_ENABLED" = 1; then + AC_MSG_ERROR([--with-msh3 and --with-quiche are mutually exclusive]) + fi dnl backup the pre-msh3 variables CLEANLDFLAGS="$LDFLAGS" @@ -3473,6 +3580,12 @@ AC_CHECK_TYPE(sa_family_t, AC_DEFINE(CURL_SA_FAMILY_T, ADDRESS_FAMILY, [IP address type in sockaddr]), AC_DEFINE(CURL_SA_FAMILY_T, unsigned short, [IP address type in sockaddr]), [ +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#endif #ifdef HAVE_SYS_SOCKET_H #include #endif @@ -3516,8 +3629,6 @@ CURL_RUN_IFELSE( AC_MSG_RESULT([no]) ]) -CURL_CONFIGURE_PULL_SYS_POLL - TYPE_IN_ADDR_T TYPE_SOCKADDR_STORAGE @@ -4578,8 +4689,11 @@ if test "x$USE_NGHTTP2" = "x1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP2" fi -if test "x$USE_NGTCP2" = "x1" -o "x$USE_QUICHE" = "x1" \ - -o "x$USE_MSH3" = "x1"; then +if test "x$USE_NGTCP2_H3" = "x1" -o "x$USE_QUICHE" = "x1" \ + -o "x$USE_OPENSSL_H3" = "x1" -o "x$USE_MSH3" = "x1"; then + if test "x$CURL_WITH_MULTI_SSL" = "x1"; then + AC_MSG_ERROR([MultiSSL cannot be enabled with HTTP/3 and vice versa]) + fi SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP3" fi @@ -4653,7 +4767,7 @@ AC_SUBST(SUPPORT_FEATURES) dnl For supported protocols in pkg-config file if test "x$CURL_DISABLE_HTTP" != "x1"; then - SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP" + SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP IPFS IPNS" if test "x$SSL_ENABLED" = "x1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS" fi diff --git a/docs/.gitignore b/docs/.gitignore index 8d0bfb31b..a087be744 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -2,7 +2,5 @@ # # SPDX-License-Identifier: curl -*.html -*.pdf -curl.1 -*.1.dist +*.1 +*.3 diff --git a/docs/ALTSVC.md b/docs/ALTSVC.md index b9117e4d4..18d2d2ad9 100644 --- a/docs/ALTSVC.md +++ b/docs/ALTSVC.md @@ -24,16 +24,16 @@ space separated fields. ## Fields 1. The ALPN id for the source origin -2. The host name for the source origin +2. The hostname for the source origin 3. The port number for the source origin 4. The ALPN id for the destination host -5. The host name for the destination host +5. The hostname for the destination host 6. The host number for the destination host 7. The expiration date and time of this entry within double quotes. The date format is "YYYYMMDD HH:MM:SS" and the time zone is GMT. 8. Boolean (1 or 0) if "persist" was set for this entry 9. Integer priority value (not currently used) -If the host name is an IPv6 numerical address, it is stored with brackets such +If the hostname is an IPv6 numerical address, it is stored with brackets such as `[::1]`. # TODO diff --git a/docs/BUFQ.md b/docs/BUFQ.md index 5ff9e28b8..1a95a884c 100644 --- a/docs/BUFQ.md +++ b/docs/BUFQ.md @@ -115,11 +115,18 @@ Note that a `bufq` length and it being "full" are only loosely related. A simple * read 1 bytes from it, it will still report "full" * read 999 more bytes from it, and it will no longer be "full" -The reason for this is that full really means: *bufq uses max_chunks and the last one cannot be written to*. - -So when you read 1 byte from the head chunk in the example above, the head still hold 999 unread bytes. Only when those are also read, can the head chunk be removed and a new tail be added. - -There is another variation to this. If you initialized a `bufq` with option `BUFQ_OPT_SOFT_LIMIT`, it will allow writes **beyond** the `max_chunks`. It will report **full**, but one can **still** write. This option is necessary, if partial writes need to be avoided. But it means that you will need other checks to keep the `bufq` from growing ever larger and larger. +The reason for this is that full really means: *bufq uses max_chunks and the +last one cannot be written to*. + +When you read 1 byte from the head chunk in the example above, the head still +hold 999 unread bytes. Only when those are also read, can the head chunk be +removed and a new tail be added. + +There is another variation to this. If you initialized a `bufq` with option +`BUFQ_OPT_SOFT_LIMIT`, it will allow writes **beyond** the `max_chunks`. It +will report **full**, but one can **still** write. This option is necessary, +if partial writes need to be avoided. It means that you will need other checks +to keep the `bufq` from growing ever larger and larger. ## pools diff --git a/docs/BUGS.md b/docs/BUGS.md index 2a8c56fe6..7333baafe 100644 --- a/docs/BUGS.md +++ b/docs/BUGS.md @@ -5,7 +5,7 @@ Curl and libcurl keep being developed. Adding features and changing code means that bugs will sneak in, no matter how hard we try to keep them out. - Of course there are lots of bugs left. And lots of misfeatures. + Of course there are lots of bugs left. Not to mention misfeatures. To help us make curl the stable and solid product we want it to be, we need bug reports and bug fixes. diff --git a/docs/CIPHERS.md b/docs/CIPHERS.md index 27de94036..f616f4972 100644 --- a/docs/CIPHERS.md +++ b/docs/CIPHERS.md @@ -363,10 +363,10 @@ individual TLS 1.3 cipher suites since Schannel does not support it directly. `TLS_AES_128_CCM_8_SHA256` `TLS_AES_128_CCM_SHA256` -Note if you set TLS 1.3 ciphers without also setting the minimum TLS version to -1.3 then it's possible Schannel may negotiate an earlier TLS version and cipher -suite if your libcurl and OS settings allow it. You can set the minimum TLS -version by using `CURLOPT_SSLVERSION` or `--tlsv1.3`. +Note if you set TLS 1.3 ciphers without also setting the minimum TLS version +to 1.3 then it is possible Schannel may negotiate an earlier TLS version and +cipher suite if your libcurl and OS settings allow it. You can set the minimum +TLS version by using `CURLOPT_SSLVERSION` or `--tlsv1.3`. ## BearSSL diff --git a/docs/CLIENT-WRITERS.md b/docs/CLIENT-WRITERS.md new file mode 100644 index 000000000..7a928826c --- /dev/null +++ b/docs/CLIENT-WRITERS.md @@ -0,0 +1,104 @@ +# curl client writers + +Client writers is a design in the internals of libcurl, not visible in its public API. They were started +in curl v8.5.0. This document describes the concepts, its high level implementation and the motivations. + +## Naming + +`libcurl` operates between clients and servers. A *client* is the application using libcurl, like the command line tool `curl` itself. Data to be uploaded to a server is **read** from the client and **send** to the server, the servers response is **received** by `libcurl` and then **written** to the client. + +With this naming established, client writers are concerned with writing responses from the server to the application. Applications register callbacks via `CURLOPT_WRITEFUNCTION` and `CURLOPT_HEADERFUNCTION` to be invoked by `libcurl` when the response is received. + +## Invoking + +All code in `libcurl` that handles response data is ultimately expected to forward this data via `Curl_client_write()` to the application. The exact prototype of this function is: + +``` +CURLcode Curl_client_write(struct Curl_easy *data, int type, char *buf, size_t blen); +``` +The `type` argument specifies what the bytes in `buf` actually are. The following bits are defined: + +``` +#define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */ +#define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */ +#define CLIENTWRITE_HEADER (1<<2) /* meta information, HEADER */ +#define CLIENTWRITE_STATUS (1<<3) /* a special status HEADER */ +#define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */ +#define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */ +#define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */ +``` + +The main types here are `CLIENTWRITE_BODY` and `CLIENTWRITE_HEADER`. They are +mutually exclusive. The other bits are enhancements to `CLIENTWRITE_HEADER` to +specify what the header is about. They are only used in HTTP and related +protocols (RTSP and WebSocket). + +The implementation of `Curl_client_write()` uses a chain of *client writer* instances to process the call and make sure that the bytes reach the proper application callbacks. This is similar to the design of connection filters: client writers can be chained to process the bytes written through them. The definition is: + +``` +struct Curl_cwtype { + const char *name; + CURLcode (*do_init)(struct Curl_easy *data, + struct Curl_cwriter *writer); + CURLcode (*do_write)(struct Curl_easy *data, + struct Curl_cwriter *writer, int type, + const char *buf, size_t nbytes); + void (*do_close)(struct Curl_easy *data, + struct Curl_cwriter *writer); +}; + +struct Curl_cwriter { + const struct Curl_cwtype *cwt; /* type implementation */ + struct Curl_cwriter *next; /* Downstream writer. */ + Curl_cwriter_phase phase; /* phase at which it operates */ +}; +``` + +`Curl_cwriter` is a writer instance with a `next` pointer to form the chain. It has a type `cwt` which provides the implementation. The main callback is `do_write()` that processes the data and calls then the `next` writer. The others are for setup and tear down. + +## Phases and Ordering + +Since client writers may transform the bytes written through them, the order in which the are called is relevant for the outcome. When a writer is created, one property it gets is the `phase` in which it operates. Writer phases are defined like: + +``` +typedef enum { + CURL_CW_RAW, /* raw data written, before any decoding */ + CURL_CW_TRANSFER_DECODE, /* remove transfer-encodings */ + CURL_CW_PROTOCOL, /* after transfer, but before content decoding */ + CURL_CW_CONTENT_DECODE, /* remove content-encodings */ + CURL_CW_CLIENT /* data written to client */ +} Curl_cwriter_phase; +``` + +If a writer for phase `PROTOCOL` is added to the chain, it is always added *after* any `RAW` or `TRANSFER_DECODE` and *before* any `CONTENT_DECODE` and `CLIENT` phase writer. If there is already a writer for the same phase present, the new writer is inserted just before that one. + +All transfers have a chain of 3 writers by default. A specific protocol handler may alter that by adding additional writers. The 3 standard writers are (name, phase): + +1. `"raw", CURL_CW_RAW `: if the transfer is verbose, it forwards the body data to the debug function. +1. `"download", CURL_CW_PROTOCOL`: checks that protocol limits are kept and updates progress counters. When a download has a known length, it checks that it is not exceeded and errors otherwise. +1. `"client", CURL_CW_CLIENT`: the main work horse. It invokes the application callbacks or writes to the configured file handles. It chops large writes into smaller parts, as documented for `CURLOPT_WRITEFUNCTION`. If also handles *pausing* of transfers when the application callback returns `CURL_WRITEFUNC_PAUSE`. + +With these writers always in place, libcurl's protocol handlers automatically have these implemented. + +## Enhanced Use + +HTTP is the protocol in curl that makes use of the client writer chain by adding writers to it. When the `libcurl` application set `CURLOPT_ACCEPT_ENCODING` (as `curl` does with `--compressed`), the server is offered an `Accept-Encoding` header with the algorithms supported. The server then may choose to send the response body compressed. For example using `gzip` or `brotli` or even both. + +In the server's response, there then will be a `Content-Encoding` header listing the encoding applied. If supported by `libcurl` it will then decompress the content before writing it out to the client. How does it do that? + +The HTTP protocol will add client writers in phase `CURL_CW_CONTENT_DECODE` on seeing such a header. For each encoding listed, it will add the corresponding writer. The response from the server is then passed through `Curl_client_write()` to the writers that decode it. If several encodings had been applied the writer chain decodes them in the proper order. + +When the server provides a `Content-Length` header, that value applies to the *compressed* content. So length checks on the response bytes must happen *before* it gets decoded. That is why this check happens in phase `CURL_CW_PROTOCOL` which always is ordered before writers in phase `CURL_CW_CONTENT_DECODE`. + +What else? + +Well, HTTP servers may also apply a `Transfer-Encoding` to the body of a response. The most well-known one is `chunked`, but algorithms like `gzip` and friends could also be applied. The difference to content encodings is that decoding needs to happen *before* protocol checks, for example on length, are done. + +That is why transfer decoding writers are added for phase `CURL_CW_TRANSFER_DECODE`. Which makes their operation happen *before* phase `CURL_CW_PROTOCOL` where length may be checked. + +## Summary + +By adding the common behavior of all protocols into `Curl_client_write()` we make sure that they do apply everywhere. Protocol handler have less to worry about. Changes to default behavior can be done without affecting handler implementations. + +Having a writer chain as implementation allows protocol handlers with extra needs, like HTTP, to add to this for special behavior. The common way of writing the actual response data stays the same. + diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index dd2c6dc74..9c0b37691 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -22,5 +22,9 @@ # ########################################################################### #add_subdirectory(examples) -add_subdirectory(libcurl) -add_subdirectory(cmdline-opts) +if(BUILD_LIBCURL_DOCS) + add_subdirectory(libcurl) +endif() +if(ENABLE_CURL_MANUAL AND BUILD_CURL_EXE) + add_subdirectory(cmdline-opts) +endif() diff --git a/docs/CODE_STYLE.md b/docs/CODE_STYLE.md index 9cdf0d17e..e6af36093 100644 --- a/docs/CODE_STYLE.md +++ b/docs/CODE_STYLE.md @@ -221,7 +221,7 @@ too long, the statement too hard to read, or due to other style guidelines above. In such a case the statement will span multiple lines. If a continuation line is part of an expression or sub-expression then you -should align on the appropriate column so that it's easy to tell what part of +should align on the appropriate column so that it is easy to tell what part of the statement it is. Operators should not start continuation lines. In other cases follow the 2-space indent guideline. Here are some examples from libcurl: diff --git a/docs/CONNECTION-FILTERS.md b/docs/CONNECTION-FILTERS.md index c4b11dbb0..a145d42c0 100644 --- a/docs/CONNECTION-FILTERS.md +++ b/docs/CONNECTION-FILTERS.md @@ -1,16 +1,26 @@ # curl connection filters -Connection filters is a design in the internals of curl, not visible in its public API. They were added -in curl v7.xx.x. This document describes the concepts, its high level implementation and the motivations. +Connection filters is a design in the internals of curl, not visible in its +public API. They were added in curl v7.87.0. This document describes the +concepts, its high level implementation and the motivations. ## Filters -A "connection filter" is a piece of code that is responsible for handling a range of operations -of curl's connections: reading, writing, waiting on external events, connecting and closing down - to name the most important ones. +A "connection filter" is a piece of code that is responsible for handling a +range of operations of curl's connections: reading, writing, waiting on +external events, connecting and closing down - to name the most important +ones. -The most important feat of connection filters is that they can be stacked on top of each other (or "chained" if you prefer that metaphor). In the common scenario that you want to retrieve a `https:` url with curl, you need 2 basic things to send the request and get the response: a TCP connection, represented by a `socket` and a SSL instance en- and decrypt over that socket. You write your request to the SSL instance, which encrypts and writes that data to the socket, which then sends the bytes over the network. +The most important feat of connection filters is that they can be stacked on +top of each other (or "chained" if you prefer that metaphor). In the common +scenario that you want to retrieve a `https:` URL with curl, you need 2 basic +things to send the request and get the response: a TCP connection, represented +by a `socket` and a SSL instance en- and decrypt over that socket. You write +your request to the SSL instance, which encrypts and writes that data to the +socket, which then sends the bytes over the network. -With connection filters, curl's internal setup will look something like this (cf for connection filter): +With connection filters, curl's internal setup will look something like this +(cf for connection filter): ``` Curl_easy *data connectdata *conn cf-ssl cf-socket @@ -27,7 +37,7 @@ While connection filters all do different things, they look the same from the "o Same is true for filters. Each filter has a pointer to the `next` filter. When SSL has encrypted the data, it does not write to a socket, it writes to the next filter. If that is indeed a socket, or a file, or an HTTP/2 connection is of no concern to the SSL filter. -And this allows the stacking, as in: +This allows stacking, as in: ``` Direct: @@ -110,18 +120,123 @@ The `recv` implementation is equivalent. ## Filter Types -The (currently) existing filter types are: SOCKET, SOCKET-ACCEPT, SSL, HTTP-PROXY and SOCKS-PROXY. Vital to establishing and read/writing a connection. But filters are also a good way to implement tasks for *managing* a connection: +The currently existing filter types (curl 8.5.0) are: -* **Statistics**: a filter that counts the number of bytes sent/received. Place one in front of SOCKET and one higher up and get the number of raw and "easy" bytes transferred. They may track the speed as well, or number of partial writes, etc. -* **Timeout**: enforce timeouts, e.g. fail if a connection cannot be established in a certain amount of time. -* **Progress**: report progress on a connection. -* **Pacing**: limit read/write rates. -* **Testing**: simulate network condition or failures. +* `TCP`, `UDP`, `UNIX`: filters that operate on a socket, providing raw I/O. +* `SOCKET-ACCEPT`: special TCP socket that has a socket that has been `accept()`ed in a `listen()` +* `SSL`: filter that applies TLS en-/decryption and handshake. Manages the underlying TLS backend implementation. +* `HTTP-PROXY`, `H1-PROXY`, `H2-PROXY`: the first manages the connection to an + HTTP proxy server and uses the other depending on which ALPN protocol has + been negotiated. +* `SOCKS-PROXY`: filter for the various SOCKS proxy protocol variations +* `HAPROXY`: filter for the protocol of the same name, providing client IP information to a server. +* `HTTP/2`: filter for handling multiplexed transfers over an HTTP/2 connection +* `HTTP/3`: filter for handling multiplexed transfers over an HTTP/3+QUIC connection +* `HAPPY-EYEBALLS`: meta filter that implements IPv4/IPv6 "happy eyeballing". It creates up to 2 sub-filters that race each other for a connection. +* `SETUP`: meta filter that manages the creation of sub-filter chains for a specific transport (e.g. TCP or QUIC). +* `HTTPS-CONNECT`: meta filter that races a TCP+TLS and a QUIC connection against each other to determine if HTTP/1.1, HTTP/2 or HTTP/3 shall be used for a transfer. -As you see, filters are a good way to add functionality to curl's internal handling of transfers without impact on other code. +Meta filters are combining other filters for a specific purpose, mostly during connection establishment. Other filters like `TCP`, `UDP` and `UNIX` are only to be found at the end of filter chains. SSL filters provide encryption, of course. Protocol filters change the bytes sent and received. -## Easy Filters? +## Filter Flags -Some things that curl needs to manage are not directly tied to a specific connection but the property of the `Curl_easy` handle, e.g. a particular transfer. When using HTTP/2 or HTTP/3, many transfers can use the same connection. If one wants to monitor of the transfer itself or restricting its speed alone, a connection filter is not the right place to do this. +Filter types carry flags that inform what they do. These are (for now): + +* `CF_TYPE_IP_CONNECT`: this filter type talks directly to a server. This does not have to be the server the transfer wants to talk to. For example when a proxy server is used. +* `CF_TYPE_SSL`: this filter type provides encryption. +* `CF_TYPE_MULTIPLEX`: this filter type can manage multiple transfers in parallel. + +Filter types can combine these flags. For example, the HTTP/3 filter types have `CF_TYPE_IP_CONNECT`, `CF_TYPE_SSL` and `CF_TYPE_MULTIPLEX` set. + +Flags are useful to extrapolate properties of a connection. To check if a connection is encrypted, libcurl inspect the filter chain in place, top down, for `CF_TYPE_SSL`. If it finds `CF_TYPE_IP_CONNECT` before any `CF_TYPE_SSL`, the connection is not encrypted. + +For example, `conn1` is for a `http:` request using a tunnel through a HTTP/2 `https:` proxy. `conn2` is a `https:` HTTP/2 connection to the same proxy. `conn3` uses HTTP/3 without proxy. The filter chains would look like this (simplified): + +``` +conn1 --> `HTTP-PROXY` --> `H2-PROXY` --> `SSL` --> `TCP` +flags: `IP_CONNECT` `SSL` `IP_CONNECT` + +conn2 --> `HTTP/2` --> `SSL` --> `HTTP-PROXY` --> `H2-PROXY` --> `SSL` --> `TCP` +flags: `SSL` `IP_CONNECT` `SSL` `IP_CONNECT` + +conn3 --> `HTTP/3` +flags: `SSL|IP_CONNECT` +``` + +Inspecting the filter chains, `conn1` is seen as unencrypted, since it contains an `IP_CONNECT` filter before any `SSL`. `conn2` is clearly encrypted as an `SSL` flagged filter is seen first. `conn3` is also encrypted as the `SSL` flag is checked before the presence of `IP_CONNECT`. + +Similar checks can determine if a connection is multiplexed or not. + +## Filter Tracing + +Filters may make use of special trace macros like `CURL_TRC_CF(data, cf, msg, ...)`. With `data` being the transfer and `cf` being the filter instance. These traces are normally not active and their execution is guarded so that they are cheap to ignore. + +Users of `curl` may activate them by adding the name of the filter type to the +`--trace-config` argument. For example, in order to get more detailed tracing +of an HTTP/2 request, invoke curl with: + +``` +> curl -v --trace-config ids,time,http/2 https://curl.se +``` +Which will give you trace output with time information, transfer+connection ids and details from the `HTTP/2` filter. Filter type names in the trace config are case insensitive. You may use `all` to enable tracing for all filter types. When using `libcurl` you may call `curl_global_trace(config_string)` at the start of your application to enable filter details. + +## Meta Filters + +Meta filters is a catch-all name for filter types that do not change the transfer data in any way but provide other important services to curl. In general, it is possible to do all sorts of silly things with them. One of the commonly used, important things is "eyeballing". + +The `HAPPY-EYEBALLS` filter is involved in the connect phase. Its job is to +try the various IPv4 and IPv6 addresses that are known for a server. If only +one address family is known (or configured), it tries the addresses one after +the other with timeouts calculated from the amount of addresses and the +overall connect timeout. + +When more than one address family is to be tried, it splits the address list into IPv4 and IPv6 and makes parallel attempts. The connection filter chain will look like this: + +``` +* create connection for http://curl.se +conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> NULL +* start connect +conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> NULL + - ballerv4 --> TCP[151.101.1.91]:443 + - ballerv6 --> TCP[2a04:4e42:c00::347]:443 +* v6 answers, connected +conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> TCP[2a04:4e42:c00::347]:443 +* transfer +``` + +The modular design of connection filters and that we can plug them into each other is used to control the parallel attempts. When a `TCP` filter does not connect (in time), it is torn down and another one is created for the next address. This keeps the `TCP` filter simple. + +The `HAPPY-EYEBALLS` on the other hand stays focused on its side of the problem. We can use it also to make other type of connection by just giving it another filter type to try and have happy eyeballing for QUIC: + +``` +* create connection for --http3-only https://curl.se +conn[curl.se] --> SETUP[QUIC] --> HAPPY-EYEBALLS --> NULL +* start connect +conn[curl.se] --> SETUP[QUIC] --> HAPPY-EYEBALLS --> NULL + - ballerv4 --> HTTP/3[151.101.1.91]:443 + - ballerv6 --> HTTP/3[2a04:4e42:c00::347]:443 +* v6 answers, connected +conn[curl.se] --> SETUP[QUIC] --> HAPPY-EYEBALLS --> HTTP/3[2a04:4e42:c00::347]:443 +* transfer +``` + +When we plug these two variants together, we get the `HTTPS-CONNECT` filter +type that is used for `--http3` when **both** HTTP/3 and HTTP/2 or HTTP/1.1 +shall be attempted: + +``` +* create connection for --http3 https://curl.se +conn[curl.se] --> HTTPS-CONNECT --> NULL +* start connect +conn[curl.se] --> HTTPS-CONNECT --> NULL + - SETUP[QUIC] --> HAPPY-EYEBALLS --> NULL + - ballerv4 --> HTTP/3[151.101.1.91]:443 + - ballerv6 --> HTTP/3[2a04:4e42:c00::347]:443 + - SETUP[TCP] --> HAPPY-EYEBALLS --> NULL + - ballerv4 --> TCP[151.101.1.91]:443 + - ballerv6 --> TCP[2a04:4e42:c00::347]:443 +* v4 QUIC answers, connected +conn[curl.se] --> HTTPS-CONNECT --> SETUP[QUIC] --> HAPPY-EYEBALLS --> HTTP/3[151.101.1.91]:443 +* transfer +``` -So we might add "easy filters" one day. Who knows? diff --git a/docs/CONTRIBUTE.md b/docs/CONTRIBUTE.md index 72d319001..29d98cf10 100644 --- a/docs/CONTRIBUTE.md +++ b/docs/CONTRIBUTE.md @@ -101,9 +101,9 @@ archive is quite OK as well. ### Documentation Writing docs is dead boring and one of the big problems with many open source -projects. But someone's gotta do it. It makes things a lot easier if you -submit a small description of your fix or your new features with every -contribution so that it can be swiftly added to the package documentation. +projects but someone's gotta do it. It makes things a lot easier if you submit +a small description of your fix or your new features with every contribution +so that it can be swiftly added to the package documentation. The documentation is always made in man pages (nroff formatted) or plain ASCII files. All HTML files on the website and in the release archives are @@ -116,7 +116,7 @@ features are working as they are supposed to. To maintain this situation and improve it, all new features and functions that are added need to be tested in the test suite. Every feature that is added should get at least one valid test case that verifies that it works as documented. If every submitter also -posts a few test cases, it will not end up as a heavy burden on a single person! +posts a few test cases, it will not end up as a heavy burden on a single person. If you do not have test cases or perhaps you have done something that is hard to write tests for, do explain exactly how you have otherwise tested and @@ -240,10 +240,10 @@ make sure that you have your own user and email setup correctly in git before you commit. Add whichever header lines as appropriate, with one line per person if more -than one person was involved. There is no need to credit yourself unless you are -using --author=... which hides your identity. Do not include people's e-mail -addresses in headers to avoid spam, unless they are already public from a -previous commit; saying `{userid} on github` is OK. +than one person was involved. There is no need to credit yourself unless you +are using --author=... which hides your identity. Do not include people's +email addresses in headers to avoid spam, unless they are already public from +a previous commit; saying `{userid} on github` is OK. ### Write Access to git Repository diff --git a/docs/CURLDOWN.md b/docs/CURLDOWN.md new file mode 100644 index 000000000..2e89eed6a --- /dev/null +++ b/docs/CURLDOWN.md @@ -0,0 +1,125 @@ +# curldown + +A markdown-like syntax for libcurl man pages. + +## Purpose + +A text format for writing libcurl documentation in the shape of man pages. + +Make it easier for users to contribute and write documentation. A format that +is easier on the eye in its source format. + +Make it harder to do syntactical mistakes. + +Use a format that allows creating man pages that end up looking exactly like +the man pages did when we wrote them in nroff format. + +Take advantage of the fact that people these days are accustomed to markdown +by using a markdown-like syntax. + +This allows us to fix issues in the nroff format easier since now we generate +them. For example: escaping minus to prevent them from being turned into +Unicode by man. + +Generate nroff output that looks (next to) *identical* to the previous files, +so that the look, existing test cases, HTML conversions, existing +infrastructure etc remain mostly intact. + +Contains meta-data in a structured way to allow better output (for example the +see also information) and general awareness of what the file is about. + +## File extension + +Since curldown looks similar to markdown, we use `.md` extensions on the +files. + +## Conversion + +Convert **from curldown to nroff** with `cd2nroff`. Generates nroff man pages. + +Convert **from nroff to curldown** with `nroff2cd`. This is only meant to be +used for the initial conversion to curldown and should ideally never be needed +again. + +Convert, check or clean up an existing curldown to nicer, better, cleaner +curldown with **cd2cd**. + +Mass-convert all curldown files to nroff in specified directories with +`cdall`: + + cdall [dir1] [dir2] [dir3] .. + +## Known issues + +The `cd2nroff` tool does not yet handle *italics* or **bold** where the start +and the end markers are used on separate lines. + +The `nroff2cd` tool generates code style quotes for all `.fi` sections since +the nroff format does not carry a distinction. + +# Format + +Each curldown starts with a header with meta-data: + + --- + c: Copyright (C) Daniel Stenberg, , et al. + SPDX-License-Identifier: curl + Title: CURLOPT_AWS_SIGV4 + Section: 3 + Source: libcurl + See-also: + - CURLOPT_HEADEROPT (3) + - CURLOPT_HTTPAUTH (3) + --- + +All curldown files *must* have all the headers present and at least one +`See-also:` entry specified. + +Following the header in the file, is the manual page using markdown-like +syntax: + +~~~ + # NAME + a page - this is a page descriving something + + # SYNOPSIS + ~~~c + #include + + CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AWS_SIGV4, char *param); + ~~~ +~~~ + +Quoted source code should start with `~~~c` and end with `~~~` while regular +quotes can start with `~~~` or just be indented with 4 spaces. + +Headers at top-level `#` get converted to `.SH`. + +`nroff2cd` supports the `##` next level header which gets converted to `.IP`. + +Write bold words or phrases within `**` like: + + This is a **bold** word. + +Write italics like: + + This is *italics*. + +Due to how man pages do not support backticks especially formatted, such +occurrences in the source will instead just use italics in the generated +output: + + This `word` appears in italics. + +When generating the nroff output, the tooling will remove superfluous newlines, +meaning they can be used freely in the source file to make the text more +readable. + +All mentioned curl symbols that have their own man pages, like +`curl_easy_perform(3)` will automatically be rendered using italics in the +output without having to enclose it with asterisks. This helps ensuring that +they get converted to links properly later in the HTML version on the website, +as converted with `roffit`. This makes the curldown text easier to read even +when mentioning many curl symbols. + +This auto-linking works for patterns matching `(lib|)curl[^ ]*(3)`. diff --git a/docs/DEPRECATE.md b/docs/DEPRECATE.md index 4cd5a22ce..fcbd92a31 100644 --- a/docs/DEPRECATE.md +++ b/docs/DEPRECATE.md @@ -10,12 +10,16 @@ how your use case cannot be satisfied properly using a workaround. This NTLM authentication method is powered by a separate tool, `ntlm_auth`. Barely anyone uses this method. It was always a quirky -implementation (including fork + exec), it has limited portability and we -don't test it in the test suite and CI. +implementation (including fork + exec), it has limited portability and we do +not test it in the test suite and CI. We keep the native NTLM implementation. -curl will remove the support for NTLM_WB auth in June 2024. +Due to a mistake, the `NTLM_WB` functionality is missing in builds since 8.4.0 +(October 2023). It needs to be manually patched to work. See [PR +12479](https://github.com/curl/curl/pull/12479). + +curl will remove the support for NTLM_WB auth in April 2024. ## space-separated `NOPROXY` patterns diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 05364aaf3..4a589e164 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -16,7 +16,7 @@ - custom maximum download time - custom least download speed acceptable - custom output result after completion - - guesses protocol from host name unless specified + - guesses protocol from hostname unless specified - uses .netrc - progress bar with time statistics while downloading - "standard" proxy environment variables support @@ -82,8 +82,8 @@ - active/passive using PORT, EPRT, PASV or EPSV - single file size information (compare to HTTP HEAD) - 'type=' URL support - - dir listing - - dir listing names-only + - directory listing + - directory listing names-only - upload - upload append - upload via http-proxy as HTTP PUT @@ -94,7 +94,7 @@ - via HTTP proxy, HTTPS proxy or SOCKS proxy - all operations can be tunneled through proxy - customizable to retrieve file modification date - - no dir depth limit + - no directory depth limit ## FTPS (1) diff --git a/docs/GOVERNANCE.md b/docs/GOVERNANCE.md index dd09de456..0f7029e82 100644 --- a/docs/GOVERNANCE.md +++ b/docs/GOVERNANCE.md @@ -179,4 +179,4 @@ this. ### Stop being a maintainer If you (appear to) not be active in the project anymore, you may be removed as -a maintainer. Thank you for your service! +a maintainer. Thank you for your service. diff --git a/docs/HISTORY.md b/docs/HISTORY.md index f39c45ea1..d28217ca6 100644 --- a/docs/HISTORY.md +++ b/docs/HISTORY.md @@ -327,7 +327,7 @@ April: added the cyassl backend (later renamed to WolfSSL) January: the curl tool defaults to HTTP/2 for HTTPS URLs - December: curl 7.52.0 introduced support for HTTPS-proxy! + December: curl 7.52.0 introduced support for HTTPS-proxy First TLS 1.3 support diff --git a/docs/HSTS.md b/docs/HSTS.md index e54102493..5f0e62459 100644 --- a/docs/HSTS.md +++ b/docs/HSTS.md @@ -10,13 +10,13 @@ HTTP Strict-Transport-Security. Added as experimental in curl ## Behavior libcurl features an in-memory cache for HSTS hosts, so that subsequent -HTTP-only requests to a host name present in the cache will get internally +HTTP-only requests to a hostname present in the cache will get internally "redirected" to the HTTPS version. ## `curl_easy_setopt()` options: - `CURLOPT_HSTS_CTRL` - enable HSTS for this easy handle - - `CURLOPT_HSTS` - specify file name where to store the HSTS cache on close + - `CURLOPT_HSTS` - specify filename where to store the HSTS cache on close (and possibly read from at startup) ## curl command line options diff --git a/docs/HTTP-COOKIES.md b/docs/HTTP-COOKIES.md index d6fd87d20..a91e824d5 100644 --- a/docs/HTTP-COOKIES.md +++ b/docs/HTTP-COOKIES.md @@ -34,6 +34,25 @@ over plain HTTP for this host. curl does this to match how popular browsers work with secure cookies. +## Super cookies + + A single cookie can be set for a domain that matches multiple hosts. Like if + set for `example.com` it gets sent to both `aa.example.com` as well as + `bb.example.com`. + + A challenge with this concept is that there are certain domains for which + cookies should not be allowed at all, because they are *Public + Suffixes*. Similarly, a client never accepts cookies set directly for the + top-level domain like for example `.com`. Cookies set for *too broad* + domains are generally referred to as *super cookies*. + + If curl is built with PSL (**Public Suffix List**) support, it detects and + discards cookies that are specified for such suffix domains that should not + be allowed to have cookies. + + if curl is *not* built with PSL support, it has no ability to stop super + cookies. + ## Cookies saved to disk Netscape once created a file format for storing cookies on disk so that they diff --git a/docs/HTTP3.md b/docs/HTTP3.md index 7f2f08ada..851a0c468 100644 --- a/docs/HTTP3.md +++ b/docs/HTTP3.md @@ -15,6 +15,8 @@ QUIC libraries we are using: [quiche](https://github.com/cloudflare/quiche) - **EXPERIMENTAL** +[OpenSSL 3.2+ QUIC](https://github.com/openssl/openssl) - **EXPERIMENTAL** + [msh3](https://github.com/nibanks/msh3) (with [msquic](https://github.com/microsoft/msquic)) - **EXPERIMENTAL** ## Experimental @@ -29,13 +31,13 @@ the master branch using pull-requests, just like ordinary changes. To fix before we remove the experimental label: - the used QUIC library needs to consider itself non-beta - - it's fine to "leave" individual backends as experimental if necessary + - it is fine to "leave" individual backends as experimental if necessary # ngtcp2 version Building curl with ngtcp2 involves 3 components: `ngtcp2` itself, `nghttp3` and a QUIC supporting TLS library. The supported TLS libraries are covered below. - * `ngtcp2`: v1.1.0 + * `ngtcp2`: v1.2.0 * `nghttp3`: v1.1.0 ## Build with quictls @@ -64,7 +66,7 @@ Build nghttp3 Build ngtcp2 % cd .. - % git clone -b v1.1.0 https://github.com/ngtcp2/ngtcp2 + % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 % cd ngtcp2 % autoreconf -fi % ./configure PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig LDFLAGS="-Wl,-rpath,/lib" --prefix= --enable-lib-only @@ -107,7 +109,7 @@ Build nghttp3 Build ngtcp2 % cd .. - % git clone -b v1.1.0 https://github.com/ngtcp2/ngtcp2 + % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 % cd ngtcp2 % autoreconf -fi % ./configure PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig LDFLAGS="-Wl,-rpath,/lib" --prefix= --enable-lib-only --with-gnutls @@ -148,7 +150,7 @@ Build nghttp3 Build ngtcp2 % cd .. - % git clone -b v1.1.0 https://github.com/ngtcp2/ngtcp2 + % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 % cd ngtcp2 % autoreconf -fi % ./configure PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig LDFLAGS="-Wl,-rpath,/lib" --prefix= --enable-lib-only --with-wolfssl @@ -175,7 +177,7 @@ Since the quiche build manages its dependencies, curl can be built against the l Build quiche and BoringSSL: - % git clone --recursive https://github.com/cloudflare/quiche + % git clone --recursive -b 0.20.0 https://github.com/cloudflare/quiche % cd quiche % cargo build --package quiche --release --features ffi,pkg-config-meta,qlog % mkdir quiche/deps/boringssl/src/lib @@ -193,6 +195,40 @@ Build curl: If `make install` results in `Permission denied` error, you will need to prepend it with `sudo`. +# OpenSSL version + +quiche QUIC support is **EXPERIMENTAL** + +Build OpenSSL 3.2.0 + + % cd .. + % git clone -b openssl-3.2.0 https://github.com/openssl/openssl + % cd openssl + % ./config enable-tls1_3 --prefix= --libdir=/lib + % make install + +Build nghttp3 + + % cd .. + % git clone -b v1.1.0 https://github.com/ngtcp2/nghttp3 + % cd nghttp3 + % autoreconf -fi + % ./configure --prefix= --enable-lib-only + % make + % make install + +Build curl: + + % cd .. + % git clone https://github.com/curl/curl + % cd curl + % autoreconf -fi + % ./configure --with-openssl= --with-openssl-quic --with-nghttp3= + % make + % make install + + If `make install` results in `Permission denied` error, you will need to prepend it with `sudo`. + # msh3 (msquic) version **Note**: The msquic HTTP/3 backend is immature and is not properly functional @@ -305,9 +341,9 @@ handshake or time out. Note that all this happens in addition to IP version happy eyeballing. If the name resolution for the server gives more than one IP address, curl will try -all those until one succeeds - just as with all other protocols. And if those -IP addresses contain both IPv6 and IPv4, those attempts will happen, delayed, -in parallel (the actual eyeballing). +all those until one succeeds - just as with all other protocols. If those IP +addresses contain both IPv6 and IPv4, those attempts will happen, delayed, in +parallel (the actual eyeballing). ## Known Bugs diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md new file mode 100644 index 000000000..6dad38740 --- /dev/null +++ b/docs/INSTALL-CMAKE.md @@ -0,0 +1,133 @@ + _ _ ____ _ + ___| | | | _ \| | + / __| | | | |_) | | + | (__| |_| | _ <| |___ + \___|\___/|_| \_\_____| + + How To Compile with CMake + +# Building with CMake + +This document describes how to configure, build and install curl and libcurl +from source code using the CMake build tool. To build with CMake, you will +of course have to first install CMake. The minimum required version of CMake +is specified in the file `CMakeLists.txt` found in the top of the curl +source tree. Once the correct version of CMake is installed you can follow +the instructions below for the platform you are building on. + +CMake builds can be configured either from the command line, or from one of +CMake's GUIs. + +# Current flaws in the curl CMake build + +Missing features in the CMake build: + + - Builds libcurl without large file support + - Does not support all SSL libraries (only OpenSSL, Schannel, Secure + Transport, and mbedTLS, WolfSSL) + - Does not allow different resolver backends (no c-ares build support) + - No RTMP support built + - Does not allow build curl and libcurl debug enabled + - Does not allow a custom CA bundle path + - Does not allow you to disable specific protocols from the build + - Does not find or use krb4 or GSS + - Rebuilds test files too eagerly, but still cannot run the tests + - Does not detect the correct `strerror_r` flavor when cross-compiling + (issue #1123) + +# Configuring + +A CMake configuration of curl is similar to the autotools build of curl. +It consists of the following steps after you have unpacked the source. + +## Using `cmake` + +You can configure for in source tree builds or for a build tree +that is apart from the source tree. + + - Build in the source tree. + + $ cmake -B . + + - Build in a separate directory (parallel to the curl source tree in this + example). The build directory will be created for you. + + $ cmake -B ../curl-build + +### Fallback for CMake before version 3.13 + +CMake before version 3.13 does not support the `-B` option. In that case, +you must create the build directory yourself, `cd` to it and run `cmake` +from there: + + $ mkdir ../curl-build + $ cd ../curl-build + $ cmake ../curl + +If you want to build in the source tree, it is enough to do this: + + $ cmake . + +## Using `ccmake` + +CMake comes with a curses based interface called `ccmake`. To run `ccmake` +on a curl use the instructions for the command line cmake, but substitute +`ccmake` for `cmake`. + +This will bring up a curses interface with instructions on the bottom of the +screen. You can press the "c" key to configure the project, and the "g" key +to generate the project. After the project is generated, you can run make. + +## Using `cmake-gui` + +CMake also comes with a Qt based GUI called `cmake-gui`. To configure with +`cmake-gui`, you run `cmake-gui` and follow these steps: + + 1. Fill in the "Where is the source code" combo box with the path to + the curl source tree. + 2. Fill in the "Where to build the binaries" combo box with the path to + the directory for your build tree, ideally this should not be the same + as the source tree, but a parallel directory called curl-build or + something similar. + 3. Once the source and binary directories are specified, press the + "Configure" button. + 4. Select the native build tool that you want to use. + 5. At this point you can change any of the options presented in the GUI. + Once you have selected all the options you want, click the "Generate" + button. + +# Building + +Build (you have to specify the build directory). + + $ cmake --build ../curl-build + +### Fallback for CMake before version 3.13 + +CMake before version 3.13 does not support the `--build` option. In that +case, you have to `cd` to the build directory and use the building tool that +corresponds to the build files that CMake generated for you. This example +assumes that CMake generates `Makefile`: + + $ cd ../curl-build + $ make + +# Testing + +(The test suite does not yet work with the cmake build) + +# Installing + +Install to default location (you have to specify the build directory). + + $ cmake --install ../curl-build + +### Fallback for CMake before version 3.15 + +CMake before version 3.15 does not support the `--install` option. In that +case, you have to `cd` to the build directory and use the building tool that +corresponds to the build files that CMake generated for you. This example +assumes that CMake generates `Makefile`: + + $ cd ../curl-build + $ make install diff --git a/docs/INSTALL.cmake b/docs/INSTALL.cmake deleted file mode 100644 index 4e7f706a9..000000000 --- a/docs/INSTALL.cmake +++ /dev/null @@ -1,89 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - - How To Compile with CMake - -Building with CMake -========================== - This document describes how to compile, build and install curl and libcurl - from source code using the CMake build tool. To build with CMake, you will - of course have to first install CMake. The minimum required version of - CMake is specified in the file CMakeLists.txt found in the top of the curl - source tree. Once the correct version of CMake is installed you can follow - the instructions below for the platform you are building on. - - CMake builds can be configured either from the command line, or from one - of CMake's GUI's. - -Current flaws in the curl CMake build -===================================== - - Missing features in the cmake build: - - - Builds libcurl without large file support - - Does not support all SSL libraries (only OpenSSL, Schannel, - Secure Transport, and mbedTLS, WolfSSL) - - Does not allow different resolver backends (no c-ares build support) - - No RTMP support built - - Does not allow build curl and libcurl debug enabled - - Does not allow a custom CA bundle path - - Does not allow you to disable specific protocols from the build - - Does not find or use krb4 or GSS - - Rebuilds test files too eagerly, but still cannot run the tests - - Does not detect the correct strerror_r flavor when cross-compiling (issue #1123) - - -Command Line CMake -================== - A CMake build of curl is similar to the autotools build of curl. It - consists of the following steps after you have unpacked the source. - - 1. Create an out of source build tree parallel to the curl source - tree and change into that directory - - $ mkdir curl-build - $ cd curl-build - - 2. Run CMake from the build tree, giving it the path to the top of - the curl source tree. CMake will pick a compiler for you. If you - want to specify the compile, you can set the CC environment - variable prior to running CMake. - - $ cmake ../curl - $ make - - 3. Install to default location: - - $ make install - - (The test suite does not work with the cmake build) - -ccmake -========= - CMake comes with a curses based interface called ccmake. To run ccmake on - a curl use the instructions for the command line cmake, but substitute - ccmake ../curl for cmake ../curl. This will bring up a curses interface - with instructions on the bottom of the screen. You can press the "c" key - to configure the project, and the "g" key to generate the project. After - the project is generated, you can run make. - -cmake-gui -========= - CMake also comes with a Qt based GUI called cmake-gui. To configure with - cmake-gui, you run cmake-gui and follow these steps: - 1. Fill in the "Where is the source code" combo box with the path to - the curl source tree. - 2. Fill in the "Where to build the binaries" combo box with the path - to the directory for your build tree, ideally this should not be the - same as the source tree, but a parallel directory called curl-build or - something similar. - 3. Once the source and binary directories are specified, press the - "Configure" button. - 4. Select the native build tool that you want to use. - 5. At this point you can change any of the options presented in the - GUI. Once you have selected all the options you want, click the - "Generate" button. - 6. Run the native build tool that you used CMake to generate. diff --git a/docs/INSTALL.md b/docs/INSTALL.md index a6780b45d..336d654e0 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -123,8 +123,8 @@ If you are a curl developer and use gcc, you might want to enable more debug options with the `--enable-debug` option. curl can be built to use a whole range of libraries to provide various useful -services, and configure will try to auto-detect a decent default. But if you -want to alter it, you can select how to deal with each individual library. +services, and configure will try to auto-detect a decent default. If you want +to alter it, you can select how to deal with each individual library. ## Select TLS backend @@ -146,7 +146,7 @@ you cannot add another OpenSSL fork (or wolfSSL) simply because they have conflicting identical symbol names. When you build with multiple TLS backends, you can select the active one at -run-time when curl starts up. +runtime when curl starts up. ## configure finding libs in wrong directory @@ -174,8 +174,8 @@ Building for Windows XP is required as a minimum. KB140584 is a must for any Windows developer. Especially important is full understanding if you are not going to follow the advice given above. - - [How To Use the C Run-Time](https://support.microsoft.com/help/94248/how-to-use-the-c-run-time) - - [Run-Time Library Compiler Options](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library) + - [How To Use the C Runtime](https://support.microsoft.com/help/94248/how-to-use-the-c-run-time) + - [Runtime Library Compiler Options](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library) - [Potential Errors Passing CRT Objects Across DLL Boundaries](https://docs.microsoft.com/cpp/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries) If your app is misbehaving in some strange way, or it is suffering from memory @@ -185,54 +185,6 @@ multi-threaded dynamic C runtime. If you get linkage errors read section 5.7 of the FAQ document. -## mingw-w64 - -Make sure that mingw-w64's bin directory is in the search path, for example: - -```cmd -set PATH=c:\mingw-w64\bin;%PATH% -``` - -then run `mingw32-make mingw32` in the root dir. There are other -make targets available to build libcurl with more features, use: - - - `mingw32-make mingw32-zlib` to build with Zlib support; - - `mingw32-make mingw32-ssl-zlib` to build with SSL and Zlib enabled; - - `mingw32-make mingw32-ssh2-ssl-zlib` to build with SSH2, SSL, Zlib; - - `mingw32-make mingw32-ssh2-ssl-sspi-zlib` to build with SSH2, SSL, Zlib - and SSPI support. - -If you have any problems linking libraries or finding header files, be sure -to verify that the provided `Makefile.mk` files use the proper paths, and -adjust as necessary. It is also possible to override these paths with -environment variables, for example: - -```cmd -set ZLIB_PATH=c:\zlib-1.2.12 -set OPENSSL_PATH=c:\openssl-3.0.5 -set LIBSSH2_PATH=c:\libssh2-1.10.0 -``` - -It is also possible to build with other LDAP installations than MS LDAP; -currently it is possible to build with native Win32 OpenLDAP, or with the -*Novell CLDAP* SDK. If you want to use these you need to set these vars: - -```cmd -set CPPFLAGS=-Ic:/openldap/include -DCURL_HAS_OPENLDAP_LDAPSDK -set LDFLAGS=-Lc:/openldap/lib -set LIBS=-lldap -llber -``` - -or for using the Novell SDK: - -```cmd -set CPPFLAGS=-Ic:/openldapsdk/inc -DCURL_HAS_NOVELL_LDAPSDK -set LDFLAGS=-Lc:/openldapsdk/lib/mscvc -set LIBS=-lldapsdk -lldapssl -lldapx -``` - -If you want to enable LDAPS support then append `-ldaps` to the make target. - ## Cygwin Almost identical to the Unix installation. Run the configure script in the @@ -388,14 +340,14 @@ In all above, the built libraries and executables can be found in the # Android -When building curl for Android it's recommended to use a Linux/macOS environment -since using curl's `configure` script is the easiest way to build curl -for Android. Before you can build curl for Android, you need to install the -Android NDK first. This can be done using the SDK Manager that is part of -Android Studio. Once you have installed the Android NDK, you need to figure out -where it has been installed and then set up some environment variables before -launching `configure`. On macOS, those variables could look like this to compile -for `aarch64` and API level 29: +When building curl for Android it is recommended to use a Linux/macOS +environment since using curl's `configure` script is the easiest way to build +curl for Android. Before you can build curl for Android, you need to install +the Android NDK first. This can be done using the SDK Manager that is part of +Android Studio. Once you have installed the Android NDK, you need to figure +out where it has been installed and then set up some environment variables +before launching `configure`. On macOS, those variables could look like this +to compile for `aarch64` and API level 29: ```bash export ANDROID_NDK_HOME=~/Library/Android/sdk/ndk/25.1.8937393 # Point into your NDK. @@ -415,13 +367,13 @@ to adjust those variables accordingly. After that you can build curl like this: ./configure --host aarch64-linux-android --with-pic --disable-shared -Note that this will not give you SSL/TLS support. If you need SSL/TLS, you have -to build curl against a SSL/TLS layer, e.g. OpenSSL, because it's impossible for -curl to access Android's native SSL/TLS layer. To build curl for Android using -OpenSSL, follow the OpenSSL build instructions and then install `libssl.a` and -`libcrypto.a` to `$TOOLCHAIN/sysroot/usr/lib` and copy `include/openssl` to -`$TOOLCHAIN/sysroot/usr/include`. Now you can build curl for Android using -OpenSSL like this: +Note that this will not give you SSL/TLS support. If you need SSL/TLS, you +have to build curl against a SSL/TLS layer, e.g. OpenSSL, because it is +impossible for curl to access Android's native SSL/TLS layer. To build curl +for Android using OpenSSL, follow the OpenSSL build instructions and then +install `libssl.a` and `libcrypto.a` to `$TOOLCHAIN/sysroot/usr/lib` and copy +`include/openssl` to `$TOOLCHAIN/sysroot/usr/include`. Now you can build curl +for Android using OpenSSL like this: ```bash LIBS="-lssl -lcrypto -lc++" # For OpenSSL/BoringSSL. In general, you will need to the SSL/TLS layer's transitive dependencies if you are linking statically. diff --git a/docs/IPFS.md b/docs/IPFS.md index 24bba8b75..aa3fb278c 100644 --- a/docs/IPFS.md +++ b/docs/IPFS.md @@ -19,12 +19,29 @@ By explicitly requesting [application/vnd.ipld.raw](https://www.iana.org/assignm This enables users to use untrusted, public gateways without worrying they might return invalid/malicious bytes. ## IPFS and IPNS protocol handling -There are various ways to access data from the IPFS network. One such way is through the concept of public "[gateways](https://docs.ipfs.tech/concepts/ipfs-gateway/#overview)". The short version is that entities can offer gateway services. An example here that is hosted by Protocol Labs (who also makes IPFS) is `dweb.link` and `ipfs.io`. Both sites expose gateway functionality. Getting a file through `ipfs.io` looks like this: `https://ipfs.io/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` -If you were to be [running your own IPFS node](https://docs.ipfs.tech/how-to/command-line-quick-start/) then you, by default, also have a [local gateway](https://specs.ipfs.tech/http-gateways/) running. In it's default configuration the earlier example would then also work in this link: `http://127.0.0.1:8080/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` +There are various ways to access data from the IPFS network. One such way is +through the concept of public +"[gateways](https://docs.ipfs.tech/concepts/ipfs-gateway/#overview)". The +short version is that entities can offer gateway services. An example here +that is hosted by Protocol Labs (who also makes IPFS) is `dweb.link` and +`ipfs.io`. Both sites expose gateway functionality. Getting a file through +`ipfs.io` looks like this: +`https://ipfs.io/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` + +If you were to be [running your own IPFS +node](https://docs.ipfs.tech/how-to/command-line-quick-start/) then you, by +default, also have a [local gateway](https://specs.ipfs.tech/http-gateways/) +running. In its default configuration the earlier example would then also work +in this link: + +`http://127.0.0.1:8080/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` ## cURL handling of the IPFS protocols -The IPFS integration in cURL hides this gateway logic for you. So instead of providing a full URL to a file on IPFS like this: + +The IPFS integration in cURL hides this gateway logic for you. Instead of +providing a full URL to a file on IPFS like this: + ``` curl http://127.0.0.1:8080/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi ``` @@ -34,49 +51,75 @@ You can provide it with the IPFS protocol instead: curl ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi ``` -With the IPFS protocol way of asking a file, cURL still needs to know the gateway. curl essentially just rewrites the IPFS based URL to a gateway URL. +With the IPFS protocol way of asking a file, cURL still needs to know the +gateway. curl essentially just rewrites the IPFS based URL to a gateway URL. ### IPFS_GATEWAY environment variable -If the `IPFS_GATEWAY` environment variable is found, it's value is used as gateway. + +If the `IPFS_GATEWAY` environment variable is found, its value is used as +gateway. ### Automatic gateway detection When you provide no additional details to cURL then cURL will: -1. First look for the `IPFS_GATEWAY` environment variable and use that if it's set. -2. Look for the file: `~/.ipfs/gateway`. If it can find that file then it means that you have a local gateway running and that file contains the URL to your local gateway. +1. First look for the `IPFS_GATEWAY` environment variable and use that if it + is set. +2. Look for the file: `~/.ipfs/gateway`. If it can find that file then it + means that you have a local gateway running and that file contains the URL + to your local gateway. -If cURL fails you'll be presented with an error message and a link to this page to the option most applicable to solving the issue. +If cURL fails you will be presented with an error message and a link to this +page to the option most applicable to solving the issue. ### `--ipfs-gateway` argument -You can also provide a `--ipfs-gateway` argument to cURL. This overrules any other gateway setting. curl won't fallback to the other options if the provided gateway didn't work. + +You can also provide a `--ipfs-gateway` argument to cURL. This overrules any +other gateway setting. curl will not fallback to the other options if the +provided gateway did not work. ## Gateway redirects -A gateway could redirect to another place. For example, `dweb.link` redirects [path based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#path-gateway) requests to [subdomain based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#subdomain-gateway) ones. So a request to: -``` -curl ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi --ipfs-gateway https://dweb.link -``` + +A gateway could redirect to another place. For example, `dweb.link` redirects +[path based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#path-gateway) +requests to [subdomain +based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#subdomain-gateway) +ones. A request using: + + curl ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi --ipfs-gateway https://dweb.link + Which would be translated to: -``` -https://dweb.link/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi -``` + + https://dweb.link/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi + Will redirect to: -``` -https://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi.ipfs.dweb.link -``` + + https://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi.ipfs.dweb.link + If you trust this behavior from your gateway of choice then passing the `-L` option will follow the redirect. ## Error messages and hints + Depending on the arguments, cURL could present the user with an error. ### Gateway file and environment variable -cURL tried to look for the file: `~/.ipfs/gateway` but couldn't find it. It also tried to look for the `IPFS_GATEWAY` environment variable but couldn't find that either. This happens when no extra arguments are passed to cURL and letting it try to figure it out [automatically](#automatic-gateway-detection). -Any IPFS implementation that has gateway support should expose it's URL in `~/.ipfs/gateway`. If you are already running a gateway, make sure it exposes the file where cURL expects to find it. +cURL tried to look for the file: `~/.ipfs/gateway` but could not find it. It +also tried to look for the `IPFS_GATEWAY` environment variable but could not +find that either. This happens when no extra arguments are passed to cURL and +letting it try to figure it out [automatically](#automatic-gateway-detection). -Alternatively you could set the `IPFS_GATEWAY` environment variable or pass the `--ipfs-gateway` flag to the cURL command. +Any IPFS implementation that has gateway support should expose its URL in +`~/.ipfs/gateway`. If you are already running a gateway, make sure it exposes +the file where cURL expects to find it. + +Alternatively you could set the `IPFS_GATEWAY` environment variable or pass +the `--ipfs-gateway` flag to the cURL command. ### Malformed gateway URL -The command executed evaluates in an invalid URL. This could be anywhere in the URL, but a likely point is a wrong gateway URL. -Inspect the URL set via the `IPFS_GATEWAY` environment variable or passed with the `--ipfs-gateway` flag. -Alternatively opt to go for the [automatic](#automatic-gateway-detection) gateway detection. +The command executed evaluates in an invalid URL. This could be anywhere in +the URL, but a likely point is a wrong gateway URL. + +Inspect the URL set via the `IPFS_GATEWAY` environment variable or passed with +the `--ipfs-gateway` flag. Alternatively opt to go for the +[automatic](#automatic-gateway-detection) gateway detection. diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS index e52774a15..f91ff63bb 100644 --- a/docs/KNOWN_BUGS +++ b/docs/KNOWN_BUGS @@ -92,7 +92,6 @@ problems may have been fixed or changed somewhat since this was written. 15.1 cmake outputs: no version information available 15.2 support build with GnuTLS 15.3 unusable tool_hugehelp.c with MinGW - 15.4 build docs/curl.1 15.6 uses -lpthread instead of Threads::Threads 15.7 generated .pc file contains strange entries 15.8 libcurl.pc uses absolute library paths @@ -110,6 +109,9 @@ problems may have been fixed or changed somewhat since this was written. 18. HTTP/3 18.1 connection migration does not work + 19. RTSP + 19.1 Some methods do not support response bodies + ============================================================================== 1. HTTP @@ -525,12 +527,6 @@ problems may have been fixed or changed somewhat since this was written. see https://github.com/curl/curl/issues/3125 -15.4 build docs/curl.1 - - The cmake build does not create the docs/curl.1 file and therefore must rely on - it being there already. This makes the --manual option not work and test - cases like 1139 cannot function. - 15.6 uses -lpthread instead of Threads::Threads See https://github.com/curl/curl/issues/6166 @@ -602,3 +598,13 @@ problems may have been fixed or changed somewhat since this was written. 18.1 connection migration does not work https://github.com/curl/curl/issues/7695 + +19. RTSP + +19.1 Some methods do not support response bodies + + The RTSP implementation is written to assume that a number of RTSP methods + will always get responses without bodies, even though there seems to be no + indication in the RFC that this is always the case. + + https://github.com/curl/curl/issues/12414 diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 8de4bd702..e7b4bb7af 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -10,7 +10,7 @@ Get a README file from an FTP server: curl ftp://ftp.example.com/README -Get a web page from a server using port 8000: +Get a webpage from a server using port 8000: curl http://www.example.com:8000/ @@ -63,12 +63,12 @@ Get a file from an SMB server: ## Download to a File -Get a web page and store in a local file with a specific name: +Get a webpage and store in a local file with a specific name: curl -o thatpage.html http://www.example.com/ -Get a web page and store in a local file, make the local file get the name of -the remote document (if no file name part is specified in the URL, this will +Get a webpage and store in a local file, make the local file get the name of +the remote document (if no filename part is specified in the URL, this will fail): curl -O http://www.example.com/index.html @@ -224,7 +224,7 @@ Upload data from a specified file, login with user and password: curl -T uploadfile -u user:passwd ftp://ftp.example.com/myfile -Upload a local file to the remote site, and use the local file name at the +Upload a local file to the remote site, and use the local filename at the remote site too: curl -T uploadfile -u user:passwd ftp://ftp.example.com/ @@ -266,7 +266,7 @@ the actual data). curl -v ftp://ftp.example.com/ To get even more details and information on what curl does, try using the -`--trace` or `--trace-ascii` options with a given file name to log to, like +`--trace` or `--trace-ascii` options with a given filename to log to, like this: curl --trace trace.txt www.haxx.se @@ -347,7 +347,7 @@ multipart/form-data type. This latter type supports things like file upload. `-F` accepts parameters like `-F "name=contents"`. If you want the contents to be read from a file, use `@filename` as contents. When specifying a file, you can also specify the file content type by appending `;type=` to the -file name. You can also post the contents of several files in one field. For +filename. You can also post the contents of several files in one field. For example, the field name `coolfiles` is used to send three files, with different content types using the following syntax: @@ -360,7 +360,7 @@ earlier file if several files are specified in a list) or else it will use the default type `application/octet-stream`. Emulate a fill-in form with `-F`. Let's say you fill in three fields in a -form. One field is a file name which to post, one field is your name and one +form. One field is a filename which to post, one field is your name and one field is a file description. We want to post the file we have written named `cooltext.txt`. To let curl do the posting of this data instead of your favorite browser, you have to read the HTML source of the form page and find @@ -556,7 +556,7 @@ transfer stalls during periods. ## Config File Curl automatically tries to read the `.curlrc` file (or `_curlrc` file on -Microsoft Windows systems) from the user's home dir on startup. +Microsoft Windows systems) from the user's home directory on startup. The config file could be made up with normal command line switches, but you can also specify the long options without the dashes to make it more @@ -592,7 +592,7 @@ URL by making a config file similar to: url = "http://help.with.curl.example.com/curlhelp.html" You can specify another config file to be read by using the `-K`/`--config` -flag. If you set config file name to `-` it will read the config from stdin, +flag. If you set config filename to `-` it will read the config from stdin, which can be handy if you want to hide options from being visible in process tables etc: @@ -601,7 +601,7 @@ tables etc: ## Extra Headers When using curl in your own programs, you may end up needing to pass on your -own custom headers when getting a web page. You can do this by using the `-H` +own custom headers when getting a webpage. You can do this by using the `-H` flag. Example, send the header `X-you-and-me: yes` to the server when getting a @@ -626,11 +626,11 @@ directory at your ftp site, do: curl ftp://user:passwd@my.example.com/README If you want the README file from the root directory of that same site, you -need to specify the absolute file name: +need to specify the absolute filename: curl ftp://user:passwd@my.example.com//README -(I.e with an extra slash in front of the file name.) +(I.e with an extra slash in front of the filename.) ## SFTP and SCP and Path Names @@ -676,7 +676,7 @@ Download with `PORT` but use 192.168.0.10 as our IP address to use: ## Network Interface -Get a web page from a server using a specified port for the interface: +Get a webpage from a server using a specified port for the interface: curl --interface eth0:1 http://www.example.com/ @@ -829,7 +829,7 @@ set in (only an asterisk, `*` matches all hosts) NO_PROXY -If the host name matches one of these strings, or the host is within the +If the hostname matches one of these strings, or the host is within the domain of one of these strings, transactions with that node will not be done over proxy. When a domain is used, it needs to start with a period. A user can specify that both www.example.com and foo.example.com should not use a proxy @@ -888,7 +888,7 @@ command line similar to: curl telnet://remote.example.com -And enter the data to pass to the server on stdin. The result will be sent to +Enter the data to pass to the server on stdin. The result will be sent to stdout or to the file you specify with `-o`. You might want the `-N`/`--no-buffer` option to switch off the buffered output diff --git a/docs/Makefile.am b/docs/Makefile.am index 9190b4411..fbe94c40e 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -26,24 +26,21 @@ AUTOMAKE_OPTIONS = foreign no-dependencies # EXTRA_DIST breaks with $(abs_builddir) so build it using this variable # but distribute it (using the relative file name) in the next variable -man_MANS = $(abs_builddir)/curl.1 +man_MANS = $(abs_builddir)/curl.1 mk-ca-bundle.1 noinst_man_MANS = curl.1 mk-ca-bundle.1 dist_man_MANS = curl-config.1 -GENHTMLPAGES = curl.html curl-config.html mk-ca-bundle.html -PDFPAGES = curl.pdf curl-config.pdf mk-ca-bundle.pdf -MANDISTPAGES = curl.1.dist curl-config.1.dist - -HTMLPAGES = $(GENHTMLPAGES) +CURLPAGES = curl-config.md mk-ca-bundle.md # Build targets in this file (.) before cmdline-opts to ensure that # the curl.1 rule below runs first -SUBDIRS = . cmdline-opts -DIST_SUBDIRS = $(SUBDIRS) examples libcurl +SUBDIRS = . cmdline-opts libcurl +DIST_SUBDIRS = $(SUBDIRS) examples -CLEANFILES = $(GENHTMLPAGES) $(PDFPAGES) $(MANDISTPAGES) curl.1 +CLEANFILES = $(man_MANS) curl.1 curl-config.1 mk-ca-bundle.1 +nodist_MANS = $(CLEANFILES) EXTRA_DIST = \ - $(noinst_man_MANS) \ + $(CURLPAGES) \ ALTSVC.md \ BINDINGS.md \ BUFREF.md \ @@ -55,9 +52,11 @@ EXTRA_DIST = \ CODE_OF_CONDUCT.md \ CODE_REVIEW.md \ CODE_STYLE.md \ + CLIENT-WRITERS.md \ CONNECTION-FILTERS.md \ CONTRIBUTE.md \ CURL-DISABLE.md \ + CURLDOWN.md \ DEPRECATE.md \ DYNBUF.md \ EARLY-RELEASE.md \ @@ -73,7 +72,7 @@ EXTRA_DIST = \ HTTP3.md \ HYPER.md \ INSTALL \ - INSTALL.cmake \ + INSTALL-CMAKE.md \ INSTALL.md \ INTERNALS.md \ KNOWN_BUGS \ @@ -97,9 +96,14 @@ EXTRA_DIST = \ VULN-DISCLOSURE-POLICY.md \ WEBSOCKET.md -MAN2HTML= roffit $< >$@ +CD2NROFF = $(top_srcdir)/scripts/cd2nroff $< >$@ + +CD2 = $(CD2_$(V)) +CD2_0 = @echo " RENDER " $@; +CD2_1 = +CD2_ = $(CD2_0) -SUFFIXES = .1 .html .pdf +SUFFIXES = .1 .md # $(abs_builddir) is to disable VPATH when searching for this file, which # would otherwise find the copy in $(srcdir) which breaks the $(HUGE) @@ -115,21 +119,10 @@ $(abs_builddir)/curl.1: && touch -r "$(srcdir)/curl.1" $@; fi cd cmdline-opts && $(MAKE) -html: $(HTMLPAGES) - cd libcurl && $(MAKE) html - -pdf: $(PDFPAGES) - cd libcurl && $(MAKE) pdf - -.1.html: - $(MAN2HTML) +.md.1: + $(CD2)$(CD2NROFF) -.1.pdf: - @(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \ - groff -Tps -man $< >$$foo.ps; \ - ps2pdf $$foo.ps $@; \ - rm $$foo.ps; \ - echo "converted $< to $@") +curl-config.1: curl-config.md distclean: rm -f $(CLEANFILES) diff --git a/docs/NEW-PROTOCOL.md b/docs/NEW-PROTOCOL.md index a8b227d3c..223815b6d 100644 --- a/docs/NEW-PROTOCOL.md +++ b/docs/NEW-PROTOCOL.md @@ -7,7 +7,7 @@ protocols and it is the Internet transfer machine for the world. In the curl project we love protocols and we love supporting many protocols and doing it well. -So how do you proceed to add a new protocol and what are the requirements? +How do you proceed to add a new protocol and what are the requirements? ## No fixed set of requirements diff --git a/docs/PARALLEL-TRANSFERS.md b/docs/PARALLEL-TRANSFERS.md index 337fab5fa..03ceb8f82 100644 --- a/docs/PARALLEL-TRANSFERS.md +++ b/docs/PARALLEL-TRANSFERS.md @@ -38,9 +38,9 @@ Example: ## Behavior differences Connections are shared fine between different easy handles, but the -"authentication contexts" are not. So for example doing HTTP Digest auth with -one handle for a particular transfer and then continue on with another handle -that reuses the same connection, the second handle cannot send the necessary +"authentication contexts" are not. For example doing HTTP Digest auth with one +handle for a particular transfer and then continue on with another handle that +reuses the same connection, the second handle cannot send the necessary Authorization header at once since the context is only kept in the original easy handle. diff --git a/docs/SECURITY-ADVISORY.md b/docs/SECURITY-ADVISORY.md index 0ddc38b90..6344d2222 100644 --- a/docs/SECURITY-ADVISORY.md +++ b/docs/SECURITY-ADVISORY.md @@ -35,7 +35,7 @@ The eleven fields for each CVE in `vuln.pm` are, in order: ### `Makefile` -The new CVE web page file name needs to be added in the `Makefile`'s `CVELIST` +The new CVE webpage filename needs to be added in the `Makefile`'s `CVELIST` macro. When the markdown is in place and the `Makefile` and `vuln.pm` are updated, diff --git a/docs/SSLCERTS.md b/docs/SSLCERTS.md index 4094e2fec..7087e1eaf 100644 --- a/docs/SSLCERTS.md +++ b/docs/SSLCERTS.md @@ -103,9 +103,9 @@ server, do one of the following: certificate store or use it stand-alone as described. Just remember that the security is no better than the way you obtained the certificate. - 4. If you are using the curl command line tool, you can specify your own CA - cert file by setting the environment variable `CURL_CA_BUNDLE` to the path - of your choice. + 4. If you are using the curl command line tool and the TLS backend is not + Schannel then you can specify your own CA cert file by setting the + environment variable `CURL_CA_BUNDLE` to the path of your choice. If you are using the curl command line tool on Windows, curl will search for a CA cert file named "curl-ca-bundle.crt" in these directories and in @@ -116,10 +116,10 @@ server, do one of the following: 4. Windows Directory (e.g. C:\windows) 5. all directories along %PATH% - 5. Get a better/different/newer CA cert bundle! One option is to extract the - one a recent Firefox browser uses by running 'make ca-bundle' in the curl - build tree root, or possibly download a version that was generated this - way for you: [CA Extract](https://curl.se/docs/caextract.html) + 5. Get another CA cert bundle. One option is to extract the one a recent + Firefox browser uses by running 'make ca-bundle' in the curl build tree + root, or possibly download a version that was generated this way for you: + [CA Extract](https://curl.se/docs/caextract.html) Neglecting to use one of the above methods when dealing with a server using a certificate that is not signed by one of the certificates in the installed CA diff --git a/docs/THANKS b/docs/THANKS index 88d924f63..eee2ec51a 100644 --- a/docs/THANKS +++ b/docs/THANKS @@ -92,6 +92,7 @@ Alex Samorukov Alex Suykov Alex Vinnik Alex Xu +Alexander Bartel Alexander Beedie Alexander Chuykov Alexander Dyagilev @@ -206,6 +207,7 @@ Andy Stamp Andy Tsouladze Angus Mackay anio on github +annalee anon00000000 on github anshnd on github Anssi Kolehmainen @@ -290,6 +292,7 @@ Basuke Suzuki baumanj on github bdry on github beckenc on github +Ben Ben Boeckel Ben Darnell Ben Fritz @@ -373,6 +376,7 @@ Brandon Dong Brandon Wang BratSinot on github Brendan Jurd +Brennan Kinney Brent Beardsley Brian Akins Brian Bergeron @@ -404,11 +408,13 @@ Bryan Henderson Bryan Kemp bsammon on github bsergean on github +bubbleguuum on github Bubu on github buzo-ffm on github bxac on github Bylon2 on github Byrial Jensen +Cajus Pollmeier Caleb Raitto Calvin Buckley calvin2021y on github @@ -441,6 +447,7 @@ Cering on github Cesar Eduardo Barros Chad Monroe Chandrakant Bagul +Chara White Charles Cazabon Charles Kerr Charles Romestant @@ -465,6 +472,7 @@ Chris Maltby Chris Mumford Chris Paulson-Ellis Chris Roberts +Chris Sauer Chris Smowton Chris Talbot Chris Young @@ -681,6 +689,7 @@ Denis Laxalde Denis Ollier Dennis Clarke Dennis Felsing +dependabot[bot] Derek Higgins Derzsi Dániel Desmond O. Chang @@ -943,6 +952,7 @@ FuccDucc on github Fujii Hironori fullincome on github fundawang on github +Gabe Gabriel Corona Gabriel Kuri Gabriel Simmer @@ -1055,6 +1065,7 @@ Hannes Magnusson Hanno Böck Hanno Kranzhoff Hans Steegers +Hans-Christian Egtvedt Hans-Christian Noren Egtvedt Hans-Jurgen May Hao Wu @@ -1066,6 +1077,7 @@ Harry Sarson Harry Sintonen Harshal Pradhan Hauke Duden +Haydar Alaidrus Hayden Roche He Qin Heikki Korpela @@ -1084,6 +1096,7 @@ Henry Ludemann Henry Roeland Herve Amblard HexTheDragon +hgdagon on github Hide Ishikawa Hidemoto Nakada highmtworks on github @@ -1117,6 +1130,7 @@ Ian Lynagh Ian Spence Ian Turner Ian Wilkes +iAroc on github iconoclasthero icy17 on github Ignacio Vazquez-Abrams @@ -1155,6 +1169,7 @@ Ishan SinghLevett Ithubg on github Ivan Avdeev Ivan Tsybulin +ivanfywang IvanoG on github Ivo Bellin Salarin iz8mbw on github @@ -1214,6 +1229,7 @@ Jan Venekamp Jan Verbeek Jan-Piet Mens JanB on github +janko-js on github Janne Blomqvist Janne Johansson Jared Jennings @@ -1235,6 +1251,7 @@ Javier Navarro Javier Sixto Jay Austin Jay Dommaschk +Jay Wu Jayesh A Shah Jaz Fresh JazJas on github @@ -1289,6 +1306,7 @@ Jerry Krinock Jerry Wu Jes Badwal Jesper Jensen +Jess Lowe Jesse Chisholm Jesse Noller Jesse Tan @@ -1600,6 +1618,7 @@ Lawrence Gripper Lawrence Matthews Lawrence Wagerfield Leah Neukirchen +Lealem Amedie Leandro Coutinho Legoff Vincent Lehel Bernadt @@ -1623,6 +1642,7 @@ LigH-de on github lijian996 on github Lijo Antony lilongyan-huawei on github +Lin Sun Linas Vepstas Lindley French Ling Thio @@ -1739,6 +1759,7 @@ Mark Davies Mark Dodgson Mark Gaiser Mark Hamilton +Mark Huang Mark Incley Mark Itzcovitz Mark Karpeles @@ -1747,6 +1768,7 @@ Mark Nottingham Mark Roszko Mark Salisbury Mark Seuffert +Mark Sinkovics Mark Snelling Mark Swaanenburg Mark Tully @@ -1835,6 +1857,7 @@ Matthias Naegler Mattias Fornander Matus Uzak Maurice Barnum +Mauricio Scheffer Mauro Iorio Mauro Rappa Maurício Meneghini Fauth @@ -1958,6 +1981,7 @@ Mohamed Lrhazi Mohamed Osama Mohammad AlSaleh Mohammad Hasbini +Mohammadreza Hendiani Mohammed Naser Mohun Biswas momala454 on github @@ -2109,6 +2133,7 @@ Oskar Liljeblad Oskar Sigvardsson Oumph on github ovidiu-benea on github +Ozan Cansel P R Schaffner Pablo Busse Palo Markovic @@ -2261,6 +2286,7 @@ Prithvi MK privetryan on github Priyanka Shah ProceduralMan on github +promptfuzz_ on hackerone Pronyushkin Petr Przemysław Tomaszewski pszemus on github @@ -2330,6 +2356,7 @@ Renaud Lehoux Rene Bernhardt Rene Rebe Reuven Wachtfogel +RevaliQaQ on github Reza Arbab Rianov Viacheslav Ricardo Cadime @@ -2355,6 +2382,7 @@ Richard Gorton Richard Gray Richard Hosking Richard Hsu +Richard Levitte Richard Marion Richard Michael Richard Moore @@ -2511,6 +2539,7 @@ Saul good Saurav Babu sayrer on github SBKarr on github +Scarlett McAllister Scott Bailey Scott Barrett Scott Cantor @@ -2556,6 +2585,7 @@ SerusDev on github Seshubabu Pasam Seth Mos Sevan Janiyan +sfan5 on github Sgharat on github Sh Diao Shachaf Ben-Kiki @@ -2705,6 +2735,7 @@ Taneli Vähäkangas Tanguy Fautre Taras Kushnir tarek112 on github +Tatsuhiko Miyagawa Tatsuhiro Tsujikawa tawmoto on github tbugfinder on github @@ -2717,6 +2748,7 @@ thanhchungbtc on github The Infinnovation team TheAssassin on github TheKnarf on github +Theo Theodore Dubois therealhirudo on github Thiago Suchorski @@ -2724,6 +2756,7 @@ tholin on github Thomas Bouzerar Thomas Braun Thomas Danielsson +Thomas Ferguson Thomas Gamper Thomas Glanzmann Thomas Guillem @@ -2961,6 +2994,7 @@ x2018 on github Xavier Bouchoux XhmikosR on github XhstormR on github +Xi Ruoyao Xiang Xiao Xiangbin Li xianghongai on github @@ -2972,6 +3006,7 @@ xtonik on github xwxbug on github Xì Gà Yaakov Selkowitz +Yadhu Krishna M Yair Lenga Yang Tse Yaobin Wen @@ -2979,10 +3014,12 @@ Yarram Sunil Yasuharu Yamada Yasuhiro Matsumoto Yechiel Kalmenson +Yedaya Katsman Yehezkel Horowitz Yehoshua Hershberg ygthien on github Yi Huang +Yifei Kong Yiming Jing Yingwei Liu yiyuaner on github @@ -3010,6 +3047,8 @@ Zachary Seguin Zdenek Pavlas Zekun Ni zelinchen on github +zengwei +zengwei2000 Zenju on github Zero King Zespre Schmidt diff --git a/docs/TODO b/docs/TODO index 06162c8bb..162944360 100644 --- a/docs/TODO +++ b/docs/TODO @@ -196,6 +196,9 @@ 21. MQTT 21.1 Support rate-limiting + 22. TFTP + 22.1 TFTP doesn't convert LF to CRLF for mode=netascii + ============================================================================== 1. libcurl @@ -1113,7 +1116,7 @@ slow, potentially with a (random) wait between transfers. There is also a proposed set of standard HTTP headers to let servers let the client adapt to its rate limits: - https://www.ietf.org/id/draft-polli-ratelimit-headers-02.html + https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/ See https://github.com/curl/curl/issues/5406 @@ -1392,3 +1395,14 @@ The rate-limiting logic is done in the PERFORMING state in multi.c but MQTT is not (yet) implemented to use that. + +22. TFTP + +22.1 TFTP doesn't convert LF to CRLF for mode=netascii + + RFC 3617 defines that an TFTP transfer can be done using "netascii" + mode. curl does not support extracting that mode from the URL nor does it treat + such transfers specifically. It should probably do LF to CRLF translations + for them. + + See https://github.com/curl/curl/issues/12655 diff --git a/docs/TheArtOfHttpScripting.md b/docs/TheArtOfHttpScripting.md index 43f13e2af..8607642f7 100644 --- a/docs/TheArtOfHttpScripting.md +++ b/docs/TheArtOfHttpScripting.md @@ -87,16 +87,16 @@ The Uniform Resource Locator format is how you specify the address of a particular resource on the Internet. You know these, you have seen URLs like https://curl.se or https://example.com a million times. RFC 3986 is the - canonical spec. And yeah, the formal name is not URL, it is URI. + canonical spec. The formal name is not URL, it is **URI**. ## Host - The host name is usually resolved using DNS or your /etc/hosts file to an IP + The hostname is usually resolved using DNS or your /etc/hosts file to an IP address and that is what curl will communicate with. Alternatively you specify the IP address directly in the URL instead of a name. For development and other trying out situations, you can point to a different - IP address for a host name than what would otherwise be used, by using curl's + IP address for a hostname than what would otherwise be used, by using curl's [`--resolve`](https://curl.se/docs/manpage.html#--resolve) option: curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/ @@ -107,7 +107,7 @@ or in some cases UDP. Normally you do not have to take that into consideration, but at times you run test servers on other ports or similar. Then you can specify the port number in the URL with a colon and a - number immediately following the host name. Like when doing HTTP to port + number immediately following the hostname. Like when doing HTTP to port 1234: curl http://www.example.org:1234/ @@ -142,20 +142,20 @@ The path part is just sent off to the server to request that it sends back the associated response. The path is what is to the right side of the slash - that follows the host name and possibly port number. + that follows the hostname and possibly port number. # Fetch a page ## GET The simplest and most common request/operation made using HTTP is to GET a - URL. The URL could itself refer to a web page, an image or a file. The client + URL. The URL could itself refer to a webpage, an image or a file. The client issues a GET request to the server and receives the document it asked for. If you issue the command line curl https://curl.se - you get a web page returned in your terminal window. The entire HTML document + you get a webpage returned in your terminal window. The entire HTML document that that URL holds. All HTTP replies contain a set of response headers that are normally hidden, @@ -309,12 +309,10 @@ This method is mainly designed to better support file uploads. A form that allows a user to upload a file could be written like this in HTML: -```html -
- - -
-``` +
+ + +
This clearly shows that the Content-Type about to be sent is `multipart/form-data`. @@ -500,7 +498,7 @@ The way the web browsers do "client side state control" is by using cookies. Cookies are just names with associated contents. The cookies are sent to the client by the server. The server tells the client for what path - and host name it wants the cookie sent back, and it also sends an expiration + and hostname it wants the cookie sent back, and it also sends an expiration date and a few more properties. When a client communicates with a server with a name and path as previously @@ -630,18 +628,17 @@ It should be noted that curl selects which methods to use on its own depending on what action to ask for. `-d` will do POST, `-I` will do HEAD and - so on. If you use the - [`--request`](https://curl.se/docs/manpage.html#-X) / `-X` option you - can change the method keyword curl selects, but you will not modify curl's - behavior. This means that if you for example use -d "data" to do a POST, you - can modify the method to a `PROPFIND` with `-X` and curl will still think it - sends a POST . You can change the normal GET to a POST method by simply - adding `-X POST` in a command line like: + so on. If you use the [`--request`](https://curl.se/docs/manpage.html#-X) / + `-X` option you can change the method keyword curl selects, but you will not + modify curl's behavior. This means that if you for example use -d "data" to + do a POST, you can modify the method to a `PROPFIND` with `-X` and curl will + still think it sends a POST. You can change the normal GET to a POST method + by simply adding `-X POST` in a command line like: curl -X POST http://example.org/ - ... but curl will still think and act as if it sent a GET so it will not send - any request body etc. + curl will however still act as if it sent a GET so it will not send any + request body etc. # Web Login diff --git a/docs/URL-SYNTAX.md b/docs/URL-SYNTAX.md index ddd99454f..011a32c38 100644 --- a/docs/URL-SYNTAX.md +++ b/docs/URL-SYNTAX.md @@ -28,7 +28,7 @@ Due to the inherent differences between URL parser implementations, it is considered a security risk to mix different implementations and assume the same behavior! -For example, if you use one parser to check if a URL uses a good host name or +For example, if you use one parser to check if a URL uses a good hostname or the correct auth field, and then pass on that same URL to a *second* parser, there will always be a risk it treats the same URL differently. There is no right and wrong in URL land, only differences of opinions. @@ -92,7 +92,7 @@ curl supports "URLs" that do not start with a scheme. This is not supported by any of the specifications. This is a shortcut to entering URLs that was supported by browsers early on and has been mimicked by curl. -Based on what the host name starts with, curl will "guess" what protocol to +Based on what the hostname starts with, curl will "guess" what protocol to use: - `ftp.` means FTP @@ -367,9 +367,9 @@ curl supports SMB version 1 (only) ## SMTP -The path part of a SMTP request specifies the host name to present during +The path part of a SMTP request specifies the hostname to present during communication with the mail server. If the path is omitted, then libcurl will -attempt to resolve the local computer's host name. However, this may not +attempt to resolve the local computer's hostname. However, this may not return the fully qualified domain name that is required by some mail servers and specifying this path allows you to set an alternative name, such as your machine's fully qualified domain name, which you might have obtained from an diff --git a/docs/VULN-DISCLOSURE-POLICY.md b/docs/VULN-DISCLOSURE-POLICY.md index 650599348..a0086634a 100644 --- a/docs/VULN-DISCLOSURE-POLICY.md +++ b/docs/VULN-DISCLOSURE-POLICY.md @@ -92,7 +92,7 @@ announcement. the same manner we always announce releases. It gets sent to the curl-announce, curl-library and curl-users mailing lists. -- The security web page on the website should get the new vulnerability +- The security webpage on the website should get the new vulnerability mentioned. ## security (at curl dot se) diff --git a/docs/WEBSOCKET.md b/docs/WEBSOCKET.md index ba84c2284..c3967b8ea 100644 --- a/docs/WEBSOCKET.md +++ b/docs/WEBSOCKET.md @@ -109,10 +109,9 @@ Ideas: ## Why not libWebSocket -[libWebSocket](https://libWebSockets.org/) is said to be a solid, fast and -efficient WebSocket library with a vast amount of users. My plan was -originally to build upon it to skip having to implement the low level parts of -WebSocket myself. +libWebSocket is said to be a solid, fast and efficient WebSocket library with +a vast amount of users. My plan was originally to build upon it to skip having +to implement the low level parts of WebSocket myself. Here are the reasons why I have decided to move forward with WebSocket in curl **without using libWebSocket**: diff --git a/docs/cmdline-opts/CMakeLists.txt b/docs/cmdline-opts/CMakeLists.txt index 3dd8be49b..ee158df99 100644 --- a/docs/cmdline-opts/CMakeLists.txt +++ b/docs/cmdline-opts/CMakeLists.txt @@ -28,8 +28,10 @@ transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc. include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") add_custom_command(OUTPUT "${MANPAGE}" - COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/gen.pl" mainpage "${CMAKE_CURRENT_SOURCE_DIR}" > "${MANPAGE}" - DEPENDS ${DPAGES} ${OTHERPAGES} + COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && "${PERL_EXECUTABLE}" "./gen.pl" mainpage ${DPAGES} > "${MANPAGE}" VERBATIM ) -add_custom_target(generate-curl.1 DEPENDS "${MANPAGE}") +add_custom_target(generate-curl.1 ALL DEPENDS "${MANPAGE}") +if(NOT CURL_DISABLE_INSTALL) + install(FILES "${MANPAGE}" DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +endif() diff --git a/docs/cmdline-opts/MANPAGE.md b/docs/cmdline-opts/MANPAGE.md index 6de32dab9..951cbe859 100644 --- a/docs/cmdline-opts/MANPAGE.md +++ b/docs/cmdline-opts/MANPAGE.md @@ -9,24 +9,38 @@ This is the curl man page generator. It generates a single nroff man page output from the set of sources files in this directory. -There is one source file for each supported command line option. The output -gets `page-header` prepended and `page-footer` appended. The format is -described below. +The `mainpage.idx` file lists all files that are rendered in that order to +produce the output. The magic `%options` keyword inserts all command line +options documented. + +The `%options` documentation is created with one source file for each +supported command line option. + +The documentation file format is described below. It is meant to look similar +to markdown which is why it uses `.md` file extensions. ## Option files Each command line option is described in a file named `.d`, where option name is written without any prefixing dashes. Like the file name for -the -v, --verbose option is named `verbose.d`. +the `-v, --verbose` option is named `verbose.d`. + +Each file has a set of meta-data in the top of the file, followed by a body of +text. -Each file has a set of meta-data and a body of text. +The documentation files that do not document options have no meta-data part. + +A line that starts with ``. ### Meta-data + --- (start of meta-data) Added: (version number in which this was added) Arg: (the argument the option takes) c: (copyright line) - Example: (example command line, without "curl" and can use `$URL`) + Example: + - (an example command line, without "curl" and can use `$URL`) + - (another example) Experimental: yes (if so) Help: (short text for the --help output for this option) Long: (long form name, without dashes) @@ -36,7 +50,9 @@ Each file has a set of meta-data and a body of text. Protocols: (space separated list for which protocols this option works) Requires: (space separated list of features this requires, no dashes) Scope: global (if the option is global) - See-also: (space separated list of related options, no dashes) + See-also: + - (a related option, no dashes) + - (another related option, no dashes) Short: (single letter, without dash) SPDX-License-Identifier: curl Tags: (space separated list) @@ -54,12 +70,33 @@ Text written within `*asterisks*` is shown using italics. Text within two Text that is prefixed with a space is treated like an "example" and gets output in monospace. -## Header and footer +Within the body, describe a list of items like this: + + ## item 1 + description + + ## item 2 + second description + +The list is automatically terminated at end of file, or you can do it +explicitly with an empty "header": + + ## + +### Headers + +The `#` header can be used by non-option files and it produces produces a +`.SH` output. + +If the `#` header is used for a command line option file, that header is +simply ignored in the generated output. It can still serve a purpose in the +source file as it helps the user identify what option the file is for. -`page-header` is the file that is output before the generated options output -for the master man page. +### Variables -`page-footer` is appended after all the individual options. +There are three different "variables" that can be used when creating the +output. They need to be written within backticks in the source file (to escape +getting spellchecked by CI jobs): `%DATE`, `%VERSION` and `%GLOBALS`. ## Generate diff --git a/docs/cmdline-opts/Makefile.am b/docs/cmdline-opts/Makefile.am index 5a8996bc2..e9b35ac05 100644 --- a/docs/cmdline-opts/Makefile.am +++ b/docs/cmdline-opts/Makefile.am @@ -28,7 +28,7 @@ MANPAGE = $(top_builddir)/docs/curl.1 include Makefile.inc -EXTRA_DIST = $(DPAGES) MANPAGE.md gen.pl $(OTHERPAGES) CMakeLists.txt +EXTRA_DIST = $(DPAGES) MANPAGE.md gen.pl $(SUPPORT) CMakeLists.txt mainpage.idx GEN = $(GN_$(V)) GN_0 = @echo " GENERATE" $@; @@ -37,5 +37,8 @@ GN_ = $(GN_0) all: $(MANPAGE) -$(MANPAGE): $(DPAGES) $(OTHERPAGES) Makefile.inc gen.pl +$(MANPAGE): $(DPAGES) $(SUPPORT) mainpage.idx Makefile.inc gen.pl $(GEN)(rm -f $(MANPAGE) && cd $(srcdir) && @PERL@ ./gen.pl mainpage $(DPAGES) > $(builddir)/manpage.tmp && mv $(builddir)/manpage.tmp $(MANPAGE)) + +listhelp: + ./gen.pl listhelp $(DPAGES) > $(top_builddir)/src/tool_listhelp.c diff --git a/docs/cmdline-opts/Makefile.inc b/docs/cmdline-opts/Makefile.inc index a7c92f264..428cc3bab 100644 --- a/docs/cmdline-opts/Makefile.inc +++ b/docs/cmdline-opts/Makefile.inc @@ -23,264 +23,283 @@ ########################################################################### # Shared between Makefile.am and CMakeLists.txt -DPAGES = \ - abstract-unix-socket.d \ - alt-svc.d \ - anyauth.d \ - append.d \ - aws-sigv4.d \ - basic.d \ - ca-native.d \ - cacert.d \ - capath.d \ - cert-status.d \ - cert-type.d \ - cert.d \ - ciphers.d \ - compressed-ssh.d \ - compressed.d \ - config.d \ - connect-timeout.d \ - connect-to.d \ - continue-at.d \ - cookie-jar.d \ - cookie.d \ - create-dirs.d \ - create-file-mode.d \ - crlf.d \ - crlfile.d \ - curves.d \ - data-ascii.d \ - data-binary.d \ - data-raw.d \ - data-urlencode.d \ - data.d \ - delegation.d \ - digest.d \ - disable-eprt.d \ - disable-epsv.d \ - disable.d \ - disallow-username-in-url.d \ - dns-interface.d \ - dns-ipv4-addr.d \ - dns-ipv6-addr.d \ - dns-servers.d \ - doh-cert-status.d \ - doh-insecure.d \ - doh-url.d \ - dump-header.d \ - egd-file.d \ - engine.d \ - etag-compare.d \ - etag-save.d \ - expect100-timeout.d \ - fail-early.d \ - fail-with-body.d \ - fail.d \ - false-start.d \ - form-escape.d \ - form-string.d \ - form.d \ - ftp-account.d \ - ftp-alternative-to-user.d \ - ftp-create-dirs.d \ - ftp-method.d \ - ftp-pasv.d \ - ftp-port.d \ - ftp-pret.d \ - ftp-skip-pasv-ip.d \ - ftp-ssl-ccc-mode.d \ - ftp-ssl-ccc.d \ - ftp-ssl-control.d \ - get.d \ - globoff.d \ - happy-eyeballs-timeout-ms.d \ - haproxy-protocol.d \ - haproxy-clientip.d \ - head.d \ - header.d \ - help.d \ - hostpubmd5.d \ - hostpubsha256.d \ - hsts.d \ - http0.9.d \ - http1.0.d \ - http1.1.d \ - http2-prior-knowledge.d \ - http2.d \ - http3.d \ - http3-only.d \ - ignore-content-length.d \ - include.d \ - insecure.d \ - interface.d \ - ipfs-gateway.d \ - ipv4.d \ - ipv6.d \ - json.d \ - junk-session-cookies.d \ - keepalive-time.d \ - key-type.d \ - key.d \ - krb.d \ - libcurl.d \ - limit-rate.d \ - list-only.d \ - local-port.d \ - location-trusted.d \ - location.d \ - login-options.d \ - mail-auth.d \ - mail-from.d \ - mail-rcpt-allowfails.d \ - mail-rcpt.d \ - manual.d \ - max-filesize.d \ - max-redirs.d \ - max-time.d \ - metalink.d \ - negotiate.d \ - netrc-file.d \ - netrc-optional.d \ - netrc.d \ - next.d \ - no-alpn.d \ - no-buffer.d \ - no-clobber.d \ - no-keepalive.d \ - no-npn.d \ - no-progress-meter.d \ - no-sessionid.d \ - noproxy.d \ - ntlm-wb.d \ - ntlm.d \ - oauth2-bearer.d \ - output-dir.d \ - output.d \ - parallel-immediate.d \ - parallel-max.d \ - parallel.d \ - pass.d \ - path-as-is.d \ - pinnedpubkey.d \ - post301.d \ - post302.d \ - post303.d \ - preproxy.d \ - progress-bar.d \ - proto-default.d \ - proto-redir.d \ - proto.d \ - proxy-anyauth.d \ - proxy-basic.d \ - proxy-ca-native.d \ - proxy-cacert.d \ - proxy-capath.d \ - proxy-cert-type.d \ - proxy-cert.d \ - proxy-ciphers.d \ - proxy-crlfile.d \ - proxy-digest.d \ - proxy-header.d \ - proxy-http2.d \ - proxy-insecure.d \ - proxy-key-type.d \ - proxy-key.d \ - proxy-negotiate.d \ - proxy-ntlm.d \ - proxy-pass.d \ - proxy-pinnedpubkey.d \ - proxy-service-name.d \ - proxy-ssl-allow-beast.d \ - proxy-ssl-auto-client-cert.d \ - proxy-tls13-ciphers.d \ - proxy-tlsauthtype.d \ - proxy-tlspassword.d \ - proxy-tlsuser.d \ - proxy-tlsv1.d \ - proxy-user.d \ - proxy.d \ - proxy1.0.d \ - proxytunnel.d \ - pubkey.d \ - quote.d \ - random-file.d \ - range.d \ - rate.d \ - raw.d \ - referer.d \ - remote-header-name.d \ - remote-name-all.d \ - remote-name.d \ - remote-time.d \ - remove-on-error.d \ - request-target.d \ - request.d \ - resolve.d \ - retry-all-errors.d \ - retry-connrefused.d \ - retry-delay.d \ - retry-max-time.d \ - retry.d \ - sasl-authzid.d \ - sasl-ir.d \ - service-name.d \ - show-error.d \ - silent.d \ - socks4.d \ - socks4a.d \ - socks5-basic.d \ - socks5-gssapi-nec.d \ - socks5-gssapi-service.d \ - socks5-gssapi.d \ - socks5-hostname.d \ - socks5.d \ - speed-limit.d \ - speed-time.d \ - ssl-allow-beast.d \ - ssl-auto-client-cert.d \ - ssl-no-revoke.d \ - ssl-reqd.d \ - ssl-revoke-best-effort.d \ - ssl.d \ - sslv2.d \ - sslv3.d \ - stderr.d \ - styled-output.d \ - suppress-connect-headers.d \ - tcp-fastopen.d \ - tcp-nodelay.d \ - telnet-option.d \ - tftp-blksize.d \ - tftp-no-options.d \ - time-cond.d \ - tls-max.d \ - tls13-ciphers.d \ - tlsauthtype.d \ - tlspassword.d \ - tlsuser.d \ - tlsv1.0.d \ - tlsv1.1.d \ - tlsv1.2.d \ - tlsv1.3.d \ - tlsv1.d \ - tr-encoding.d \ - trace-ascii.d \ - trace-config.d \ - trace-ids.d \ - trace-time.d \ - trace.d \ - unix-socket.d \ - upload-file.d \ - url.d \ - url-query.d \ - use-ascii.d \ - user-agent.d \ - user.d \ - variable.d \ - verbose.d \ - version.d \ - write-out.d \ - xattr.d +SUPPORT = \ + _AUTHORS.md \ + _BUGS.md \ + _DESCRIPTION.md \ + _ENVIRONMENT.md \ + _EXITCODES.md \ + _FILES.md \ + _GLOBBING.md \ + _NAME.md \ + _OPTIONS.md \ + _OUTPUT.md \ + _PROGRESS.md \ + _PROTOCOLS.md \ + _PROXYPREFIX.md \ + _SEEALSO.md \ + _SYNOPSIS.md \ + _URL.md \ + _VARIABLES.md \ + _VERSION.md \ + _WWW.md -OTHERPAGES = page-footer page-header +DPAGES = \ + abstract-unix-socket.md \ + alt-svc.md \ + anyauth.md \ + append.md \ + aws-sigv4.md \ + basic.md \ + ca-native.md \ + cacert.md \ + capath.md \ + cert-status.md \ + cert-type.md \ + cert.md \ + ciphers.md \ + compressed-ssh.md \ + compressed.md \ + config.md \ + connect-timeout.md \ + connect-to.md \ + continue-at.md \ + cookie-jar.md \ + cookie.md \ + create-dirs.md \ + create-file-mode.md \ + crlf.md \ + crlfile.md \ + curves.md \ + data-ascii.md \ + data-binary.md \ + data-raw.md \ + data-urlencode.md \ + data.md \ + delegation.md \ + digest.md \ + disable-eprt.md \ + disable-epsv.md \ + disable.md \ + disallow-username-in-url.md \ + dns-interface.md \ + dns-ipv4-addr.md \ + dns-ipv6-addr.md \ + dns-servers.md \ + doh-cert-status.md \ + doh-insecure.md \ + doh-url.md \ + dump-header.md \ + egd-file.md \ + engine.md \ + etag-compare.md \ + etag-save.md \ + expect100-timeout.md \ + fail-early.md \ + fail-with-body.md \ + fail.md \ + false-start.md \ + form-escape.md \ + form-string.md \ + form.md \ + ftp-account.md \ + ftp-alternative-to-user.md \ + ftp-create-dirs.md \ + ftp-method.md \ + ftp-pasv.md \ + ftp-port.md \ + ftp-pret.md \ + ftp-skip-pasv-ip.md \ + ftp-ssl-ccc-mode.md \ + ftp-ssl-ccc.md \ + ftp-ssl-control.md \ + get.md \ + globoff.md \ + happy-eyeballs-timeout-ms.md \ + haproxy-protocol.md \ + haproxy-clientip.md \ + head.md \ + header.md \ + help.md \ + hostpubmd5.md \ + hostpubsha256.md \ + hsts.md \ + http0.9.md \ + http1.0.md \ + http1.1.md \ + http2-prior-knowledge.md \ + http2.md \ + http3.md \ + http3-only.md \ + ignore-content-length.md \ + include.md \ + insecure.md \ + interface.md \ + ipfs-gateway.md \ + ipv4.md \ + ipv6.md \ + json.md \ + junk-session-cookies.md \ + keepalive-time.md \ + key-type.md \ + key.md \ + krb.md \ + libcurl.md \ + limit-rate.md \ + list-only.md \ + local-port.md \ + location-trusted.md \ + location.md \ + login-options.md \ + mail-auth.md \ + mail-from.md \ + mail-rcpt-allowfails.md \ + mail-rcpt.md \ + manual.md \ + max-filesize.md \ + max-redirs.md \ + max-time.md \ + metalink.md \ + negotiate.md \ + netrc-file.md \ + netrc-optional.md \ + netrc.md \ + next.md \ + no-alpn.md \ + no-buffer.md \ + no-clobber.md \ + no-keepalive.md \ + no-npn.md \ + no-progress-meter.md \ + no-sessionid.md \ + noproxy.md \ + ntlm-wb.md \ + ntlm.md \ + oauth2-bearer.md \ + output-dir.md \ + output.md \ + parallel-immediate.md \ + parallel-max.md \ + parallel.md \ + pass.md \ + path-as-is.md \ + pinnedpubkey.md \ + post301.md \ + post302.md \ + post303.md \ + preproxy.md \ + progress-bar.md \ + proto-default.md \ + proto-redir.md \ + proto.md \ + proxy-anyauth.md \ + proxy-basic.md \ + proxy-ca-native.md \ + proxy-cacert.md \ + proxy-capath.md \ + proxy-cert-type.md \ + proxy-cert.md \ + proxy-ciphers.md \ + proxy-crlfile.md \ + proxy-digest.md \ + proxy-header.md \ + proxy-http2.md \ + proxy-insecure.md \ + proxy-key-type.md \ + proxy-key.md \ + proxy-negotiate.md \ + proxy-ntlm.md \ + proxy-pass.md \ + proxy-pinnedpubkey.md \ + proxy-service-name.md \ + proxy-ssl-allow-beast.md \ + proxy-ssl-auto-client-cert.md \ + proxy-tls13-ciphers.md \ + proxy-tlsauthtype.md \ + proxy-tlspassword.md \ + proxy-tlsuser.md \ + proxy-tlsv1.md \ + proxy-user.md \ + proxy.md \ + proxy1.0.md \ + proxytunnel.md \ + pubkey.md \ + quote.md \ + random-file.md \ + range.md \ + rate.md \ + raw.md \ + referer.md \ + remote-header-name.md \ + remote-name-all.md \ + remote-name.md \ + remote-time.md \ + remove-on-error.md \ + request-target.md \ + request.md \ + resolve.md \ + retry-all-errors.md \ + retry-connrefused.md \ + retry-delay.md \ + retry-max-time.md \ + retry.md \ + sasl-authzid.md \ + sasl-ir.md \ + service-name.md \ + show-error.md \ + silent.md \ + socks4.md \ + socks4a.md \ + socks5-basic.md \ + socks5-gssapi-nec.md \ + socks5-gssapi-service.md \ + socks5-gssapi.md \ + socks5-hostname.md \ + socks5.md \ + speed-limit.md \ + speed-time.md \ + ssl-allow-beast.md \ + ssl-auto-client-cert.md \ + ssl-no-revoke.md \ + ssl-reqd.md \ + ssl-revoke-best-effort.md \ + ssl.md \ + sslv2.md \ + sslv3.md \ + stderr.md \ + styled-output.md \ + suppress-connect-headers.md \ + tcp-fastopen.md \ + tcp-nodelay.md \ + telnet-option.md \ + tftp-blksize.md \ + tftp-no-options.md \ + time-cond.md \ + tls-max.md \ + tls13-ciphers.md \ + tlsauthtype.md \ + tlspassword.md \ + tlsuser.md \ + tlsv1.0.md \ + tlsv1.1.md \ + tlsv1.2.md \ + tlsv1.3.md \ + tlsv1.md \ + tr-encoding.md \ + trace-ascii.md \ + trace-config.md \ + trace-ids.md \ + trace-time.md \ + trace.md \ + unix-socket.md \ + upload-file.md \ + url.md \ + url-query.md \ + use-ascii.md \ + user-agent.md \ + user.md \ + variable.md \ + verbose.md \ + version.md \ + write-out.md \ + xattr.md diff --git a/docs/cmdline-opts/_AUTHORS.md b/docs/cmdline-opts/_AUTHORS.md new file mode 100644 index 000000000..0c9bfb953 --- /dev/null +++ b/docs/cmdline-opts/_AUTHORS.md @@ -0,0 +1,5 @@ + + +# AUTHORS +Daniel Stenberg is the main author, but the whole list of contributors is +found in the separate THANKS file. diff --git a/docs/cmdline-opts/_BUGS.md b/docs/cmdline-opts/_BUGS.md new file mode 100644 index 000000000..45630d435 --- /dev/null +++ b/docs/cmdline-opts/_BUGS.md @@ -0,0 +1,5 @@ + + +# BUGS +If you experience any problems with curl, submit an issue in the project's bug +tracker on GitHub: https://github.com/curl/curl/issues diff --git a/docs/cmdline-opts/_DESCRIPTION.md b/docs/cmdline-opts/_DESCRIPTION.md new file mode 100644 index 000000000..3e06c1b38 --- /dev/null +++ b/docs/cmdline-opts/_DESCRIPTION.md @@ -0,0 +1,11 @@ + + +# DESCRIPTION + +**curl** is a tool for transferring data from or to a server using URLs. It +supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, +IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + +curl is powered by libcurl for all transfer-related features. See +*libcurl(3)* for details. diff --git a/docs/cmdline-opts/_ENVIRONMENT.md b/docs/cmdline-opts/_ENVIRONMENT.md new file mode 100644 index 000000000..cf30d4740 --- /dev/null +++ b/docs/cmdline-opts/_ENVIRONMENT.md @@ -0,0 +1,114 @@ + + +# ENVIRONMENT +The environment variables can be specified in lower case or upper case. The +lower case version has precedence. `http_proxy` is an exception as it is only +available in lower case. + +Using an environment variable to set the proxy has the same effect as using +the --proxy option. + +## `http_proxy` [protocol://][:port] +Sets the proxy server to use for HTTP. + +## `HTTPS_PROXY` [protocol://][:port] +Sets the proxy server to use for HTTPS. + +## `[url-protocol]_PROXY` [protocol://][:port] +Sets the proxy server to use for [url-protocol], where the protocol is a +protocol that curl supports and as specified in a URL. FTP, FTPS, POP3, IMAP, +SMTP, LDAP, etc. + +## `ALL_PROXY` [protocol://][:port] +Sets the proxy server to use if no protocol-specific proxy is set. + +## `NO_PROXY` +list of host names that should not go through any proxy. If set to an asterisk +'*' only, it matches all hosts. Each name in this list is matched as either +a domain name which contains the hostname, or the hostname itself. + +This environment variable disables use of the proxy even when specified with +the --proxy option. That is + + NO_PROXY=direct.example.com curl -x http://proxy.example.com + http://direct.example.com + +accesses the target URL directly, and + + NO_PROXY=direct.example.com curl -x http://proxy.example.com + http://somewhere.example.com + +accesses the target URL through the proxy. + +The list of host names can also be include numerical IP addresses, and IPv6 +versions should then be given without enclosing brackets. + +IP addresses can be specified using CIDR notation: an appended slash and +number specifies the number of "network bits" out of the address to use in the +comparison (added in 7.86.0). For example "192.168.0.0/16" would match all +addresses starting with "192.168". + +## `APPDATA` +On Windows, this variable is used when trying to find the home directory. If +the primary home variable are all unset. + +## `COLUMNS` +If set, the specified number of characters is used as the terminal width when +the alternative progress-bar is shown. If not set, curl tries to figure it out +using other ways. + +## `CURL_CA_BUNDLE` +If set, it is used as the --cacert value. This environment variable is ignored +if Schannel is used as the TLS backend. + +## `CURL_HOME` +If set, is the first variable curl checks when trying to find its home +directory. If not set, it continues to check *XDG_CONFIG_HOME* + +## `CURL_SSL_BACKEND` +If curl was built with support for "MultiSSL", meaning that it has built-in +support for more than one TLS backend, this environment variable can be set to +the case insensitive name of the particular backend to use when curl is +invoked. Setting a name that is not a built-in alternative makes curl stay +with the default. + +SSL backend names (case-insensitive): **bearssl**, **gnutls**, **mbedtls**, +**openssl**, **rustls**, **schannel**, **secure-transport**, **wolfssl** + +## `HOME` +If set, this is used to find the home directory when that is needed. Like when +looking for the default .curlrc. *CURL_HOME* and *XDG_CONFIG_HOME* +have preference. + +## `QLOGDIR` +If curl was built with HTTP/3 support, setting this environment variable to a +local directory makes curl produce **qlogs** in that directory, using file +names named after the destination connection id (in hex). Do note that these +files can become rather large. Works with the ngtcp2 and quiche QUIC backends. + +## `SHELL` +Used on VMS when trying to detect if using a **DCL** or a **unix** shell. + +## `SSL_CERT_DIR` +If set, it is used as the --capath value. This environment variable is ignored +if Schannel is used as the TLS backend. + +## `SSL_CERT_FILE` +If set, it is used as the --cacert value. This environment variable is ignored +if Schannel is used as the TLS backend. + +## `SSLKEYLOGFILE` +If you set this environment variable to a file name, curl stores TLS secrets +from its connections in that file when invoked to enable you to analyze the +TLS traffic in real time using network analyzing tools such as Wireshark. This +works with the following TLS backends: OpenSSL, libressl, BoringSSL, GnuTLS +and wolfSSL. + +## `USERPROFILE` +On Windows, this variable is used when trying to find the home directory. If +the other, primary, variable are all unset. If set, curl uses the path +**"$USERPROFILE\Application Data"**. + +## `XDG_CONFIG_HOME` +If *CURL_HOME* is not set, this variable is checked when looking for a +default .curlrc file. diff --git a/docs/cmdline-opts/_EXITCODES.md b/docs/cmdline-opts/_EXITCODES.md new file mode 100644 index 000000000..ac7ab5ca1 --- /dev/null +++ b/docs/cmdline-opts/_EXITCODES.md @@ -0,0 +1,201 @@ + + +# EXIT CODES +There are a bunch of different error codes and their corresponding error +messages that may appear under error conditions. At the time of this writing, +the exit codes are: +## 0 +Success. The operation completed successfully according to the instructions. +## 1 +Unsupported protocol. This build of curl has no support for this protocol. +## 2 +Failed to initialize. +## 3 +URL malformed. The syntax was not correct. +## 4 +A feature or option that was needed to perform the desired request was not +enabled or was explicitly disabled at build-time. To make curl able to do +this, you probably need another build of libcurl. +## 5 +Could not resolve proxy. The given proxy host could not be resolved. +## 6 +Could not resolve host. The given remote host could not be resolved. +## 7 +Failed to connect to host. +## 8 +Weird server reply. The server sent data curl could not parse. +## 9 +FTP access denied. The server denied login or denied access to the particular +resource or directory you wanted to reach. Most often you tried to change to a +directory that does not exist on the server. +## 10 +FTP accept failed. While waiting for the server to connect back when an active +FTP session is used, an error code was sent over the control connection or +similar. +## 11 +FTP weird PASS reply. Curl could not parse the reply sent to the PASS request. +## 12 +During an active FTP session while waiting for the server to connect back to +curl, the timeout expired. +## 13 +FTP weird PASV reply, Curl could not parse the reply sent to the PASV request. +## 14 +FTP weird 227 format. Curl could not parse the 227-line the server sent. +## 15 +FTP cannot use host. Could not resolve the host IP we got in the 227-line. +## 16 +HTTP/2 error. A problem was detected in the HTTP2 framing layer. This is +somewhat generic and can be one out of several problems, see the error message +for details. +## 17 +FTP could not set binary. Could not change transfer method to binary. +## 18 +Partial file. Only a part of the file was transferred. +## 19 +FTP could not download/access the given file, the RETR (or similar) command +failed. +## 21 +FTP quote error. A quote command returned error from the server. +## 22 +HTTP page not retrieved. The requested URL was not found or returned another +error with the HTTP error code being 400 or above. This return code only +appears if --fail is used. +## 23 +Write error. Curl could not write data to a local filesystem or similar. +## 25 +Failed starting the upload. For FTP, the server typically denied the STOR +command. +## 26 +Read error. Various reading problems. +## 27 +Out of memory. A memory allocation request failed. +## 28 +Operation timeout. The specified time-out period was reached according to the +conditions. +## 30 +FTP PORT failed. The PORT command failed. Not all FTP servers support the PORT +command, try doing a transfer using PASV instead. +## 31 +FTP could not use REST. The REST command failed. This command is used for +resumed FTP transfers. +## 33 +HTTP range error. The range "command" did not work. +## 34 +HTTP post error. Internal post-request generation error. +## 35 +SSL connect error. The SSL handshaking failed. +## 36 +Bad download resume. Could not continue an earlier aborted download. +## 37 +FILE could not read file. Failed to open the file. Permissions? +## 38 +LDAP cannot bind. LDAP bind operation failed. +## 39 +LDAP search failed. +## 41 +Function not found. A required LDAP function was not found. +## 42 +Aborted by callback. An application told curl to abort the operation. +## 43 +Internal error. A function was called with a bad parameter. +## 45 +Interface error. A specified outgoing interface could not be used. +## 47 +Too many redirects. When following redirects, curl hit the maximum amount. +## 48 +Unknown option specified to libcurl. This indicates that you passed a weird +option to curl that was passed on to libcurl and rejected. Read up in the +manual! +## 49 +Malformed telnet option. +## 52 +The server did not reply anything, which here is considered an error. +## 53 +SSL crypto engine not found. +## 54 +Cannot set SSL crypto engine as default. +## 55 +Failed sending network data. +## 56 +Failure in receiving network data. +## 58 +Problem with the local certificate. +## 59 +Could not use specified SSL cipher. +## 60 +Peer certificate cannot be authenticated with known CA certificates. +## 61 +Unrecognized transfer encoding. +## 63 +Maximum file size exceeded. +## 64 +Requested FTP SSL level failed. +## 65 +Sending the data requires a rewind that failed. +## 66 +Failed to initialize SSL Engine. +## 67 +The user name, password, or similar was not accepted and curl failed to log in. +## 68 +File not found on TFTP server. +## 69 +Permission problem on TFTP server. +## 70 +Out of disk space on TFTP server. +## 71 +Illegal TFTP operation. +## 72 +Unknown TFTP transfer ID. +## 73 +File already exists (TFTP). +## 74 +No such user (TFTP). +## 77 +Problem reading the SSL CA cert (path? access rights?). +## 78 +The resource referenced in the URL does not exist. +## 79 +An unspecified error occurred during the SSH session. +## 80 +Failed to shut down the SSL connection. +## 82 +Could not load CRL file, missing or wrong format (added in 7.19.0). +## 83 +Issuer check failed (added in 7.19.0). +## 84 +The FTP PRET command failed. +## 85 +Mismatch of RTSP CSeq numbers. +## 86 +Mismatch of RTSP Session Identifiers. +## 87 +Unable to parse FTP file list. +## 88 +FTP chunk callback reported error. +## 89 +No connection available, the session is queued. +## 90 +SSL public key does not matched pinned public key. +## 91 +Invalid SSL certificate status. +## 92 +Stream error in HTTP/2 framing layer. +## 93 +An API function was called from inside a callback. +## 94 +An authentication function returned an error. +## 95 +A problem was detected in the HTTP/3 layer. This is somewhat generic and can +be one out of several problems, see the error message for details. +## 96 +QUIC connection error. This error may be caused by an SSL library error. QUIC +is the protocol used for HTTP/3 transfers. +## 97 +Proxy handshake error. +## 98 +A client-side certificate is required to complete the TLS handshake. +## 99 +Poll or select returned fatal error. +## XX +More error codes might appear here in future releases. The existing ones are +meant to never change. diff --git a/docs/cmdline-opts/_FILES.md b/docs/cmdline-opts/_FILES.md new file mode 100644 index 000000000..8c5d3faa7 --- /dev/null +++ b/docs/cmdline-opts/_FILES.md @@ -0,0 +1,6 @@ + + +# FILES +*~/.curlrc* + +Default config file, see --config for details. diff --git a/docs/cmdline-opts/_GLOBBING.md b/docs/cmdline-opts/_GLOBBING.md new file mode 100644 index 000000000..282356c3e --- /dev/null +++ b/docs/cmdline-opts/_GLOBBING.md @@ -0,0 +1,40 @@ + + +# GLOBBING +You can specify multiple URLs or parts of URLs by writing lists within braces +or ranges within brackets. We call this "globbing". + +Provide a list with three different names like this: + + "http://site.{one,two,three}.com" + +Do sequences of alphanumeric series by using [] as in: + + "ftp://ftp.example.com/file[1-100].txt" + +With leading zeroes: + + "ftp://ftp.example.com/file[001-100].txt" + +With letters through the alphabet: + + "ftp://ftp.example.com/file[a-z].txt" + +Nested sequences are not supported, but you can use several ones next to each +other: + + "http://example.com/archive[1996-1999]/vol[1-4]/part{a,b,c}.html" + +You can specify a step counter for the ranges to get every Nth number or +letter: + + "http://example.com/file[1-100:10].txt" + + "http://example.com/file[a-z:2].txt" + +When using [] or {} sequences when invoked from a command line prompt, you +probably have to put the full URL within double quotes to avoid the shell from +interfering with it. This also goes for other characters treated special, like +for example '&', '?' and '*'. + +Switch off globbing with --globoff. diff --git a/docs/cmdline-opts/_NAME.md b/docs/cmdline-opts/_NAME.md new file mode 100644 index 000000000..b0d891614 --- /dev/null +++ b/docs/cmdline-opts/_NAME.md @@ -0,0 +1,4 @@ + + +# NAME +curl - transfer a URL diff --git a/docs/cmdline-opts/_OPTIONS.md b/docs/cmdline-opts/_OPTIONS.md new file mode 100644 index 000000000..1b2556659 --- /dev/null +++ b/docs/cmdline-opts/_OPTIONS.md @@ -0,0 +1,26 @@ + + +# OPTIONS +Options start with one or two dashes. Many of the options require an +additional value next to them. If provided text does not start with a dash, it +is presumed to be and treated as a URL. + +The short "single-dash" form of the options, -d for example, may be used with +or without a space between it and its value, although a space is a recommended +separator. The long "double-dash" form, --data for example, requires a space +between it and its value. + +Short version options that do not need any additional values can be used +immediately next to each other, like for example you can specify all the +options *-O*, *-L* and *-v* at once as *-OLv*. + +In general, all boolean options are enabled with --**option** and yet again +disabled with --**no-**option. That is, you use the same option name but +prefix it with "no-". However, in this list we mostly only list and show the +*--option* version of them. + +When --next is used, it resets the parser state and you start again with a +clean option state, except for the options that are "global". Global options +retain their values and meaning even after --next. + +The following options are global: `%GLOBALS`. diff --git a/docs/cmdline-opts/_OUTPUT.md b/docs/cmdline-opts/_OUTPUT.md new file mode 100644 index 000000000..32a5457af --- /dev/null +++ b/docs/cmdline-opts/_OUTPUT.md @@ -0,0 +1,11 @@ + + +# OUTPUT +If not told otherwise, curl writes the received data to stdout. It can be +instructed to instead save that data into a local file, using the --output or +--remote-name options. If curl is given multiple URLs to transfer on the +command line, it similarly needs multiple options for where to save them. + +curl does not parse or otherwise "understand" the content it gets or writes as +output. It does no encoding or decoding, unless explicitly asked to with +dedicated command line options. diff --git a/docs/cmdline-opts/_PROGRESS.md b/docs/cmdline-opts/_PROGRESS.md new file mode 100644 index 000000000..80e36f102 --- /dev/null +++ b/docs/cmdline-opts/_PROGRESS.md @@ -0,0 +1,25 @@ + + +# "PROGRESS METER" + +curl normally displays a progress meter during operations, indicating the +amount of transferred data, transfer speeds and estimated time left, etc. The +progress meter displays the transfer rate in bytes per second. The suffixes +(k, M, G, T, P) are 1024 based. For example 1k is 1024 bytes. 1M is 1048576 +bytes. + +curl displays this data to the terminal by default, so if you invoke curl to +do an operation and it is about to write data to the terminal, it *disables* +the progress meter as otherwise it would mess up the output mixing progress +meter and response data. + +If you want a progress meter for HTTP POST or PUT requests, you need to +redirect the response output to a file, using shell redirect (>), --output or +similar. + +This does not apply to FTP upload as that operation does not spit out any +response data to the terminal. + +If you prefer a progress "bar" instead of the regular meter, --progress-bar is +your friend. You can also disable the progress meter completely with the +--silent option. diff --git a/docs/cmdline-opts/_PROTOCOLS.md b/docs/cmdline-opts/_PROTOCOLS.md new file mode 100644 index 000000000..b834f9ae3 --- /dev/null +++ b/docs/cmdline-opts/_PROTOCOLS.md @@ -0,0 +1,51 @@ + + +# PROTOCOLS +curl supports numerous protocols, or put in URL terms: schemes. Your +particular build may not support them all. +## DICT +Lets you lookup words using online dictionaries. +## FILE +Read or write local files. curl does not support accessing file:// URL +remotely, but when running on Microsoft Windows using the native UNC approach +works. +## FTP(S) +curl supports the File Transfer Protocol with a lot of tweaks and levers. With +or without using TLS. +## GOPHER(S) +Retrieve files. +## HTTP(S) +curl supports HTTP with numerous options and variations. It can speak HTTP +version 0.9, 1.0, 1.1, 2 and 3 depending on build options and the correct +command line options. +## IMAP(S) +Using the mail reading protocol, curl can "download" emails for you. With or +without using TLS. +## LDAP(S) +curl can do directory lookups for you, with or without TLS. +## MQTT +curl supports MQTT version 3. Downloading over MQTT equals "subscribe" to a +topic while uploading/posting equals "publish" on a topic. MQTT over TLS is +not supported (yet). +## POP3(S) +Downloading from a pop3 server means getting a mail. With or without using +TLS. +## RTMP(S) +The **Realtime Messaging Protocol** is primarily used to serve streaming media +and curl can download it. +## RTSP +curl supports RTSP 1.0 downloads. +## SCP +curl supports SSH version 2 scp transfers. +## SFTP +curl supports SFTP (draft 5) done over SSH version 2. +## SMB(S) +curl supports SMB version 1 for upload and download. +## SMTP(S) +Uploading contents to an SMTP server means sending an email. With or without +TLS. +## TELNET +Telling curl to fetch a telnet URL starts an interactive session where it +sends what it reads on stdin and outputs what the server sends it. +## TFTP +curl can do TFTP downloads and uploads. diff --git a/docs/cmdline-opts/_PROXYPREFIX.md b/docs/cmdline-opts/_PROXYPREFIX.md new file mode 100644 index 000000000..297b56c4b --- /dev/null +++ b/docs/cmdline-opts/_PROXYPREFIX.md @@ -0,0 +1,22 @@ + + +# PROXY PROTOCOL PREFIXES +The proxy string may be specified with a protocol:// prefix to specify +alternative proxy protocols. (Added in 7.21.7) + +If no protocol is specified in the proxy string or if the string does not +match a supported one, the proxy is treated as an HTTP proxy. + +The supported proxy protocol prefixes are as follows: +## http:// +Makes it use it as an HTTP proxy. The default if no scheme prefix is used. +## https:// +Makes it treated as an **HTTPS** proxy. +## socks4:// +Makes it the equivalent of --socks4 +## socks4a:// +Makes it the equivalent of --socks4a +## socks5:// +Makes it the equivalent of --socks5 +## socks5h:// +Makes it the equivalent of --socks5-hostname diff --git a/docs/cmdline-opts/_SEEALSO.md b/docs/cmdline-opts/_SEEALSO.md new file mode 100644 index 000000000..f4d0b55cf --- /dev/null +++ b/docs/cmdline-opts/_SEEALSO.md @@ -0,0 +1,5 @@ + + +# SEE ALSO + +**ftp (1)**, **wget (1)** diff --git a/docs/cmdline-opts/_SYNOPSIS.md b/docs/cmdline-opts/_SYNOPSIS.md new file mode 100644 index 000000000..381587744 --- /dev/null +++ b/docs/cmdline-opts/_SYNOPSIS.md @@ -0,0 +1,5 @@ + + +# SYNOPSIS + +**curl [options / URLs]** diff --git a/docs/cmdline-opts/_URL.md b/docs/cmdline-opts/_URL.md new file mode 100644 index 000000000..0084ec612 --- /dev/null +++ b/docs/cmdline-opts/_URL.md @@ -0,0 +1,28 @@ + + +# URL +The URL syntax is protocol-dependent. You find a detailed description in +RFC 3986. + +If you provide a URL without a leading **protocol://** scheme, curl guesses +what protocol you want. It then defaults to HTTP but assumes others based on +often-used host name prefixes. For example, for host names starting with +"ftp." curl assumes you want FTP. + +You can specify any amount of URLs on the command line. They are fetched in a +sequential manner in the specified order unless you use --parallel. You can +specify command line options and URLs mixed and in any order on the command +line. + +curl attempts to reuse connections when doing multiple transfers, so that +getting many files from the same server do not use multiple connects and setup +handshakes. This improves speed. Connection reuse can only be done for URLs +specified for a single command line invocation and cannot be performed between +separate curl runs. + +Provide an IPv6 zone id in the URL with an escaped percentage sign. Like in + + "http://[fe80::3%25eth0]/" + +Everything provided on the command line that is not a command line option or +its argument, curl assumes is a URL and treats it as such. diff --git a/docs/cmdline-opts/_VARIABLES.md b/docs/cmdline-opts/_VARIABLES.md new file mode 100644 index 000000000..3e17bfdae --- /dev/null +++ b/docs/cmdline-opts/_VARIABLES.md @@ -0,0 +1,44 @@ + + +# VARIABLES +curl supports command line variables (added in 8.3.0). Set variables with +--variable name=content or --variable name@file (where "file" can be stdin if +set to a single dash (-)). + +Variable contents can be expanded in option parameters using "{{name}}" (without +the quotes) if the option name is prefixed with "--expand-". This gets the +contents of the variable "name" inserted, or a blank if the name does not +exist as a variable. Insert "{{" verbatim in the string by prefixing it with a +backslash, like "\{{". + +You an access and expand environment variables by first importing them. You +can select to either require the environment variable to be set or you can +provide a default value in case it is not already set. Plain --variable %name +imports the variable called 'name' but exits with an error if that environment +variable is not already set. To provide a default value if it is not set, use +--variable %name=content or --variable %name@content. + +Example. Get the USER environment variable into the URL, fail if USER is not +set: + + --variable '%USER' + --expand-url = "https://example.com/api/{{USER}}/method" + +When expanding variables, curl supports a set of functions that can make the +variable contents more convenient to use. It can trim leading and trailing +white space with *trim*, it can output the contents as a JSON quoted string +with *json*, URL encode the string with *url* or base64 encode it with +*b64*. You apply function to a variable expansion, add them colon separated to +the right side of the variable. Variable content holding null bytes that are +not encoded when expanded cause error. + +Example: get the contents of a file called $HOME/.secret into a variable +called "fix". Make sure that the content is trimmed and percent-encoded sent +as POST data: + + --variable %HOME + --expand-variable fix@{{HOME}}/.secret + --expand-data "{{fix:trim:url}}" + https://example.com/ + +Command line variables and expansions were added in in 8.3.0. diff --git a/docs/cmdline-opts/_VERSION.md b/docs/cmdline-opts/_VERSION.md new file mode 100644 index 000000000..4c759f147 --- /dev/null +++ b/docs/cmdline-opts/_VERSION.md @@ -0,0 +1,15 @@ + + +# VERSION + +This man page describes curl %VERSION. If you use a later version, chances are +this man page does not fully document it. If you use an earlier version, this +document tries to include version information about which specific version +that introduced changes. + +You can always learn which the latest curl version is by running + + curl https://curl.se/info + +The online version of this man page is always showing the latest incarnation: +https://curl.se/docs/manpage.html diff --git a/docs/cmdline-opts/_WWW.md b/docs/cmdline-opts/_WWW.md new file mode 100644 index 000000000..35d946697 --- /dev/null +++ b/docs/cmdline-opts/_WWW.md @@ -0,0 +1,4 @@ + + +# WWW +https://curl.se diff --git a/docs/cmdline-opts/abstract-unix-socket.d b/docs/cmdline-opts/abstract-unix-socket.d deleted file mode 100644 index 5c2fd4a47..000000000 --- a/docs/cmdline-opts/abstract-unix-socket.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: abstract-unix-socket -Arg: -Help: Connect via abstract Unix domain socket -Added: 7.53.0 -Protocols: HTTP -Category: connection -See-also: unix-socket -Example: --abstract-unix-socket socketpath $URL -Multi: single ---- -Connect through an abstract Unix domain socket, instead of using the network. -Note: netstat shows the path of an abstract socket prefixed with '@', however -the argument should not have this leading character. diff --git a/docs/cmdline-opts/abstract-unix-socket.md b/docs/cmdline-opts/abstract-unix-socket.md new file mode 100644 index 000000000..27bc8cad6 --- /dev/null +++ b/docs/cmdline-opts/abstract-unix-socket.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: abstract-unix-socket +Arg: +Help: Connect via abstract Unix domain socket +Added: 7.53.0 +Protocols: HTTP +Category: connection +Multi: single +See-also: + - unix-socket +Example: + - --abstract-unix-socket socketpath $URL +--- + +# `--abstract-unix-socket` + +Connect through an abstract Unix domain socket, instead of using the network. +Note: netstat shows the path of an abstract socket prefixed with '@', however +the argument should not have this leading character. diff --git a/docs/cmdline-opts/alt-svc.d b/docs/cmdline-opts/alt-svc.d deleted file mode 100644 index 276ac1b66..000000000 --- a/docs/cmdline-opts/alt-svc.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: alt-svc -Arg: -Protocols: HTTPS -Help: Enable alt-svc with this cache file -Added: 7.64.1 -Category: http -See-also: resolve connect-to -Example: --alt-svc svc.txt $URL -Multi: append ---- -This option enables the alt-svc parser in curl. If the file name points to an -existing alt-svc cache file, that gets used. After a completed transfer, the -cache is saved to the file name again if it has been modified. - -Specify a "" file name (zero length) to avoid loading/saving and make curl -just handle the cache in memory. - -If this option is used several times, curl loads contents from all the -files but the last one is used for saving. diff --git a/docs/cmdline-opts/alt-svc.md b/docs/cmdline-opts/alt-svc.md new file mode 100644 index 000000000..0a0f17df5 --- /dev/null +++ b/docs/cmdline-opts/alt-svc.md @@ -0,0 +1,28 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: alt-svc +Arg: +Protocols: HTTPS +Help: Enable alt-svc with this cache file +Added: 7.64.1 +Category: http +Multi: append +See-also: + - resolve + - connect-to +Example: + - --alt-svc svc.txt $URL +--- + +# `--alt-svc` + +This option enables the alt-svc parser in curl. If the file name points to an +existing alt-svc cache file, that gets used. After a completed transfer, the +cache is saved to the file name again if it has been modified. + +Specify a "" file name (zero length) to avoid loading/saving and make curl +just handle the cache in memory. + +If this option is used several times, curl loads contents from all the +files but the last one is used for saving. diff --git a/docs/cmdline-opts/anyauth.d b/docs/cmdline-opts/anyauth.d deleted file mode 100644 index 2498bdcd8..000000000 --- a/docs/cmdline-opts/anyauth.d +++ /dev/null @@ -1,22 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: anyauth -Help: Pick any authentication method -Protocols: HTTP -See-also: proxy-anyauth basic digest -Category: http proxy auth -Example: --anyauth --user me:pwd $URL -Added: 7.10.6 -Multi: mutex ---- -Tells curl to figure out authentication method by itself, and use the most -secure one the remote site claims to support. This is done by first doing a -request and checking the response-headers, thus possibly inducing an extra -network round-trip. This is used instead of setting a specific authentication -method, which you can do with --basic, --digest, --ntlm, and --negotiate. - -Using --anyauth is not recommended if you do uploads from stdin, since it may -require data to be sent twice and then the client must be able to rewind. If -the need should arise when uploading from stdin, the upload operation fails. - -Used together with --user. diff --git a/docs/cmdline-opts/anyauth.md b/docs/cmdline-opts/anyauth.md new file mode 100644 index 000000000..150e069e8 --- /dev/null +++ b/docs/cmdline-opts/anyauth.md @@ -0,0 +1,30 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: anyauth +Help: Pick any authentication method +Protocols: HTTP +Category: http proxy auth +Added: 7.10.6 +Multi: mutex +See-also: + - proxy-anyauth + - basic + - digest +Example: + - --anyauth --user me:pwd $URL +--- + +# `--anyauth` + +Tells curl to figure out authentication method by itself, and use the most +secure one the remote site claims to support. This is done by first doing a +request and checking the response-headers, thus possibly inducing an extra +network round-trip. This is used instead of setting a specific authentication +method, which you can do with --basic, --digest, --ntlm, and --negotiate. + +Using --anyauth is not recommended if you do uploads from stdin, since it may +require data to be sent twice and then the client must be able to rewind. If +the need should arise when uploading from stdin, the upload operation fails. + +Used together with --user. diff --git a/docs/cmdline-opts/append.d b/docs/cmdline-opts/append.d deleted file mode 100644 index 7561c951c..000000000 --- a/docs/cmdline-opts/append.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: a -Long: append -Help: Append to target file when uploading -Protocols: FTP SFTP -Category: ftp sftp -See-also: range continue-at -Example: --upload-file local --append ftp://example.com/ -Added: 4.8 -Multi: boolean ---- -When used in an upload, this option makes curl append to the target file -instead of overwriting it. If the remote file does not exist, it is -created. Note that this flag is ignored by some SFTP servers (including -OpenSSH). diff --git a/docs/cmdline-opts/append.md b/docs/cmdline-opts/append.md new file mode 100644 index 000000000..3d0030d6a --- /dev/null +++ b/docs/cmdline-opts/append.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: a +Long: append +Help: Append to target file when uploading +Protocols: FTP SFTP +Category: ftp sftp +Added: 4.8 +Multi: boolean +See-also: + - range + - continue-at +Example: + - --upload-file local --append ftp://example.com/ +--- + +# `--append` + +When used in an upload, this option makes curl append to the target file +instead of overwriting it. If the remote file does not exist, it is +created. Note that this flag is ignored by some SFTP servers (including +OpenSSH). diff --git a/docs/cmdline-opts/aws-sigv4.d b/docs/cmdline-opts/aws-sigv4.d deleted file mode 100644 index b771eee6a..000000000 --- a/docs/cmdline-opts/aws-sigv4.d +++ /dev/null @@ -1,22 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: aws-sigv4 -Arg: -Help: Use AWS V4 signature authentication -Category: auth http -Added: 7.75.0 -See-also: basic user -Example: --aws-sigv4 "aws:amz:us-east-2:es" --user "key:secret" $URL -Multi: single ---- -Use AWS V4 signature authentication in the transfer. - -The provider argument is a string that is used by the algorithm when creating -outgoing authentication headers. - -The region argument is a string that points to a geographic area of -a resources collection (region-code) when the region name is omitted from -the endpoint. - -The service argument is a string that points to a function provided by a cloud -(service-code) when the service name is omitted from the endpoint. diff --git a/docs/cmdline-opts/aws-sigv4.md b/docs/cmdline-opts/aws-sigv4.md new file mode 100644 index 000000000..1b3909244 --- /dev/null +++ b/docs/cmdline-opts/aws-sigv4.md @@ -0,0 +1,30 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: aws-sigv4 +Protocols: HTTP +Arg: +Help: Use AWS V4 signature authentication +Category: auth http +Added: 7.75.0 +Multi: single +See-also: + - basic + - user +Example: + - --aws-sigv4 "aws:amz:us-east-2:es" --user "key:secret" $URL +--- + +# `--aws-sigv4` + +Use AWS V4 signature authentication in the transfer. + +The provider argument is a string that is used by the algorithm when creating +outgoing authentication headers. + +The region argument is a string that points to a geographic area of +a resources collection (region-code) when the region name is omitted from +the endpoint. + +The service argument is a string that points to a function provided by a cloud +(service-code) when the service name is omitted from the endpoint. diff --git a/docs/cmdline-opts/basic.d b/docs/cmdline-opts/basic.d deleted file mode 100644 index cb0642620..000000000 --- a/docs/cmdline-opts/basic.d +++ /dev/null @@ -1,17 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: basic -Help: Use HTTP Basic Authentication -See-also: proxy-basic -Protocols: HTTP -Category: auth -Example: -u name:password --basic $URL -Added: 7.10.6 -Multi: mutex ---- -Tells curl to use HTTP Basic authentication with the remote host. This is the -default and this option is usually pointless, unless you use it to override a -previously set option that sets a different authentication method (such as ---ntlm, --digest, or --negotiate). - -Used together with --user. diff --git a/docs/cmdline-opts/basic.md b/docs/cmdline-opts/basic.md new file mode 100644 index 000000000..34b019175 --- /dev/null +++ b/docs/cmdline-opts/basic.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: basic +Help: Use HTTP Basic Authentication +Protocols: HTTP +Category: auth +Added: 7.10.6 +Multi: mutex +See-also: + - proxy-basic +Example: + - -u name:password --basic $URL +--- + +# `--basic` + +Tells curl to use HTTP Basic authentication with the remote host. This is the +default and this option is usually pointless, unless you use it to override a +previously set option that sets a different authentication method (such as +--ntlm, --digest, or --negotiate). + +Used together with --user. diff --git a/docs/cmdline-opts/ca-native.d b/docs/cmdline-opts/ca-native.d deleted file mode 100644 index 51e36918a..000000000 --- a/docs/cmdline-opts/ca-native.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ca-native -Help: Use CA certificates from the native OS -Protocols: TLS -Category: tls -See-also: cacert capath insecure -Example: --ca-native $URL -Added: 8.2.0 -Multi: boolean ---- -Tells curl to use the CA store from the native operating system to verify the -peer. By default, curl otherwise uses a CA store provided in a single file or -directory, but when using this option it interfaces the operating system's -own vault. - -This option only works for curl on Windows when built to use OpenSSL. When -curl on Windows is built to use Schannel, this feature is implied and curl -then only uses the native CA store. - -curl built with wolfSSL also supports this option (added in 8.3.0). diff --git a/docs/cmdline-opts/ca-native.md b/docs/cmdline-opts/ca-native.md new file mode 100644 index 000000000..d0b4bfa5a --- /dev/null +++ b/docs/cmdline-opts/ca-native.md @@ -0,0 +1,28 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ca-native +Help: Use CA certificates from the native OS +Protocols: TLS +Category: tls +Added: 8.2.0 +Multi: boolean +See-also: + - cacert + - capath + - insecure +Example: + - --ca-native $URL +--- + +# `--ca-native` + +Tells curl to use the CA store from the native operating system to verify the +peer. By default, curl otherwise uses a CA store provided in a single file or +directory, but when using this option it interfaces the operating system's +own vault. + +This option works for curl on Windows when built to use OpenSSL, wolfSSL +(added in 8.3.0) or GnuTLS (added in 8.5.0). When curl on Windows is built to +use Schannel, this feature is implied and curl then only uses the native CA +store. diff --git a/docs/cmdline-opts/cacert.d b/docs/cmdline-opts/cacert.d deleted file mode 100644 index 5e4e74901..000000000 --- a/docs/cmdline-opts/cacert.d +++ /dev/null @@ -1,35 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: cacert -Arg: -Help: CA certificate to verify peer against -Protocols: TLS -Category: tls -See-also: capath insecure -Example: --cacert CA-file.txt $URL -Added: 7.5 -Multi: single ---- -Tells curl to use the specified certificate file to verify the peer. The file -may contain multiple CA certificates. The certificate(s) must be in PEM -format. Normally curl is built to use a default file for this, so this option -is typically used to alter that default file. - -curl recognizes the environment variable named 'CURL_CA_BUNDLE' if it is -set, and uses the given path as a path to a CA cert bundle. This option -overrides that variable. - -The windows version of curl automatically looks for a CA certs file named -'curl-ca-bundle.crt', either in the same directory as curl.exe, or in the -Current Working Directory, or in any folder along your PATH. - -(iOS and macOS only) If curl is built against Secure Transport, then this -option is supported for backward compatibility with other SSL engines, but it -should not be set. If the option is not set, then curl uses the certificates -in the system and user Keychain to verify the peer, which is the preferred -method of verifying the peer's certificate chain. - -(Schannel only) This option is supported for Schannel in Windows 7 or later -(added in 7.60.0). This option is supported for backward compatibility with -other SSL engines; instead it is recommended to use Windows' store of root -certificates (the default for Schannel). diff --git a/docs/cmdline-opts/cacert.md b/docs/cmdline-opts/cacert.md new file mode 100644 index 000000000..7b1b2174b --- /dev/null +++ b/docs/cmdline-opts/cacert.md @@ -0,0 +1,42 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: cacert +Arg: +Help: CA certificate to verify peer against +Protocols: TLS +Category: tls +Added: 7.5 +Multi: single +See-also: + - capath + - insecure +Example: + - --cacert CA-file.txt $URL +--- + +# `--cacert` + +Tells curl to use the specified certificate file to verify the peer. The file +may contain multiple CA certificates. The certificate(s) must be in PEM +format. Normally curl is built to use a default file for this, so this option +is typically used to alter that default file. + +curl recognizes the environment variable named 'CURL_CA_BUNDLE' if it is set +and the TLS backend is not Schannel, and uses the given path as a path to a CA +cert bundle. This option overrides that variable. + +The windows version of curl automatically looks for a CA certs file named +'curl-ca-bundle.crt', either in the same directory as curl.exe, or in the +Current Working Directory, or in any folder along your PATH. + +(iOS and macOS only) If curl is built against Secure Transport, then this +option is supported for backward compatibility with other SSL engines, but it +should not be set. If the option is not set, then curl uses the certificates +in the system and user Keychain to verify the peer, which is the preferred +method of verifying the peer's certificate chain. + +(Schannel only) This option is supported for Schannel in Windows 7 or later +(added in 7.60.0). This option is supported for backward compatibility with +other SSL engines; instead it is recommended to use Windows' store of root +certificates (the default for Schannel). diff --git a/docs/cmdline-opts/capath.d b/docs/cmdline-opts/capath.d deleted file mode 100644 index 75e9f2e40..000000000 --- a/docs/cmdline-opts/capath.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: capath -Arg: -Help: CA directory to verify peer against -Protocols: TLS -Category: tls -See-also: cacert insecure -Example: --capath /local/directory $URL -Added: 7.9.8 -Multi: single ---- -Tells curl to use the specified certificate directory to verify the -peer. Multiple paths can be provided by separating them with ":" (e.g. -"path1:path2:path3"). The certificates must be in PEM format, and if curl is -built against OpenSSL, the directory must have been processed using the -c_rehash utility supplied with OpenSSL. Using --capath can allow -OpenSSL-powered curl to make SSL-connections much more efficiently than using ---cacert if the --cacert file contains many CA certificates. - -If this option is set, the default capath value is ignored. diff --git a/docs/cmdline-opts/capath.md b/docs/cmdline-opts/capath.md new file mode 100644 index 000000000..ecd28df24 --- /dev/null +++ b/docs/cmdline-opts/capath.md @@ -0,0 +1,28 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: capath +Arg: +Help: CA directory to verify peer against +Protocols: TLS +Category: tls +Added: 7.9.8 +Multi: single +See-also: + - cacert + - insecure +Example: + - --capath /local/directory $URL +--- + +# `--capath` + +Tells curl to use the specified certificate directory to verify the +peer. Multiple paths can be provided by separating them with ":" (e.g. +"path1:path2:path3"). The certificates must be in PEM format, and if curl is +built against OpenSSL, the directory must have been processed using the +c_rehash utility supplied with OpenSSL. Using --capath can allow +OpenSSL-powered curl to make SSL-connections much more efficiently than using +--cacert if the --cacert file contains many CA certificates. + +If this option is set, the default capath value is ignored. diff --git a/docs/cmdline-opts/cert-status.d b/docs/cmdline-opts/cert-status.d deleted file mode 100644 index e2d1d7aa2..000000000 --- a/docs/cmdline-opts/cert-status.d +++ /dev/null @@ -1,19 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: cert-status -Protocols: TLS -Added: 7.41.0 -Help: Verify the status of the server cert via OCSP-staple -Category: tls -See-also: pinnedpubkey -Example: --cert-status $URL -Multi: boolean ---- -Tells curl to verify the status of the server certificate by using the -Certificate Status Request (aka. OCSP stapling) TLS extension. - -If this option is enabled and the server sends an invalid (e.g. expired) -response, if the response suggests that the server certificate has been -revoked, or no response at all is received, the verification fails. - -This is currently only implemented in the OpenSSL and GnuTLS backends. diff --git a/docs/cmdline-opts/cert-status.md b/docs/cmdline-opts/cert-status.md new file mode 100644 index 000000000..bfbd3af83 --- /dev/null +++ b/docs/cmdline-opts/cert-status.md @@ -0,0 +1,25 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: cert-status +Protocols: TLS +Added: 7.41.0 +Help: Verify the status of the server cert via OCSP-staple +Category: tls +Multi: boolean +See-also: + - pinnedpubkey +Example: + - --cert-status $URL +--- + +# `--cert-status` + +Tells curl to verify the status of the server certificate by using the +Certificate Status Request (aka. OCSP stapling) TLS extension. + +If this option is enabled and the server sends an invalid (e.g. expired) +response, if the response suggests that the server certificate has been +revoked, or no response at all is received, the verification fails. + +This is currently only implemented in the OpenSSL and GnuTLS backends. diff --git a/docs/cmdline-opts/cert-type.d b/docs/cmdline-opts/cert-type.d deleted file mode 100644 index cf9f17b7d..000000000 --- a/docs/cmdline-opts/cert-type.d +++ /dev/null @@ -1,18 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: cert-type -Protocols: TLS -Arg: -Help: Certificate type (DER/PEM/ENG/P12) -See-also: cert key key-type -Category: tls -Example: --cert-type PEM --cert file $URL -Added: 7.9.3 -Multi: single ---- -Tells curl what type the provided client certificate is using. PEM, DER, ENG -and P12 are recognized types. - -The default type depends on the TLS backend and is usually PEM, however for -Secure Transport and Schannel it is P12. If --cert is a pkcs11: URI then ENG is -the default type. diff --git a/docs/cmdline-opts/cert-type.md b/docs/cmdline-opts/cert-type.md new file mode 100644 index 000000000..a0030a59d --- /dev/null +++ b/docs/cmdline-opts/cert-type.md @@ -0,0 +1,26 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: cert-type +Protocols: TLS +Arg: +Help: Certificate type (DER/PEM/ENG/P12) +Category: tls +Added: 7.9.3 +Multi: single +See-also: + - cert + - key + - key-type +Example: + - --cert-type PEM --cert file $URL +--- + +# `--cert-type` + +Tells curl what type the provided client certificate is using. PEM, DER, ENG +and P12 are recognized types. + +The default type depends on the TLS backend and is usually PEM, however for +Secure Transport and Schannel it is P12. If --cert is a pkcs11: URI then ENG is +the default type. diff --git a/docs/cmdline-opts/cert.d b/docs/cmdline-opts/cert.d deleted file mode 100644 index 56d0df7fd..000000000 --- a/docs/cmdline-opts/cert.d +++ /dev/null @@ -1,49 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: E -Long: cert -Arg: -Help: Client certificate file and password -Protocols: TLS -See-also: cert-type key key-type -Category: tls -Example: --cert certfile --key keyfile $URL -Added: 5.0 -Multi: single ---- -Tells curl to use the specified client certificate file when getting a file -with HTTPS, FTPS or another SSL-based protocol. The certificate must be in -PKCS#12 format if using Secure Transport, or PEM format if using any other -engine. If the optional password is not specified, it is queried for on -the terminal. Note that this option assumes a certificate file that is the -private key and the client certificate concatenated. See --cert and --key to -specify them independently. - -In the portion of the argument, you must escape the character ":" -as "\\:" so that it is not recognized as the password delimiter. Similarly, you -must escape the character "\\" as "\\\\" so that it is not recognized as an -escape character. - -If curl is built against OpenSSL library, and the engine pkcs11 is available, -then a PKCS#11 URI (RFC 7512) can be used to specify a certificate located in -a PKCS#11 device. A string beginning with "pkcs11:" is interpreted as a -PKCS#11 URI. If a PKCS#11 URI is provided, then the --engine option is set as -"pkcs11" if none was provided and the --cert-type option is set as "ENG" if -none was provided. - -(iOS and macOS only) If curl is built against Secure Transport, then the -certificate string can either be the name of a certificate/private key in the -system or user keychain, or the path to a PKCS#12-encoded certificate and -private key. If you want to use a file from the current directory, please -precede it with "./" prefix, in order to avoid confusion with a nickname. - -(Schannel only) Client certificates must be specified by a path -expression to a certificate store. (Loading *PFX* is not supported; you can -import it to a store first). You can use -"\\\\" to refer to a certificate -in the system certificates store, for example, -*"CurrentUser\\MY\\934a7ac6f8a5d579285a74fa61e19f23ddfe8d7a"*. Thumbprint is -usually a SHA-1 hex string which you can see in certificate details. Following -store locations are supported: *CurrentUser*, *LocalMachine*, *CurrentService*, -*Services*, *CurrentUserGroupPolicy*, *LocalMachineGroupPolicy* and -*LocalMachineEnterprise*. diff --git a/docs/cmdline-opts/cert.md b/docs/cmdline-opts/cert.md new file mode 100644 index 000000000..6df5d0ebf --- /dev/null +++ b/docs/cmdline-opts/cert.md @@ -0,0 +1,56 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: E +Long: cert +Arg: +Help: Client certificate file and password +Protocols: TLS +Category: tls +Added: 5.0 +Multi: single +See-also: + - cert-type + - key + - key-type +Example: + - --cert certfile --key keyfile $URL +--- + +# `--cert` + +Tells curl to use the specified client certificate file when getting a file +with HTTPS, FTPS or another SSL-based protocol. The certificate must be in +PKCS#12 format if using Secure Transport, or PEM format if using any other +engine. If the optional password is not specified, it is queried for on +the terminal. Note that this option assumes a certificate file that is the +private key and the client certificate concatenated. See --cert and --key to +specify them independently. + +In the portion of the argument, you must escape the character +":" as "\:" so that it is not recognized as the password delimiter. Similarly, +you must escape the double quote character as \" so that it is not recognized +as an escape character. + +If curl is built against OpenSSL library, and the engine pkcs11 is available, +then a PKCS#11 URI (RFC 7512) can be used to specify a certificate located in +a PKCS#11 device. A string beginning with "pkcs11:" is interpreted as a +PKCS#11 URI. If a PKCS#11 URI is provided, then the --engine option is set as +"pkcs11" if none was provided and the --cert-type option is set as "ENG" if +none was provided. + +(iOS and macOS only) If curl is built against Secure Transport, then the +certificate string can either be the name of a certificate/private key in the +system or user keychain, or the path to a PKCS#12-encoded certificate and +private key. If you want to use a file from the current directory, please +precede it with "./" prefix, in order to avoid confusion with a nickname. + +(Schannel only) Client certificates must be specified by a path expression to +a certificate store. (Loading *PFX* is not supported; you can import it to a +store first). You can use "\\" to +refer to a certificate in the system certificates store, for example, +*"CurrentUser\MY\934a7ac6f8a5d579285a74fa61e19f23ddfe8d7a"*. Thumbprint is +usually a SHA-1 hex string which you can see in certificate details. Following +store locations are supported: *CurrentUser*, *LocalMachine*, +*CurrentService*, *Services*, *CurrentUserGroupPolicy*, +*LocalMachineGroupPolicy* and *LocalMachineEnterprise*. diff --git a/docs/cmdline-opts/ciphers.d b/docs/cmdline-opts/ciphers.d deleted file mode 100644 index a30902bdb..000000000 --- a/docs/cmdline-opts/ciphers.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ciphers -Arg: -Help: SSL ciphers to use -Protocols: TLS -Category: tls -See-also: tlsv1.3 tls13-ciphers proxy-ciphers -Example: --ciphers ECDHE-ECDSA-AES256-CCM8 $URL -Added: 7.9 -Multi: single ---- -Specifies which ciphers to use in the connection. The list of ciphers must -specify valid ciphers. Read up on SSL cipher list details on this URL: - -https://curl.se/docs/ssl-ciphers.html diff --git a/docs/cmdline-opts/ciphers.md b/docs/cmdline-opts/ciphers.md new file mode 100644 index 000000000..9d7e0c6fe --- /dev/null +++ b/docs/cmdline-opts/ciphers.md @@ -0,0 +1,24 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ciphers +Arg: +Help: SSL ciphers to use +Protocols: TLS +Category: tls +Added: 7.9 +Multi: single +See-also: + - tlsv1.3 + - tls13-ciphers + - proxy-ciphers +Example: + - --ciphers ECDHE-ECDSA-AES256-CCM8 $URL +--- + +# `--ciphers` + +Specifies which ciphers to use in the connection. The list of ciphers must +specify valid ciphers. Read up on SSL cipher list details on this URL: + +https://curl.se/docs/ssl-ciphers.html diff --git a/docs/cmdline-opts/compressed-ssh.d b/docs/cmdline-opts/compressed-ssh.d deleted file mode 100644 index 897395677..000000000 --- a/docs/cmdline-opts/compressed-ssh.d +++ /dev/null @@ -1,13 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: compressed-ssh -Help: Enable SSH compression -Protocols: SCP SFTP -Added: 7.56.0 -Category: scp ssh -See-also: compressed -Example: --compressed-ssh sftp://example.com/ -Multi: boolean ---- -Enables built-in SSH compression. -This is a request, not an order; the server may or may not do it. diff --git a/docs/cmdline-opts/compressed-ssh.md b/docs/cmdline-opts/compressed-ssh.md new file mode 100644 index 000000000..c52e5a7a3 --- /dev/null +++ b/docs/cmdline-opts/compressed-ssh.md @@ -0,0 +1,19 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: compressed-ssh +Help: Enable SSH compression +Protocols: SCP SFTP +Added: 7.56.0 +Category: scp ssh +Multi: boolean +See-also: + - compressed +Example: + - --compressed-ssh sftp://example.com/ +--- + +# `--compressed-ssh` + +Enables built-in SSH compression. +This is a request, not an order; the server may or may not do it. diff --git a/docs/cmdline-opts/compressed.d b/docs/cmdline-opts/compressed.d deleted file mode 100644 index bb1d3baa7..000000000 --- a/docs/cmdline-opts/compressed.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: compressed -Help: Request compressed response -Protocols: HTTP -Category: http -Example: --compressed $URL -See-also: compressed-ssh -Added: 7.10 -Multi: boolean ---- -Request a compressed response using one of the algorithms curl supports, and -automatically decompress the content. - -Response headers are not modified when saved, so if they are "interpreted" -separately again at a later point they might appear to be saying that the -content is (still) compressed; while in fact it has already been decompressed. - -If this option is used and the server sends an unsupported encoding, curl -reports an error. This is a request, not an order; the server may or may not -deliver data compressed. diff --git a/docs/cmdline-opts/compressed.md b/docs/cmdline-opts/compressed.md new file mode 100644 index 000000000..35bbab813 --- /dev/null +++ b/docs/cmdline-opts/compressed.md @@ -0,0 +1,27 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: compressed +Help: Request compressed response +Protocols: HTTP +Category: http +Added: 7.10 +Multi: boolean +See-also: + - compressed-ssh +Example: + - --compressed $URL +--- + +# `--compressed` + +Request a compressed response using one of the algorithms curl supports, and +automatically decompress the content. + +Response headers are not modified when saved, so if they are "interpreted" +separately again at a later point they might appear to be saying that the +content is (still) compressed; while in fact it has already been decompressed. + +If this option is used and the server sends an unsupported encoding, curl +reports an error. This is a request, not an order; the server may or may not +deliver data compressed. diff --git a/docs/cmdline-opts/config.d b/docs/cmdline-opts/config.d deleted file mode 100644 index c22a827f6..000000000 --- a/docs/cmdline-opts/config.d +++ /dev/null @@ -1,77 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: config -Arg: -Help: Read config from a file -Short: K -Category: curl -Example: --config file.txt $URL -Added: 4.10 -See-also: disable -Multi: append ---- -Specify a text file to read curl arguments from. The command line arguments -found in the text file are used as if they were provided on the command -line. - -Options and their parameters must be specified on the same line in the file, -separated by whitespace, colon, or the equals sign. Long option names can -optionally be given in the config file without the initial double dashes and -if so, the colon or equals characters can be used as separators. If the option -is specified with one or two dashes, there can be no colon or equals character -between the option and its parameter. - -If the parameter contains whitespace or starts with a colon (:) or equals sign -(=), it must be specified enclosed within double quotes (\&"). Within double -quotes the following escape sequences are available: \\\\, \\", \\t, \\n, \\r -and \\v. A backslash preceding any other letter is ignored. - -If the first non-blank column of a config line is a '#' character, that line -is treated as a comment. - -Only write one option per physical line in the config file. A single line is -required to be no more than 10 megabytes (since 8.2.0). - -Specify the filename to --config as '-' to make curl read the file from stdin. - -Note that to be able to specify a URL in the config file, you need to specify -it using the --url option, and not by simply writing the URL on its own -line. So, it could look similar to this: - -url = "https://curl.se/docs/" - - # --- Example file --- - # this is a comment - url = "example.com" - output = "curlhere.html" - user-agent = "superagent/1.0" - - # and fetch another URL too - url = "example.com/docs/manpage.html" - -O - referer = "http://nowhereatall.example.com/" - # --- End of example file --- - -When curl is invoked, it (unless --disable is used) checks for a default -config file and uses it if found, even when --config is used. The default -config file is checked for in the following places in this order: - -1) **"$CURL_HOME/.curlrc"** - -2) **"$XDG_CONFIG_HOME/curlrc"** (Added in 7.73.0) - -3) **"$HOME/.curlrc"** - -4) Windows: **"%USERPROFILE%\\.curlrc"** - -5) Windows: **"%APPDATA%\\.curlrc"** - -6) Windows: **"%USERPROFILE%\\Application Data\\.curlrc"** - -7) Non-Windows: use getpwuid to find the home directory - -8) On Windows, if it finds no *.curlrc* file in the sequence described above, it -checks for one in the same dir the curl executable is placed. - -On Windows two filenames are checked per location: *.curlrc* and *_curlrc*, -preferring the former. Older versions on Windows checked for *_curlrc* only. diff --git a/docs/cmdline-opts/config.md b/docs/cmdline-opts/config.md new file mode 100644 index 000000000..2f393e27e --- /dev/null +++ b/docs/cmdline-opts/config.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: config +Arg: +Help: Read config from a file +Short: K +Category: curl +Added: 4.10 +Multi: append +See-also: + - disable +Example: + - --config file.txt $URL +--- + +# `--config` + +Specify a text file to read curl arguments from. The command line arguments +found in the text file are used as if they were provided on the command +line. + +Options and their parameters must be specified on the same line in the file, +separated by whitespace, colon, or the equals sign. Long option names can +optionally be given in the config file without the initial double dashes and +if so, the colon or equals characters can be used as separators. If the option +is specified with one or two dashes, there can be no colon or equals character +between the option and its parameter. + +If the parameter contains whitespace or starts with a colon (:) or equals sign +(=), it must be specified enclosed within double quotes ("). Within double +quotes the following escape sequences are available: \\, \", \t, \n, \r and +\v. A backslash preceding any other letter is ignored. + +If the first non-blank column of a config line is a '#' character, that line +is treated as a comment. + +Only write one option per physical line in the config file. A single line is +required to be no more than 10 megabytes (since 8.2.0). + +Specify the filename to --config as '-' to make curl read the file from stdin. + +Note that to be able to specify a URL in the config file, you need to specify +it using the --url option, and not by simply writing the URL on its own +line. So, it could look similar to this: + + url = "https://curl.se/docs/" + + # --- Example file --- + # this is a comment + url = "example.com" + output = "curlhere.html" + user-agent = "superagent/1.0" + + # and fetch another URL too + url = "example.com/docs/manpage.html" + -O + referer = "http://nowhereatall.example.com/" + # --- End of example file --- + +When curl is invoked, it (unless --disable is used) checks for a default +config file and uses it if found, even when --config is used. The default +config file is checked for in the following places in this order: + +1) **"$CURL_HOME/.curlrc"** + +2) **"$XDG_CONFIG_HOME/curlrc"** (Added in 7.73.0) + +3) **"$HOME/.curlrc"** + +4) Windows: **"%USERPROFILE%\.curlrc"** + +5) Windows: **"%APPDATA%\.curlrc"** + +6) Windows: **"%USERPROFILE%\Application Data\.curlrc"** + +7) Non-Windows: use getpwuid to find the home directory + +8) On Windows, if it finds no *.curlrc* file in the sequence described above, it +checks for one in the same dir the curl executable is placed. + +On Windows two filenames are checked per location: *.curlrc* and *_curlrc*, +preferring the former. Older versions on Windows checked for *_curlrc* only. diff --git a/docs/cmdline-opts/connect-timeout.d b/docs/cmdline-opts/connect-timeout.d deleted file mode 100644 index b3d19b3c3..000000000 --- a/docs/cmdline-opts/connect-timeout.d +++ /dev/null @@ -1,22 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: connect-timeout -Arg: -Help: Maximum time allowed for connection -See-also: max-time -Category: connection -Example: --connect-timeout 20 $URL -Example: --connect-timeout 3.14 $URL -Added: 7.7 -Multi: single ---- -Maximum time in seconds that you allow curl's connection to take. This only -limits the connection phase, so if curl connects within the given period it -continues - if not it exits. - -This option accepts decimal values (added in 7.32.0). The decimal value needs -to be provided using a dot (.) as decimal separator - not the local version -even if it might be using another separator. - -The connection phase is considered complete when the DNS lookup and requested -TCP, TLS or QUIC handshakes are done. diff --git a/docs/cmdline-opts/connect-timeout.md b/docs/cmdline-opts/connect-timeout.md new file mode 100644 index 000000000..f7281b09a --- /dev/null +++ b/docs/cmdline-opts/connect-timeout.md @@ -0,0 +1,28 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: connect-timeout +Arg: +Help: Maximum time allowed for connection +Category: connection +Added: 7.7 +Multi: single +See-also: + - max-time +Example: + - --connect-timeout 20 $URL + - --connect-timeout 3.14 $URL +--- + +# `--connect-timeout` + +Maximum time in seconds that you allow curl's connection to take. This only +limits the connection phase, so if curl connects within the given period it +continues - if not it exits. + +This option accepts decimal values (added in 7.32.0). The decimal value needs +to be provided using a dot (.) as decimal separator - not the local version +even if it might be using another separator. + +The connection phase is considered complete when the DNS lookup and requested +TCP, TLS or QUIC handshakes are done. diff --git a/docs/cmdline-opts/connect-to.d b/docs/cmdline-opts/connect-to.d deleted file mode 100644 index 95fab9112..000000000 --- a/docs/cmdline-opts/connect-to.d +++ /dev/null @@ -1,24 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: connect-to -Arg: -Help: Connect to host -Added: 7.49.0 -See-also: resolve header -Category: connection -Example: --connect-to example.com:443:example.net:8443 $URL -Multi: append ---- - -For a request to the given HOST1:PORT1 pair, connect to HOST2:PORT2 instead. -This option is suitable to direct requests at a specific server, e.g. at a -specific cluster node in a cluster of servers. This option is only used to -establish the network connection. It does NOT affect the hostname/port that is -used for TLS/SSL (e.g. SNI, certificate verification) or for the application -protocols. "HOST1" and "PORT1" may be the empty string, meaning "any -host/port". "HOST2" and "PORT2" may also be the empty string, meaning "use the -request's original host/port". - -A "host" specified to this option is compared as a string, so it needs to -match the name used in request URL. It can be either numerical such as -"127.0.0.1" or the full host name such as "example.org". diff --git a/docs/cmdline-opts/connect-to.md b/docs/cmdline-opts/connect-to.md new file mode 100644 index 000000000..7cd0aa857 --- /dev/null +++ b/docs/cmdline-opts/connect-to.md @@ -0,0 +1,30 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: connect-to +Arg: +Help: Connect to host +Added: 7.49.0 +Category: connection +Multi: append +See-also: + - resolve + - header +Example: + - --connect-to example.com:443:example.net:8443 $URL +--- + +# `--connect-to` + +For a request to the given `HOST1:PORT1` pair, connect to `HOST2:PORT2` +instead. This option is suitable to direct requests at a specific server, +e.g. at a specific cluster node in a cluster of servers. This option is only +used to establish the network connection. It does NOT affect the hostname/port +that is used for TLS/SSL (e.g. SNI, certificate verification) or for the +application protocols. `HOST1` and `PORT1` may be the empty string, meaning +"any host/port". `HOST2` and `PORT2` may also be the empty string, meaning +"use the request's original host/port". + +A hostname specified to this option is compared as a string, so it needs to +match the name used in request URL. It can be either numerical such as +`127.0.0.1` or the full host name such as `example.org`. diff --git a/docs/cmdline-opts/continue-at.d b/docs/cmdline-opts/continue-at.d deleted file mode 100644 index a4fc1a969..000000000 --- a/docs/cmdline-opts/continue-at.d +++ /dev/null @@ -1,20 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: C -Long: continue-at -Arg: -Help: Resumed transfer offset -See-also: range -Category: connection -Example: -C - $URL -Example: -C 400 $URL -Added: 4.8 -Multi: single ---- -Continue/Resume a previous file transfer at the given offset. The given offset -is the exact number of bytes that are skipped, counting from the beginning -of the source file before it is transferred to the destination. If used with -uploads, the FTP server command SIZE is not used by curl. - -Use "-C -" to tell curl to automatically find out where/how to resume the -transfer. It then uses the given output/input files to figure that out. diff --git a/docs/cmdline-opts/continue-at.md b/docs/cmdline-opts/continue-at.md new file mode 100644 index 000000000..67a79fd70 --- /dev/null +++ b/docs/cmdline-opts/continue-at.md @@ -0,0 +1,26 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: C +Long: continue-at +Arg: +Help: Resumed transfer offset +Category: connection +Added: 4.8 +Multi: single +See-also: + - range +Example: + - -C - $URL + - -C 400 $URL +--- + +# `--continue-at` + +Continue/Resume a previous file transfer at the given offset. The given offset +is the exact number of bytes that are skipped, counting from the beginning +of the source file before it is transferred to the destination. If used with +uploads, the FTP server command SIZE is not used by curl. + +Use "-C -" to tell curl to automatically find out where/how to resume the +transfer. It then uses the given output/input files to figure that out. diff --git a/docs/cmdline-opts/cookie-jar.d b/docs/cmdline-opts/cookie-jar.d deleted file mode 100644 index 28738cac9..000000000 --- a/docs/cmdline-opts/cookie-jar.d +++ /dev/null @@ -1,31 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: c -Long: cookie-jar -Arg: -Protocols: HTTP -Help: Write cookies to after operation -Category: http -Example: -c store-here.txt $URL -Example: -c store-here.txt -b read-these $URL -Added: 7.9 -See-also: cookie -Multi: single ---- -Specify to which file you want curl to write all cookies after a completed -operation. Curl writes all cookies from its in-memory cookie storage to the -given file at the end of operations. If no cookies are known, no data is -written. The file is created using the Netscape cookie file format. If you set -the file name to a single dash, "-", the cookies are written to stdout. - -The file specified with --cookie-jar is only used for output. No cookies are -read from the file. To read cookies, use the --cookie option. Both options -can specify the same file. - -This command line option activates the cookie engine that makes curl record -and use cookies. The --cookie option also activates it. - -If the cookie jar cannot be created or written to, the whole curl operation -does not fail or even report an error clearly. Using --verbose gets a warning -displayed, but that is the only visible feedback you get about this possibly -lethal situation. diff --git a/docs/cmdline-opts/cookie-jar.md b/docs/cmdline-opts/cookie-jar.md new file mode 100644 index 000000000..5453152e4 --- /dev/null +++ b/docs/cmdline-opts/cookie-jar.md @@ -0,0 +1,37 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: c +Long: cookie-jar +Arg: +Protocols: HTTP +Help: Write cookies to after operation +Category: http +Added: 7.9 +Multi: single +See-also: + - cookie +Example: + - -c store-here.txt $URL + - -c store-here.txt -b read-these $URL +--- + +# `--cookie-jar` + +Specify to which file you want curl to write all cookies after a completed +operation. Curl writes all cookies from its in-memory cookie storage to the +given file at the end of operations. If no cookies are known, no data is +written. The file is created using the Netscape cookie file format. If you set +the file name to a single dash, "-", the cookies are written to stdout. + +The file specified with --cookie-jar is only used for output. No cookies are +read from the file. To read cookies, use the --cookie option. Both options +can specify the same file. + +This command line option activates the cookie engine that makes curl record +and use cookies. The --cookie option also activates it. + +If the cookie jar cannot be created or written to, the whole curl operation +does not fail or even report an error clearly. Using --verbose gets a warning +displayed, but that is the only visible feedback you get about this possibly +lethal situation. diff --git a/docs/cmdline-opts/cookie.d b/docs/cmdline-opts/cookie.d deleted file mode 100644 index 0f858d661..000000000 --- a/docs/cmdline-opts/cookie.d +++ /dev/null @@ -1,42 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: b -Long: cookie -Arg: -Protocols: HTTP -Help: Send cookies from string/file -Category: http -Example: -b cookiefile $URL -Example: -b cookiefile -c cookiefile $URL -See-also: cookie-jar junk-session-cookies -Added: 4.9 -Multi: append ---- -Pass the data to the HTTP server in the Cookie header. It is supposedly the -data previously received from the server in a "Set-Cookie:" line. The data -should be in the format "NAME1=VALUE1; NAME2=VALUE2". This makes curl use the -cookie header with this content explicitly in all outgoing request(s). If -multiple requests are done due to authentication, followed redirects or -similar, they all get this cookie passed on. - -If no '=' symbol is used in the argument, it is instead treated as a filename -to read previously stored cookie from. This option also activates the cookie -engine which makes curl record incoming cookies, which may be handy if you are -using this in combination with the --location option or do multiple URL -transfers on the same invoke. If the file name is exactly a minus ("-"), curl -instead reads the contents from stdin. - -The file format of the file to read cookies from should be plain HTTP headers -(Set-Cookie style) or the Netscape/Mozilla cookie file format. - -The file specified with --cookie is only used as input. No cookies are written -to the file. To store cookies, use the --cookie-jar option. - -If you use the Set-Cookie file format and do not specify a domain then the -cookie is not sent since the domain never matches. To address this, set a -domain in Set-Cookie line (doing that includes subdomains) or preferably: use -the Netscape format. - -Users often want to both read cookies from a file and write updated cookies -back to a file, so using both --cookie and --cookie-jar in the same command -line is common. diff --git a/docs/cmdline-opts/cookie.md b/docs/cmdline-opts/cookie.md new file mode 100644 index 000000000..d0a6d3539 --- /dev/null +++ b/docs/cmdline-opts/cookie.md @@ -0,0 +1,58 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: b +Long: cookie +Arg: +Protocols: HTTP +Help: Send cookies from string/file +Category: http +Added: 4.9 +Multi: append +See-also: + - cookie-jar + - junk-session-cookies +Example: + - -b "" $URL + - -b cookiefile $URL + - -b cookiefile -c cookiefile $URL +--- + +# `--cookie` + +Pass the data to the HTTP server in the Cookie header. It is supposedly the +data previously received from the server in a "Set-Cookie:" line. The data +should be in the format "NAME1=VALUE1; NAME2=VALUE2". This makes curl use the +cookie header with this content explicitly in all outgoing request(s). If +multiple requests are done due to authentication, followed redirects or +similar, they all get this cookie passed on. + +If no '=' symbol is used in the argument, it is instead treated as a filename +to read previously stored cookie from. This option also activates the cookie +engine which makes curl record incoming cookies, which may be handy if you are +using this in combination with the --location option or do multiple URL +transfers on the same invoke. + +If the file name is exactly a minus ("-"), curl instead reads the contents from +stdin. If the file name is an empty string ("") and is the only cookie input, +curl will activate the cookie engine without any cookies. + +The file format of the file to read cookies from should be plain HTTP headers +(Set-Cookie style) or the Netscape/Mozilla cookie file format. + +The file specified with --cookie is only used as input. No cookies are written +to the file. To store cookies, use the --cookie-jar option. + +If you use the Set-Cookie file format and do not specify a domain then the +cookie is not sent since the domain never matches. To address this, set a +domain in Set-Cookie line (doing that includes subdomains) or preferably: use +the Netscape format. + +Users often want to both read cookies from a file and write updated cookies +back to a file, so using both --cookie and --cookie-jar in the same command +line is common. + +If curl is built with PSL (**Public Suffix List**) support, it detects and +discards cookies that are specified for such suffix domains that should not be +allowed to have cookies. If curl is *not* built with PSL support, it has no +ability to stop super cookies. diff --git a/docs/cmdline-opts/create-dirs.d b/docs/cmdline-opts/create-dirs.d deleted file mode 100644 index 966b70384..000000000 --- a/docs/cmdline-opts/create-dirs.d +++ /dev/null @@ -1,19 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: create-dirs -Help: Create necessary local directory hierarchy -Category: curl -Example: --create-dirs --output local/dir/file $URL -Added: 7.10.3 -See-also: ftp-create-dirs output-dir -Multi: boolean ---- -When used in conjunction with the --output option, curl creates the necessary -local directory hierarchy as needed. This option creates the directories -mentioned with the --output option combined with the path possibly set with ---output-dir. If the combined output file name uses no directory, or if the -directories it mentions already exist, no directories are created. - -Created directories are made with mode 0750 on unix style file systems. - -To create remote directories when using FTP or SFTP, try --ftp-create-dirs. diff --git a/docs/cmdline-opts/create-dirs.md b/docs/cmdline-opts/create-dirs.md new file mode 100644 index 000000000..de48807d4 --- /dev/null +++ b/docs/cmdline-opts/create-dirs.md @@ -0,0 +1,26 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: create-dirs +Help: Create necessary local directory hierarchy +Category: curl +Added: 7.10.3 +Multi: boolean +See-also: + - ftp-create-dirs + - output-dir +Example: + - --create-dirs --output local/dir/file $URL +--- + +# `--create-dirs` + +When used in conjunction with the --output option, curl creates the necessary +local directory hierarchy as needed. This option creates the directories +mentioned with the --output option combined with the path possibly set with +--output-dir. If the combined output file name uses no directory, or if the +directories it mentions already exist, no directories are created. + +Created directories are made with mode 0750 on unix style file systems. + +To create remote directories when using FTP or SFTP, try --ftp-create-dirs. diff --git a/docs/cmdline-opts/create-file-mode.d b/docs/cmdline-opts/create-file-mode.d deleted file mode 100644 index c0ebc08d4..000000000 --- a/docs/cmdline-opts/create-file-mode.d +++ /dev/null @@ -1,17 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: create-file-mode -Arg: -Help: File mode for created files -Protocols: SFTP SCP FILE -Category: sftp scp file upload -See-also: ftp-create-dirs -Added: 7.75.0 -Example: --create-file-mode 0777 -T localfile sftp://example.com/new -Multi: single ---- -When curl is used to create files remotely using one of the supported -protocols, this option allows the user to set which 'mode' to set on the file -at creation time, instead of the default 0644. - -This option takes an octal number as argument. diff --git a/docs/cmdline-opts/create-file-mode.md b/docs/cmdline-opts/create-file-mode.md new file mode 100644 index 000000000..c6467d15a --- /dev/null +++ b/docs/cmdline-opts/create-file-mode.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: create-file-mode +Arg: +Help: File mode for created files +Protocols: SFTP SCP FILE +Category: sftp scp file upload +Added: 7.75.0 +Multi: single +See-also: + - ftp-create-dirs +Example: + - --create-file-mode 0777 -T localfile sftp://example.com/new +--- + +# `--create-file-mode` + +When curl is used to create files remotely using one of the supported +protocols, this option allows the user to set which 'mode' to set on the file +at creation time, instead of the default 0644. + +This option takes an octal number as argument. diff --git a/docs/cmdline-opts/crlf.d b/docs/cmdline-opts/crlf.d deleted file mode 100644 index ea7fb1526..000000000 --- a/docs/cmdline-opts/crlf.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: crlf -Help: Convert LF to CRLF in upload -Protocols: FTP SMTP -Category: ftp smtp -Example: --crlf -T file ftp://example.com/ -Added: 5.7 -See-also: use-ascii -Multi: boolean ---- -Convert line feeds to carriage return plus line feeds in upload. Useful for -**MVS (OS/390)**. - -(SMTP added in 7.40.0) diff --git a/docs/cmdline-opts/crlf.md b/docs/cmdline-opts/crlf.md new file mode 100644 index 000000000..81a14ef6f --- /dev/null +++ b/docs/cmdline-opts/crlf.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: crlf +Help: Convert LF to CRLF in upload +Protocols: FTP SMTP +Category: ftp smtp +Added: 5.7 +Multi: boolean +See-also: + - use-ascii +Example: + - --crlf -T file ftp://example.com/ +--- + +# `--crlf` + +Convert line feeds to carriage return plus line feeds in upload. Useful for +**MVS (OS/390)**. + +(SMTP added in 7.40.0) diff --git a/docs/cmdline-opts/crlfile.d b/docs/cmdline-opts/crlfile.d deleted file mode 100644 index da0d239ba..000000000 --- a/docs/cmdline-opts/crlfile.d +++ /dev/null @@ -1,14 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: crlfile -Arg: -Protocols: TLS -Help: Use this CRL list -Added: 7.19.7 -Category: tls -Example: --crlfile rejects.txt $URL -See-also: cacert capath -Multi: single ---- -Provide a file using PEM format with a Certificate Revocation List that may -specify peer certificates that are to be considered revoked. diff --git a/docs/cmdline-opts/crlfile.md b/docs/cmdline-opts/crlfile.md new file mode 100644 index 000000000..16bd7b35b --- /dev/null +++ b/docs/cmdline-opts/crlfile.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: crlfile +Arg: +Protocols: TLS +Help: Use this CRL list +Added: 7.19.7 +Category: tls +Multi: single +See-also: + - cacert + - capath +Example: + - --crlfile rejects.txt $URL +--- + +# `--crlfile` + +Provide a file using PEM format with a Certificate Revocation List that may +specify peer certificates that are to be considered revoked. diff --git a/docs/cmdline-opts/curves.d b/docs/cmdline-opts/curves.d deleted file mode 100644 index 58d472d20..000000000 --- a/docs/cmdline-opts/curves.d +++ /dev/null @@ -1,22 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: curves -Arg: -Help: (EC) TLS key exchange algorithm(s) to request -Protocols: TLS -Added: 7.73.0 -Category: tls -Example: --curves X25519 $URL -See-also: ciphers -Multi: single ---- -Tells curl to request specific curves to use during SSL session establishment -according to RFC 8422, 5.1. Multiple algorithms can be provided by separating -them with ":" (e.g. "X25519:P-521"). The parameter is available identically -in the "openssl s_client/s_server" utilities. - ---curves allows a OpenSSL powered curl to make SSL-connections with exactly -the (EC) curve requested by the client, avoiding nontransparent client/server -negotiations. - -If this option is set, the default curves list built into OpenSSL are ignored. diff --git a/docs/cmdline-opts/curves.md b/docs/cmdline-opts/curves.md new file mode 100644 index 000000000..99f1ad48a --- /dev/null +++ b/docs/cmdline-opts/curves.md @@ -0,0 +1,28 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: curves +Arg: +Help: (EC) TLS key exchange algorithm(s) to request +Protocols: TLS +Added: 7.73.0 +Category: tls +Multi: single +See-also: + - ciphers +Example: + - --curves X25519 $URL +--- + +# `--curves` + +Tells curl to request specific curves to use during SSL session establishment +according to RFC 8422, 5.1. Multiple algorithms can be provided by separating +them with `:` (e.g. `X25519:P-521`). The parameter is available identically in +the OpenSSL `s_client` and `s_server` utilities. + +--curves allows a OpenSSL powered curl to make SSL-connections with exactly +the (EC) curve requested by the client, avoiding nontransparent client/server +negotiations. + +If this option is set, the default curves list built into OpenSSL are ignored. diff --git a/docs/cmdline-opts/data-ascii.d b/docs/cmdline-opts/data-ascii.d deleted file mode 100644 index 5c7840bbc..000000000 --- a/docs/cmdline-opts/data-ascii.d +++ /dev/null @@ -1,13 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: data-ascii -Arg: -Help: HTTP POST ASCII data -Protocols: HTTP -Category: http post upload -Example: --data-ascii @file $URL -Added: 7.2 -See-also: data-binary data-raw data-urlencode -Multi: append ---- -This is just an alias for --data. diff --git a/docs/cmdline-opts/data-ascii.md b/docs/cmdline-opts/data-ascii.md new file mode 100644 index 000000000..124dee13c --- /dev/null +++ b/docs/cmdline-opts/data-ascii.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: data-ascii +Arg: +Help: HTTP POST ASCII data +Protocols: HTTP +Category: http post upload +Added: 7.2 +Multi: append +See-also: + - data-binary + - data-raw + - data-urlencode +Example: + - --data-ascii @file $URL +--- + +# `--data-ascii` + +This is just an alias for --data. diff --git a/docs/cmdline-opts/data-binary.d b/docs/cmdline-opts/data-binary.d deleted file mode 100644 index 2cedda97b..000000000 --- a/docs/cmdline-opts/data-binary.d +++ /dev/null @@ -1,25 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: data-binary -Arg: -Help: HTTP POST binary data -Protocols: HTTP -Category: http post upload -Example: --data-binary @filename $URL -Added: 7.2 -See-also: data-ascii -Multi: append ---- -This posts data exactly as specified with no extra processing whatsoever. - -If you start the data with the letter @, the rest should be a filename. Data -is posted in a similar manner as --data does, except that newlines and -carriage returns are preserved and conversions are never done. - -Like --data the default content-type sent to the server is -application/x-www-form-urlencoded. If you want the data to be treated as -arbitrary binary data by the server then set the content-type to octet-stream: --H "Content-Type: application/octet-stream". - -If this option is used several times, the ones following the first append -data as described in --data. diff --git a/docs/cmdline-opts/data-binary.md b/docs/cmdline-opts/data-binary.md new file mode 100644 index 000000000..3d563fbdd --- /dev/null +++ b/docs/cmdline-opts/data-binary.md @@ -0,0 +1,31 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: data-binary +Arg: +Help: HTTP POST binary data +Protocols: HTTP +Category: http post upload +Added: 7.2 +Multi: append +See-also: + - data-ascii +Example: + - --data-binary @filename $URL +--- + +# `--data-binary` + +This posts data exactly as specified with no extra processing whatsoever. + +If you start the data with the letter @, the rest should be a filename. Data +is posted in a similar manner as --data does, except that newlines and +carriage returns are preserved and conversions are never done. + +Like --data the default content-type sent to the server is +application/x-www-form-urlencoded. If you want the data to be treated as +arbitrary binary data by the server then set the content-type to octet-stream: +-H "Content-Type: application/octet-stream". + +If this option is used several times, the ones following the first append +data as described in --data. diff --git a/docs/cmdline-opts/data-raw.d b/docs/cmdline-opts/data-raw.d deleted file mode 100644 index e6a5a5b2b..000000000 --- a/docs/cmdline-opts/data-raw.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: data-raw -Arg: -Protocols: HTTP -Help: HTTP POST data, '@' allowed -Added: 7.43.0 -See-also: data -Category: http post upload -Example: --data-raw "hello" $URL -Example: --data-raw "@at@at@" $URL -Multi: append ---- -This posts data similarly to --data but without the special -interpretation of the @ character. diff --git a/docs/cmdline-opts/data-raw.md b/docs/cmdline-opts/data-raw.md new file mode 100644 index 000000000..2cb46938b --- /dev/null +++ b/docs/cmdline-opts/data-raw.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: data-raw +Arg: +Protocols: HTTP +Help: HTTP POST data, '@' allowed +Added: 7.43.0 +Category: http post upload +Multi: append +See-also: + - data +Example: + - --data-raw "hello" $URL + - --data-raw "@at@at@" $URL +--- + +# `--data-raw` + +This posts data similarly to --data but without the special +interpretation of the @ character. diff --git a/docs/cmdline-opts/data-urlencode.d b/docs/cmdline-opts/data-urlencode.d deleted file mode 100644 index 3c436b26b..000000000 --- a/docs/cmdline-opts/data-urlencode.d +++ /dev/null @@ -1,42 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: data-urlencode -Arg: -Help: HTTP POST data URL encoded -Protocols: HTTP -See-also: data data-raw -Added: 7.18.0 -Category: http post upload -Example: --data-urlencode name=val $URL -Example: --data-urlencode =encodethis $URL -Example: --data-urlencode name@file $URL -Example: --data-urlencode @fileonly $URL -Multi: append ---- -This posts data, similar to the other --data options with the exception -that this performs URL-encoding. - -To be CGI-compliant, the part should begin with a *name* followed -by a separator and a content specification. The part can be passed to -curl using one of the following syntaxes: -.RS -.IP "content" -This makes curl URL-encode the content and pass that on. Just be careful -so that the content does not contain any = or @ symbols, as that makes -the syntax match one of the other cases below! -.IP "=content" -This makes curl URL-encode the content and pass that on. The preceding = -symbol is not included in the data. -.IP "name=content" -This makes curl URL-encode the content part and pass that on. Note that -the name part is expected to be URL-encoded already. -.IP "@filename" -This makes curl load data from the given file (including any newlines), -URL-encode that data and pass it on in the POST. -.IP "name@filename" -This makes curl load data from the given file (including any newlines), -URL-encode that data and pass it on in the POST. The name part gets an equal -sign appended, resulting in *name=urlencoded-file-content*. Note that the -name is expected to be URL-encoded already. -.RE -.IP diff --git a/docs/cmdline-opts/data-urlencode.md b/docs/cmdline-opts/data-urlencode.md new file mode 100644 index 000000000..4d3f29813 --- /dev/null +++ b/docs/cmdline-opts/data-urlencode.md @@ -0,0 +1,51 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: data-urlencode +Arg: +Help: HTTP POST data URL encoded +Protocols: HTTP +Added: 7.18.0 +Category: http post upload +Multi: append +See-also: + - data + - data-raw +Example: + - --data-urlencode name=val $URL + - --data-urlencode =encodethis $URL + - --data-urlencode name@file $URL + - --data-urlencode @fileonly $URL +--- + +# `--data-urlencode` + +This posts data, similar to the other --data options with the exception +that this performs URL-encoding. + +To be CGI-compliant, the part should begin with a *name* followed +by a separator and a content specification. The part can be passed to +curl using one of the following syntaxes: + +## content +This makes curl URL-encode the content and pass that on. Just be careful +so that the content does not contain any = or @ symbols, as that makes +the syntax match one of the other cases below! + +## =content +This makes curl URL-encode the content and pass that on. The preceding = +symbol is not included in the data. + +## name=content +This makes curl URL-encode the content part and pass that on. Note that +the name part is expected to be URL-encoded already. + +## @filename +This makes curl load data from the given file (including any newlines), +URL-encode that data and pass it on in the POST. + +## name@filename +This makes curl load data from the given file (including any newlines), +URL-encode that data and pass it on in the POST. The name part gets an equal +sign appended, resulting in *name=urlencoded-file-content*. Note that the +name is expected to be URL-encoded already. diff --git a/docs/cmdline-opts/data.d b/docs/cmdline-opts/data.d deleted file mode 100644 index f1d67b950..000000000 --- a/docs/cmdline-opts/data.d +++ /dev/null @@ -1,41 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: data -Short: d -Arg: -Help: HTTP POST data -Protocols: HTTP MQTT -See-also: data-binary data-urlencode data-raw -Mutexed: form head upload-file -Category: important http post upload -Example: -d "name=curl" $URL -Example: -d "name=curl" -d "tool=cmdline" $URL -Example: -d @filename $URL -Added: 4.0 -Multi: append ---- -Sends the specified data in a POST request to the HTTP server, in the same way -that a browser does when a user has filled in an HTML form and presses the -submit button. This makes curl pass the data to the server using the -content-type application/x-www-form-urlencoded. Compare to --form. - ---data-raw is almost the same but does not have a special interpretation of -the @ character. To post data purely binary, you should instead use the ---data-binary option. To URL-encode the value of a form field you may use ---data-urlencode. - -If any of these options is used more than once on the same command line, the -data pieces specified are merged with a separating &-symbol. Thus, using -'-d name=daniel -d skill=lousy' would generate a post chunk that looks like -'name=daniel&skill=lousy'. - -If you start the data with the letter @, the rest should be a file name to -read the data from, or - if you want curl to read the data from stdin. Posting -data from a file named 'foobar' would thus be done with --data @foobar. When ---data is told to read from a file like that, carriage returns and newlines -are stripped out. If you do not want the @ character to have a special -interpretation use --data-raw instead. - -The data for this option is passed on to the server exactly as provided on the -command line. curl does not convert, change or improve it. It is up to the -user to provide the data in the correct form. diff --git a/docs/cmdline-opts/data.md b/docs/cmdline-opts/data.md new file mode 100644 index 000000000..fb3b84872 --- /dev/null +++ b/docs/cmdline-opts/data.md @@ -0,0 +1,49 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: data +Short: d +Arg: +Help: HTTP POST data +Protocols: HTTP MQTT +Mutexed: form head upload-file +Category: important http post upload +Added: 4.0 +Multi: append +See-also: + - data-binary + - data-urlencode + - data-raw +Example: + - -d "name=curl" $URL + - -d "name=curl" -d "tool=cmdline" $URL + - -d @filename $URL +--- + +# `--data` + +Sends the specified data in a POST request to the HTTP server, in the same way +that a browser does when a user has filled in an HTML form and presses the +submit button. This makes curl pass the data to the server using the +content-type application/x-www-form-urlencoded. Compare to --form. + +--data-raw is almost the same but does not have a special interpretation of +the @ character. To post data purely binary, you should instead use the +--data-binary option. To URL-encode the value of a form field you may use +--data-urlencode. + +If any of these options is used more than once on the same command line, the +data pieces specified are merged with a separating &-symbol. Thus, using +'-d name=daniel -d skill=lousy' would generate a post chunk that looks like +'name=daniel&skill=lousy'. + +If you start the data with the letter @, the rest should be a file name to +read the data from, or - if you want curl to read the data from stdin. Posting +data from a file named 'foobar' would thus be done with --data @foobar. When +--data is told to read from a file like that, carriage returns and newlines +are stripped out. If you do not want the @ character to have a special +interpretation use --data-raw instead. + +The data for this option is passed on to the server exactly as provided on the +command line. curl does not convert, change or improve it. It is up to the +user to provide the data in the correct form. diff --git a/docs/cmdline-opts/delegation.d b/docs/cmdline-opts/delegation.d deleted file mode 100644 index 794184934..000000000 --- a/docs/cmdline-opts/delegation.d +++ /dev/null @@ -1,24 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: delegation -Arg: -Help: GSS-API delegation permission -Protocols: GSS/kerberos -Category: auth -Example: --delegation "none" $URL -Added: 7.22.0 -See-also: insecure ssl -Multi: single ---- -Set LEVEL to tell the server what it is allowed to delegate when it -comes to user credentials. -.RS -.IP "none" -Do not allow any delegation. -.IP "policy" -Delegates if and only if the OK-AS-DELEGATE flag is set in the Kerberos -service ticket, which is a matter of realm policy. -.IP "always" -Unconditionally allow the server to delegate. -.RE -.IP diff --git a/docs/cmdline-opts/delegation.md b/docs/cmdline-opts/delegation.md new file mode 100644 index 000000000..3d6cff899 --- /dev/null +++ b/docs/cmdline-opts/delegation.md @@ -0,0 +1,31 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: delegation +Arg: +Help: GSS-API delegation permission +Protocols: GSS/kerberos +Category: auth +Added: 7.22.0 +Multi: single +See-also: + - insecure + - ssl +Example: + - --delegation "none" $URL +--- + +# `--delegation` + +Set LEVEL to tell the server what it is allowed to delegate when it +comes to user credentials. + +## none +Do not allow any delegation. + +## policy +Delegates if and only if the OK-AS-DELEGATE flag is set in the Kerberos +service ticket, which is a matter of realm policy. + +## always +Unconditionally allow the server to delegate. diff --git a/docs/cmdline-opts/digest.d b/docs/cmdline-opts/digest.d deleted file mode 100644 index f2ee551c5..000000000 --- a/docs/cmdline-opts/digest.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: digest -Help: Use HTTP Digest Authentication -Protocols: HTTP -Mutexed: basic ntlm negotiate -See-also: user proxy-digest anyauth -Category: proxy auth http -Example: -u name:password --digest $URL -Added: 7.10.6 -Multi: boolean ---- -Enables HTTP Digest authentication. This is an authentication scheme that -prevents the password from being sent over the wire in clear text. Use this in -combination with the normal --user option to set user name and password. diff --git a/docs/cmdline-opts/digest.md b/docs/cmdline-opts/digest.md new file mode 100644 index 000000000..f05c01fed --- /dev/null +++ b/docs/cmdline-opts/digest.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: digest +Help: Use HTTP Digest Authentication +Protocols: HTTP +Mutexed: basic ntlm negotiate +Category: proxy auth http +Added: 7.10.6 +Multi: boolean +See-also: + - user + - proxy-digest + - anyauth +Example: + - -u name:password --digest $URL +--- + +# `--digest` + +Enables HTTP Digest authentication. This is an authentication scheme that +prevents the password from being sent over the wire in clear text. Use this in +combination with the normal --user option to set user name and password. diff --git a/docs/cmdline-opts/disable-eprt.d b/docs/cmdline-opts/disable-eprt.d deleted file mode 100644 index b6d382baf..000000000 --- a/docs/cmdline-opts/disable-eprt.d +++ /dev/null @@ -1,25 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: disable-eprt -Help: Inhibit using EPRT or LPRT -Protocols: FTP -Category: ftp -Example: --disable-eprt ftp://example.com/ -Added: 7.10.5 -See-also: disable-epsv ftp-port -Multi: boolean ---- -Tell curl to disable the use of the EPRT and LPRT commands when doing active -FTP transfers. Curl normally first attempts to use EPRT before using PORT, but -with this option, it uses PORT right away. EPRT is an extension to the -original FTP protocol, and does not work on all servers, but enables more -functionality in a better way than the traditional PORT command. - ---eprt can be used to explicitly enable EPRT again and --no-eprt is an alias -for --disable-eprt. - -If the server is accessed using IPv6, this option has no effect as EPRT is -necessary then. - -Disabling EPRT only changes the active behavior. If you want to switch to -passive mode you need to not use --ftp-port or force it with --ftp-pasv. diff --git a/docs/cmdline-opts/disable-eprt.md b/docs/cmdline-opts/disable-eprt.md new file mode 100644 index 000000000..80ae05691 --- /dev/null +++ b/docs/cmdline-opts/disable-eprt.md @@ -0,0 +1,32 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: disable-eprt +Help: Inhibit using EPRT or LPRT +Protocols: FTP +Category: ftp +Added: 7.10.5 +Multi: boolean +See-also: + - disable-epsv + - ftp-port +Example: + - --disable-eprt ftp://example.com/ +--- + +# `--disable-eprt` + +Tell curl to disable the use of the EPRT and LPRT commands when doing active +FTP transfers. Curl normally first attempts to use EPRT before using PORT, but +with this option, it uses PORT right away. EPRT is an extension to the +original FTP protocol, and does not work on all servers, but enables more +functionality in a better way than the traditional PORT command. + +--eprt can be used to explicitly enable EPRT again and --no-eprt is an alias +for --disable-eprt. + +If the server is accessed using IPv6, this option has no effect as EPRT is +necessary then. + +Disabling EPRT only changes the active behavior. If you want to switch to +passive mode you need to not use --ftp-port or force it with --ftp-pasv. diff --git a/docs/cmdline-opts/disable-epsv.d b/docs/cmdline-opts/disable-epsv.d deleted file mode 100644 index f02df763d..000000000 --- a/docs/cmdline-opts/disable-epsv.d +++ /dev/null @@ -1,23 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: disable-epsv -Help: Inhibit using EPSV -Protocols: FTP -Category: ftp -Example: --disable-epsv ftp://example.com/ -Added: 7.9.2 -See-also: disable-eprt ftp-port -Multi: boolean ---- -Tell curl to disable the use of the EPSV command when doing passive FTP -transfers. Curl normally first attempts to use EPSV before PASV, but with this -option, it does not try EPSV. - ---epsv can be used to explicitly enable EPSV again and --no-epsv is an alias -for --disable-epsv. - -If the server is an IPv6 host, this option has no effect as EPSV is necessary -then. - -Disabling EPSV only changes the passive behavior. If you want to switch to -active mode you need to use --ftp-port. diff --git a/docs/cmdline-opts/disable-epsv.md b/docs/cmdline-opts/disable-epsv.md new file mode 100644 index 000000000..f4a8de8c0 --- /dev/null +++ b/docs/cmdline-opts/disable-epsv.md @@ -0,0 +1,30 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: disable-epsv +Help: Inhibit using EPSV +Protocols: FTP +Category: ftp +Added: 7.9.2 +Multi: boolean +See-also: + - disable-eprt + - ftp-port +Example: + - --disable-epsv ftp://example.com/ +--- + +# `--disable-epsv` + +Tell curl to disable the use of the EPSV command when doing passive FTP +transfers. Curl normally first attempts to use EPSV before PASV, but with this +option, it does not try EPSV. + +--epsv can be used to explicitly enable EPSV again and --no-epsv is an alias +for --disable-epsv. + +If the server is an IPv6 host, this option has no effect as EPSV is necessary +then. + +Disabling EPSV only changes the passive behavior. If you want to switch to +active mode you need to use --ftp-port. diff --git a/docs/cmdline-opts/disable.d b/docs/cmdline-opts/disable.d deleted file mode 100644 index 979c03991..000000000 --- a/docs/cmdline-opts/disable.d +++ /dev/null @@ -1,17 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: disable -Short: q -Help: Disable .curlrc -Category: curl -Example: -q $URL -Added: 5.0 -See-also: config -Multi: boolean ---- -If used as the **first** parameter on the command line, the *curlrc* config -file is not read or used. See the --config for details on the default config -file search path. - -Prior to 7.50.0 curl supported the short option name *q* but not the long -option name *disable*. diff --git a/docs/cmdline-opts/disable.md b/docs/cmdline-opts/disable.md new file mode 100644 index 000000000..e22a2bb4a --- /dev/null +++ b/docs/cmdline-opts/disable.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: disable +Short: q +Help: Disable .curlrc +Category: curl +Added: 5.0 +Multi: boolean +See-also: + - config +Example: + - -q $URL +--- + +# `--disable` + +If used as the **first** parameter on the command line, the *curlrc* config +file is not read or used. See the --config for details on the default config +file search path. + +Prior to 7.50.0 curl supported the short option name *q* but not the long +option name *disable*. diff --git a/docs/cmdline-opts/disallow-username-in-url.d b/docs/cmdline-opts/disallow-username-in-url.d deleted file mode 100644 index d0537db97..000000000 --- a/docs/cmdline-opts/disallow-username-in-url.d +++ /dev/null @@ -1,13 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: disallow-username-in-url -Help: Disallow username in URL -Protocols: HTTP -Added: 7.61.0 -See-also: proto -Category: curl http -Example: --disallow-username-in-url $URL -Multi: boolean ---- -This tells curl to exit if passed a URL containing a username. This is probably -most useful when the URL is being provided at runtime or similar. diff --git a/docs/cmdline-opts/disallow-username-in-url.md b/docs/cmdline-opts/disallow-username-in-url.md new file mode 100644 index 000000000..faa4d8834 --- /dev/null +++ b/docs/cmdline-opts/disallow-username-in-url.md @@ -0,0 +1,18 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: disallow-username-in-url +Help: Disallow username in URL +Added: 7.61.0 +Category: curl +Multi: boolean +See-also: + - proto +Example: + - --disallow-username-in-url $URL +--- + +# `--disallow-username-in-url` + +This tells curl to exit if passed a URL containing a username. This is probably +most useful when the URL is being provided at runtime or similar. diff --git a/docs/cmdline-opts/dns-interface.d b/docs/cmdline-opts/dns-interface.d deleted file mode 100644 index fd924b897..000000000 --- a/docs/cmdline-opts/dns-interface.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: dns-interface -Arg: -Help: Interface to use for DNS requests -Protocols: DNS -See-also: dns-ipv4-addr dns-ipv6-addr -Added: 7.33.0 -Requires: c-ares -Category: dns -Example: --dns-interface eth0 $URL -Multi: single ---- -Tell curl to send outgoing DNS requests through . This option is a -counterpart to --interface (which does not affect DNS). The supplied string -must be an interface name (not an address). diff --git a/docs/cmdline-opts/dns-interface.md b/docs/cmdline-opts/dns-interface.md new file mode 100644 index 000000000..afc5573e5 --- /dev/null +++ b/docs/cmdline-opts/dns-interface.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: dns-interface +Arg: +Help: Interface to use for DNS requests +Protocols: DNS +Added: 7.33.0 +Requires: c-ares +Category: dns +Multi: single +See-also: + - dns-ipv4-addr + - dns-ipv6-addr +Example: + - --dns-interface eth0 $URL +--- + +# `--dns-interface` + +Tell curl to send outgoing DNS requests through . This option is a +counterpart to --interface (which does not affect DNS). The supplied string +must be an interface name (not an address). diff --git a/docs/cmdline-opts/dns-ipv4-addr.d b/docs/cmdline-opts/dns-ipv4-addr.d deleted file mode 100644 index 593055739..000000000 --- a/docs/cmdline-opts/dns-ipv4-addr.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: dns-ipv4-addr -Arg:
-Help: IPv4 address to use for DNS requests -Protocols: DNS -See-also: dns-interface dns-ipv6-addr -Added: 7.33.0 -Requires: c-ares -Category: dns -Example: --dns-ipv4-addr 10.1.2.3 $URL -Multi: single ---- -Tell curl to bind to a specific IP address when making IPv4 DNS requests, so -that the DNS requests originate from this address. The argument should be a -single IPv4 address. diff --git a/docs/cmdline-opts/dns-ipv4-addr.md b/docs/cmdline-opts/dns-ipv4-addr.md new file mode 100644 index 000000000..ff4163bc1 --- /dev/null +++ b/docs/cmdline-opts/dns-ipv4-addr.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: dns-ipv4-addr +Arg:
+Help: IPv4 address to use for DNS requests +Protocols: DNS +Added: 7.33.0 +Requires: c-ares +Category: dns +Multi: single +See-also: + - dns-interface + - dns-ipv6-addr +Example: + - --dns-ipv4-addr 10.1.2.3 $URL +--- + +# `--dns-ipv4-addr` + +Tell curl to bind to a specific IP address when making IPv4 DNS requests, so +that the DNS requests originate from this address. The argument should be a +single IPv4 address. diff --git a/docs/cmdline-opts/dns-ipv6-addr.d b/docs/cmdline-opts/dns-ipv6-addr.d deleted file mode 100644 index a76120cdc..000000000 --- a/docs/cmdline-opts/dns-ipv6-addr.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: dns-ipv6-addr -Arg:
-Help: IPv6 address to use for DNS requests -Protocols: DNS -See-also: dns-interface dns-ipv4-addr -Added: 7.33.0 -Requires: c-ares -Category: dns -Example: --dns-ipv6-addr 2a04:4e42::561 $URL -Multi: single ---- -Tell curl to bind to a specific IP address when making IPv6 DNS requests, so -that the DNS requests originate from this address. The argument should be a -single IPv6 address. diff --git a/docs/cmdline-opts/dns-ipv6-addr.md b/docs/cmdline-opts/dns-ipv6-addr.md new file mode 100644 index 000000000..7d4d1c1f5 --- /dev/null +++ b/docs/cmdline-opts/dns-ipv6-addr.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: dns-ipv6-addr +Arg:
+Help: IPv6 address to use for DNS requests +Protocols: DNS +Added: 7.33.0 +Requires: c-ares +Category: dns +Multi: single +See-also: + - dns-interface + - dns-ipv4-addr +Example: + - --dns-ipv6-addr 2a04:4e42::561 $URL +--- + +# `--dns-ipv6-addr` + +Tell curl to bind to a specific IP address when making IPv6 DNS requests, so +that the DNS requests originate from this address. The argument should be a +single IPv6 address. diff --git a/docs/cmdline-opts/dns-servers.d b/docs/cmdline-opts/dns-servers.d deleted file mode 100644 index bec23a3c3..000000000 --- a/docs/cmdline-opts/dns-servers.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: dns-servers -Arg: -Help: DNS server addrs to use -Requires: c-ares -Added: 7.33.0 -Category: dns -Example: --dns-servers 192.168.0.1,192.168.0.2 $URL -See-also: dns-interface dns-ipv4-addr -Multi: single ---- -Set the list of DNS servers to be used instead of the system default. -The list of IP addresses should be separated with commas. Port numbers -may also optionally be given as *:* after each IP -address. diff --git a/docs/cmdline-opts/dns-servers.md b/docs/cmdline-opts/dns-servers.md new file mode 100644 index 000000000..3eab6668d --- /dev/null +++ b/docs/cmdline-opts/dns-servers.md @@ -0,0 +1,24 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: dns-servers +Arg: +Help: DNS server addrs to use +Protocols: DNS +Requires: c-ares +Added: 7.33.0 +Category: dns +Multi: single +See-also: + - dns-interface + - dns-ipv4-addr +Example: + - --dns-servers 192.168.0.1,192.168.0.2 $URL +--- + +# `--dns-servers` + +Set the list of DNS servers to be used instead of the system default. +The list of IP addresses should be separated with commas. Port numbers +may also optionally be given as *:* after each IP +address. diff --git a/docs/cmdline-opts/doh-cert-status.d b/docs/cmdline-opts/doh-cert-status.d deleted file mode 100644 index 37ae0f827..000000000 --- a/docs/cmdline-opts/doh-cert-status.d +++ /dev/null @@ -1,11 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: doh-cert-status -Help: Verify the status of the DoH server cert via OCSP-staple -Added: 7.76.0 -Category: dns tls -Example: --doh-cert-status --doh-url https://doh.example $URL -See-also: doh-insecure -Multi: boolean ---- -Same as --cert-status but used for DoH (DNS-over-HTTPS). diff --git a/docs/cmdline-opts/doh-cert-status.md b/docs/cmdline-opts/doh-cert-status.md new file mode 100644 index 000000000..efa9da75c --- /dev/null +++ b/docs/cmdline-opts/doh-cert-status.md @@ -0,0 +1,17 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: doh-cert-status +Help: Verify the status of the DoH server cert via OCSP-staple +Added: 7.76.0 +Category: dns tls +Multi: boolean +See-also: + - doh-insecure +Example: + - --doh-cert-status --doh-url https://doh.example $URL +--- + +# `--doh-cert-status` + +Same as --cert-status but used for DoH (DNS-over-HTTPS). diff --git a/docs/cmdline-opts/doh-insecure.d b/docs/cmdline-opts/doh-insecure.d deleted file mode 100644 index dcc65fb6c..000000000 --- a/docs/cmdline-opts/doh-insecure.d +++ /dev/null @@ -1,11 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: doh-insecure -Help: Allow insecure DoH server connections -Added: 7.76.0 -Category: dns tls -Example: --doh-insecure --doh-url https://doh.example $URL -See-also: doh-url -Multi: boolean ---- -Same as --insecure but used for DoH (DNS-over-HTTPS). diff --git a/docs/cmdline-opts/doh-insecure.md b/docs/cmdline-opts/doh-insecure.md new file mode 100644 index 000000000..684428ddf --- /dev/null +++ b/docs/cmdline-opts/doh-insecure.md @@ -0,0 +1,17 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: doh-insecure +Help: Allow insecure DoH server connections +Added: 7.76.0 +Category: dns tls +Multi: boolean +See-also: + - doh-url +Example: + - --doh-insecure --doh-url https://doh.example $URL +--- + +# `--doh-insecure` + +Same as --insecure but used for DoH (DNS-over-HTTPS). diff --git a/docs/cmdline-opts/doh-url.d b/docs/cmdline-opts/doh-url.d deleted file mode 100644 index 6d0dd1605..000000000 --- a/docs/cmdline-opts/doh-url.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: doh-url -Arg: -Help: Resolve host names over DoH -Added: 7.62.0 -Category: dns -Example: --doh-url https://doh.example $URL -See-also: doh-insecure -Multi: single ---- -Specifies which DNS-over-HTTPS (DoH) server to use to resolve hostnames, -instead of using the default name resolver mechanism. The URL must be HTTPS. - -Some SSL options that you set for your transfer also applies to DoH since the -name lookups take place over SSL. However, the certificate verification -settings are not inherited but are controlled separately via --doh-insecure -and --doh-cert-status. - -This option is unset if an empty string "" is used as the URL. -(Added in 7.85.0) diff --git a/docs/cmdline-opts/doh-url.md b/docs/cmdline-opts/doh-url.md new file mode 100644 index 000000000..d12bf5194 --- /dev/null +++ b/docs/cmdline-opts/doh-url.md @@ -0,0 +1,27 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: doh-url +Arg: +Help: Resolve host names over DoH +Added: 7.62.0 +Category: dns +Multi: single +See-also: + - doh-insecure +Example: + - --doh-url https://doh.example $URL +--- + +# `--doh-url` + +Specifies which DNS-over-HTTPS (DoH) server to use to resolve hostnames, +instead of using the default name resolver mechanism. The URL must be HTTPS. + +Some SSL options that you set for your transfer also applies to DoH since the +name lookups take place over SSL. However, the certificate verification +settings are not inherited but are controlled separately via --doh-insecure +and --doh-cert-status. + +This option is unset if an empty string "" is used as the URL. +(Added in 7.85.0) diff --git a/docs/cmdline-opts/dump-header.d b/docs/cmdline-opts/dump-header.d deleted file mode 100644 index 42a79e7dd..000000000 --- a/docs/cmdline-opts/dump-header.d +++ /dev/null @@ -1,21 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: dump-header -Short: D -Arg: -Help: Write the received headers to -Protocols: HTTP FTP -See-also: output -Category: http ftp -Example: --dump-header store.txt $URL -Added: 5.7 -Multi: single ---- -Write the received protocol headers to the specified file. If no headers are -received, the use of this option creates an empty file. - -When used in FTP, the FTP server response lines are considered being "headers" -and thus are saved there. - -Having multiple transfers in one set of operations (i.e. the URLs in one ---next clause), appends them to the same file, separated by a blank line. diff --git a/docs/cmdline-opts/dump-header.md b/docs/cmdline-opts/dump-header.md new file mode 100644 index 000000000..42d3e85ed --- /dev/null +++ b/docs/cmdline-opts/dump-header.md @@ -0,0 +1,27 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: dump-header +Short: D +Arg: +Help: Write the received headers to +Protocols: HTTP FTP +Category: http ftp +Added: 5.7 +Multi: single +See-also: + - output +Example: + - --dump-header store.txt $URL +--- + +# `--dump-header` + +Write the received protocol headers to the specified file. If no headers are +received, the use of this option creates an empty file. + +When used in FTP, the FTP server response lines are considered being "headers" +and thus are saved there. + +Having multiple transfers in one set of operations (i.e. the URLs in one +--next clause), appends them to the same file, separated by a blank line. diff --git a/docs/cmdline-opts/egd-file.d b/docs/cmdline-opts/egd-file.d deleted file mode 100644 index 4543ecf15..000000000 --- a/docs/cmdline-opts/egd-file.d +++ /dev/null @@ -1,17 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: egd-file -Arg: -Help: EGD socket path for random data -Protocols: TLS -See-also: random-file -Category: tls -Example: --egd-file /random/here $URL -Added: 7.7 -Multi: single ---- -Deprecated option (added in 7.84.0). Prior to that it only had an effect on -curl if built to use old versions of OpenSSL. - -Specify the path name to the Entropy Gathering Daemon socket. The socket is -used to seed the random engine for SSL connections. diff --git a/docs/cmdline-opts/egd-file.md b/docs/cmdline-opts/egd-file.md new file mode 100644 index 000000000..b68b7d496 --- /dev/null +++ b/docs/cmdline-opts/egd-file.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: egd-file +Arg: +Help: EGD socket path for random data +Protocols: TLS +Category: tls +Added: 7.7 +Multi: single +See-also: + - random-file +Example: + - --egd-file /random/here $URL +--- + +# `--egd-file` + +Deprecated option (added in 7.84.0). Prior to that it only had an effect on +curl if built to use old versions of OpenSSL. + +Specify the path name to the Entropy Gathering Daemon socket. The socket is +used to seed the random engine for SSL connections. diff --git a/docs/cmdline-opts/engine.d b/docs/cmdline-opts/engine.d deleted file mode 100644 index 1ebc779c0..000000000 --- a/docs/cmdline-opts/engine.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: engine -Arg: -Help: Crypto engine to use -Protocols: TLS -Category: tls -Example: --engine flavor $URL -Added: 7.9.3 -See-also: ciphers curves -Multi: single ---- -Select the OpenSSL crypto engine to use for cipher operations. Use --engine -list to print a list of build-time supported engines. Note that not all (and -possibly none) of the engines may be available at runtime. diff --git a/docs/cmdline-opts/engine.md b/docs/cmdline-opts/engine.md new file mode 100644 index 000000000..511190023 --- /dev/null +++ b/docs/cmdline-opts/engine.md @@ -0,0 +1,22 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: engine +Arg: +Help: Crypto engine to use +Protocols: TLS +Category: tls +Added: 7.9.3 +Multi: single +See-also: + - ciphers + - curves +Example: + - --engine flavor $URL +--- + +# `--engine` + +Select the OpenSSL crypto engine to use for cipher operations. Use --engine +list to print a list of build-time supported engines. Note that not all (and +possibly none) of the engines may be available at runtime. diff --git a/docs/cmdline-opts/etag-compare.d b/docs/cmdline-opts/etag-compare.d deleted file mode 100644 index d3c48d17a..000000000 --- a/docs/cmdline-opts/etag-compare.d +++ /dev/null @@ -1,23 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: etag-compare -Arg: -Help: Pass an ETag from a file as a custom header -Protocols: HTTP -Added: 7.68.0 -Category: http -Example: --etag-compare etag.txt $URL -See-also: etag-save time-cond -Multi: single ---- -This option makes a conditional HTTP request for the specific ETag read -from the given file by sending a custom If-None-Match header using the -stored ETag. - -For correct results, make sure that the specified file contains only a -single line with the desired ETag. An empty file is parsed as an empty -ETag. - -Use the option --etag-save to first save the ETag from a response, and -then use this option to compare against the saved ETag in a subsequent -request. diff --git a/docs/cmdline-opts/etag-compare.md b/docs/cmdline-opts/etag-compare.md new file mode 100644 index 000000000..11c1d0e87 --- /dev/null +++ b/docs/cmdline-opts/etag-compare.md @@ -0,0 +1,30 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: etag-compare +Arg: +Help: Pass an ETag from a file as a custom header +Protocols: HTTP +Added: 7.68.0 +Category: http +Multi: single +See-also: + - etag-save + - time-cond +Example: + - --etag-compare etag.txt $URL +--- + +# `--etag-compare` + +This option makes a conditional HTTP request for the specific ETag read +from the given file by sending a custom If-None-Match header using the +stored ETag. + +For correct results, make sure that the specified file contains only a +single line with the desired ETag. An empty file is parsed as an empty +ETag. + +Use the option --etag-save to first save the ETag from a response, and +then use this option to compare against the saved ETag in a subsequent +request. diff --git a/docs/cmdline-opts/etag-save.d b/docs/cmdline-opts/etag-save.d deleted file mode 100644 index 6295a9e31..000000000 --- a/docs/cmdline-opts/etag-save.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: etag-save -Arg: -Help: Parse ETag from a request and save it to a file -Protocols: HTTP -Added: 7.68.0 -Category: http -Example: --etag-save storetag.txt $URL -See-also: etag-compare -Multi: single ---- -This option saves an HTTP ETag to the specified file. An ETag is a -caching related header, usually returned in a response. - -If no ETag is sent by the server, an empty file is created. diff --git a/docs/cmdline-opts/etag-save.md b/docs/cmdline-opts/etag-save.md new file mode 100644 index 000000000..f6fb14a51 --- /dev/null +++ b/docs/cmdline-opts/etag-save.md @@ -0,0 +1,22 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: etag-save +Arg: +Help: Parse ETag from a request and save it to a file +Protocols: HTTP +Added: 7.68.0 +Category: http +Multi: single +See-also: + - etag-compare +Example: + - --etag-save storetag.txt $URL +--- + +# `--etag-save` + +This option saves an HTTP ETag to the specified file. An ETag is a +caching related header, usually returned in a response. + +If no ETag is sent by the server, an empty file is created. diff --git a/docs/cmdline-opts/expect100-timeout.d b/docs/cmdline-opts/expect100-timeout.d deleted file mode 100644 index f9a119bd9..000000000 --- a/docs/cmdline-opts/expect100-timeout.d +++ /dev/null @@ -1,19 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: expect100-timeout -Arg: -Help: How long to wait for 100-continue -Protocols: HTTP -Added: 7.47.0 -See-also: connect-timeout -Category: http -Example: --expect100-timeout 2.5 -T file $URL -Multi: single ---- -Maximum time in seconds that you allow curl to wait for a 100-continue -response when curl emits an Expects: 100-continue header in its request. By -default curl waits one second. This option accepts decimal values! When -curl stops waiting, it continues as if the response has been received. - -The decimal value needs to provided using a dot (.) as decimal separator - not -the local version even if it might be using another separator. diff --git a/docs/cmdline-opts/expect100-timeout.md b/docs/cmdline-opts/expect100-timeout.md new file mode 100644 index 000000000..9554568a7 --- /dev/null +++ b/docs/cmdline-opts/expect100-timeout.md @@ -0,0 +1,25 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: expect100-timeout +Arg: +Help: How long to wait for 100-continue +Protocols: HTTP +Added: 7.47.0 +Category: http +Multi: single +See-also: + - connect-timeout +Example: + - --expect100-timeout 2.5 -T file $URL +--- + +# `--expect100-timeout` + +Maximum time in seconds that you allow curl to wait for a 100-continue +response when curl emits an Expects: 100-continue header in its request. By +default curl waits one second. This option accepts decimal values! When +curl stops waiting, it continues as if the response has been received. + +The decimal value needs to provided using a dot (.) as decimal separator - not +the local version even if it might be using another separator. diff --git a/docs/cmdline-opts/fail-early.d b/docs/cmdline-opts/fail-early.d deleted file mode 100644 index 36b330999..000000000 --- a/docs/cmdline-opts/fail-early.d +++ /dev/null @@ -1,25 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: fail-early -Help: Fail on first transfer error, do not continue -Added: 7.52.0 -Category: curl -Example: --fail-early $URL https://two.example -See-also: fail fail-with-body -Multi: boolean -Scope: global ---- -Fail and exit on the first detected transfer error. - -When curl is used to do multiple transfers on the command line, it attempts to -operate on each given URL, one by one. By default, it ignores errors if there -are more URLs given and the last URL's success determines the error code curl -returns. So early failures are "hidden" by subsequent successful transfers. - -Using this option, curl instead returns an error on the first transfer that -fails, independent of the amount of URLs that are given on the command -line. This way, no transfer failures go undetected by scripts and similar. - -This option does not imply --fail, which causes transfers to fail due to the -server's HTTP status code. You can combine the two options, however note --fail -is not global and is therefore contained by --next. diff --git a/docs/cmdline-opts/fail-early.md b/docs/cmdline-opts/fail-early.md new file mode 100644 index 000000000..b68160c20 --- /dev/null +++ b/docs/cmdline-opts/fail-early.md @@ -0,0 +1,32 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: fail-early +Help: Fail on first transfer error, do not continue +Added: 7.52.0 +Category: curl +Multi: boolean +Scope: global +See-also: + - fail + - fail-with-body +Example: + - --fail-early $URL https://two.example +--- + +# `--fail-early` + +Fail and exit on the first detected transfer error. + +When curl is used to do multiple transfers on the command line, it attempts to +operate on each given URL, one by one. By default, it ignores errors if there +are more URLs given and the last URL's success determines the error code curl +returns. So early failures are "hidden" by subsequent successful transfers. + +Using this option, curl instead returns an error on the first transfer that +fails, independent of the amount of URLs that are given on the command +line. This way, no transfer failures go undetected by scripts and similar. + +This option does not imply --fail, which causes transfers to fail due to the +server's HTTP status code. You can combine the two options, however note --fail +is not global and is therefore contained by --next. diff --git a/docs/cmdline-opts/fail-with-body.d b/docs/cmdline-opts/fail-with-body.d deleted file mode 100644 index dddb86e22..000000000 --- a/docs/cmdline-opts/fail-with-body.d +++ /dev/null @@ -1,20 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: fail-with-body -Protocols: HTTP -Help: Fail on HTTP errors but save the body -Category: http output -Added: 7.76.0 -See-also: fail fail-early -Mutexed: fail -Example: --fail-with-body $URL -Multi: boolean ---- -Return an error on server errors where the HTTP response code is 400 or -greater). In normal cases when an HTTP server fails to deliver a document, it -returns an HTML document stating so (which often also describes why and -more). This flag allows curl to output and save that content but also to -return error 22. - -This is an alternative option to --fail which makes curl fail for the same -circumstances but without saving the content. diff --git a/docs/cmdline-opts/fail-with-body.md b/docs/cmdline-opts/fail-with-body.md new file mode 100644 index 000000000..e340cb034 --- /dev/null +++ b/docs/cmdline-opts/fail-with-body.md @@ -0,0 +1,27 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: fail-with-body +Protocols: HTTP +Help: Fail on HTTP errors but save the body +Category: http output +Added: 7.76.0 +Mutexed: fail +Multi: boolean +See-also: + - fail + - fail-early +Example: + - --fail-with-body $URL +--- + +# `--fail-with-body` + +Return an error on server errors where the HTTP response code is 400 or +greater). In normal cases when an HTTP server fails to deliver a document, it +returns an HTML document stating so (which often also describes why and +more). This flag allows curl to output and save that content but also to +return error 22. + +This is an alternative option to --fail which makes curl fail for the same +circumstances but without saving the content. diff --git a/docs/cmdline-opts/fail.d b/docs/cmdline-opts/fail.d deleted file mode 100644 index 8196a908d..000000000 --- a/docs/cmdline-opts/fail.d +++ /dev/null @@ -1,22 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: fail -Short: f -Protocols: HTTP -Help: Fail fast with no output on HTTP errors -See-also: fail-with-body fail-early -Category: important http -Example: --fail $URL -Mutexed: fail-with-body -Added: 4.0 -Multi: boolean ---- -Fail fast with no output at all on server errors. This is useful to enable -scripts and users to better deal with failed attempts. In normal cases when an -HTTP server fails to deliver a document, it returns an HTML document stating -so (which often also describes why and more). This flag prevents curl from -outputting that and return error 22. - -This method is not fail-safe and there are occasions where non-successful -response codes slip through, especially when authentication is involved -(response codes 401 and 407). diff --git a/docs/cmdline-opts/fail.md b/docs/cmdline-opts/fail.md new file mode 100644 index 000000000..b8de4ebb2 --- /dev/null +++ b/docs/cmdline-opts/fail.md @@ -0,0 +1,29 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: fail +Short: f +Protocols: HTTP +Help: Fail fast with no output on HTTP errors +Category: important http +Mutexed: fail-with-body +Added: 4.0 +Multi: boolean +See-also: + - fail-with-body + - fail-early +Example: + - --fail $URL +--- + +# `--fail` + +Fail fast with no output at all on server errors. This is useful to enable +scripts and users to better deal with failed attempts. In normal cases when an +HTTP server fails to deliver a document, it returns an HTML document stating +so (which often also describes why and more). This flag prevents curl from +outputting that and return error 22. + +This method is not fail-safe and there are occasions where non-successful +response codes slip through, especially when authentication is involved +(response codes 401 and 407). diff --git a/docs/cmdline-opts/false-start.d b/docs/cmdline-opts/false-start.d deleted file mode 100644 index 73240492b..000000000 --- a/docs/cmdline-opts/false-start.d +++ /dev/null @@ -1,18 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: false-start -Help: Enable TLS False Start -Protocols: TLS -Added: 7.42.0 -Category: tls -Example: --false-start $URL -See-also: tcp-fastopen -Multi: boolean ---- -Tells curl to use false start during the TLS handshake. False start is a mode -where a TLS client starts sending application data before verifying the -server's Finished message, thus saving a round trip when performing a full -handshake. - -This is currently only implemented in the Secure Transport (on iOS 7.0 or -later, or OS X 10.9 or later) backend. diff --git a/docs/cmdline-opts/false-start.md b/docs/cmdline-opts/false-start.md new file mode 100644 index 000000000..d2697da53 --- /dev/null +++ b/docs/cmdline-opts/false-start.md @@ -0,0 +1,24 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: false-start +Help: Enable TLS False Start +Protocols: TLS +Added: 7.42.0 +Category: tls +Multi: boolean +See-also: + - tcp-fastopen +Example: + - --false-start $URL +--- + +# `--false-start` + +Tells curl to use false start during the TLS handshake. False start is a mode +where a TLS client starts sending application data before verifying the +server's Finished message, thus saving a round trip when performing a full +handshake. + +This is currently only implemented in the Secure Transport (on iOS 7.0 or +later, or OS X 10.9 or later) backend. diff --git a/docs/cmdline-opts/form-escape.d b/docs/cmdline-opts/form-escape.d deleted file mode 100644 index 304bfe814..000000000 --- a/docs/cmdline-opts/form-escape.d +++ /dev/null @@ -1,13 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: form-escape -Help: Escape multipart form field/file names using backslash -Protocols: HTTP -See-also: form -Added: 7.81.0 -Category: http upload -Example: --form-escape -F 'field\\name=curl' -F 'file=@load"this' $URL -Multi: single ---- -Tells curl to pass on names of multipart form fields and files using -backslash-escaping instead of percent-encoding. diff --git a/docs/cmdline-opts/form-escape.md b/docs/cmdline-opts/form-escape.md new file mode 100644 index 000000000..62973f172 --- /dev/null +++ b/docs/cmdline-opts/form-escape.md @@ -0,0 +1,19 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: form-escape +Help: Escape multipart form field/file names using backslash +Protocols: HTTP +Added: 7.81.0 +Category: http upload +Multi: single +See-also: + - form +Example: + - --form-escape -F 'field\name=curl' -F 'file=@load"this' $URL +--- + +# `--form-escape` + +Tells curl to pass on names of multipart form fields and files using +backslash-escaping instead of percent-encoding. diff --git a/docs/cmdline-opts/form-string.d b/docs/cmdline-opts/form-string.d deleted file mode 100644 index 6d7a500a4..000000000 --- a/docs/cmdline-opts/form-string.d +++ /dev/null @@ -1,17 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: form-string -Help: Specify multipart MIME data -Protocols: HTTP SMTP IMAP -Arg: -See-also: form -Category: http upload -Example: --form-string "data" $URL -Added: 7.13.2 -Multi: append ---- -Similar to --form except that the value string for the named parameter is used -literally. Leading '@' and '<' characters, and the ';type=' string in -the value have no special meaning. Use this in preference to --form if -there is any possibility that the string value may accidentally trigger the -'@' or '<' features of --form. diff --git a/docs/cmdline-opts/form-string.md b/docs/cmdline-opts/form-string.md new file mode 100644 index 000000000..d26c47142 --- /dev/null +++ b/docs/cmdline-opts/form-string.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: form-string +Help: Specify multipart MIME data +Protocols: HTTP SMTP IMAP +Arg: +Category: http upload +Added: 7.13.2 +Multi: append +See-also: + - form +Example: + - --form-string "data" $URL +--- + +# `--form-string` + +Similar to --form except that the value string for the named parameter is used +literally. Leading '@' and '<' characters, and the ';type=' string in +the value have no special meaning. Use this in preference to --form if +there is any possibility that the string value may accidentally trigger the +'@' or '<' features of --form. diff --git a/docs/cmdline-opts/form.d b/docs/cmdline-opts/form.d deleted file mode 100644 index e53e93ae0..000000000 --- a/docs/cmdline-opts/form.d +++ /dev/null @@ -1,134 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: form -Short: F -Arg: -Help: Specify multipart MIME data -Protocols: HTTP SMTP IMAP -Mutexed: data head upload-file -Category: http upload -Example: --form "name=curl" --form "file=@loadthis" $URL -Added: 5.0 -See-also: data form-string form-escape -Multi: append ---- -For HTTP protocol family, this lets curl emulate a filled-in form in which a -user has pressed the submit button. This causes curl to POST data using the -Content-Type multipart/form-data according to RFC 2388. - -For SMTP and IMAP protocols, this is the means to compose a multipart mail -message to transmit. - -This enables uploading of binary files etc. To force the 'content' part to be -a file, prefix the file name with an @ sign. To just get the content part from -a file, prefix the file name with the symbol <. The difference between @ and < -is then that @ makes a file get attached in the post as a file upload, while -the < makes a text field and just get the contents for that text field from a -file. - -Tell curl to read content from stdin instead of a file by using - as -filename. This goes for both @ and < constructs. When stdin is used, the -contents is buffered in memory first by curl to determine its size and allow a -possible resend. Defining a part's data from a named non-regular file (such as -a named pipe or similar) is not subject to buffering and is instead read at -transmission time; since the full size is unknown before the transfer starts, -such data is sent as chunks by HTTP and rejected by IMAP. - -Example: send an image to an HTTP server, where 'profile' is the name of the -form-field to which the file **portrait.jpg** is the input: - - curl -F profile=@portrait.jpg https://example.com/upload.cgi - -Example: send your name and shoe size in two text fields to the server: - - curl -F name=John -F shoesize=11 https://example.com/ - -Example: send your essay in a text field to the server. Send it as a plain -text field, but get the contents for it from a local file: - - curl -F "story=HTML message;type=text/html' \\ - -F '=)' -F '=@textfile.txt' ... smtp://example.com - -Data can be encoded for transfer using encoder=. Available encodings are -*binary* and *8bit* that do nothing else than adding the corresponding -Content-Transfer-Encoding header, *7bit* that only rejects 8-bit characters -with a transfer error, *quoted-printable* and *base64* that encodes data -according to the corresponding schemes, limiting lines length to 76 -characters. - -Example: send multipart mail with a quoted-printable text message and a -base64 attached file: - - curl -F '=text message;encoder=quoted-printable' \\ - -F '=@localfile;encoder=base64' ... smtp://example.com - -See further examples and details in the MANUAL. diff --git a/docs/cmdline-opts/form.md b/docs/cmdline-opts/form.md new file mode 100644 index 000000000..0ba552136 --- /dev/null +++ b/docs/cmdline-opts/form.md @@ -0,0 +1,142 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: form +Short: F +Arg: +Help: Specify multipart MIME data +Protocols: HTTP SMTP IMAP +Mutexed: data head upload-file +Category: http upload +Added: 5.0 +Multi: append +See-also: + - data + - form-string + - form-escape +Example: + - --form "name=curl" --form "file=@loadthis" $URL +--- + +# `--form` + +For HTTP protocol family, this lets curl emulate a filled-in form in which a +user has pressed the submit button. This causes curl to POST data using the +Content-Type multipart/form-data according to RFC 2388. + +For SMTP and IMAP protocols, this is the means to compose a multipart mail +message to transmit. + +This enables uploading of binary files etc. To force the 'content' part to be +a file, prefix the file name with an @ sign. To just get the content part from +a file, prefix the file name with the symbol <. The difference between @ and < +is then that @ makes a file get attached in the post as a file upload, while +the < makes a text field and just get the contents for that text field from a +file. + +Tell curl to read content from stdin instead of a file by using - as +filename. This goes for both @ and < constructs. When stdin is used, the +contents is buffered in memory first by curl to determine its size and allow a +possible resend. Defining a part's data from a named non-regular file (such as +a named pipe or similar) is not subject to buffering and is instead read at +transmission time; since the full size is unknown before the transfer starts, +such data is sent as chunks by HTTP and rejected by IMAP. + +Example: send an image to an HTTP server, where 'profile' is the name of the +form-field to which the file **portrait.jpg** is the input: + + curl -F profile=@portrait.jpg https://example.com/upload.cgi + +Example: send your name and shoe size in two text fields to the server: + + curl -F name=John -F shoesize=11 https://example.com/ + +Example: send your essay in a text field to the server. Send it as a plain +text field, but get the contents for it from a local file: + + curl -F "story=HTML message;type=text/html' \ + -F '=)' -F '=@textfile.txt' ... smtp://example.com + +Data can be encoded for transfer using encoder=. Available encodings are +*binary* and *8bit* that do nothing else than adding the corresponding +Content-Transfer-Encoding header, *7bit* that only rejects 8-bit characters +with a transfer error, *quoted-printable* and *base64* that encodes data +according to the corresponding schemes, limiting lines length to 76 +characters. + +Example: send multipart mail with a quoted-printable text message and a +base64 attached file: + + curl -F '=text message;encoder=quoted-printable' \ + -F '=@localfile;encoder=base64' ... smtp://example.com + +See further examples and details in the MANUAL. diff --git a/docs/cmdline-opts/ftp-account.d b/docs/cmdline-opts/ftp-account.d deleted file mode 100644 index eb669c562..000000000 --- a/docs/cmdline-opts/ftp-account.d +++ /dev/null @@ -1,14 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-account -Arg: -Help: Account data string -Protocols: FTP -Added: 7.13.0 -Category: ftp auth -Example: --ftp-account "mr.robot" ftp://example.com/ -See-also: user -Multi: single ---- -When an FTP server asks for "account data" after user name and password has -been provided, this data is sent off using the ACCT command. diff --git a/docs/cmdline-opts/ftp-account.md b/docs/cmdline-opts/ftp-account.md new file mode 100644 index 000000000..2f3363943 --- /dev/null +++ b/docs/cmdline-opts/ftp-account.md @@ -0,0 +1,20 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-account +Arg: +Help: Account data string +Protocols: FTP +Added: 7.13.0 +Category: ftp auth +Multi: single +See-also: + - user +Example: + - --ftp-account "mr.robot" ftp://example.com/ +--- + +# `--ftp-account` + +When an FTP server asks for "account data" after user name and password has +been provided, this data is sent off using the ACCT command. diff --git a/docs/cmdline-opts/ftp-alternative-to-user.d b/docs/cmdline-opts/ftp-alternative-to-user.d deleted file mode 100644 index f030bcf59..000000000 --- a/docs/cmdline-opts/ftp-alternative-to-user.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-alternative-to-user -Arg: -Help: String to replace USER [name] -Protocols: FTP -Added: 7.15.5 -Category: ftp -Example: --ftp-alternative-to-user "U53r" ftp://example.com -See-also: ftp-account user -Multi: single ---- -If authenticating with the USER and PASS commands fails, send this command. -When connecting to Tumbleweed's Secure Transport server over FTPS using a -client certificate, using "SITE AUTH" tells the server to retrieve the -username from the certificate. diff --git a/docs/cmdline-opts/ftp-alternative-to-user.md b/docs/cmdline-opts/ftp-alternative-to-user.md new file mode 100644 index 000000000..9bd368600 --- /dev/null +++ b/docs/cmdline-opts/ftp-alternative-to-user.md @@ -0,0 +1,23 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-alternative-to-user +Arg: +Help: String to replace USER [name] +Protocols: FTP +Added: 7.15.5 +Category: ftp +Multi: single +See-also: + - ftp-account + - user +Example: + - --ftp-alternative-to-user "U53r" ftp://example.com +--- + +# `--ftp-alternative-to-user` + +If authenticating with the USER and PASS commands fails, send this command. +When connecting to Tumbleweed's Secure Transport server over FTPS using a +client certificate, using "SITE AUTH" tells the server to retrieve the +username from the certificate. diff --git a/docs/cmdline-opts/ftp-create-dirs.d b/docs/cmdline-opts/ftp-create-dirs.d deleted file mode 100644 index 7c64f0e21..000000000 --- a/docs/cmdline-opts/ftp-create-dirs.d +++ /dev/null @@ -1,14 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-create-dirs -Protocols: FTP SFTP -Help: Create the remote dirs if not present -See-also: create-dirs -Category: ftp sftp curl -Example: --ftp-create-dirs -T file ftp://example.com/remote/path/file -Added: 7.10.7 -Multi: boolean ---- -When an FTP or SFTP URL/operation uses a path that does not currently exist on -the server, the standard behavior of curl is to fail. Using this option, curl -instead attempts to create missing directories. diff --git a/docs/cmdline-opts/ftp-create-dirs.md b/docs/cmdline-opts/ftp-create-dirs.md new file mode 100644 index 000000000..5151e336c --- /dev/null +++ b/docs/cmdline-opts/ftp-create-dirs.md @@ -0,0 +1,20 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-create-dirs +Protocols: FTP SFTP +Help: Create the remote dirs if not present +Category: ftp sftp curl +Added: 7.10.7 +Multi: boolean +See-also: + - create-dirs +Example: + - --ftp-create-dirs -T file ftp://example.com/remote/path/file +--- + +# `--ftp-create-dirs` + +When an FTP or SFTP URL/operation uses a path that does not currently exist on +the server, the standard behavior of curl is to fail. Using this option, curl +instead attempts to create missing directories. diff --git a/docs/cmdline-opts/ftp-method.d b/docs/cmdline-opts/ftp-method.d deleted file mode 100644 index 8061d2b68..000000000 --- a/docs/cmdline-opts/ftp-method.d +++ /dev/null @@ -1,30 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-method -Arg: -Help: Control CWD usage -Protocols: FTP -Added: 7.15.1 -Category: ftp -Example: --ftp-method multicwd ftp://example.com/dir1/dir2/file -Example: --ftp-method nocwd ftp://example.com/dir1/dir2/file -Example: --ftp-method singlecwd ftp://example.com/dir1/dir2/file -See-also: list-only -Multi: single ---- -Control what method curl should use to reach a file on an FTP(S) -server. The method argument should be one of the following alternatives: -.RS -.IP multicwd -curl does a single CWD operation for each path part in the given URL. For deep -hierarchies this means many commands. This is how RFC 1738 says it should -be done. This is the default but the slowest behavior. -.IP nocwd -curl does no CWD at all. curl does SIZE, RETR, STOR etc and give a full -path to the server for all these commands. This is the fastest behavior. -.IP singlecwd -curl does one CWD with the full target directory and then operates on the file -"normally" (like in the multicwd case). This is somewhat more standards -compliant than 'nocwd' but without the full penalty of 'multicwd'. -.RE -.IP diff --git a/docs/cmdline-opts/ftp-method.md b/docs/cmdline-opts/ftp-method.md new file mode 100644 index 000000000..e4e346858 --- /dev/null +++ b/docs/cmdline-opts/ftp-method.md @@ -0,0 +1,36 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-method +Arg: +Help: Control CWD usage +Protocols: FTP +Added: 7.15.1 +Category: ftp +Multi: single +See-also: + - list-only +Example: + - --ftp-method multicwd ftp://example.com/dir1/dir2/file + - --ftp-method nocwd ftp://example.com/dir1/dir2/file + - --ftp-method singlecwd ftp://example.com/dir1/dir2/file +--- + +# `--ftp-method` + +Control what method curl should use to reach a file on an FTP(S) +server. The method argument should be one of the following alternatives: + +## multicwd +curl does a single CWD operation for each path part in the given URL. For deep +hierarchies this means many commands. This is how RFC 1738 says it should +be done. This is the default but the slowest behavior. + +## nocwd +curl does no CWD at all. curl does SIZE, RETR, STOR etc and give a full +path to the server for all these commands. This is the fastest behavior. + +## singlecwd +curl does one CWD with the full target directory and then operates on the file +"normally" (like in the multicwd case). This is somewhat more standards +compliant than 'nocwd' but without the full penalty of 'multicwd'. diff --git a/docs/cmdline-opts/ftp-pasv.d b/docs/cmdline-opts/ftp-pasv.d deleted file mode 100644 index c43bf2bee..000000000 --- a/docs/cmdline-opts/ftp-pasv.d +++ /dev/null @@ -1,20 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-pasv -Help: Use PASV/EPSV instead of PORT -Protocols: FTP -Added: 7.11.0 -See-also: disable-epsv -Category: ftp -Example: --ftp-pasv ftp://example.com/ -Multi: boolean ---- -Use passive mode for the data connection. Passive is the internal default -behavior, but using this option can be used to override a previous --ftp-port -option. - -Reversing an enforced passive really is not doable but you must then instead -enforce the correct --ftp-port again. - -Passive mode means that curl tries the EPSV command first and then PASV, -unless --disable-epsv is used. diff --git a/docs/cmdline-opts/ftp-pasv.md b/docs/cmdline-opts/ftp-pasv.md new file mode 100644 index 000000000..265a8e453 --- /dev/null +++ b/docs/cmdline-opts/ftp-pasv.md @@ -0,0 +1,26 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-pasv +Help: Use PASV/EPSV instead of PORT +Protocols: FTP +Added: 7.11.0 +Category: ftp +Multi: boolean +See-also: + - disable-epsv +Example: + - --ftp-pasv ftp://example.com/ +--- + +# `--ftp-pasv` + +Use passive mode for the data connection. Passive is the internal default +behavior, but using this option can be used to override a previous --ftp-port +option. + +Reversing an enforced passive really is not doable but you must then instead +enforce the correct --ftp-port again. + +Passive mode means that curl tries the EPSV command first and then PASV, +unless --disable-epsv is used. diff --git a/docs/cmdline-opts/ftp-port.d b/docs/cmdline-opts/ftp-port.d deleted file mode 100644 index e1f4a1dba..000000000 --- a/docs/cmdline-opts/ftp-port.d +++ /dev/null @@ -1,41 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-port -Arg:
-Help: Use PORT instead of PASV -Short: P -Protocols: FTP -See-also: ftp-pasv disable-eprt -Category: ftp -Example: -P - ftp:/example.com -Example: -P eth0 ftp:/example.com -Example: -P 192.168.0.2 ftp:/example.com -Added: 4.0 -Multi: single ---- -Reverses the default initiator/listener roles when connecting with FTP. This -option makes curl use active mode. curl then tells the server to connect back -to the client's specified address and port, while passive mode asks the server -to setup an IP address and port for it to connect to.
should be one -of: -.RS -.IP interface -e.g. "eth0" to specify which interface's IP address you want to use (Unix only) -.IP "IP address" -e.g. "192.168.10.1" to specify the exact IP address -.IP "host name" -e.g. "my.host.domain" to specify the machine -.IP "-" -make curl pick the same IP address that is already used for the control -connection -.RE -.IP - -Disable the use of PORT with --ftp-pasv. Disable the attempt to use the EPRT -command instead of PORT by using --disable-eprt. EPRT is really PORT++. - -You can also append ":[start]-[end]\&" to the right of the address, to tell -curl what TCP port range to use. That means you specify a port range, from a -lower to a higher number. A single number works as well, but do note that it -increases the risk of failure since the port may not be available. -(Added in 7.19.5) diff --git a/docs/cmdline-opts/ftp-port.md b/docs/cmdline-opts/ftp-port.md new file mode 100644 index 000000000..e9ec59146 --- /dev/null +++ b/docs/cmdline-opts/ftp-port.md @@ -0,0 +1,51 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-port +Arg:
+Help: Use PORT instead of PASV +Short: P +Protocols: FTP +Category: ftp +Added: 4.0 +Multi: single +See-also: + - ftp-pasv + - disable-eprt +Example: + - -P - ftp:/example.com + - -P eth0 ftp:/example.com + - -P 192.168.0.2 ftp:/example.com +--- + +# `--ftp-port` + +Reverses the default initiator/listener roles when connecting with FTP. This +option makes curl use active mode. curl then tells the server to connect back +to the client's specified address and port, while passive mode asks the server +to setup an IP address and port for it to connect to.
should be one +of: + +## interface +e.g. **eth0** to specify which interface's IP address you want to use (Unix only) + +## IP address +e.g. **192.168.10.1** to specify the exact IP address + +## host name +e.g. **my.host.domain** to specify the machine + +## - +make curl pick the same IP address that is already used for the control +connection. This is the recommended choice. + +## + +Disable the use of PORT with --ftp-pasv. Disable the attempt to use the EPRT +command instead of PORT by using --disable-eprt. EPRT is really PORT++. + +You can also append ":[start]-[end]" to the right of the address, to tell +curl what TCP port range to use. That means you specify a port range, from a +lower to a higher number. A single number works as well, but do note that it +increases the risk of failure since the port may not be available. +(Added in 7.19.5) diff --git a/docs/cmdline-opts/ftp-pret.d b/docs/cmdline-opts/ftp-pret.d deleted file mode 100644 index 4bea99e6d..000000000 --- a/docs/cmdline-opts/ftp-pret.d +++ /dev/null @@ -1,14 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-pret -Help: Send PRET before PASV -Protocols: FTP -Added: 7.20.0 -Category: ftp -Example: --ftp-pret ftp://example.com/ -See-also: ftp-port ftp-pasv -Multi: boolean ---- -Tell curl to send a PRET command before PASV (and EPSV). Certain FTP servers, -mainly drftpd, require this non-standard command for directory listings as -well as up and downloads in PASV mode. diff --git a/docs/cmdline-opts/ftp-pret.md b/docs/cmdline-opts/ftp-pret.md new file mode 100644 index 000000000..accbc226d --- /dev/null +++ b/docs/cmdline-opts/ftp-pret.md @@ -0,0 +1,21 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-pret +Help: Send PRET before PASV +Protocols: FTP +Added: 7.20.0 +Category: ftp +Multi: boolean +See-also: + - ftp-port + - ftp-pasv +Example: + - --ftp-pret ftp://example.com/ +--- + +# `--ftp-pret` + +Tell curl to send a PRET command before PASV (and EPSV). Certain FTP servers, +mainly drftpd, require this non-standard command for directory listings as +well as up and downloads in PASV mode. diff --git a/docs/cmdline-opts/ftp-skip-pasv-ip.d b/docs/cmdline-opts/ftp-skip-pasv-ip.d deleted file mode 100644 index 3af9c6de4..000000000 --- a/docs/cmdline-opts/ftp-skip-pasv-ip.d +++ /dev/null @@ -1,18 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-skip-pasv-ip -Help: Skip the IP address for PASV -Protocols: FTP -Added: 7.14.2 -See-also: ftp-pasv -Category: ftp -Example: --ftp-skip-pasv-ip ftp://example.com/ -Multi: boolean ---- -Tell curl to not use the IP address the server suggests in its response to -curl's PASV command when curl connects the data connection. Instead curl -reuses the same IP address it already uses for the control connection. - -This option is enabled by default (added in 7.74.0). - -This option has no effect if PORT, EPRT or EPSV is used instead of PASV. diff --git a/docs/cmdline-opts/ftp-skip-pasv-ip.md b/docs/cmdline-opts/ftp-skip-pasv-ip.md new file mode 100644 index 000000000..ef94b34af --- /dev/null +++ b/docs/cmdline-opts/ftp-skip-pasv-ip.md @@ -0,0 +1,24 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-skip-pasv-ip +Help: Skip the IP address for PASV +Protocols: FTP +Added: 7.14.2 +Category: ftp +Multi: boolean +See-also: + - ftp-pasv +Example: + - --ftp-skip-pasv-ip ftp://example.com/ +--- + +# `--ftp-skip-pasv-ip` + +Tell curl to not use the IP address the server suggests in its response to +curl's PASV command when curl connects the data connection. Instead curl +reuses the same IP address it already uses for the control connection. + +This option is enabled by default (added in 7.74.0). + +This option has no effect if PORT, EPRT or EPSV is used instead of PASV. diff --git a/docs/cmdline-opts/ftp-ssl-ccc-mode.d b/docs/cmdline-opts/ftp-ssl-ccc-mode.d deleted file mode 100644 index ae9af9429..000000000 --- a/docs/cmdline-opts/ftp-ssl-ccc-mode.d +++ /dev/null @@ -1,16 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-ssl-ccc-mode -Arg: -Help: Set CCC mode -Protocols: FTP -Added: 7.16.2 -See-also: ftp-ssl-ccc -Category: ftp tls -Example: --ftp-ssl-ccc-mode active --ftp-ssl-ccc ftps://example.com/ -Multi: boolean ---- -Sets the CCC mode. The passive mode does not initiate the shutdown, but -instead waits for the server to do it, and does not reply to the shutdown from -the server. The active mode initiates the shutdown and waits for a reply from -the server. diff --git a/docs/cmdline-opts/ftp-ssl-ccc-mode.md b/docs/cmdline-opts/ftp-ssl-ccc-mode.md new file mode 100644 index 000000000..5f428dc0f --- /dev/null +++ b/docs/cmdline-opts/ftp-ssl-ccc-mode.md @@ -0,0 +1,22 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-ssl-ccc-mode +Arg: +Help: Set CCC mode +Protocols: FTP +Added: 7.16.2 +Category: ftp tls +Multi: boolean +See-also: + - ftp-ssl-ccc +Example: + - --ftp-ssl-ccc-mode active --ftp-ssl-ccc ftps://example.com/ +--- + +# `--ftp-ssl-ccc-mode` + +Sets the CCC mode. The passive mode does not initiate the shutdown, but +instead waits for the server to do it, and does not reply to the shutdown from +the server. The active mode initiates the shutdown and waits for a reply from +the server. diff --git a/docs/cmdline-opts/ftp-ssl-ccc.d b/docs/cmdline-opts/ftp-ssl-ccc.d deleted file mode 100644 index 33ae83b1c..000000000 --- a/docs/cmdline-opts/ftp-ssl-ccc.d +++ /dev/null @@ -1,15 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-ssl-ccc -Help: Send CCC after authenticating -Protocols: FTP -See-also: ssl ftp-ssl-ccc-mode -Added: 7.16.1 -Category: ftp tls -Example: --ftp-ssl-ccc ftps://example.com/ -Multi: boolean ---- -Use CCC (Clear Command Channel) Shuts down the SSL/TLS layer after -authenticating. The rest of the control channel communication is be -unencrypted. This allows NAT routers to follow the FTP transaction. The -default mode is passive. diff --git a/docs/cmdline-opts/ftp-ssl-ccc.md b/docs/cmdline-opts/ftp-ssl-ccc.md new file mode 100644 index 000000000..d477606fe --- /dev/null +++ b/docs/cmdline-opts/ftp-ssl-ccc.md @@ -0,0 +1,22 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-ssl-ccc +Help: Send CCC after authenticating +Protocols: FTP +Added: 7.16.1 +Category: ftp tls +Multi: boolean +See-also: + - ssl + - ftp-ssl-ccc-mode +Example: + - --ftp-ssl-ccc ftps://example.com/ +--- + +# `--ftp-ssl-ccc` + +Use CCC (Clear Command Channel) Shuts down the SSL/TLS layer after +authenticating. The rest of the control channel communication is be +unencrypted. This allows NAT routers to follow the FTP transaction. The +default mode is passive. diff --git a/docs/cmdline-opts/ftp-ssl-control.d b/docs/cmdline-opts/ftp-ssl-control.d deleted file mode 100644 index b89577927..000000000 --- a/docs/cmdline-opts/ftp-ssl-control.d +++ /dev/null @@ -1,14 +0,0 @@ -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: ftp-ssl-control -Help: Require SSL/TLS for FTP login, clear for transfer -Protocols: FTP -Added: 7.16.0 -Category: ftp tls -Example: --ftp-ssl-control ftp://example.com -See-also: ssl -Multi: boolean ---- -Require SSL/TLS for the FTP login, clear for transfer. Allows secure -authentication, but non-encrypted data transfers for efficiency. Fails the -transfer if the server does not support SSL/TLS. diff --git a/docs/cmdline-opts/ftp-ssl-control.md b/docs/cmdline-opts/ftp-ssl-control.md new file mode 100644 index 000000000..ace1ab29f --- /dev/null +++ b/docs/cmdline-opts/ftp-ssl-control.md @@ -0,0 +1,20 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: ftp-ssl-control +Help: Require SSL/TLS for FTP login, clear for transfer +Protocols: FTP +Added: 7.16.0 +Category: ftp tls +Multi: boolean +See-also: + - ssl +Example: + - --ftp-ssl-control ftp://example.com +--- + +# `--ftp-ssl-control` + +Require SSL/TLS for the FTP login, clear for transfer. Allows secure +authentication, but non-encrypted data transfers for efficiency. Fails the +transfer if the server does not support SSL/TLS. diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl index edf90622b..f4dcce8ae 100755 --- a/docs/cmdline-opts/gen.pl +++ b/docs/cmdline-opts/gen.pl @@ -90,52 +90,8 @@ sub printdesc { my @desc = @_; my $exam = 0; for my $d (@desc) { - if($d =~ /\(Added in ([0-9.]+)\)/i) { - my $ver = $1; - if(too_old($ver)) { - $d =~ s/ *\(Added in $ver\)//gi; - } - } - if($d !~ /^.\\"/) { - # **bold** - $d =~ s/\*\*([^ ]*)\*\*/\\fB$1\\fP/g; - # *italics* - $d =~ s/\*([^ ]*)\*/\\fI$1\\fP/g; - } - if(!$exam && ($d =~ /^ /)) { - # start of example - $exam = 1; - print ".nf\n"; # no-fill - } - elsif($exam && ($d !~ /^ /)) { - # end of example - $exam = 0; - print ".fi\n"; # fill-in - } - # skip lines starting with space (examples) - if($d =~ /^[^ ]/ && $d =~ /--/) { - # scan for options in longest-names first order - for my $k (sort {length($b) <=> length($a)} keys %optlong) { - # --tlsv1 is complicated since --tlsv1.2 etc are also - # acceptable options! - if(($k eq "tlsv1") && ($d =~ /--tlsv1\.[0-9]\\f/)) { - next; - } - my $l = manpageify($k); - $d =~ s/\-\-$k([^a-z0-9-])/$l$1/g; - } - } - # quote minuses in the output - $d =~ s/([^\\])-/$1\\-/g; - # replace single quotes - $d =~ s/\'/\\(aq/g; - # handle double quotes first on the line - $d =~ s/^(\s*)\"/$1\\(dq/; print $d; } - if($exam) { - print ".fi\n"; # fill-in - } } sub seealso { @@ -200,9 +156,173 @@ sub added { } } +sub render { + my ($fh, $f, $line) = @_; + my @desc; + my $tablemode = 0; + my $header = 0; + # if $top is TRUE, it means a top-level page and not a command line option + my $top = ($line == 1); + my $quote; + $start = 0; + + while(<$fh>) { + my $d = $_; + $line++; + if($d =~ /^\.(SH|BR|IP|B)/) { + print STDERR "$f:$line:1:ERROR: nroff instruction in input: \".$1\"\n"; + return 4; + } + if(/^ * +# NAME + +libcurl-security - security considerations when using libcurl + +# Security + +The libcurl project takes security seriously. The library is written with +caution and precautions are taken to mitigate many kinds of risks encountered +while operating with potentially malicious servers on the Internet. It is a +powerful library, however, which allows application writers to make trade-offs +between ease of writing and exposure to potential risky operations. If used +the right way, you can use libcurl to transfer data pretty safely. + +Many applications are used in closed networks where users and servers can +(possibly) be trusted, but many others are used on arbitrary servers and are +fed input from potentially untrusted users. Following is a discussion about +some risks in the ways in which applications commonly use libcurl and +potential mitigations of those risks. It is not comprehensive, but shows +classes of attacks that robust applications should consider. The Common +Weakness Enumeration project at https://cwe.mitre.org/ is a good reference for +many of these and similar types of weaknesses of which application writers +should be aware. + +# Command Lines + +If you use a command line tool (such as curl) that uses libcurl, and you give +options to the tool on the command line those options can get read by other +users of your system when they use *ps* or other tools to list currently +running processes. + +To avoid these problems, never feed sensitive things to programs using command +line options. Write them to a protected file and use the -K option to avoid +this. + +# .netrc + +.netrc is a pretty handy file/feature that allows you to login quickly and +automatically to frequently visited sites. The file contains passwords in +clear text and is a real security risk. In some cases, your .netrc is also +stored in a home directory that is NFS mounted or used on another network +based file system, so the clear text password flies through your network every +time anyone reads that file. + +For applications that enable .netrc use, a user who manage to set the right +URL might then be possible to pass on passwords. + +To avoid these problems, do not use .netrc files and never store passwords in +plain text anywhere. + +# Clear Text Passwords + +Many of the protocols libcurl supports send name and password unencrypted as +clear text (HTTP Basic authentication, FTP, TELNET etc). It is easy for anyone +on your network or a network nearby yours to just fire up a network analyzer +tool and eavesdrop on your passwords. Do not let the fact that HTTP Basic uses +base64 encoded passwords fool you. They may not look readable at a first +glance, but they are easily "deciphered" by anyone within seconds. + +To avoid this problem, use an authentication mechanism or other protocol that +does not let snoopers see your password: Digest, CRAM-MD5, Kerberos, SPNEGO or +NTLM authentication. Or even better: use authenticated protocols that protect +the entire connection and everything sent over it. + +# Unauthenticated Connections + +Protocols that do not have any form of cryptographic authentication cannot +with any certainty know that they communicate with the right remote server. + +If your application is using a fixed scheme or fixed hostname, it is not safe +as long as the connection is unauthenticated. There can be a man-in-the-middle +or in fact the whole server might have been replaced by an evil actor. + +Unauthenticated protocols are unsafe. The data that comes back to curl may +have been injected by an attacker. The data that curl sends might be modified +before it reaches the intended server. If it even reaches the intended server +at all. + +Remedies: + +## Restrict operations to authenticated transfers + +Use authenticated protocols protected with HTTPS or SSH. + +## Make sure the server's certificate etc is verified + +Never ever switch off certificate verification. + +# Redirects + +The CURLOPT_FOLLOWLOCATION(3) option automatically follows HTTP +redirects sent by a remote server. These redirects can refer to any kind of +URL, not just HTTP. libcurl restricts the protocols allowed to be used in +redirects for security reasons: only HTTP, HTTPS, FTP and FTPS are +enabled by default. Applications may opt to restrict that set further. + +A redirect to a file: URL would cause the libcurl to read (or write) arbitrary +files from the local filesystem. If the application returns the data back to +the user (as would happen in some kinds of CGI scripts), an attacker could +leverage this to read otherwise forbidden data (e.g. +**file://localhost/etc/passwd**). + +If authentication credentials are stored in the ~/.netrc file, or Kerberos is +in use, any other URL type (not just file:) that requires authentication is +also at risk. A redirect such as **ftp://some-internal-server/private-file** would +then return data even when the server is password protected. + +In the same way, if an unencrypted SSH private key has been configured for the +user running the libcurl application, SCP: or SFTP: URLs could access password +or private-key protected resources, +e.g. **sftp://user@some-internal-server/etc/passwd** + +The CURLOPT_REDIR_PROTOCOLS(3) and CURLOPT_NETRC(3) options can be +used to mitigate against this kind of attack. + +A redirect can also specify a location available only on the machine running +libcurl, including servers hidden behind a firewall from the attacker. +E.g. **http://127.0.0.1/** or **http://intranet/delete-stuff.cgi?delete=all** or +**tftp://bootp-server/pc-config-data** + +Applications can mitigate against this by disabling +CURLOPT_FOLLOWLOCATION(3) and handling redirects itself, sanitizing URLs +as necessary. Alternately, an app could leave CURLOPT_FOLLOWLOCATION(3) +enabled but set CURLOPT_REDIR_PROTOCOLS(3) and install a +CURLOPT_OPENSOCKETFUNCTION(3) or CURLOPT_PREREQFUNCTION(3) callback +function in which addresses are sanitized before use. + +# CRLF in Headers + +For all options in libcurl which specify headers, including but not limited to +CURLOPT_HTTPHEADER(3), CURLOPT_PROXYHEADER(3), +CURLOPT_COOKIE(3), CURLOPT_USERAGENT(3), CURLOPT_REFERER(3) +and CURLOPT_RANGE(3), libcurl sends the headers as-is and does not apply +any special sanitation or normalization to them. + +If you allow untrusted user input into these options without sanitizing CRLF +sequences in them, someone malicious may be able to modify the request in a +way you did not intend such as injecting new headers. + +# Local Resources + +A user who can control the DNS server of a domain being passed in within a URL +can change the address of the host to a local, private address which a +server-side libcurl-using application could then use. E.g. the innocuous URL +**http://fuzzybunnies.example.com/** could actually resolve to the IP +address of a server behind a firewall, such as 127.0.0.1 or +10.1.2.3. Applications can mitigate against this by setting a +CURLOPT_OPENSOCKETFUNCTION(3) or CURLOPT_PREREQFUNCTION(3) and +checking the address before a connection. + +All the malicious scenarios regarding redirected URLs apply just as well to +non-redirected URLs, if the user is allowed to specify an arbitrary URL that +could point to a private resource. For example, a web app providing a +translation service might happily translate **file://localhost/etc/passwd** +and display the result. Applications can mitigate against this with the +CURLOPT_PROTOCOLS(3) option as well as by similar mitigation techniques +for redirections. + +A malicious FTP server could in response to the PASV command return an IP +address and port number for a server local to the app running libcurl but +behind a firewall. Applications can mitigate against this by using the +CURLOPT_FTP_SKIP_PASV_IP(3) option or CURLOPT_FTPPORT(3). + +Local servers sometimes assume local access comes from friends and trusted +users. An application that expects https://example.com/file_to_read that and +instead gets http://192.168.0.1/my_router_config might print a file that would +otherwise be protected by the firewall. + +Allowing your application to connect to local hosts, be it the same machine +that runs the application or a machine on the same local network, might be +possible to exploit by an attacker who then perhaps can "port-scan" the +particular hosts - depending on how the application and servers acts. + +# IPv4 Addresses + +Some users might be tempted to filter access to local resources or similar +based on numerical IPv4 addresses used in URLs. This is a bad and error-prone +idea because of the many different ways a numerical IPv4 address can be +specified and libcurl accepts: one to four dot-separated fields using one of +or a mix of decimal, octal or hexadecimal encoding. + +# IPv6 Addresses + +libcurl handles IPv6 addresses transparently and just as easily as IPv4 +addresses. That means that a sanitizing function that filters out addresses +like 127.0.0.1 is not sufficient - the equivalent IPv6 addresses **::1**, +**::**, **0:00::0:1**, **::127.0.0.1** and **::ffff:7f00:1** supplied +somehow by an attacker would all bypass a naive filter and could allow access +to undesired local resources. IPv6 also has special address blocks like +link-local and site-local that generally should not be accessed by a +server-side libcurl-using application. A poorly configured firewall installed +in a data center, organization or server may also be configured to limit IPv4 +connections but leave IPv6 connections wide open. In some cases, setting +CURLOPT_IPRESOLVE(3) to CURL_IPRESOLVE_V4 can be used to limit resolved +addresses to IPv4 only and bypass these issues. + +# Uploads + +When uploading, a redirect can cause a local (or remote) file to be +overwritten. Applications must not allow any unsanitized URL to be passed in +for uploads. Also, CURLOPT_FOLLOWLOCATION(3) should not be used on +uploads. Instead, the applications should consider handling redirects itself, +sanitizing each URL first. + +# Authentication + +Use of CURLOPT_UNRESTRICTED_AUTH(3) could cause authentication +information to be sent to an unknown second server. Applications can mitigate +against this by disabling CURLOPT_FOLLOWLOCATION(3) and handling +redirects itself, sanitizing where necessary. + +Use of the CURLAUTH_ANY option to CURLOPT_HTTPAUTH(3) could result in +user name and password being sent in clear text to an HTTP server. Instead, +use CURLAUTH_ANYSAFE which ensures that the password is encrypted over the +network, or else fail the request. + +Use of the CURLUSESSL_TRY option to CURLOPT_USE_SSL(3) could result in +user name and password being sent in clear text to an FTP server. Instead, +use CURLUSESSL_CONTROL to ensure that an encrypted connection is used or else +fail the request. + +# Cookies + +If cookies are enabled and cached, then a user could craft a URL which +performs some malicious action to a site whose authentication is already +stored in a cookie. E.g. +**http://mail.example.com/delete-stuff.cgi?delete=all** Applications can +mitigate against this by disabling cookies or clearing them between requests. + +# Dangerous SCP URLs + +SCP URLs can contain raw commands within the scp: URL, which is a side effect +of how the SCP protocol is designed. E.g. +~~~ + scp://user:pass@host/a;date >/tmp/test; +~~~ +Applications must not allow unsanitized SCP: URLs to be passed in for +downloads. + +# file:// + +By default curl and libcurl support file:// URLs. Such a URL is always an +access, or attempted access, to a local resource. If your application wants to +avoid that, keep control of what URLs to use and/or prevent curl/libcurl from +using the protocol. + +By default, libcurl prohibits redirects to file:// URLs. + +# Warning: file:// on Windows + +The Windows operating system tries automatically, and without any way for +applications to disable it, to establish a connection to another host over the +network and access it (over SMB or other protocols), if only the correct file +path is accessed. + +When first realizing this, the curl team tried to filter out such attempts in +order to protect applications for inadvertent probes of for example internal +networks etc. This resulted in CVE-2019-15601 and the associated security fix. + +However, we have since been made aware of the fact that the previous fix was far +from adequate as there are several other ways to accomplish more or less the +same thing: accessing a remote host over the network instead of the local file +system. + +The conclusion we have come to is that this is a weakness or feature in the +Windows operating system itself, that we as an application cannot safely +protect users against. It would just be a whack-a-mole race we do not want to +participate in. There are too many ways to do it and there is no knob we can +use to turn off the practice. + +If you use curl or libcurl on Windows (any version), disable the use of the +FILE protocol in curl or be prepared that accesses to a range of "magic paths" +potentially make your system access other hosts on your network. curl cannot +protect you against this. + +# What if the user can set the URL + +Applications may find it tempting to let users set the URL that it can work +on. That is probably fine, but opens up for mischief and trickery that you as +an application author may want to address or take precautions against. + +If your curl-using script allow a custom URL do you also, perhaps +unintentionally, allow the user to pass other options to the curl command line +if creative use of special characters are applied? + +If the user can set the URL, the user can also specify the scheme part to +other protocols that you did not intend for users to use and perhaps did not +consider. curl supports over 20 different URL schemes. "http://" might be what +you thought, "ftp://" or "imap://" might be what the user gives your +application. Also, cross-protocol operations might be done by using a +particular scheme in the URL but point to a server doing a different protocol +on a non-standard port. + +Remedies: + +## Use --proto + +curl command lines can use *--proto* to limit what URL schemes it accepts + +## Use CURLOPT_PROTOCOLS + +libcurl programs can use CURLOPT_PROTOCOLS(3) to limit what URL schemes it accepts + +## consider not allowing the user to set the full URL + +Maybe just let the user provide data for parts of it? Or maybe filter input to +only allow specific choices? + +# RFC 3986 vs WHATWG URL + +curl supports URLs mostly according to how they are defined in RFC 3986, and +has done so since the beginning. + +Web browsers mostly adhere to the WHATWG URL Specification. + +This deviance makes some URLs copied between browsers (or returned over HTTP +for redirection) and curl not work the same way. It can also cause problems if +an application parses URLs differently from libcurl and makes different +assumptions about a link. This can mislead users into getting the wrong thing, +connecting to the wrong host or otherwise not working identically. + +Within an application, this can be mitigated by always using the +curl_url(3) API to parse URLs, ensuring that they are parsed the same way +as within libcurl itself. + +# FTP uses two connections + +When performing an FTP transfer, two TCP connections are used: one for setting +up the transfer and one for the actual data. + +FTP is not only unauthenticated, but the setting up of the second transfer is +also a weak spot. The second connection to use for data, is either setup with +the PORT/EPRT command that makes the server connect back to the client on the +given IP+PORT, or with PASV/EPSV that makes the server setup a port to listen +to and tells the client to connect to a given IP+PORT. + +Again, unauthenticated means that the connection might be meddled with by a +man-in-the-middle or that there is a malicious server pretending to be the +right one. + +A malicious FTP server can respond to PASV commands with the IP+PORT of a +totally different machine. Perhaps even a third party host, and when there are +many clients trying to connect to that third party, it could create a +Distributed Denial-Of-Service attack out of it. If the client makes an upload +operation, it can make the client send the data to another site. If the +attacker can affect what data the client uploads, it can be made to work as a +HTTP request and then the client could be made to issue HTTP requests to third +party hosts. + +An attacker that manages to control curl's command line options can tell curl +to send an FTP PORT command to ask the server to connect to a third party host +instead of back to curl. + +The fact that FTP uses two connections makes it vulnerable in a way that is +hard to avoid. + +# Denial of Service + +A malicious server could cause libcurl to effectively hang by sending data +slowly, or even no data at all but just keeping the TCP connection open. This +could effectively result in a denial-of-service attack. The +CURLOPT_TIMEOUT(3) and/or CURLOPT_LOW_SPEED_LIMIT(3) options can +be used to mitigate against this. + +A malicious server could cause libcurl to download an infinite amount of data, +potentially causing all of memory or disk to be filled. Setting the +CURLOPT_MAXFILESIZE_LARGE(3) option is not sufficient to guard against +this. Instead, applications should monitor the amount of data received within +the write or progress callback and abort once the limit is reached. + +A malicious HTTP server could cause an infinite redirection loop, causing a +denial-of-service. This can be mitigated by using the +CURLOPT_MAXREDIRS(3) option. + +# Arbitrary Headers + +User-supplied data must be sanitized when used in options like +CURLOPT_USERAGENT(3), CURLOPT_HTTPHEADER(3), +CURLOPT_POSTFIELDS(3) and others that are used to generate structured +data. Characters like embedded carriage returns or ampersands could allow the +user to create additional headers or fields that could cause malicious +transactions. + +# Server-supplied Names + +A server can supply data which the application may, in some cases, use as a +filename. The curl command-line tool does this with *--remote-header-name*, +using the Content-disposition: header to generate a filename. An application +could also use CURLINFO_EFFECTIVE_URL(3) to generate a filename from a +server-supplied redirect URL. Special care must be taken to sanitize such +names to avoid the possibility of a malicious server supplying one like +**"/etc/passwd"**, **"autoexec.bat"**, **"prn:"** or even **".bashrc"**. + +# Server Certificates + +A secure application should never use the CURLOPT_SSL_VERIFYPEER(3) +option to disable certificate validation. There are numerous attacks that are +enabled by applications that fail to properly validate server TLS/SSL +certificates, thus enabling a malicious server to spoof a legitimate +one. HTTPS without validated certificates is potentially as insecure as a +plain HTTP connection. + +# Showing What You Do + +Relatedly, be aware that in situations when you have problems with libcurl and +ask someone for help, everything you reveal in order to get best possible help +might also impose certain security related risks. Host names, user names, +paths, operating system specifics, etc. (not to mention passwords of course) +may in fact be used by intruders to gain additional information of a potential +target. + +Be sure to limit access to application logs if they could hold private or +security-related data. Besides the obvious candidates like user names and +passwords, things like URLs, cookies or even file names could also hold +sensitive data. + +To avoid this problem, you must of course use your common sense. Often, you +can just edit out the sensitive data or just search/replace your true +information with faked data. + +# setuid applications using libcurl + +libcurl-using applications that set the 'setuid' bit to run with elevated or +modified rights also implicitly give that extra power to libcurl and this +should only be done after careful considerations. + +Giving setuid powers to the application means that libcurl can save files using +those new rights (if for example the `SSLKEYLOGFILE` environment variable is +set). Also: if the application wants these powers to read or manage secrets +that the user is otherwise not able to view (like credentials for a login +etc), it should be noted that libcurl still might understand proxy environment +variables that allow the user to redirect libcurl operations to use a proxy +controlled by the user. + +# File descriptors, fork and NTLM + +An application that uses libcurl and invokes *fork()* gets all file +descriptors duplicated in the child process, including the ones libcurl +created. + +libcurl itself uses *fork()* and *execl()* if told to use the +**CURLAUTH_NTLM_WB** authentication method which then invokes the helper +command in a child process with file descriptors duplicated. Make sure that +only the trusted and reliable helper program is invoked! + +# Secrets in memory + +When applications pass user names, passwords or other sensitive data to +libcurl to be used for upcoming transfers, those secrets are kept around as-is +in memory. In many cases they are stored in the heap for as long as the handle +itself for which the options are set. + +If an attacker can access the heap, like maybe by reading swap space or via a +core dump file, such data might be accessible. + +Further, when eventually closing a handle and the secrets are no longer +needed, libcurl does not explicitly clear memory before freeing it, so +credentials may be left in freed data. + +# Saving files + +libcurl cannot protect against attacks where an attacker has write access to +the same directory where libcurl is directed to save files. + +# Cookies + +If libcurl is built with PSL (**Public Suffix List**) support, it detects and +discards cookies that are specified for such suffix domains that should not be +allowed to have cookies. + +if libcurl is *not* built with PSL support, it has no ability to stop super +cookies. + +# Report Security Problems + +Should you detect or just suspect a security problem in libcurl or curl, +contact the project curl security team immediately. See +https://curl.se/dev/secprocess.html for details. diff --git a/docs/libcurl/libcurl-share.3 b/docs/libcurl/libcurl-share.3 deleted file mode 100644 index 7e7ee2ae6..000000000 --- a/docs/libcurl/libcurl-share.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH libcurl-share 3 "8 Aug 2003" "libcurl" "libcurl" -.SH NAME -libcurl-share \- how to use the share interface -.SH DESCRIPTION -This is an overview on how to use the libcurl share interface in your C -programs. There are specific man pages for each function mentioned in -here. - -All functions in the share interface are prefixed with curl_share. - -.SH "OBJECTIVES" -The share interface was added to enable sharing of data between curl -\&"handles". -.SH "ONE SET OF DATA - MANY TRANSFERS" -You can have multiple easy handles share data between them. Have them update -and use the \fBsame\fP cookie database, DNS cache, TLS session cache and/or -connection cache! This way, each single transfer takes advantage from data -updates made by the other transfer(s). -.SH "SHARE OBJECT" -You create a shared object with \fIcurl_share_init(3)\fP. It returns a handle -for a newly created one. - -You tell the shared object what data you want it to share by using -\fIcurl_share_setopt(3)\fP. - -Since you can use this share from multiple threads, and libcurl has no -internal thread synchronization, you must provide mutex callbacks if you are -using this multi-threaded. You set lock and unlock functions with -\fIcurl_share_setopt(3)\fP too. - -Then, you make an easy handle to use this share, you set the -\fICURLOPT_SHARE(3)\fP option with \fIcurl_easy_setopt(3)\fP, and pass in -share handle. You can make any number of easy handles share the same share -handle. - -To make an easy handle stop using that particular share, you set -\fICURLOPT_SHARE(3)\fP to NULL for that easy handle. To make a handle stop -sharing a particular data, you can \fICURLSHOPT_UNSHARE(3)\fP it. - -When you are done using the share, make sure that no easy handle is still using -it, and call \fIcurl_share_cleanup(3)\fP on the handle. -.SH "SEE ALSO" -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR curl_share_cleanup (3), -.BR libcurl-errors (3), -.BR libcurl-easy (3), -.BR libcurl-multi (3) diff --git a/docs/libcurl/libcurl-share.md b/docs/libcurl/libcurl-share.md new file mode 100644 index 000000000..e244b9726 --- /dev/null +++ b/docs/libcurl/libcurl-share.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl-share +Section: 3 +Source: libcurl +See-also: + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) + - libcurl-easy (3) + - libcurl-errors (3) + - libcurl-multi (3) +--- + +# NAME + +libcurl-share - how to use the share interface + +# DESCRIPTION + +This is an overview on how to use the libcurl share interface in your C +programs. There are specific man pages for each function mentioned in +here. + +All functions in the share interface are prefixed with curl_share. + +# OBJECTIVES + +The share interface was added to enable sharing of data between curl handles. + +# ONE SET OF DATA - MANY TRANSFERS + +You can have multiple easy handles share data between them. Have them update +and use the **same** cookie database, DNS cache, TLS session cache and/or +connection cache! This way, each single transfer takes advantage from data +updates made by the other transfer(s). + +# SHARE OBJECT + +You create a shared object with curl_share_init(3). It returns a handle +for a newly created one. + +You tell the shared object what data you want it to share by using +curl_share_setopt(3). + +Since you can use this share from multiple threads, and libcurl has no +internal thread synchronization, you must provide mutex callbacks if you are +using this multi-threaded. You set lock and unlock functions with +curl_share_setopt(3) too. + +Then, you make an easy handle to use this share, you set the +CURLOPT_SHARE(3) option with curl_easy_setopt(3), and pass in +share handle. You can make any number of easy handles share the same share +handle. + +To make an easy handle stop using that particular share, you set +CURLOPT_SHARE(3) to NULL for that easy handle. To make a handle stop +sharing a particular data, you can CURLSHOPT_UNSHARE(3) it. + +When you are done using the share, make sure that no easy handle is still using +it, and call curl_share_cleanup(3) on the handle. diff --git a/docs/libcurl/libcurl-thread.3 b/docs/libcurl/libcurl-thread.3 deleted file mode 100644 index 397eeae66..000000000 --- a/docs/libcurl/libcurl-thread.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH libcurl-thread 3 "13 Jul 2015" "libcurl" "libcurl" -.SH NAME -libcurl-thread \- libcurl thread safety -.SH "Multi-threading with libcurl" -libcurl is thread safe but has no internal thread synchronization. You may have -to provide your own locking should you meet any of the thread safety exceptions -below. - -.SH "Handles" -You must \fBnever\fP share the same handle in multiple threads. You can pass -the handles around among threads, but you must never use a single handle from -more than one thread at any given time. -.SH "Shared objects" -You can share certain data between multiple handles by using the share -interface but you must provide your own locking and set -\fIcurl_share_setopt(3)\fP CURLSHOPT_LOCKFUNC and CURLSHOPT_UNLOCKFUNC. - -Note that some items are specifically documented as not thread-safe in the -share API (the connection pool and HSTS cache for example). -.SH TLS -All current TLS libraries libcurl supports are thread-safe. OpenSSL 1.1.0+ can -be safely used in multi-threaded applications provided that support for the -underlying OS threading API is built-in. For older versions of OpenSSL, the -user must set mutex callbacks. -.SH "Signals" -Signals are used for timing out name resolves (during DNS lookup) - when built -without using either the c-ares or threaded resolver backends. On systems that -have a signal concept. - -When using multiple threads you should set the \fICURLOPT_NOSIGNAL(3)\fP -option to 1L for all handles. Everything works fine except that timeouts -cannot be honored during DNS lookups - which you can work around by building -libcurl with c-ares or threaded-resolver support. c-ares is a library that -provides asynchronous name resolves. On some platforms, libcurl simply cannot -function properly multi-threaded unless the \fICURLOPT_NOSIGNAL(3)\fP option -is set. - -When \fICURLOPT_NOSIGNAL(3)\fP is set to 1L, your application needs to deal -with the risk of a SIGPIPE (that at least the OpenSSL backend can -trigger). Note that setting \fICURLOPT_NOSIGNAL(3)\fP to 0L does not work in a -threaded situation as there is a race condition where libcurl risks restoring -the former signal handler while another thread should still ignore it. -.SH "Name resolving" -The \fBgethostbyname\fP or \fBgetaddrinfo\fP and other name resolving system -calls used by libcurl are provided by your operating system and must be thread -safe. It is important that libcurl can find and use thread safe versions of -these and other system calls, as otherwise it cannot function fully thread -safe. Some operating systems are known to have faulty thread -implementations. We have previously received problem reports on *BSD (at least -in the past, they may be working fine these days). Some operating systems that -are known to have solid and working thread support are Linux, Solaris and -Windows. -.SH "curl_global_* functions" -These functions are thread-safe since libcurl 7.84.0 if -\fIcurl_version_info(3)\fP has the \fBCURL_VERSION_THREADSAFE\fP feature bit -set (most platforms). - -If these functions are not thread-safe and you are using libcurl with multiple -threads it is especially important that before use you call -\fIcurl_global_init(3)\fP or \fIcurl_global_init_mem(3)\fP to explicitly -initialize the library and its dependents, rather than rely on the "lazy" -fail-safe initialization that takes place the first time -\fIcurl_easy_init(3)\fP is called. For an in-depth explanation refer to -\fIlibcurl(3)\fP section \fBGLOBAL CONSTANTS\fP. -.SH "Memory functions" -These functions, provided either by your operating system or your own -replacements, must be thread safe. You can use \fIcurl_global_init_mem(3)\fP -to set your own replacement memory functions. -.SH "Non-safe functions" -\fICURLOPT_DNS_USE_GLOBAL_CACHE(3)\fP is not thread-safe. - -\fIcurl_version_info(3)\fP is not thread-safe before libcurl initialization. diff --git a/docs/libcurl/libcurl-thread.md b/docs/libcurl/libcurl-thread.md new file mode 100644 index 000000000..b3e9ecf82 --- /dev/null +++ b/docs/libcurl/libcurl-thread.md @@ -0,0 +1,99 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl-thread +Section: 3 +Source: libcurl +See-also: + - libcurl-security (3) +--- + +# NAME + +libcurl-thread - libcurl thread safety + +# Multi-threading with libcurl + +libcurl is thread safe but has no internal thread synchronization. You may have +to provide your own locking should you meet any of the thread safety exceptions +below. + +# Handles + +You must **never** share the same handle in multiple threads. You can pass the +handles around among threads, but you must never use a single handle from more +than one thread at any given time. + +# Shared objects + +You can share certain data between multiple handles by using the share +interface but you must provide your own locking and set +curl_share_setopt(3) CURLSHOPT_LOCKFUNC and CURLSHOPT_UNLOCKFUNC. + +Note that some items are specifically documented as not thread-safe in the +share API (the connection pool and HSTS cache for example). + +# TLS + +All current TLS libraries libcurl supports are thread-safe. OpenSSL 1.1.0+ can +be safely used in multi-threaded applications provided that support for the +underlying OS threading API is built-in. For older versions of OpenSSL, the +user must set mutex callbacks. + +# Signals + +Signals are used for timing out name resolves (during DNS lookup) - when built +without using either the c-ares or threaded resolver backends. On systems that +have a signal concept. + +When using multiple threads you should set the CURLOPT_NOSIGNAL(3) +option to 1L for all handles. Everything works fine except that timeouts +cannot be honored during DNS lookups - which you can work around by building +libcurl with c-ares or threaded-resolver support. c-ares is a library that +provides asynchronous name resolves. On some platforms, libcurl simply cannot +function properly multi-threaded unless the CURLOPT_NOSIGNAL(3) option +is set. + +When CURLOPT_NOSIGNAL(3) is set to 1L, your application needs to deal +with the risk of a SIGPIPE (that at least the OpenSSL backend can +trigger). Note that setting CURLOPT_NOSIGNAL(3) to 0L does not work in a +threaded situation as there is a race condition where libcurl risks restoring +the former signal handler while another thread should still ignore it. + +# Name resolving + +The **gethostbyname** or **getaddrinfo** and other name resolving system +calls used by libcurl are provided by your operating system and must be thread +safe. It is important that libcurl can find and use thread safe versions of +these and other system calls, as otherwise it cannot function fully thread +safe. Some operating systems are known to have faulty thread +implementations. We have previously received problem reports on *BSD (at least +in the past, they may be working fine these days). Some operating systems that +are known to have solid and working thread support are Linux, Solaris and +Windows. + +# curl_global_* functions + +These functions are thread-safe since libcurl 7.84.0 if +curl_version_info(3) has the **CURL_VERSION_THREADSAFE** feature bit +set (most platforms). + +If these functions are not thread-safe and you are using libcurl with multiple +threads it is especially important that before use you call +curl_global_init(3) or curl_global_init_mem(3) to explicitly +initialize the library and its dependents, rather than rely on the "lazy" +fail-safe initialization that takes place the first time +curl_easy_init(3) is called. For an in-depth explanation refer to +libcurl(3) section **GLOBAL CONSTANTS**. + +# Memory functions + +These functions, provided either by your operating system or your own +replacements, must be thread safe. You can use curl_global_init_mem(3) +to set your own replacement memory functions. + +# Non-safe functions + +CURLOPT_DNS_USE_GLOBAL_CACHE(3) is not thread-safe. + +curl_version_info(3) is not thread-safe before libcurl initialization. diff --git a/docs/libcurl/libcurl-tutorial.3 b/docs/libcurl/libcurl-tutorial.3 deleted file mode 100644 index d312bd5de..000000000 --- a/docs/libcurl/libcurl-tutorial.3 +++ /dev/null @@ -1,1398 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH libcurl-tutorial 3 "19 Sep 2014" "libcurl" "libcurl" -.SH NAME -libcurl-tutorial \- libcurl programming tutorial -.SH "Objective" -This document attempts to describe the general principles and some basic -approaches to consider when programming with libcurl. The text focuses on the -C interface but should apply fairly well on other language bindings as well as -they usually follow the C API pretty closely. - -This document refers to 'the user' as the person writing the source code that -uses libcurl. That would probably be you or someone in your position. What is -generally referred to as 'the program' is the collected source code that you -write that is using libcurl for transfers. The program is outside libcurl and -libcurl is outside of the program. - -To get more details on all options and functions described herein, please -refer to their respective man pages. - -.SH "Building" -There are many different ways to build C programs. This chapter assumes a Unix -style build process. If you use a different build system, you can still read -this to get general information that may apply to your environment as well. -.IP "Compiling the Program" -Your compiler needs to know where the libcurl headers are located. Therefore -you must set your compiler's include path to point to the directory where you -installed them. The 'curl-config'[3] tool can be used to get this information: -.nf - $ curl-config --cflags -.fi -.IP "Linking the Program with libcurl" -When having compiled the program, you need to link your object files to create -a single executable. For that to succeed, you need to link with libcurl and -possibly also with other libraries that libcurl itself depends on. Like the -OpenSSL libraries, but even some standard OS libraries may be needed on the -command line. To figure out which flags to use, once again the 'curl-config' -tool comes to the rescue: -.nf - $ curl-config --libs -.fi -.IP "SSL or Not" -libcurl can be built and customized in many ways. One of the things that -varies from different libraries and builds is the support for SSL-based -transfers, like HTTPS and FTPS. If a supported SSL library was detected -properly at build-time, libcurl is built with SSL support. To figure out if an -installed libcurl has been built with SSL support enabled, use \&'curl-config' -like this: -.nf - $ curl-config --feature -.fi -And if SSL is supported, the keyword \fISSL\fP is written to stdout, possibly -together with a other features that could be either on or off on for different -libcurls. - -See also the "Features libcurl Provides" further down. -.IP "autoconf macro" -When you write your configure script to detect libcurl and setup variables -accordingly, we offer a macro that probably does everything you need in this -area. See docs/libcurl/libcurl.m4 file - it includes docs on how to use it. - -.SH "Portable Code in a Portable World" -The people behind libcurl have put a considerable effort to make libcurl work -on a large amount of different operating systems and environments. - -You program libcurl the same way on all platforms that libcurl runs on. There -are only a few minor details that differ. If you just make sure to write your -code portable enough, you can create a portable program. libcurl should not -stop you from that. - -.SH "Global Preparation" -The program must initialize some of the libcurl functionality globally. That -means it should be done exactly once, no matter how many times you intend to -use the library. Once for your program's entire life time. This is done using -.nf - curl_global_init() -.fi -and it takes one parameter which is a bit pattern that tells libcurl what to -initialize. Using \fICURL_GLOBAL_ALL\fP makes it initialize all known internal -sub modules, and might be a good default option. The current two bits that are -specified are: -.RS -.IP "CURL_GLOBAL_WIN32" -which only does anything on Windows machines. When used on a Windows machine, -it makes libcurl initialize the win32 socket stuff. Without having that -initialized properly, your program cannot use sockets properly. You should -only do this once for each application, so if your program already does this -or of another library in use does it, you should not tell libcurl to do this -as well. -.IP CURL_GLOBAL_SSL -which only does anything on libcurls compiled and built SSL-enabled. On these -systems, this makes libcurl initialize the SSL library properly for this -application. This only needs to be done once for each application so if your -program or another library already does this, this bit should not be needed. -.RE - -libcurl has a default protection mechanism that detects if -\fIcurl_global_init(3)\fP has not been called by the time -\fIcurl_easy_perform(3)\fP is called and if that is the case, libcurl runs the -function itself with a guessed bit pattern. Please note that depending solely -on this is not considered nice nor good. - -When the program no longer uses libcurl, it should call -\fIcurl_global_cleanup(3)\fP, which is the opposite of the init call. It -performs the reversed operations to cleanup the resources the -\fIcurl_global_init(3)\fP call initialized. - -Repeated calls to \fIcurl_global_init(3)\fP and \fIcurl_global_cleanup(3)\fP -should be avoided. They should only be called once each. - -.SH "Features libcurl Provides" -It is considered best-practice to determine libcurl features at runtime rather -than at build-time (if possible of course). By calling -\fIcurl_version_info(3)\fP and checking out the details of the returned -struct, your program can figure out exactly what the currently running libcurl -supports. - -.SH "Two Interfaces" -libcurl first introduced the so called easy interface. All operations in the -easy interface are prefixed with 'curl_easy'. The easy interface lets you do -single transfers with a synchronous and blocking function call. - -libcurl also offers another interface that allows multiple simultaneous -transfers in a single thread, the so called multi interface. More about that -interface is detailed in a separate chapter further down. You still need to -understand the easy interface first, so please continue reading for better -understanding. -.SH "Handle the Easy libcurl" -To use the easy interface, you must first create yourself an easy handle. You -need one handle for each easy session you want to perform. Basically, you -should use one handle for every thread you plan to use for transferring. You -must never share the same handle in multiple threads. - -Get an easy handle with -.nf - handle = curl_easy_init(); -.fi -It returns an easy handle. Using that you proceed to the next step: setting -up your preferred actions. A handle is just a logic entity for the upcoming -transfer or series of transfers. - -You set properties and options for this handle using -\fIcurl_easy_setopt(3)\fP. They control how the subsequent transfer or -transfers using this handle are made. Options remain set in the handle until -set again to something different. They are sticky. Multiple requests using the -same handle use the same options. - -If you at any point would like to blank all previously set options for a -single easy handle, you can call \fIcurl_easy_reset(3)\fP and you can also -make a clone of an easy handle (with all its set options) using -\fIcurl_easy_duphandle(3)\fP. - -Many of the options you set in libcurl are "strings", pointers to data -terminated with a zero byte. When you set strings with -\fIcurl_easy_setopt(3)\fP, libcurl makes its own copy so that they do not need -to be kept around in your application after being set[4]. - -One of the most basic properties to set in the handle is the URL. You set your -preferred URL to transfer with \fICURLOPT_URL(3)\fP in a manner similar to: - -.nf - curl_easy_setopt(handle, CURLOPT_URL, "http://domain.com/"); -.fi - -Let's assume for a while that you want to receive data as the URL identifies a -remote resource you want to get here. Since you write a sort of application -that needs this transfer, I assume that you would like to get the data passed -to you directly instead of simply getting it passed to stdout. So, you write -your own function that matches this prototype: -.nf - size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp); -.fi -You tell libcurl to pass all data to this function by issuing a function -similar to this: -.nf - curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_data); -.fi -You can control what data your callback function gets in the fourth argument -by setting another property: -.nf - curl_easy_setopt(handle, CURLOPT_WRITEDATA, &internal_struct); -.fi -Using that property, you can easily pass local data between your application -and the function that gets invoked by libcurl. libcurl itself does not touch -the data you pass with \fICURLOPT_WRITEDATA(3)\fP. - -libcurl offers its own default internal callback that takes care of the data -if you do not set the callback with \fICURLOPT_WRITEFUNCTION(3)\fP. It simply -outputs the received data to stdout. You can have the default callback write -the data to a different file handle by passing a 'FILE *' to a file opened for -writing with the \fICURLOPT_WRITEDATA(3)\fP option. - -Now, we need to take a step back and take a deep breath. Here is one of those -rare platform-dependent nitpicks. Did you spot it? On some platforms[2], -libcurl is not able to operate on file handles opened by the -program. Therefore, if you use the default callback and pass in an open file -handle with \fICURLOPT_WRITEDATA(3)\fP, libcurl crashes. You should avoid this -to make your program run fine virtually everywhere. - -(\fICURLOPT_WRITEDATA(3)\fP was formerly known as \fICURLOPT_FILE\fP. Both -names still work and do the same thing). - -If you are using libcurl as a win32 DLL, you MUST use the -\fICURLOPT_WRITEFUNCTION(3)\fP if you set \fICURLOPT_WRITEDATA(3)\fP - or -experience crashes. - -There are of course many more options you can set, and we get back to a few of -them later. Let's instead continue to the actual transfer: -.nf - success = curl_easy_perform(handle); -.fi -\fIcurl_easy_perform(3)\fP connects to the remote site, does the necessary -commands and performs the transfer. Whenever it receives data, it calls the -callback function we previously set. The function may get one byte at a time, -or it may get many kilobytes at once. libcurl delivers as much as possible as -often as possible. Your callback function should return the number of bytes it -\&"took care of". If that is not the same amount of bytes that was passed to -it, libcurl aborts the operation and returns with an error code. - -When the transfer is complete, the function returns a return code that informs -you if it succeeded in its mission or not. If a return code is not enough for -you, you can use the \fICURLOPT_ERRORBUFFER(3)\fP to point libcurl to a buffer -of yours where it stores a human readable error message as well. - -If you then want to transfer another file, the handle is ready to be used -again. It is even preferred and encouraged that you reuse an existing handle -if you intend to make another transfer. libcurl then attempts to reuse a -previous connection. - -For some protocols, downloading a file can involve a complicated process of -logging in, setting the transfer mode, changing the current directory and -finally transferring the file data. libcurl takes care of all that -complication for you. Given simply the URL to a file, libcurl takes care of -all the details needed to get the file moved from one machine to another. - -.SH "Multi-threading Issues" -libcurl is thread safe but there are a few exceptions. Refer to -\fIlibcurl-thread(3)\fP for more information. - -.SH "When It does not Work" -There are times when the transfer fails for some reason. You might have set -the wrong libcurl option or misunderstood what the libcurl option actually -does, or the remote server might return non-standard replies that confuse the -library which then confuses your program. - -There is one golden rule when these things occur: set the -\fICURLOPT_VERBOSE(3)\fP option to 1. it causes the library to spew out the -entire protocol details it sends, some internal info and some received -protocol data as well (especially when using FTP). If you are using HTTP, -adding the headers in the received output to study is also a clever way to get -a better understanding why the server behaves the way it does. Include headers -in the normal body output with \fICURLOPT_HEADER(3)\fP set 1. - -Of course, there are bugs left. We need to know about them to be able to fix -them, so we are quite dependent on your bug reports. When you do report -suspected bugs in libcurl, please include as many details as you possibly can: -a protocol dump that \fICURLOPT_VERBOSE(3)\fP produces, library version, as -much as possible of your code that uses libcurl, operating system name and -version, compiler name and version etc. - -If \fICURLOPT_VERBOSE(3)\fP is not enough, you increase the level of debug -data your application receive by using the \fICURLOPT_DEBUGFUNCTION(3)\fP. - -Getting some in-depth knowledge about the protocols involved is never wrong, -and if you are trying to do funny things, you might understand libcurl and how -to use it better if you study the appropriate RFC documents at least briefly. - -.SH "Upload Data to a Remote Site" -libcurl tries to keep a protocol independent approach to most transfers, thus -uploading to a remote FTP site is similar to uploading data to an HTTP server -with a PUT request. - -Of course, first you either create an easy handle or you reuse one existing -one. Then you set the URL to operate on just like before. This is the remote -URL, that we now upload. - -Since we write an application, we most likely want libcurl to get the upload -data by asking us for it. To make it do that, we set the read callback and the -custom pointer libcurl passes to our read callback. The read callback should -have a prototype similar to: -.nf - size_t function(char *bufptr, size_t size, size_t nitems, void *userp); -.fi -Where \fIbufptr\fP is the pointer to a buffer we fill in with data to upload -and \fIsize*nitems\fP is the size of the buffer and therefore also the maximum -amount of data we can return to libcurl in this call. The \fIuserp\fP pointer -is the custom pointer we set to point to a struct of ours to pass private data -between the application and the callback. -.nf - curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_function); - - curl_easy_setopt(handle, CURLOPT_READDATA, &filedata); -.fi -Tell libcurl that we want to upload: -.nf - curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); -.fi -A few protocols do not behave properly when uploads are done without any prior -knowledge of the expected file size. So, set the upload file size using the -\fICURLOPT_INFILESIZE_LARGE(3)\fP for all known file sizes like this[1]: - -.nf - /* in this example, file_size must be an curl_off_t variable */ - curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, file_size); -.fi - -When you call \fIcurl_easy_perform(3)\fP this time, it performs all the -necessary operations and when it has invoked the upload it calls your supplied -callback to get the data to upload. The program should return as much data as -possible in every invoke, as that is likely to make the upload perform as fast -as possible. The callback should return the number of bytes it wrote in the -buffer. Returning 0 signals the end of the upload. - -.SH "Passwords" -Many protocols use or even require that user name and password are provided -to be able to download or upload the data of your choice. libcurl offers -several ways to specify them. - -Most protocols support that you specify the name and password in the URL -itself. libcurl detects this and use them accordingly. This is written like -this: -.nf - protocol://user:password@example.com/path/ -.fi -If you need any odd letters in your user name or password, you should enter -them URL encoded, as %XX where XX is a two-digit hexadecimal number. - -libcurl also provides options to set various passwords. The user name and -password as shown embedded in the URL can instead get set with the -\fICURLOPT_USERPWD(3)\fP option. The argument passed to libcurl should be a -char * to a string in the format "user:password". In a manner like this: -.nf - curl_easy_setopt(handle, CURLOPT_USERPWD, "myname:thesecret"); -.fi -Another case where name and password might be needed at times, is for those -users who need to authenticate themselves to a proxy they use. libcurl offers -another option for this, the \fICURLOPT_PROXYUSERPWD(3)\fP. It is used quite -similar to the \fICURLOPT_USERPWD(3)\fP option like this: -.nf - curl_easy_setopt(handle, CURLOPT_PROXYUSERPWD, "myname:thesecret"); -.fi -There is a long time Unix "standard" way of storing FTP user names and -passwords, namely in the $HOME/.netrc file (on Windows, libcurl also checks -the \fI%USERPROFILE% environment\fP variable if \fI%HOME%\fP is unset, and -tries "_netrc" as name). The file should be made private so that only the user -may read it (see also the "Security Considerations" chapter), as it might -contain the password in plain text. libcurl has the ability to use this file -to figure out what set of user name and password to use for a particular -host. As an extension to the normal functionality, libcurl also supports this -file for non-FTP protocols such as HTTP. To make curl use this file, use the -\fICURLOPT_NETRC(3)\fP option: -.nf - curl_easy_setopt(handle, CURLOPT_NETRC, 1L); -.fi -And a basic example of how such a .netrc file may look like: - -.nf - machine myhost.mydomain.com - login userlogin - password secretword -.fi - -All these examples have been cases where the password has been optional, or -at least you could leave it out and have libcurl attempt to do its job -without it. There are times when the password is not optional, like when -you are using an SSL private key for secure transfers. - -To pass the known private key password to libcurl: -.nf - curl_easy_setopt(handle, CURLOPT_KEYPASSWD, "keypassword"); -.fi -.SH "HTTP Authentication" -The previous chapter showed how to set user name and password for getting URLs -that require authentication. When using the HTTP protocol, there are many -different ways a client can provide those credentials to the server and you -can control which way libcurl uses them. The default HTTP authentication -method is called 'Basic', which is sending the name and password in clear-text -in the HTTP request, base64-encoded. This is insecure. - -At the time of this writing, libcurl can be built to use: Basic, Digest, NTLM, -Negotiate (SPNEGO). You can tell libcurl which one to use -with \fICURLOPT_HTTPAUTH(3)\fP as in: -.nf - curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); -.fi -And when you send authentication to a proxy, you can also set authentication -type the same way but instead with \fICURLOPT_PROXYAUTH(3)\fP: -.nf - curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM); -.fi -Both these options allow you to set multiple types (by ORing them together), -to make libcurl pick the most secure one out of the types the server/proxy -claims to support. This method does however add a round-trip since libcurl -must first ask the server what it supports: -.nf - curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); -.fi -For convenience, you can use the \fICURLAUTH_ANY\fP define (instead of a list -with specific types) which allows libcurl to use whatever method it wants. - -When asking for multiple types, libcurl picks the available one it considers -"best" in its own internal order of preference. - -.SH "HTTP POSTing" -We get many questions regarding how to issue HTTP POSTs with libcurl the -proper way. This chapter thus includes examples using both different versions -of HTTP POST that libcurl supports. - -The first version is the simple POST, the most common version, that most HTML -pages using the
tag uses. We provide a pointer to the data and tell -libcurl to post it all to the remote site: - -.nf - char *data="name=daniel&project=curl"; - curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data); - curl_easy_setopt(handle, CURLOPT_URL, "http://posthere.com/"); - - curl_easy_perform(handle); /* post away! */ -.fi - -Simple enough, huh? Since you set the POST options with the -\fICURLOPT_POSTFIELDS(3)\fP, this automatically switches the handle to use -POST in the upcoming request. - -What if you want to post binary data that also requires you to set the -Content-Type: header of the post? Well, binary posts prevent libcurl from being -able to do strlen() on the data to figure out the size, so therefore we must -tell libcurl the size of the post data. Setting headers in libcurl requests are -done in a generic way, by building a list of our own headers and then passing -that list to libcurl. - -.nf - struct curl_slist *headers=NULL; - headers = curl_slist_append(headers, "Content-Type: text/xml"); - - /* post binary data */ - curl_easy_setopt(handle, CURLOPT_POSTFIELDS, binaryptr); - - /* set the size of the postfields data */ - curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, 23L); - - /* pass our list of custom made headers */ - curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); - - curl_easy_perform(handle); /* post away! */ - - curl_slist_free_all(headers); /* free the header list */ -.fi - -While the simple examples above cover the majority of all cases where HTTP -POST operations are required, they do not do multi-part formposts. Multi-part -formposts were introduced as a better way to post (possibly large) binary data -and were first documented in the RFC 1867 (updated in RFC 2388). they are -called multi-part because they are built by a chain of parts, each part being -a single unit of data. Each part has its own name and contents. You can in -fact create and post a multi-part formpost with the regular libcurl POST -support described above, but that would require that you build a formpost -yourself and provide to libcurl. To make that easier, libcurl provides a MIME -API consisting in several functions: using those, you can create and fill a -multi-part form. Function \fIcurl_mime_init(3)\fP creates a multi-part body; -you can then append new parts to a multi-part body using -\fIcurl_mime_addpart(3)\fP. There are three possible data sources for a part: -memory using \fIcurl_mime_data(3)\fP, file using \fIcurl_mime_filedata(3)\fP -and user-defined data read callback using \fIcurl_mime_data_cb(3)\fP. -\fIcurl_mime_name(3)\fP sets a part's (i.e.: form field) name, while -\fIcurl_mime_filename(3)\fP fills in the remote file name. With -\fIcurl_mime_type(3)\fP, you can tell the MIME type of a part, -\fIcurl_mime_headers(3)\fP allows defining the part's headers. When a -multi-part body is no longer needed, you can destroy it using -\fIcurl_mime_free(3)\fP. - -The following example sets two simple text parts with plain textual contents, -and then a file with binary contents and uploads the whole thing. - -.nf - curl_mime *multipart = curl_mime_init(handle); - curl_mimepart *part = curl_mime_addpart(multipart); - curl_mime_name(part, "name"); - curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); - part = curl_mime_addpart(multipart); - curl_mime_name(part, "project"); - curl_mime_data(part, "curl", CURL_ZERO_TERMINATED); - part = curl_mime_addpart(multipart); - curl_mime_name(part, "logotype-image"); - curl_mime_filedata(part, "curl.png"); - - /* Set the form info */ - curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart); - - curl_easy_perform(handle); /* post away! */ - - /* free the post data again */ - curl_mime_free(multipart); -.fi - -To post multiple files for a single form field, you must supply each file in -a separate part, all with the same field name. Although function -\fIcurl_mime_subparts(3)\fP implements nested multi-parts, this way of -multiple files posting is deprecated by RFC 7578, chapter 4.3. - -To set the data source from an already opened FILE pointer, use: - -.nf - curl_mime_data_cb(part, filesize, (curl_read_callback) fread, - (curl_seek_callback) fseek, NULL, filepointer); -.fi - -A deprecated \fIcurl_formadd(3)\fP function is still supported in libcurl. -It should however not be used anymore for new designs and programs using it -ought to be converted to the MIME API. It is however described here as an -aid to conversion. - -Using \fIcurl_formadd\fP, you add parts to the form. When you are done adding -parts, you post the whole form. - -The MIME API example above is expressed as follows using this function: - -.nf - struct curl_httppost *post=NULL; - struct curl_httppost *last=NULL; - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "name", - CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "project", - CURLFORM_COPYCONTENTS, "curl", CURLFORM_END); - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "logotype-image", - CURLFORM_FILECONTENT, "curl.png", CURLFORM_END); - - /* Set the form info */ - curl_easy_setopt(handle, CURLOPT_HTTPPOST, post); - - curl_easy_perform(handle); /* post away! */ - - /* free the post data again */ - curl_formfree(post); -.fi - -Multipart formposts are chains of parts using MIME-style separators and -headers. It means that each one of these separate parts get a few headers set -that describe the individual content-type, size etc. To enable your -application to handicraft this formpost even more, libcurl allows you to -supply your own set of custom headers to such an individual form part. You can -of course supply headers to as many parts as you like, but this little example -shows how you set headers to one specific part when you add that to the post -handle: - -.nf - struct curl_slist *headers=NULL; - headers = curl_slist_append(headers, "Content-Type: text/xml"); - - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "logotype-image", - CURLFORM_FILECONTENT, "curl.xml", - CURLFORM_CONTENTHEADER, headers, - CURLFORM_END); - - curl_easy_perform(handle); /* post away! */ - - curl_formfree(post); /* free post */ - curl_slist_free_all(headers); /* free custom header list */ -.fi - -Since all options on an easy handle are "sticky", they remain the same until -changed even if you do call \fIcurl_easy_perform(3)\fP, you may need to tell -curl to go back to a plain GET request if you intend to do one as your next -request. You force an easy handle to go back to GET by using the -\fICURLOPT_HTTPGET(3)\fP option: -.nf - curl_easy_setopt(handle, CURLOPT_HTTPGET, 1L); -.fi -Just setting \fICURLOPT_POSTFIELDS(3)\fP to "" or NULL does *not* stop libcurl -from doing a POST. It just makes it POST without any data to send! - -.SH "Converting from deprecated form API to MIME API" -Four rules have to be respected in building the multi-part: -.br -- The easy handle must be created before building the multi-part. -.br -- The multi-part is always created by a call to curl_mime_init(handle). -.br -- Each part is created by a call to curl_mime_addpart(multipart). -.br -- When complete, the multi-part must be bound to the easy handle using -\fICURLOPT_MIMEPOST(3)\fP instead of \fICURLOPT_HTTPPOST(3)\fP. - -Here are some example of \fIcurl_formadd\fP calls to MIME API sequences: - -.nf - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "id", - CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); - CURLFORM_CONTENTHEADER, headers, - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "id"); - curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); - curl_mime_headers(part, headers, FALSE); -.fi - -Setting the last \fIcurl_mime_headers(3)\fP argument to TRUE would have caused -the headers to be automatically released upon destroyed the multi-part, thus -saving a clean-up call to \fIcurl_slist_free_all(3)\fP. - -.nf - curl_formadd(&post, &last, - CURLFORM_PTRNAME, "logotype-image", - CURLFORM_FILECONTENT, "-", - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "logotype-image"); - curl_mime_data_cb(part, (curl_off_t) -1, fread, fseek, NULL, stdin); -.fi - -\fIcurl_mime_name(3)\fP always copies the field name. The special file name -"-" is not supported by \fIcurl_mime_filename(3)\fP: to read an open file, use -a callback source using fread(). The transfer is be chunk-encoded since the -data size is unknown. - -.nf - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "datafile[]", - CURLFORM_FILE, "file1", - CURLFORM_FILE, "file2", - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "datafile[]"); - curl_mime_filedata(part, "file1"); - part = curl_mime_addpart(multipart); - curl_mime_name(part, "datafile[]"); - curl_mime_filedata(part, "file2"); -.fi - -The deprecated multipart/mixed implementation of multiple files field is -translated to two distinct parts with the same name. - -.nf - curl_easy_setopt(handle, CURLOPT_READFUNCTION, myreadfunc); - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "stream", - CURLFORM_STREAM, arg, - CURLFORM_CONTENTLEN, (curl_off_t) datasize, - CURLFORM_FILENAME, "archive.zip", - CURLFORM_CONTENTTYPE, "application/zip", - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "stream"); - curl_mime_data_cb(part, (curl_off_t) datasize, - myreadfunc, NULL, NULL, arg); - curl_mime_filename(part, "archive.zip"); - curl_mime_type(part, "application/zip"); -.fi - -\fICURLOPT_READFUNCTION(3)\fP callback is not used: it is replace by directly -setting the part source data from the callback read function. - -.nf - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "memfile", - CURLFORM_BUFFER, "memfile.bin", - CURLFORM_BUFFERPTR, databuffer, - CURLFORM_BUFFERLENGTH, (long) sizeof databuffer, - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "memfile"); - curl_mime_data(part, databuffer, (curl_off_t) sizeof databuffer); - curl_mime_filename(part, "memfile.bin"); -.fi - -\fIcurl_mime_data(3)\fP always copies the initial data: data buffer is thus -free for immediate reuse. - -.nf - curl_formadd(&post, &last, - CURLFORM_COPYNAME, "message", - CURLFORM_FILECONTENT, "msg.txt", - CURLFORM_END); -.fi -becomes: -.nf - part = curl_mime_addpart(multipart); - curl_mime_name(part, "message"); - curl_mime_filedata(part, "msg.txt"); - curl_mime_filename(part, NULL); -.fi - -Use of \fIcurl_mime_filedata(3)\fP sets the remote file name as a side effect: -it is therefore necessary to clear it for \fICURLFORM_FILECONTENT\fP -emulation. - -.SH "Showing Progress" - -For historical and traditional reasons, libcurl has a built-in progress meter -that can be switched on and then makes it present a progress meter in your -terminal. - -Switch on the progress meter by, oddly enough, setting -\fICURLOPT_NOPROGRESS(3)\fP to zero. This option is set to 1 by default. - -For most applications however, the built-in progress meter is useless and what -instead is interesting is the ability to specify a progress callback. The -function pointer you pass to libcurl is then called on irregular intervals -with information about the current transfer. - -Set the progress callback by using \fICURLOPT_PROGRESSFUNCTION(3)\fP. And pass -a pointer to a function that matches this prototype: - -.nf - int progress_callback(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow); -.fi - -If any of the input arguments is unknown, a 0 is provided. The first argument, -the 'clientp' is the pointer you pass to libcurl with -\fICURLOPT_PROGRESSDATA(3)\fP. libcurl does not touch it. - -.SH "libcurl with C++" - -There is basically only one thing to keep in mind when using C++ instead of C -when interfacing libcurl: - -The callbacks CANNOT be non-static class member functions - -Example C++ code: - -.nf -class AClass { - static size_t write_data(void *ptr, size_t size, size_t nmemb, - void *ourpointer) - { - /* do what you want with the data */ - } - } -.fi - -.SH "Proxies" - -What "proxy" means according to Merriam-Webster: "a person authorized to act -for another" but also "the agency, function, or office of a deputy who acts as -a substitute for another". - -Proxies are exceedingly common these days. Companies often only offer Internet -access to employees through their proxies. Network clients or user-agents ask -the proxy for documents, the proxy does the actual request and then it returns -them. - -libcurl supports SOCKS and HTTP proxies. When a given URL is wanted, libcurl -asks the proxy for it instead of trying to connect to the actual remote host -identified in the URL. - -If you are using a SOCKS proxy, you may find that libcurl does not quite support -all operations through it. - -For HTTP proxies: the fact that the proxy is an HTTP proxy puts certain -restrictions on what can actually happen. A requested URL that might not be a -HTTP URL is passed to the HTTP proxy to deliver back to libcurl. This happens -transparently, and an application may not need to know. I say "may", because -at times it is important to understand that all operations over an HTTP proxy -use the HTTP protocol. For example, you cannot invoke your own custom FTP -commands or even proper FTP directory listings. - -.IP "Proxy Options" - -To tell libcurl to use a proxy at a given port number: -.nf - curl_easy_setopt(handle, CURLOPT_PROXY, "proxy-host.com:8080"); -.fi -Some proxies require user authentication before allowing a request, and you -pass that information similar to this: -.nf - curl_easy_setopt(handle, CURLOPT_PROXYUSERPWD, "user:password"); -.fi -If you want to, you can specify the host name only in the -\fICURLOPT_PROXY(3)\fP option, and set the port number separately with -\fICURLOPT_PROXYPORT(3)\fP. - -Tell libcurl what kind of proxy it is with \fICURLOPT_PROXYTYPE(3)\fP (if not, -it defaults to assuming an HTTP proxy): -.nf - curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); -.fi -.IP "Environment Variables" - -libcurl automatically checks and uses a set of environment variables to know -what proxies to use for certain protocols. The names of the variables are -following an old tradition and are built up as "[protocol]_proxy" (note the -lower casing). Which makes the variable \&'http_proxy' checked for a name of a -proxy to use when the input URL is HTTP. Following the same rule, the variable -named 'ftp_proxy' is checked for FTP URLs. Again, the proxies are always HTTP -proxies, the different names of the variables simply allows different HTTP -proxies to be used. - -The proxy environment variable contents should be in the format -\&"[protocol://][user:password@]machine[:port]". Where the protocol:// part -specifies which type of proxy it is, and the optional port number specifies on -which port the proxy operates. If not specified, the internal default port -number is used and that is most likely not the one you would like it to be. - -There are two special environment variables. 'all_proxy' is what sets proxy -for any URL in case the protocol specific variable was not set, and -\&'no_proxy' defines a list of hosts that should not use a proxy even though a -variable may say so. If 'no_proxy' is a plain asterisk ("*") it matches all -hosts. - -To explicitly disable libcurl's checking for and using the proxy environment -variables, set the proxy name to "" - an empty string - with -\fICURLOPT_PROXY(3)\fP. -.IP "SSL and Proxies" - -SSL is for secure point-to-point connections. This involves strong encryption -and similar things, which effectively makes it impossible for a proxy to -operate as a "man in between" which the proxy's task is, as previously -discussed. Instead, the only way to have SSL work over an HTTP proxy is to ask -the proxy to tunnel everything through without being able to check or fiddle -with the traffic. - -Opening an SSL connection over an HTTP proxy is therefore a matter of asking the -proxy for a straight connection to the target host on a specified port. This -is made with the HTTP request CONNECT. ("please dear proxy, connect me to that -remote host"). - -Because of the nature of this operation, where the proxy has no idea what kind -of data that is passed in and out through this tunnel, this breaks some of the -few advantages that come from using a proxy, such as caching. Many -organizations prevent this kind of tunneling to other destination port numbers -than 443 (which is the default HTTPS port number). - -.IP "Tunneling Through Proxy" -As explained above, tunneling is required for SSL to work and often even -restricted to the operation intended for SSL; HTTPS. - -This is however not the only time proxy-tunneling might offer benefits to -you or your application. - -As tunneling opens a direct connection from your application to the remote -machine, it suddenly also re-introduces the ability to do non-HTTP -operations over an HTTP proxy. You can in fact use things such as FTP -upload or FTP custom commands this way. - -Again, this is often prevented by the administrators of proxies and is -rarely allowed. - -Tell libcurl to use proxy tunneling like this: -.nf - curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1L); -.fi -In fact, there might even be times when you want to do plain HTTP operations -using a tunnel like this, as it then enables you to operate on the remote -server instead of asking the proxy to do so. libcurl does not stand in the way -for such innovative actions either! - -.IP "Proxy Auto-Config" - -Netscape first came up with this. It is basically a web page (usually using a -\&.pac extension) with a JavaScript that when executed by the browser with the -requested URL as input, returns information to the browser on how to connect -to the URL. The returned information might be "DIRECT" (which means no proxy -should be used), "PROXY host:port" (to tell the browser where the proxy for -this particular URL is) or "SOCKS host:port" (to direct the browser to a SOCKS -proxy). - -libcurl has no means to interpret or evaluate JavaScript and thus it does not -support this. If you get yourself in a position where you face this nasty -invention, the following advice have been mentioned and used in the past: - -- Depending on the JavaScript complexity, write up a script that translates it -to another language and execute that. - -- Read the JavaScript code and rewrite the same logic in another language. - -- Implement a JavaScript interpreter; people have successfully used the -Mozilla JavaScript engine in the past. - -- Ask your admins to stop this, for a static proxy setup or similar. - -.SH "Persistence Is The Way to Happiness" - -Re-cycling the same easy handle several times when doing multiple requests is -the way to go. - -After each single \fIcurl_easy_perform(3)\fP operation, libcurl keeps the -connection alive and open. A subsequent request using the same easy handle to -the same host might just be able to use the already open connection! This -reduces network impact a lot. - -Even if the connection is dropped, all connections involving SSL to the same -host again, benefit from libcurl's session ID cache that drastically reduces -re-connection time. - -FTP connections that are kept alive save a lot of time, as the command- -response round-trips are skipped, and also you do not risk getting blocked -without permission to login again like on many FTP servers only allowing N -persons to be logged in at the same time. - -libcurl caches DNS name resolving results, to make lookups of a previously -looked up name a lot faster. - -Other interesting details that improve performance for subsequent requests -may also be added in the future. - -Each easy handle attempts to keep the last few connections alive for a while -in case they are to be used again. You can set the size of this "cache" with -the \fICURLOPT_MAXCONNECTS(3)\fP option. Default is 5. There is rarely any -point in changing this value, and if you think of changing this it is often -just a matter of thinking again. - -To force your upcoming request to not use an already existing connection, you -can do that by setting \fICURLOPT_FRESH_CONNECT(3)\fP to 1. In a similar -spirit, you can also forbid the upcoming request to be "lying" around and -possibly get reused after the request by setting -\fICURLOPT_FORBID_REUSE(3)\fP to 1. - -.SH "HTTP Headers Used by libcurl" -When you use libcurl to do HTTP requests, it passes along a series of headers -automatically. It might be good for you to know and understand these. You can -replace or remove them by using the \fICURLOPT_HTTPHEADER(3)\fP option. - -.IP "Host" -This header is required by HTTP 1.1 and even many 1.0 servers and should be -the name of the server we want to talk to. This includes the port number if -anything but default. - -.IP "Accept" -\&"*/*". - -.IP "Expect" -When doing POST requests, libcurl sets this header to \&"100-continue" to ask -the server for an "OK" message before it proceeds with sending the data part -of the post. If the posted data amount is deemed "small", libcurl does not use -this header. - -.SH "Customizing Operations" -There is an ongoing development today where more and more protocols are built -upon HTTP for transport. This has obvious benefits as HTTP is a tested and -reliable protocol that is widely deployed and has excellent proxy-support. - -When you use one of these protocols, and even when doing other kinds of -programming you may need to change the traditional HTTP (or FTP or...) -manners. You may need to change words, headers or various data. - -libcurl is your friend here too. - -.IP CUSTOMREQUEST -If just changing the actual HTTP request keyword is what you want, like when -GET, HEAD or POST is not good enough for you, \fICURLOPT_CUSTOMREQUEST(3)\fP -is there for you. It is simple to use: -.nf - curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MYOWNREQUEST"); -.fi -When using the custom request, you change the request keyword of the actual -request you are performing. Thus, by default you make a GET request but you can -also make a POST operation (as described before) and then replace the POST -keyword if you want to. you are the boss. - -.IP "Modify Headers" -HTTP-like protocols pass a series of headers to the server when doing the -request, and you are free to pass any amount of extra headers that you -think fit. Adding headers is this easy: - -.nf - struct curl_slist *headers=NULL; /* init to NULL is important */ - - headers = curl_slist_append(headers, "Hey-server-hey: how are you?"); - headers = curl_slist_append(headers, "X-silly-content: yes"); - - /* pass our list of custom made headers */ - curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); - - curl_easy_perform(handle); /* transfer http */ - - curl_slist_free_all(headers); /* free the header list */ -.fi - -\&... and if you think some of the internally generated headers, such as -Accept: or Host: do not contain the data you want them to contain, you can -replace them by simply setting them too: - -.nf - headers = curl_slist_append(headers, "Accept: Agent-007"); - headers = curl_slist_append(headers, "Host: munged.host.line"); -.fi - -.IP "Delete Headers" -If you replace an existing header with one with no contents, you prevent the -header from being sent. For instance, if you want to completely prevent the -\&"Accept:" header from being sent, you can disable it with code similar to -this: - - headers = curl_slist_append(headers, "Accept:"); - -Both replacing and canceling internal headers should be done with careful -consideration and you should be aware that you may violate the HTTP protocol -when doing so. - -.IP "Enforcing chunked transfer-encoding" - -By making sure a request uses the custom header "Transfer-Encoding: chunked" -when doing a non-GET HTTP operation, libcurl switches over to "chunked" -upload, even though the size of the data to upload might be known. By default, -libcurl usually switches over to chunked upload automatically if the upload -data size is unknown. - -.IP "HTTP Version" - -All HTTP requests includes the version number to tell the server which version -we support. libcurl speaks HTTP 1.1 by default. Some old servers do not like -getting 1.1-requests and when dealing with stubborn old things like that, you -can tell libcurl to use 1.0 instead by doing something like this: - - curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - -.IP "FTP Custom Commands" - -Not all protocols are HTTP-like, and thus the above may not help you when -you want to make, for example, your FTP transfers to behave differently. - -Sending custom commands to an FTP server means that you need to send the -commands exactly as the FTP server expects them (RFC 959 is a good guide -here), and you can only use commands that work on the control-connection -alone. All kinds of commands that require data interchange and thus need a -data-connection must be left to libcurl's own judgment. Also be aware that -libcurl does its best to change directory to the target directory before doing -any transfer, so if you change directory (with CWD or similar) you might -confuse libcurl and then it might not attempt to transfer the file in the -correct remote directory. - -A little example that deletes a given file before an operation: - -.nf - headers = curl_slist_append(headers, "DELE file-to-remove"); - - /* pass the list of custom commands to the handle */ - curl_easy_setopt(handle, CURLOPT_QUOTE, headers); - - curl_easy_perform(handle); /* transfer ftp data! */ - - curl_slist_free_all(headers); /* free the header list */ -.fi - -If you would instead want this operation (or chain of operations) to happen -_after_ the data transfer took place the option to \fIcurl_easy_setopt(3)\fP -would instead be called \fICURLOPT_POSTQUOTE(3)\fP and used the exact same -way. - -The custom FTP commands are issued to the server in the same order they are -added to the list, and if a command gets an error code returned back from the -server, no more commands are issued and libcurl bails out with an error code -(CURLE_QUOTE_ERROR). Note that if you use \fICURLOPT_QUOTE(3)\fP to send -commands before a transfer, no transfer actually takes place when a quote -command has failed. - -If you set the \fICURLOPT_HEADER(3)\fP to 1, you tell libcurl to get -information about the target file and output "headers" about it. The headers -are in "HTTP-style", looking like they do in HTTP. - -The option to enable headers or to run custom FTP commands may be useful to -combine with \fICURLOPT_NOBODY(3)\fP. If this option is set, no actual file -content transfer is performed. - -.IP "FTP Custom CUSTOMREQUEST" -If you do want to list the contents of an FTP directory using your own defined -FTP command, \fICURLOPT_CUSTOMREQUEST(3)\fP does just that. "NLST" is the -default one for listing directories but you are free to pass in your idea of a -good alternative. - -.SH "Cookies Without Chocolate Chips" -In the HTTP sense, a cookie is a name with an associated value. A server sends -the name and value to the client, and expects it to get sent back on every -subsequent request to the server that matches the particular conditions -set. The conditions include that the domain name and path match and that the -cookie has not become too old. - -In real-world cases, servers send new cookies to replace existing ones to -update them. Server use cookies to "track" users and to keep "sessions". - -Cookies are sent from server to clients with the header Set-Cookie: and -they are sent from clients to servers with the Cookie: header. - -To just send whatever cookie you want to a server, you can use -\fICURLOPT_COOKIE(3)\fP to set a cookie string like this: -.nf - curl_easy_setopt(handle, CURLOPT_COOKIE, "name1=var1; name2=var2;"); -.fi -In many cases, that is not enough. You might want to dynamically save -whatever cookies the remote server passes to you, and make sure those cookies -are then used accordingly on later requests. - -One way to do this, is to save all headers you receive in a plain file and -when you make a request, you tell libcurl to read the previous headers to -figure out which cookies to use. Set the header file to read cookies from with -\fICURLOPT_COOKIEFILE(3)\fP. - -The \fICURLOPT_COOKIEFILE(3)\fP option also automatically enables the cookie -parser in libcurl. Until the cookie parser is enabled, libcurl does not parse -or understand incoming cookies and they are just be ignored. However, when the -parser is enabled the cookies are understood and the cookies are kept in -memory and used properly in subsequent requests when the same handle is -used. Many times this is enough, and you may not have to save the cookies to -disk at all. Note that the file you specify to \fICURLOPT_COOKIEFILE(3)\fP -does not have to exist to enable the parser, so a common way to just enable -the parser and not read any cookies is to use the name of a file you know does -not exist. - -If you would rather use existing cookies that you have previously received -with your Netscape or Mozilla browsers, you can make libcurl use that cookie -file as input. The \fICURLOPT_COOKIEFILE(3)\fP is used for that too, as -libcurl automatically finds out what kind of file it is and acts accordingly. - -Perhaps the most advanced cookie operation libcurl offers, is saving the -entire internal cookie state back into a Netscape/Mozilla formatted cookie -file. We call that the cookie-jar. When you set a file name with -\fICURLOPT_COOKIEJAR(3)\fP, that file name is created and all received cookies -get stored in it when \fIcurl_easy_cleanup(3)\fP is called. This enables -cookies to get passed on properly between multiple handles without any -information getting lost. - -.SH "FTP Peculiarities We Need" - -FTP transfers use a second TCP/IP connection for the data transfer. This is -usually a fact you can forget and ignore but at times this detail comes back -to haunt you. libcurl offers several different ways to customize how the -second connection is being made. - -libcurl can either connect to the server a second time or tell the server to -connect back to it. The first option is the default and it is also what works -best for all the people behind firewalls, NATs or IP-masquerading setups. -libcurl then tells the server to open up a new port and wait for a second -connection. This is by default attempted with EPSV first, and if that does not -work it tries PASV instead. (EPSV is an extension to the original FTP spec -and does not exist nor work on all FTP servers.) - -You can prevent libcurl from first trying the EPSV command by setting -\fICURLOPT_FTP_USE_EPSV(3)\fP to zero. - -In some cases, you want to have the server connect back to you for the second -connection. This might be when the server is perhaps behind a firewall or -something and only allows connections on a single port. libcurl then informs -the remote server which IP address and port number to connect to. This is -made with the \fICURLOPT_FTPPORT(3)\fP option. If you set it to "-", libcurl -uses your system's "default IP address". If you want to use a particular IP, -you can set the full IP address, a host name to resolve to an IP address or -even a local network interface name that libcurl gets the IP address from. - -When doing the "PORT" approach, libcurl attempts to use the EPRT and the LPRT -before trying PORT, as they work with more protocols. You can disable this -behavior by setting \fICURLOPT_FTP_USE_EPRT(3)\fP to zero. - -.SH "MIME API revisited for SMTP and IMAP" -In addition to support HTTP multi-part form fields, the MIME API can be used -to build structured email messages and send them via SMTP or append such -messages to IMAP directories. - -A structured email message may contain several parts: some are displayed -inline by the MUA, some are attachments. Parts can also be structured as -multi-part, for example to include another email message or to offer several -text formats alternatives. This can be nested to any level. - -To build such a message, you prepare the nth-level multi-part and then include -it as a source to the parent multi-part using function -\fIcurl_mime_subparts(3)\fP. Once it has been -bound to its parent multi-part, a nth-level multi-part belongs to it and -should not be freed explicitly. - -Email messages data is not supposed to be non-ascii and line length is -limited: fortunately, some transfer encodings are defined by the standards to -support the transmission of such incompatible data. Function -\fIcurl_mime_encoder(3)\fP tells a part that its source data must be encoded -before being sent. It also generates the corresponding header for that part. -If the part data you want to send is already encoded in such a scheme, do not -use this function (this would over-encode it), but explicitly set the -corresponding part header. - -Upon sending such a message, libcurl prepends it with the header list -set with \fICURLOPT_HTTPHEADER(3)\fP, as zero level mime part headers. - -Here is an example building an email message with an inline plain/html text -alternative and a file attachment encoded in base64: - -.nf - curl_mime *message = curl_mime_init(handle); - - /* The inline part is an alternative proposing the html and the text - versions of the email. */ - curl_mime *alt = curl_mime_init(handle); - - /* HTML message. */ - curl_mimepart *part = curl_mime_addpart(alt); - curl_mime_data(part, "

This is HTML

", - CURL_ZERO_TERMINATED); - curl_mime_type(part, "text/html"); - - /* Text message. */ - part = curl_mime_addpart(alt); - curl_mime_data(part, "This is plain text message", - CURL_ZERO_TERMINATED); - - /* Create the inline part. */ - part = curl_mime_addpart(message); - curl_mime_subparts(part, alt); - curl_mime_type(part, "multipart/alternative"); - struct curl_slist *headers = curl_slist_append(NULL, - "Content-Disposition: inline"); - curl_mime_headers(part, headers, TRUE); - - /* Add the attachment. */ - part = curl_mime_addpart(message); - curl_mime_filedata(part, "manual.pdf"); - curl_mime_encoder(part, "base64"); - - /* Build the mail headers. */ - headers = curl_slist_append(NULL, "From: me@example.com"); - headers = curl_slist_append(headers, "To: you@example.com"); - - /* Set these into the easy handle. */ - curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); - curl_easy_setopt(handle, CURLOPT_MIMEPOST, mime); -.fi - -It should be noted that appending a message to an IMAP directory requires -the message size to be known prior upload. It is therefore not possible to -include parts with unknown data size in this context. - -.SH "Headers Equal Fun" - -Some protocols provide "headers", meta-data separated from the normal -data. These headers are by default not included in the normal data stream, but -you can make them appear in the data stream by setting \fICURLOPT_HEADER(3)\fP -to 1. - -What might be even more useful, is libcurl's ability to separate the headers -from the data and thus make the callbacks differ. You can for example set a -different pointer to pass to the ordinary write callback by setting -\fICURLOPT_HEADERDATA(3)\fP. - -Or, you can set an entirely separate function to receive the headers, by using -\fICURLOPT_HEADERFUNCTION(3)\fP. - -The headers are passed to the callback function one by one, and you can -depend on that fact. It makes it easier for you to add custom header parsers -etc. - -\&"Headers" for FTP transfers equal all the FTP server responses. They are not -actually true headers, but in this case we pretend they are! ;-) - -.SH "Post Transfer Information" -See \fIcurl_easy_getinfo(3)\fP. -.SH "The multi Interface" -The easy interface as described in detail in this document is a synchronous -interface that transfers one file at a time and does not return until it is -done. - -The multi interface, on the other hand, allows your program to transfer -multiple files in both directions at the same time, without forcing you to use -multiple threads. The name might make it seem that the multi interface is for -multi-threaded programs, but the truth is almost the reverse. The multi -interface allows a single-threaded application to perform the same kinds of -multiple, simultaneous transfers that multi-threaded programs can perform. It -allows many of the benefits of multi-threaded transfers without the complexity -of managing and synchronizing many threads. - -To complicate matters somewhat more, there are even two versions of the multi -interface. The event based one, also called multi_socket and the "normal one" -designed for using with select(). See the libcurl-multi.3 man page for details -on the multi_socket event based API, this description here is for the select() -oriented one. - -To use this interface, you are better off if you first understand the basics -of how to use the easy interface. The multi interface is simply a way to make -multiple transfers at the same time by adding up multiple easy handles into -a "multi stack". - -You create the easy handles you want, one for each concurrent transfer, and -you set all the options just like you learned above, and then you create a -multi handle with \fIcurl_multi_init(3)\fP and add all those easy handles to -that multi handle with \fIcurl_multi_add_handle(3)\fP. - -When you have added the handles you have for the moment (you can still add new -ones at any time), you start the transfers by calling -\fIcurl_multi_perform(3)\fP. - -\fIcurl_multi_perform(3)\fP is asynchronous. It only performs what can be done -now and then return control to your program. It is designed to never -block. You need to keep calling the function until all transfers are -completed. - -The best usage of this interface is when you do a select() on all possible -file descriptors or sockets to know when to call libcurl again. This also -makes it easy for you to wait and respond to actions on your own application's -sockets/handles. You figure out what to select() for by using -\fIcurl_multi_fdset(3)\fP, that fills in a set of \fIfd_set\fP variables for -you with the particular file descriptors libcurl uses for the moment. - -When you then call select(), it returns when one of the file handles signal -action and you then call \fIcurl_multi_perform(3)\fP to allow libcurl to do -what it wants to do. Take note that libcurl does also feature some time-out -code so we advise you to never use long timeouts on select() before you call -\fIcurl_multi_perform(3)\fP again. \fIcurl_multi_timeout(3)\fP is provided to -help you get a suitable timeout period. - -Another precaution you should use: always call \fIcurl_multi_fdset(3)\fP -immediately before the select() call since the current set of file descriptors -may change in any curl function invoke. - -If you want to stop the transfer of one of the easy handles in the stack, you -can use \fIcurl_multi_remove_handle(3)\fP to remove individual easy -handles. Remember that easy handles should be \fIcurl_easy_cleanup(3)\fPed. - -When a transfer within the multi stack has finished, the counter of running -transfers (as filled in by \fIcurl_multi_perform(3)\fP) decreases. When the -number reaches zero, all transfers are done. - -\fIcurl_multi_info_read(3)\fP can be used to get information about completed -transfers. It then returns the CURLcode for each easy transfer, to allow you -to figure out success on each individual transfer. - -.SH "SSL, Certificates and Other Tricks" - - [ seeding, passwords, keys, certificates, ENGINE, ca certs ] - -.SH "Sharing Data Between Easy Handles" -You can share some data between easy handles when the easy interface is used, -and some data is share automatically when you use the multi interface. - -When you add easy handles to a multi handle, these easy handles automatically -share a lot of the data that otherwise would be kept on a per-easy handle -basis when the easy interface is used. - -The DNS cache is shared between handles within a multi handle, making -subsequent name resolving faster, and the connection pool that is kept to -better allow persistent connections and connection reuse is also shared. If -you are using the easy interface, you can still share these between specific -easy handles by using the share interface, see \fIlibcurl-share(3)\fP. - -Some things are never shared automatically, not within multi handles, like for -example cookies so the only way to share that is with the share interface. -.SH "Footnotes" - -.IP "[1]" -libcurl 7.10.3 and later have the ability to switch over to chunked -Transfer-Encoding in cases where HTTP uploads are done with data of an unknown -size. -.IP "[2]" -This happens on Windows machines when libcurl is built and used as a -DLL. However, you can still do this on Windows if you link with a static -library. -.IP "[3]" -The curl-config tool is generated at build-time (on Unix-like systems) and -should be installed with the 'make install' or similar instruction that -installs the library, header files, man pages etc. -.IP "[4]" -This behavior was different in versions before 7.17.0, where strings had to -remain valid past the end of the \fIcurl_easy_setopt(3)\fP call. -.SH "SEE ALSO" -.BR libcurl-easy (3), -.BR libcurl-errors (3), -.BR libcurl-multi (3), -.BR libcurl-url (3) diff --git a/docs/libcurl/libcurl-tutorial.md b/docs/libcurl/libcurl-tutorial.md new file mode 100644 index 000000000..2bf5f0547 --- /dev/null +++ b/docs/libcurl/libcurl-tutorial.md @@ -0,0 +1,1451 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl-tutorial +Section: 3 +Source: libcurl +See-also: + - libcurl-easy (3) + - libcurl-errors (3) + - libcurl-multi (3) + - libcurl-url (3) +--- + +# NAME + +libcurl-tutorial - libcurl programming tutorial + +# Objective + +This document attempts to describe the general principles and some basic +approaches to consider when programming with libcurl. The text focuses on the +C interface but should apply fairly well on other language bindings as well as +they usually follow the C API pretty closely. + +This document refers to 'the user' as the person writing the source code that +uses libcurl. That would probably be you or someone in your position. What is +generally referred to as 'the program' is the collected source code that you +write that is using libcurl for transfers. The program is outside libcurl and +libcurl is outside of the program. + +To get more details on all options and functions described herein, please +refer to their respective man pages. + +# Building + +There are many different ways to build C programs. This chapter assumes a Unix +style build process. If you use a different build system, you can still read +this to get general information that may apply to your environment as well. + +## Compiling the Program + +Your compiler needs to know where the libcurl headers are located. Therefore +you must set your compiler's include path to point to the directory where you +installed them. The 'curl-config'[3] tool can be used to get this information: +~~~c + $ curl-config --cflags +~~~ + +## Linking the Program with libcurl + +When having compiled the program, you need to link your object files to create +a single executable. For that to succeed, you need to link with libcurl and +possibly also with other libraries that libcurl itself depends on. Like the +OpenSSL libraries, but even some standard OS libraries may be needed on the +command line. To figure out which flags to use, once again the 'curl-config' +tool comes to the rescue: +~~~c + $ curl-config --libs +~~~ + +## SSL or Not + +libcurl can be built and customized in many ways. One of the things that +varies from different libraries and builds is the support for SSL-based +transfers, like HTTPS and FTPS. If a supported SSL library was detected +properly at build-time, libcurl is built with SSL support. To figure out if an +installed libcurl has been built with SSL support enabled, use *curl-config* +like this: + +~~~c + $ curl-config --feature +~~~ + +If SSL is supported, the keyword *SSL* is written to stdout, possibly together +with a other features that could be either on or off on for different +libcurls. + +See also the "Features libcurl Provides" further down. + +## autoconf macro + +When you write your configure script to detect libcurl and setup variables +accordingly, we offer a macro that probably does everything you need in this +area. See docs/libcurl/libcurl.m4 file - it includes docs on how to use it. + +# Portable Code in a Portable World + +The people behind libcurl have put a considerable effort to make libcurl work +on a large amount of different operating systems and environments. + +You program libcurl the same way on all platforms that libcurl runs on. There +are only a few minor details that differ. If you just make sure to write your +code portable enough, you can create a portable program. libcurl should not +stop you from that. + +# Global Preparation + +The program must initialize some of the libcurl functionality globally. That +means it should be done exactly once, no matter how many times you intend to +use the library. Once for your program's entire life time. This is done using +~~~c + curl_global_init() +~~~ +and it takes one parameter which is a bit pattern that tells libcurl what to +initialize. Using *CURL_GLOBAL_ALL* makes it initialize all known internal +sub modules, and might be a good default option. The current two bits that are +specified are: + +## CURL_GLOBAL_WIN32 + +which only does anything on Windows machines. When used on a Windows machine, +it makes libcurl initialize the win32 socket stuff. Without having that +initialized properly, your program cannot use sockets properly. You should +only do this once for each application, so if your program already does this +or of another library in use does it, you should not tell libcurl to do this +as well. + +## CURL_GLOBAL_SSL + +which only does anything on libcurls compiled and built SSL-enabled. On these +systems, this makes libcurl initialize the SSL library properly for this +application. This only needs to be done once for each application so if your +program or another library already does this, this bit should not be needed. + +libcurl has a default protection mechanism that detects if +curl_global_init(3) has not been called by the time +curl_easy_perform(3) is called and if that is the case, libcurl runs the +function itself with a guessed bit pattern. Please note that depending solely +on this is not considered nice nor good. + +When the program no longer uses libcurl, it should call +curl_global_cleanup(3), which is the opposite of the init call. It +performs the reversed operations to cleanup the resources the +curl_global_init(3) call initialized. + +Repeated calls to curl_global_init(3) and curl_global_cleanup(3) +should be avoided. They should only be called once each. + +# Features libcurl Provides + +It is considered best-practice to determine libcurl features at runtime rather +than at build-time (if possible of course). By calling +curl_version_info(3) and checking out the details of the returned +struct, your program can figure out exactly what the currently running libcurl +supports. + +# Two Interfaces + +libcurl first introduced the so called easy interface. All operations in the +easy interface are prefixed with 'curl_easy'. The easy interface lets you do +single transfers with a synchronous and blocking function call. + +libcurl also offers another interface that allows multiple simultaneous +transfers in a single thread, the so called multi interface. More about that +interface is detailed in a separate chapter further down. You still need to +understand the easy interface first, so please continue reading for better +understanding. + +# Handle the Easy libcurl + +To use the easy interface, you must first create yourself an easy handle. You +need one handle for each easy session you want to perform. Basically, you +should use one handle for every thread you plan to use for transferring. You +must never share the same handle in multiple threads. + +Get an easy handle with +~~~c + handle = curl_easy_init(); +~~~ +It returns an easy handle. Using that you proceed to the next step: setting +up your preferred actions. A handle is just a logic entity for the upcoming +transfer or series of transfers. + +You set properties and options for this handle using +curl_easy_setopt(3). They control how the subsequent transfer or +transfers using this handle are made. Options remain set in the handle until +set again to something different. They are sticky. Multiple requests using the +same handle use the same options. + +If you at any point would like to blank all previously set options for a +single easy handle, you can call curl_easy_reset(3) and you can also +make a clone of an easy handle (with all its set options) using +curl_easy_duphandle(3). + +Many of the options you set in libcurl are "strings", pointers to data +terminated with a zero byte. When you set strings with +curl_easy_setopt(3), libcurl makes its own copy so that they do not need +to be kept around in your application after being set[4]. + +One of the most basic properties to set in the handle is the URL. You set your +preferred URL to transfer with CURLOPT_URL(3) in a manner similar to: + +~~~c + curl_easy_setopt(handle, CURLOPT_URL, "http://domain.com/"); +~~~ + +Let's assume for a while that you want to receive data as the URL identifies a +remote resource you want to get here. Since you write a sort of application +that needs this transfer, I assume that you would like to get the data passed +to you directly instead of simply getting it passed to stdout. So, you write +your own function that matches this prototype: +~~~c + size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp); +~~~ +You tell libcurl to pass all data to this function by issuing a function +similar to this: +~~~c + curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_data); +~~~ +You can control what data your callback function gets in the fourth argument +by setting another property: +~~~c + curl_easy_setopt(handle, CURLOPT_WRITEDATA, &internal_struct); +~~~ +Using that property, you can easily pass local data between your application +and the function that gets invoked by libcurl. libcurl itself does not touch +the data you pass with CURLOPT_WRITEDATA(3). + +libcurl offers its own default internal callback that takes care of the data +if you do not set the callback with CURLOPT_WRITEFUNCTION(3). It simply +outputs the received data to stdout. You can have the default callback write +the data to a different file handle by passing a 'FILE *' to a file opened for +writing with the CURLOPT_WRITEDATA(3) option. + +Now, we need to take a step back and take a deep breath. Here is one of those +rare platform-dependent nitpicks. Did you spot it? On some platforms[2], +libcurl is not able to operate on file handles opened by the +program. Therefore, if you use the default callback and pass in an open file +handle with CURLOPT_WRITEDATA(3), libcurl crashes. You should avoid this +to make your program run fine virtually everywhere. + +(CURLOPT_WRITEDATA(3) was formerly known as *CURLOPT_FILE*. Both names still +work and do the same thing). + +If you are using libcurl as a win32 DLL, you MUST use the +CURLOPT_WRITEFUNCTION(3) if you set CURLOPT_WRITEDATA(3) - or experience +crashes. + +There are of course many more options you can set, and we get back to a few of +them later. Let's instead continue to the actual transfer: + +~~~c + success = curl_easy_perform(handle); +~~~ + +curl_easy_perform(3) connects to the remote site, does the necessary commands +and performs the transfer. Whenever it receives data, it calls the callback +function we previously set. The function may get one byte at a time, or it may +get many kilobytes at once. libcurl delivers as much as possible as often as +possible. Your callback function should return the number of bytes it "took +care of". If that is not the same amount of bytes that was passed to it, +libcurl aborts the operation and returns with an error code. + +When the transfer is complete, the function returns a return code that informs +you if it succeeded in its mission or not. If a return code is not enough for +you, you can use the CURLOPT_ERRORBUFFER(3) to point libcurl to a buffer of +yours where it stores a human readable error message as well. + +If you then want to transfer another file, the handle is ready to be used +again. It is even preferred and encouraged that you reuse an existing handle +if you intend to make another transfer. libcurl then attempts to reuse a +previous connection. + +For some protocols, downloading a file can involve a complicated process of +logging in, setting the transfer mode, changing the current directory and +finally transferring the file data. libcurl takes care of all that +complication for you. Given simply the URL to a file, libcurl takes care of +all the details needed to get the file moved from one machine to another. + +# Multi-threading Issues + +libcurl is thread safe but there are a few exceptions. Refer to +libcurl-thread(3) for more information. + +# When It does not Work + +There are times when the transfer fails for some reason. You might have set +the wrong libcurl option or misunderstood what the libcurl option actually +does, or the remote server might return non-standard replies that confuse the +library which then confuses your program. + +There is one golden rule when these things occur: set the +CURLOPT_VERBOSE(3) option to 1. it causes the library to spew out the +entire protocol details it sends, some internal info and some received +protocol data as well (especially when using FTP). If you are using HTTP, +adding the headers in the received output to study is also a clever way to get +a better understanding why the server behaves the way it does. Include headers +in the normal body output with CURLOPT_HEADER(3) set 1. + +Of course, there are bugs left. We need to know about them to be able to fix +them, so we are quite dependent on your bug reports. When you do report +suspected bugs in libcurl, please include as many details as you possibly can: +a protocol dump that CURLOPT_VERBOSE(3) produces, library version, as +much as possible of your code that uses libcurl, operating system name and +version, compiler name and version etc. + +If CURLOPT_VERBOSE(3) is not enough, you increase the level of debug +data your application receive by using the CURLOPT_DEBUGFUNCTION(3). + +Getting some in-depth knowledge about the protocols involved is never wrong, +and if you are trying to do funny things, you might understand libcurl and how +to use it better if you study the appropriate RFC documents at least briefly. + +# Upload Data to a Remote Site + +libcurl tries to keep a protocol independent approach to most transfers, thus +uploading to a remote FTP site is similar to uploading data to an HTTP server +with a PUT request. + +Of course, first you either create an easy handle or you reuse one existing +one. Then you set the URL to operate on just like before. This is the remote +URL, that we now upload. + +Since we write an application, we most likely want libcurl to get the upload +data by asking us for it. To make it do that, we set the read callback and the +custom pointer libcurl passes to our read callback. The read callback should +have a prototype similar to: +~~~c + size_t function(char *bufptr, size_t size, size_t nitems, void *userp); +~~~ +Where *bufptr* is the pointer to a buffer we fill in with data to upload +and *size*nitems* is the size of the buffer and therefore also the maximum +amount of data we can return to libcurl in this call. The *userp* pointer +is the custom pointer we set to point to a struct of ours to pass private data +between the application and the callback. +~~~c + curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_function); + + curl_easy_setopt(handle, CURLOPT_READDATA, &filedata); +~~~ +Tell libcurl that we want to upload: +~~~c + curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); +~~~ +A few protocols do not behave properly when uploads are done without any prior +knowledge of the expected file size. So, set the upload file size using the +CURLOPT_INFILESIZE_LARGE(3) for all known file sizes like this[1]: + +~~~c + /* in this example, file_size must be an curl_off_t variable */ + curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, file_size); +~~~ + +When you call curl_easy_perform(3) this time, it performs all the +necessary operations and when it has invoked the upload it calls your supplied +callback to get the data to upload. The program should return as much data as +possible in every invoke, as that is likely to make the upload perform as fast +as possible. The callback should return the number of bytes it wrote in the +buffer. Returning 0 signals the end of the upload. + +# Passwords + +Many protocols use or even require that user name and password are provided +to be able to download or upload the data of your choice. libcurl offers +several ways to specify them. + +Most protocols support that you specify the name and password in the URL +itself. libcurl detects this and use them accordingly. This is written like +this: +~~~c + protocol://user:password@example.com/path/ +~~~ +If you need any odd letters in your user name or password, you should enter +them URL encoded, as %XX where XX is a two-digit hexadecimal number. + +libcurl also provides options to set various passwords. The user name and +password as shown embedded in the URL can instead get set with the +CURLOPT_USERPWD(3) option. The argument passed to libcurl should be a +char * to a string in the format "user:password". In a manner like this: + +~~~c + curl_easy_setopt(handle, CURLOPT_USERPWD, "myname:thesecret"); +~~~ + +Another case where name and password might be needed at times, is for those +users who need to authenticate themselves to a proxy they use. libcurl offers +another option for this, the CURLOPT_PROXYUSERPWD(3). It is used quite similar +to the CURLOPT_USERPWD(3) option like this: + +~~~c + curl_easy_setopt(handle, CURLOPT_PROXYUSERPWD, "myname:thesecret"); +~~~ + +There is a long time Unix "standard" way of storing FTP user names and +passwords, namely in the $HOME/.netrc file (on Windows, libcurl also checks +the *%USERPROFILE% environment* variable if *%HOME%* is unset, and tries +"_netrc" as name). The file should be made private so that only the user may +read it (see also the "Security Considerations" chapter), as it might contain +the password in plain text. libcurl has the ability to use this file to figure +out what set of user name and password to use for a particular host. As an +extension to the normal functionality, libcurl also supports this file for +non-FTP protocols such as HTTP. To make curl use this file, use the +CURLOPT_NETRC(3) option: + +~~~c + curl_easy_setopt(handle, CURLOPT_NETRC, 1L); +~~~ + +A basic example of how such a .netrc file may look like: + +~~~c + machine myhost.mydomain.com + login userlogin + password secretword +~~~ + +All these examples have been cases where the password has been optional, or +at least you could leave it out and have libcurl attempt to do its job +without it. There are times when the password is not optional, like when +you are using an SSL private key for secure transfers. + +To pass the known private key password to libcurl: +~~~c + curl_easy_setopt(handle, CURLOPT_KEYPASSWD, "keypassword"); +~~~ + +# HTTP Authentication + +The previous chapter showed how to set user name and password for getting URLs +that require authentication. When using the HTTP protocol, there are many +different ways a client can provide those credentials to the server and you +can control which way libcurl uses them. The default HTTP authentication +method is called 'Basic', which is sending the name and password in clear-text +in the HTTP request, base64-encoded. This is insecure. + +At the time of this writing, libcurl can be built to use: Basic, Digest, NTLM, +Negotiate (SPNEGO). You can tell libcurl which one to use with +CURLOPT_HTTPAUTH(3) as in: + +~~~c + curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + +~~~ + +When you send authentication to a proxy, you can also set authentication type +the same way but instead with CURLOPT_PROXYAUTH(3): + +~~~c + curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM); +~~~ + +Both these options allow you to set multiple types (by ORing them together), +to make libcurl pick the most secure one out of the types the server/proxy +claims to support. This method does however add a round-trip since libcurl +must first ask the server what it supports: + +~~~c + curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); +~~~ + +For convenience, you can use the *CURLAUTH_ANY* define (instead of a list with +specific types) which allows libcurl to use whatever method it wants. + +When asking for multiple types, libcurl picks the available one it considers +"best" in its own internal order of preference. + +# HTTP POSTing + +We get many questions regarding how to issue HTTP POSTs with libcurl the +proper way. This chapter thus includes examples using both different versions +of HTTP POST that libcurl supports. + +The first version is the simple POST, the most common version, that most HTML +pages using the tag uses. We provide a pointer to the data and tell +libcurl to post it all to the remote site: + +~~~c + char *data="name=daniel&project=curl"; + curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data); + curl_easy_setopt(handle, CURLOPT_URL, "http://posthere.com/"); + + curl_easy_perform(handle); /* post away! */ +~~~ + +Simple enough, huh? Since you set the POST options with the +CURLOPT_POSTFIELDS(3), this automatically switches the handle to use +POST in the upcoming request. + +What if you want to post binary data that also requires you to set the +Content-Type: header of the post? Well, binary posts prevent libcurl from being +able to do strlen() on the data to figure out the size, so therefore we must +tell libcurl the size of the post data. Setting headers in libcurl requests are +done in a generic way, by building a list of our own headers and then passing +that list to libcurl. + +~~~c + struct curl_slist *headers=NULL; + headers = curl_slist_append(headers, "Content-Type: text/xml"); + + /* post binary data */ + curl_easy_setopt(handle, CURLOPT_POSTFIELDS, binaryptr); + + /* set the size of the postfields data */ + curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, 23L); + + /* pass our list of custom made headers */ + curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); + + curl_easy_perform(handle); /* post away! */ + + curl_slist_free_all(headers); /* free the header list */ +~~~ + +While the simple examples above cover the majority of all cases where HTTP +POST operations are required, they do not do multi-part formposts. Multi-part +formposts were introduced as a better way to post (possibly large) binary data +and were first documented in the RFC 1867 (updated in RFC 2388). They are +called multi-part because they are built by a chain of parts, each part being +a single unit of data. Each part has its own name and contents. You can in +fact create and post a multi-part formpost with the regular libcurl POST +support described above, but that would require that you build a formpost +yourself and provide to libcurl. + +To make that easier, libcurl provides a MIME API consisting in several +functions: using those, you can create and fill a multi-part form. Function +curl_mime_init(3) creates a multi-part body; you can then append new parts +to a multi-part body using curl_mime_addpart(3). + +There are three possible data sources for a part: memory using +curl_mime_data(3), file using curl_mime_filedata(3) and user-defined data +read callback using curl_mime_data_cb(3). curl_mime_name(3) sets a part's +(i.e.: form field) name, while curl_mime_filename(3) fills in the remote +filename. With curl_mime_type(3), you can tell the MIME type of a part, +curl_mime_headers(3) allows defining the part's headers. When a multi-part +body is no longer needed, you can destroy it using curl_mime_free(3). + +The following example sets two simple text parts with plain textual contents, +and then a file with binary contents and uploads the whole thing. + +~~~c + curl_mime *multipart = curl_mime_init(handle); + curl_mimepart *part = curl_mime_addpart(multipart); + curl_mime_name(part, "name"); + curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); + part = curl_mime_addpart(multipart); + curl_mime_name(part, "project"); + curl_mime_data(part, "curl", CURL_ZERO_TERMINATED); + part = curl_mime_addpart(multipart); + curl_mime_name(part, "logotype-image"); + curl_mime_filedata(part, "curl.png"); + + /* Set the form info */ + curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart); + + curl_easy_perform(handle); /* post away! */ + + /* free the post data again */ + curl_mime_free(multipart); +~~~ + +To post multiple files for a single form field, you must supply each file in +a separate part, all with the same field name. Although function +curl_mime_subparts(3) implements nested multi-parts, this way of +multiple files posting is deprecated by RFC 7578, chapter 4.3. + +To set the data source from an already opened FILE pointer, use: + +~~~c + curl_mime_data_cb(part, filesize, (curl_read_callback) fread, + (curl_seek_callback) fseek, NULL, filepointer); +~~~ + +A deprecated curl_formadd(3) function is still supported in libcurl. +It should however not be used anymore for new designs and programs using it +ought to be converted to the MIME API. It is however described here as an +aid to conversion. + +Using *curl_formadd*, you add parts to the form. When you are done adding +parts, you post the whole form. + +The MIME API example above is expressed as follows using this function: + +~~~c + struct curl_httppost *post=NULL; + struct curl_httppost *last=NULL; + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "name", + CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "project", + CURLFORM_COPYCONTENTS, "curl", CURLFORM_END); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "logotype-image", + CURLFORM_FILECONTENT, "curl.png", CURLFORM_END); + + /* Set the form info */ + curl_easy_setopt(handle, CURLOPT_HTTPPOST, post); + + curl_easy_perform(handle); /* post away! */ + + /* free the post data again */ + curl_formfree(post); +~~~ + +Multipart formposts are chains of parts using MIME-style separators and +headers. It means that each one of these separate parts get a few headers set +that describe the individual content-type, size etc. To enable your +application to handicraft this formpost even more, libcurl allows you to +supply your own set of custom headers to such an individual form part. You can +of course supply headers to as many parts as you like, but this little example +shows how you set headers to one specific part when you add that to the post +handle: + +~~~c + struct curl_slist *headers=NULL; + headers = curl_slist_append(headers, "Content-Type: text/xml"); + + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "logotype-image", + CURLFORM_FILECONTENT, "curl.xml", + CURLFORM_CONTENTHEADER, headers, + CURLFORM_END); + + curl_easy_perform(handle); /* post away! */ + + curl_formfree(post); /* free post */ + curl_slist_free_all(headers); /* free custom header list */ +~~~ + +Since all options on an easy handle are "sticky", they remain the same until +changed even if you do call curl_easy_perform(3), you may need to tell +curl to go back to a plain GET request if you intend to do one as your next +request. You force an easy handle to go back to GET by using the +CURLOPT_HTTPGET(3) option: +~~~c + curl_easy_setopt(handle, CURLOPT_HTTPGET, 1L); +~~~ +Just setting CURLOPT_POSTFIELDS(3) to "" or NULL does *not* stop libcurl +from doing a POST. It just makes it POST without any data to send! + +# Converting from deprecated form API to MIME API + +Four rules have to be respected in building the multi-part: + +- The easy handle must be created before building the multi-part. + +- The multi-part is always created by a call to curl_mime_init(handle). + +- Each part is created by a call to curl_mime_addpart(multipart). + +- When complete, the multi-part must be bound to the easy handle using +CURLOPT_MIMEPOST(3) instead of CURLOPT_HTTPPOST(3). + +Here are some example of *curl_formadd* calls to MIME API sequences: + +~~~c + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "id", + CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); + CURLFORM_CONTENTHEADER, headers, + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "id"); + curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); + curl_mime_headers(part, headers, FALSE); +~~~ + +Setting the last curl_mime_headers(3) argument to TRUE would have caused +the headers to be automatically released upon destroyed the multi-part, thus +saving a clean-up call to curl_slist_free_all(3). + +~~~c + curl_formadd(&post, &last, + CURLFORM_PTRNAME, "logotype-image", + CURLFORM_FILECONTENT, "-", + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "logotype-image"); + curl_mime_data_cb(part, (curl_off_t) -1, fread, fseek, NULL, stdin); +~~~ + +curl_mime_name(3) always copies the field name. The special file name +"-" is not supported by curl_mime_filename(3): to read an open file, use +a callback source using fread(). The transfer is be chunk-encoded since the +data size is unknown. + +~~~c + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "datafile[]", + CURLFORM_FILE, "file1", + CURLFORM_FILE, "file2", + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "datafile[]"); + curl_mime_filedata(part, "file1"); + part = curl_mime_addpart(multipart); + curl_mime_name(part, "datafile[]"); + curl_mime_filedata(part, "file2"); +~~~ + +The deprecated multipart/mixed implementation of multiple files field is +translated to two distinct parts with the same name. + +~~~c + curl_easy_setopt(handle, CURLOPT_READFUNCTION, myreadfunc); + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "stream", + CURLFORM_STREAM, arg, + CURLFORM_CONTENTLEN, (curl_off_t) datasize, + CURLFORM_FILENAME, "archive.zip", + CURLFORM_CONTENTTYPE, "application/zip", + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "stream"); + curl_mime_data_cb(part, (curl_off_t) datasize, + myreadfunc, NULL, NULL, arg); + curl_mime_filename(part, "archive.zip"); + curl_mime_type(part, "application/zip"); +~~~ + +CURLOPT_READFUNCTION(3) callback is not used: it is replace by directly +setting the part source data from the callback read function. + +~~~c + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "memfile", + CURLFORM_BUFFER, "memfile.bin", + CURLFORM_BUFFERPTR, databuffer, + CURLFORM_BUFFERLENGTH, (long) sizeof databuffer, + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "memfile"); + curl_mime_data(part, databuffer, (curl_off_t) sizeof databuffer); + curl_mime_filename(part, "memfile.bin"); +~~~ + +curl_mime_data(3) always copies the initial data: data buffer is thus +free for immediate reuse. + +~~~c + curl_formadd(&post, &last, + CURLFORM_COPYNAME, "message", + CURLFORM_FILECONTENT, "msg.txt", + CURLFORM_END); +~~~ +becomes: +~~~c + part = curl_mime_addpart(multipart); + curl_mime_name(part, "message"); + curl_mime_filedata(part, "msg.txt"); + curl_mime_filename(part, NULL); +~~~ + +Use of curl_mime_filedata(3) sets the remote filename as a side effect: it is +therefore necessary to clear it for *CURLFORM_FILECONTENT* emulation. + +# Showing Progress + +For historical and traditional reasons, libcurl has a built-in progress meter +that can be switched on and then makes it present a progress meter in your +terminal. + +Switch on the progress meter by, oddly enough, setting +CURLOPT_NOPROGRESS(3) to zero. This option is set to 1 by default. + +For most applications however, the built-in progress meter is useless and what +instead is interesting is the ability to specify a progress callback. The +function pointer you pass to libcurl is then called on irregular intervals +with information about the current transfer. + +Set the progress callback by using CURLOPT_PROGRESSFUNCTION(3). Pass a pointer +to a function that matches this prototype: + +~~~c + int progress_callback(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); +~~~ + +If any of the input arguments is unknown, a 0 is provided. The first argument, +the 'clientp' is the pointer you pass to libcurl with +CURLOPT_PROGRESSDATA(3). libcurl does not touch it. + +# libcurl with C++ + +There is basically only one thing to keep in mind when using C++ instead of C +when interfacing libcurl: + +The callbacks CANNOT be non-static class member functions + +Example C++ code: + +~~~c +class AClass { + static size_t write_data(void *ptr, size_t size, size_t nmemb, + void *ourpointer) + { + /* do what you want with the data */ + } + } +~~~ + +# Proxies + +What "proxy" means according to Merriam-Webster: "a person authorized to act +for another" but also "the agency, function, or office of a deputy who acts as +a substitute for another". + +Proxies are exceedingly common these days. Companies often only offer Internet +access to employees through their proxies. Network clients or user-agents ask +the proxy for documents, the proxy does the actual request and then it returns +them. + +libcurl supports SOCKS and HTTP proxies. When a given URL is wanted, libcurl +asks the proxy for it instead of trying to connect to the actual remote host +identified in the URL. + +If you are using a SOCKS proxy, you may find that libcurl does not quite support +all operations through it. + +For HTTP proxies: the fact that the proxy is an HTTP proxy puts certain +restrictions on what can actually happen. A requested URL that might not be a +HTTP URL is passed to the HTTP proxy to deliver back to libcurl. This happens +transparently, and an application may not need to know. I say "may", because +at times it is important to understand that all operations over an HTTP proxy +use the HTTP protocol. For example, you cannot invoke your own custom FTP +commands or even proper FTP directory listings. + +## Proxy Options + +To tell libcurl to use a proxy at a given port number: +~~~c + curl_easy_setopt(handle, CURLOPT_PROXY, "proxy-host.com:8080"); +~~~ +Some proxies require user authentication before allowing a request, and you +pass that information similar to this: +~~~c + curl_easy_setopt(handle, CURLOPT_PROXYUSERPWD, "user:password"); +~~~ +If you want to, you can specify the hostname only in the +CURLOPT_PROXY(3) option, and set the port number separately with +CURLOPT_PROXYPORT(3). + +Tell libcurl what kind of proxy it is with CURLOPT_PROXYTYPE(3) (if not, +it defaults to assuming an HTTP proxy): +~~~c + curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); +~~~ + +## Environment Variables + +libcurl automatically checks and uses a set of environment variables to know +what proxies to use for certain protocols. The names of the variables are +following an old tradition and are built up as "[protocol]_proxy" (note the +lower casing). Which makes the variable 'http_proxy' checked for a name of a +proxy to use when the input URL is HTTP. Following the same rule, the variable +named 'ftp_proxy' is checked for FTP URLs. Again, the proxies are always HTTP +proxies, the different names of the variables simply allows different HTTP +proxies to be used. + +The proxy environment variable contents should be in the format +"[protocol://][user:password@]machine[:port]". Where the protocol:// part +specifies which type of proxy it is, and the optional port number specifies on +which port the proxy operates. If not specified, the internal default port +number is used and that is most likely not the one you would like it to be. + +There are two special environment variables. 'all_proxy' is what sets proxy +for any URL in case the protocol specific variable was not set, and 'no_proxy' +defines a list of hosts that should not use a proxy even though a variable may +say so. If 'no_proxy' is a plain asterisk ("*") it matches all hosts. + +To explicitly disable libcurl's checking for and using the proxy environment +variables, set the proxy name to "" - an empty string - with +CURLOPT_PROXY(3). + +## SSL and Proxies + +SSL is for secure point-to-point connections. This involves strong encryption +and similar things, which effectively makes it impossible for a proxy to +operate as a "man in between" which the proxy's task is, as previously +discussed. Instead, the only way to have SSL work over an HTTP proxy is to ask +the proxy to tunnel everything through without being able to check or fiddle +with the traffic. + +Opening an SSL connection over an HTTP proxy is therefore a matter of asking the +proxy for a straight connection to the target host on a specified port. This +is made with the HTTP request CONNECT. ("please dear proxy, connect me to that +remote host"). + +Because of the nature of this operation, where the proxy has no idea what kind +of data that is passed in and out through this tunnel, this breaks some of the +few advantages that come from using a proxy, such as caching. Many +organizations prevent this kind of tunneling to other destination port numbers +than 443 (which is the default HTTPS port number). + +## Tunneling Through Proxy + +As explained above, tunneling is required for SSL to work and often even +restricted to the operation intended for SSL; HTTPS. + +This is however not the only time proxy-tunneling might offer benefits to +you or your application. + +As tunneling opens a direct connection from your application to the remote +machine, it suddenly also re-introduces the ability to do non-HTTP +operations over an HTTP proxy. You can in fact use things such as FTP +upload or FTP custom commands this way. + +Again, this is often prevented by the administrators of proxies and is +rarely allowed. + +Tell libcurl to use proxy tunneling like this: +~~~c + curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1L); +~~~ +In fact, there might even be times when you want to do plain HTTP operations +using a tunnel like this, as it then enables you to operate on the remote +server instead of asking the proxy to do so. libcurl does not stand in the way +for such innovative actions either! + +## Proxy Auto-Config + +Netscape first came up with this. It is basically a webpage (usually using a +.pac extension) with a JavaScript that when executed by the browser with the +requested URL as input, returns information to the browser on how to connect +to the URL. The returned information might be "DIRECT" (which means no proxy +should be used), "PROXY host:port" (to tell the browser where the proxy for +this particular URL is) or "SOCKS host:port" (to direct the browser to a SOCKS +proxy). + +libcurl has no means to interpret or evaluate JavaScript and thus it does not +support this. If you get yourself in a position where you face this nasty +invention, the following advice have been mentioned and used in the past: + +- Depending on the JavaScript complexity, write up a script that translates it +to another language and execute that. + +- Read the JavaScript code and rewrite the same logic in another language. + +- Implement a JavaScript interpreter; people have successfully used the +Mozilla JavaScript engine in the past. + +- Ask your admins to stop this, for a static proxy setup or similar. + +# Persistence Is The Way to Happiness + +Re-cycling the same easy handle several times when doing multiple requests is +the way to go. + +After each single curl_easy_perform(3) operation, libcurl keeps the +connection alive and open. A subsequent request using the same easy handle to +the same host might just be able to use the already open connection! This +reduces network impact a lot. + +Even if the connection is dropped, all connections involving SSL to the same +host again, benefit from libcurl's session ID cache that drastically reduces +re-connection time. + +FTP connections that are kept alive save a lot of time, as the command- +response round-trips are skipped, and also you do not risk getting blocked +without permission to login again like on many FTP servers only allowing N +persons to be logged in at the same time. + +libcurl caches DNS name resolving results, to make lookups of a previously +looked up name a lot faster. + +Other interesting details that improve performance for subsequent requests +may also be added in the future. + +Each easy handle attempts to keep the last few connections alive for a while +in case they are to be used again. You can set the size of this "cache" with +the CURLOPT_MAXCONNECTS(3) option. Default is 5. There is rarely any +point in changing this value, and if you think of changing this it is often +just a matter of thinking again. + +To force your upcoming request to not use an already existing connection, you +can do that by setting CURLOPT_FRESH_CONNECT(3) to 1. In a similar +spirit, you can also forbid the upcoming request to be "lying" around and +possibly get reused after the request by setting +CURLOPT_FORBID_REUSE(3) to 1. + +# HTTP Headers Used by libcurl + +When you use libcurl to do HTTP requests, it passes along a series of headers +automatically. It might be good for you to know and understand these. You can +replace or remove them by using the CURLOPT_HTTPHEADER(3) option. + +## Host + +This header is required by HTTP 1.1 and even many 1.0 servers and should be +the name of the server we want to talk to. This includes the port number if +anything but default. + +## Accept + +"*/*" + +## Expect + +When doing POST requests, libcurl sets this header to "100-continue" to ask +the server for an "OK" message before it proceeds with sending the data part +of the post. If the posted data amount is deemed "small", libcurl does not use +this header. + +# Customizing Operations + +There is an ongoing development today where more and more protocols are built +upon HTTP for transport. This has obvious benefits as HTTP is a tested and +reliable protocol that is widely deployed and has excellent proxy-support. + +When you use one of these protocols, and even when doing other kinds of +programming you may need to change the traditional HTTP (or FTP or...) +manners. You may need to change words, headers or various data. + +libcurl is your friend here too. + +## CUSTOMREQUEST + +If just changing the actual HTTP request keyword is what you want, like when +GET, HEAD or POST is not good enough for you, CURLOPT_CUSTOMREQUEST(3) +is there for you. It is simple to use: +~~~c +curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MYOWNREQUEST"); +~~~ +When using the custom request, you change the request keyword of the actual +request you are performing. Thus, by default you make a GET request but you +can also make a POST operation (as described before) and then replace the POST +keyword if you want to. You are the boss. + +## Modify Headers + +HTTP-like protocols pass a series of headers to the server when doing the +request, and you are free to pass any amount of extra headers that you +think fit. Adding headers is this easy: + +~~~c +struct curl_slist *headers=NULL; /* init to NULL is important */ + +headers = curl_slist_append(headers, "Hey-server-hey: how are you?"); +headers = curl_slist_append(headers, "X-silly-content: yes"); + +/* pass our list of custom made headers */ +curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); + +curl_easy_perform(handle); /* transfer http */ + +curl_slist_free_all(headers); /* free the header list */ +~~~ + +... and if you think some of the internally generated headers, such as Accept: +or Host: do not contain the data you want them to contain, you can replace +them by simply setting them too: + +~~~c +headers = curl_slist_append(headers, "Accept: Agent-007"); +headers = curl_slist_append(headers, "Host: munged.host.line"); +~~~ + +## Delete Headers + +If you replace an existing header with one with no contents, you prevent the +header from being sent. For instance, if you want to completely prevent the +"Accept:" header from being sent, you can disable it with code similar to +this: + + headers = curl_slist_append(headers, "Accept:"); + +Both replacing and canceling internal headers should be done with careful +consideration and you should be aware that you may violate the HTTP protocol +when doing so. + +## Enforcing chunked transfer-encoding + +By making sure a request uses the custom header "Transfer-Encoding: chunked" +when doing a non-GET HTTP operation, libcurl switches over to "chunked" +upload, even though the size of the data to upload might be known. By default, +libcurl usually switches over to chunked upload automatically if the upload +data size is unknown. + +## HTTP Version + +All HTTP requests includes the version number to tell the server which version +we support. libcurl speaks HTTP 1.1 by default. Some old servers do not like +getting 1.1-requests and when dealing with stubborn old things like that, you +can tell libcurl to use 1.0 instead by doing something like this: + + curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + +## FTP Custom Commands + +Not all protocols are HTTP-like, and thus the above may not help you when +you want to make, for example, your FTP transfers to behave differently. + +Sending custom commands to an FTP server means that you need to send the +commands exactly as the FTP server expects them (RFC 959 is a good guide +here), and you can only use commands that work on the control-connection +alone. All kinds of commands that require data interchange and thus need a +data-connection must be left to libcurl's own judgment. Also be aware that +libcurl does its best to change directory to the target directory before doing +any transfer, so if you change directory (with CWD or similar) you might +confuse libcurl and then it might not attempt to transfer the file in the +correct remote directory. + +A little example that deletes a given file before an operation: + +~~~c + headers = curl_slist_append(headers, "DELE file-to-remove"); + + /* pass the list of custom commands to the handle */ + curl_easy_setopt(handle, CURLOPT_QUOTE, headers); + + curl_easy_perform(handle); /* transfer ftp data! */ + + curl_slist_free_all(headers); /* free the header list */ +~~~ + +If you would instead want this operation (or chain of operations) to happen +_after_ the data transfer took place the option to curl_easy_setopt(3) +would instead be called CURLOPT_POSTQUOTE(3) and used the exact same +way. + +The custom FTP commands are issued to the server in the same order they are +added to the list, and if a command gets an error code returned back from the +server, no more commands are issued and libcurl bails out with an error code +(CURLE_QUOTE_ERROR). Note that if you use CURLOPT_QUOTE(3) to send +commands before a transfer, no transfer actually takes place when a quote +command has failed. + +If you set the CURLOPT_HEADER(3) to 1, you tell libcurl to get +information about the target file and output "headers" about it. The headers +are in "HTTP-style", looking like they do in HTTP. + +The option to enable headers or to run custom FTP commands may be useful to +combine with CURLOPT_NOBODY(3). If this option is set, no actual file +content transfer is performed. + +## FTP Custom CUSTOMREQUEST + +If you do want to list the contents of an FTP directory using your own defined +FTP command, CURLOPT_CUSTOMREQUEST(3) does just that. "NLST" is the +default one for listing directories but you are free to pass in your idea of a +good alternative. + +# Cookies Without Chocolate Chips + +In the HTTP sense, a cookie is a name with an associated value. A server sends +the name and value to the client, and expects it to get sent back on every +subsequent request to the server that matches the particular conditions +set. The conditions include that the domain name and path match and that the +cookie has not become too old. + +In real-world cases, servers send new cookies to replace existing ones to +update them. Server use cookies to "track" users and to keep "sessions". + +Cookies are sent from server to clients with the header Set-Cookie: and +they are sent from clients to servers with the Cookie: header. + +To just send whatever cookie you want to a server, you can use +CURLOPT_COOKIE(3) to set a cookie string like this: +~~~c + curl_easy_setopt(handle, CURLOPT_COOKIE, "name1=var1; name2=var2;"); +~~~ +In many cases, that is not enough. You might want to dynamically save +whatever cookies the remote server passes to you, and make sure those cookies +are then used accordingly on later requests. + +One way to do this, is to save all headers you receive in a plain file and +when you make a request, you tell libcurl to read the previous headers to +figure out which cookies to use. Set the header file to read cookies from with +CURLOPT_COOKIEFILE(3). + +The CURLOPT_COOKIEFILE(3) option also automatically enables the cookie +parser in libcurl. Until the cookie parser is enabled, libcurl does not parse +or understand incoming cookies and they are just be ignored. However, when the +parser is enabled the cookies are understood and the cookies are kept in +memory and used properly in subsequent requests when the same handle is +used. Many times this is enough, and you may not have to save the cookies to +disk at all. Note that the file you specify to CURLOPT_COOKIEFILE(3) +does not have to exist to enable the parser, so a common way to just enable +the parser and not read any cookies is to use the name of a file you know does +not exist. + +If you would rather use existing cookies that you have previously received +with your Netscape or Mozilla browsers, you can make libcurl use that cookie +file as input. The CURLOPT_COOKIEFILE(3) is used for that too, as +libcurl automatically finds out what kind of file it is and acts accordingly. + +Perhaps the most advanced cookie operation libcurl offers, is saving the +entire internal cookie state back into a Netscape/Mozilla formatted cookie +file. We call that the cookie-jar. When you set a filename with +CURLOPT_COOKIEJAR(3), that filename is created and all received cookies get +stored in it when curl_easy_cleanup(3) is called. This enables cookies to get +passed on properly between multiple handles without any information getting +lost. + +# FTP Peculiarities We Need + +FTP transfers use a second TCP/IP connection for the data transfer. This is +usually a fact you can forget and ignore but at times this detail comes back +to haunt you. libcurl offers several different ways to customize how the +second connection is being made. + +libcurl can either connect to the server a second time or tell the server to +connect back to it. The first option is the default and it is also what works +best for all the people behind firewalls, NATs or IP-masquerading setups. +libcurl then tells the server to open up a new port and wait for a second +connection. This is by default attempted with EPSV first, and if that does not +work it tries PASV instead. (EPSV is an extension to the original FTP spec +and does not exist nor work on all FTP servers.) + +You can prevent libcurl from first trying the EPSV command by setting +CURLOPT_FTP_USE_EPSV(3) to zero. + +In some cases, you want to have the server connect back to you for the second +connection. This might be when the server is perhaps behind a firewall or +something and only allows connections on a single port. libcurl then informs +the remote server which IP address and port number to connect to. This is made +with the CURLOPT_FTPPORT(3) option. If you set it to "-", libcurl uses your +system's "default IP address". If you want to use a particular IP, you can set +the full IP address, a hostname to resolve to an IP address or even a local +network interface name that libcurl gets the IP address from. + +When doing the "PORT" approach, libcurl attempts to use the EPRT and the LPRT +before trying PORT, as they work with more protocols. You can disable this +behavior by setting CURLOPT_FTP_USE_EPRT(3) to zero. + +# MIME API revisited for SMTP and IMAP + +In addition to support HTTP multi-part form fields, the MIME API can be used +to build structured email messages and send them via SMTP or append such +messages to IMAP directories. + +A structured email message may contain several parts: some are displayed +inline by the MUA, some are attachments. Parts can also be structured as +multi-part, for example to include another email message or to offer several +text formats alternatives. This can be nested to any level. + +To build such a message, you prepare the nth-level multi-part and then include +it as a source to the parent multi-part using function +curl_mime_subparts(3). Once it has been +bound to its parent multi-part, a nth-level multi-part belongs to it and +should not be freed explicitly. + +Email messages data is not supposed to be non-ascii and line length is +limited: fortunately, some transfer encodings are defined by the standards to +support the transmission of such incompatible data. Function +curl_mime_encoder(3) tells a part that its source data must be encoded +before being sent. It also generates the corresponding header for that part. +If the part data you want to send is already encoded in such a scheme, do not +use this function (this would over-encode it), but explicitly set the +corresponding part header. + +Upon sending such a message, libcurl prepends it with the header list +set with CURLOPT_HTTPHEADER(3), as zero level mime part headers. + +Here is an example building an email message with an inline plain/html text +alternative and a file attachment encoded in base64: + +~~~c + curl_mime *message = curl_mime_init(handle); + + /* The inline part is an alternative proposing the html and the text + versions of the email. */ + curl_mime *alt = curl_mime_init(handle); + + /* HTML message. */ + curl_mimepart *part = curl_mime_addpart(alt); + curl_mime_data(part, "

This is HTML

", + CURL_ZERO_TERMINATED); + curl_mime_type(part, "text/html"); + + /* Text message. */ + part = curl_mime_addpart(alt); + curl_mime_data(part, "This is plain text message", + CURL_ZERO_TERMINATED); + + /* Create the inline part. */ + part = curl_mime_addpart(message); + curl_mime_subparts(part, alt); + curl_mime_type(part, "multipart/alternative"); + struct curl_slist *headers = curl_slist_append(NULL, + "Content-Disposition: inline"); + curl_mime_headers(part, headers, TRUE); + + /* Add the attachment. */ + part = curl_mime_addpart(message); + curl_mime_filedata(part, "manual.pdf"); + curl_mime_encoder(part, "base64"); + + /* Build the mail headers. */ + headers = curl_slist_append(NULL, "From: me@example.com"); + headers = curl_slist_append(headers, "To: you@example.com"); + + /* Set these into the easy handle. */ + curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(handle, CURLOPT_MIMEPOST, mime); +~~~ + +It should be noted that appending a message to an IMAP directory requires +the message size to be known prior upload. It is therefore not possible to +include parts with unknown data size in this context. + +# Headers Equal Fun + +Some protocols provide "headers", meta-data separated from the normal +data. These headers are by default not included in the normal data stream, but +you can make them appear in the data stream by setting CURLOPT_HEADER(3) +to 1. + +What might be even more useful, is libcurl's ability to separate the headers +from the data and thus make the callbacks differ. You can for example set a +different pointer to pass to the ordinary write callback by setting +CURLOPT_HEADERDATA(3). + +Or, you can set an entirely separate function to receive the headers, by using +CURLOPT_HEADERFUNCTION(3). + +The headers are passed to the callback function one by one, and you can +depend on that fact. It makes it easier for you to add custom header parsers +etc. + +"Headers" for FTP transfers equal all the FTP server responses. They are not +actually true headers, but in this case we pretend they are! ;-) + +# Post Transfer Information + +See curl_easy_getinfo(3). + +# The multi Interface + +The easy interface as described in detail in this document is a synchronous +interface that transfers one file at a time and does not return until it is +done. + +The multi interface, on the other hand, allows your program to transfer +multiple files in both directions at the same time, without forcing you to use +multiple threads. The name might make it seem that the multi interface is for +multi-threaded programs, but the truth is almost the reverse. The multi +interface allows a single-threaded application to perform the same kinds of +multiple, simultaneous transfers that multi-threaded programs can perform. It +allows many of the benefits of multi-threaded transfers without the complexity +of managing and synchronizing many threads. + +To complicate matters somewhat more, there are even two versions of the multi +interface. The event based one, also called multi_socket and the "normal one" +designed for using with select(). See the libcurl-multi.3 man page for details +on the multi_socket event based API, this description here is for the select() +oriented one. + +To use this interface, you are better off if you first understand the basics +of how to use the easy interface. The multi interface is simply a way to make +multiple transfers at the same time by adding up multiple easy handles into +a "multi stack". + +You create the easy handles you want, one for each concurrent transfer, and +you set all the options just like you learned above, and then you create a +multi handle with curl_multi_init(3) and add all those easy handles to +that multi handle with curl_multi_add_handle(3). + +When you have added the handles you have for the moment (you can still add new +ones at any time), you start the transfers by calling +curl_multi_perform(3). + +curl_multi_perform(3) is asynchronous. It only performs what can be done +now and then return control to your program. It is designed to never +block. You need to keep calling the function until all transfers are +completed. + +The best usage of this interface is when you do a select() on all possible +file descriptors or sockets to know when to call libcurl again. This also +makes it easy for you to wait and respond to actions on your own application's +sockets/handles. You figure out what to select() for by using +curl_multi_fdset(3), that fills in a set of *fd_set* variables for +you with the particular file descriptors libcurl uses for the moment. + +When you then call select(), it returns when one of the file handles signal +action and you then call curl_multi_perform(3) to allow libcurl to do +what it wants to do. Take note that libcurl does also feature some time-out +code so we advise you to never use long timeouts on select() before you call +curl_multi_perform(3) again. curl_multi_timeout(3) is provided to +help you get a suitable timeout period. + +Another precaution you should use: always call curl_multi_fdset(3) +immediately before the select() call since the current set of file descriptors +may change in any curl function invoke. + +If you want to stop the transfer of one of the easy handles in the stack, you +can use curl_multi_remove_handle(3) to remove individual easy +handles. Remember that easy handles should be curl_easy_cleanup(3)ed. + +When a transfer within the multi stack has finished, the counter of running +transfers (as filled in by curl_multi_perform(3)) decreases. When the +number reaches zero, all transfers are done. + +curl_multi_info_read(3) can be used to get information about completed +transfers. It then returns the CURLcode for each easy transfer, to allow you +to figure out success on each individual transfer. + +# SSL, Certificates and Other Tricks + + [ seeding, passwords, keys, certificates, ENGINE, ca certs ] + +# Sharing Data Between Easy Handles + +You can share some data between easy handles when the easy interface is used, +and some data is share automatically when you use the multi interface. + +When you add easy handles to a multi handle, these easy handles automatically +share a lot of the data that otherwise would be kept on a per-easy handle +basis when the easy interface is used. + +The DNS cache is shared between handles within a multi handle, making +subsequent name resolving faster, and the connection pool that is kept to +better allow persistent connections and connection reuse is also shared. If +you are using the easy interface, you can still share these between specific +easy handles by using the share interface, see libcurl-share(3). + +Some things are never shared automatically, not within multi handles, like for +example cookies so the only way to share that is with the share interface. + +# Footnotes + +## [1] + +libcurl 7.10.3 and later have the ability to switch over to chunked +Transfer-Encoding in cases where HTTP uploads are done with data of an unknown +size. + +## [2] + +This happens on Windows machines when libcurl is built and used as a +DLL. However, you can still do this on Windows if you link with a static +library. + +## [3] + +The curl-config tool is generated at build-time (on Unix-like systems) and +should be installed with the 'make install' or similar instruction that +installs the library, header files, man pages etc. + +## [4] + +This behavior was different in versions before 7.17.0, where strings had to +remain valid past the end of the curl_easy_setopt(3) call. diff --git a/docs/libcurl/libcurl-url.3 b/docs/libcurl/libcurl-url.3 deleted file mode 100644 index fb96a1f03..000000000 --- a/docs/libcurl/libcurl-url.3 +++ /dev/null @@ -1,151 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH libcurl 3 "10 Sep 2018" "libcurl" "libcurl" -.SH NAME -libcurl-url \- URL interface overview -.SH DESCRIPTION -The URL interface provides functions for parsing and generating URLs. -.SH INCLUDE -You still only include in your code. -.SH CREATE -Create a handle that holds URL info and resources with \fIcurl_url(3)\fP: -.nf - CURLU *h = curl_url(); -.fi -.SH CLEANUP -When done with it, clean it up with \fIcurl_url_cleanup(3)\fP -.nf - curl_url_cleanup(h); -.fi -.SH DUPLICATE -When you need a copy of a handle, just duplicate it with \fIcurl_url_dup(3)\fP: -.nf - CURLU *nh = curl_url_dup(h); -.fi -.SH PARSING -By setting a URL to the handle with \fIcurl_url_set(3)\fP, the URL is parsed -and stored in the handle. If the URL is not syntactically correct it returns -an error instead. -.nf - rc = curl_url_set(h, CURLUPART_URL, - "https://example.com:449/foo/bar?name=moo", 0); -.fi - -The zero in the fourth argument is a bitmask for changing specific features. - -If successful, this stores the URL in its individual parts within the handle. -.SH REDIRECT -When a handle already contains info about a URL, setting a relative URL makes -it "redirect" to that. -.nf - rc = curl_url_set(h, CURLUPART_URL, "../test?another", 0); -.fi -.SH "GET URL" -The \fBCURLU\fP handle represents a URL and you can easily extract that with -\fIcurl_url_get(3)\fP: -.nf - char *url; - rc = curl_url_get(h, CURLUPART_URL, &url, 0); - curl_free(url); -.fi -The zero in the fourth argument is a bitmask for changing specific features. -.SH "GET PARTS" -When a URL has been parsed or parts have been set, you can extract those -pieces from the handle at any time. - -.nf - rc = curl_url_get(h, CURLUPART_FRAGMENT, &fragment, 0); - rc = curl_url_get(h, CURLUPART_HOST, &host, 0); - rc = curl_url_get(h, CURLUPART_PASSWORD, &password, 0); - rc = curl_url_get(h, CURLUPART_PATH, &path, 0); - rc = curl_url_get(h, CURLUPART_PORT, &port, 0); - rc = curl_url_get(h, CURLUPART_QUERY, &query, 0); - rc = curl_url_get(h, CURLUPART_SCHEME, &scheme, 0); - rc = curl_url_get(h, CURLUPART_USER, &user, 0); - rc = curl_url_get(h, CURLUPART_ZONEID, &zoneid, 0); -.fi - -Extracted parts are not URL decoded unless the user also asks for it with the -\fICURLU_URLDECODE\fP flag set in the fourth bitmask argument. - -Remember to free the returned string with \fIcurl_free(3)\fP when you are done -with it! -.SH "SET PARTS" -A user set individual URL parts, either after having parsed a full URL or -instead of parsing such. - -.nf - rc = curl_url_set(urlp, CURLUPART_FRAGMENT, "anchor", 0); - rc = curl_url_set(urlp, CURLUPART_HOST, "www.example.com", 0); - rc = curl_url_set(urlp, CURLUPART_PASSWORD, "doe", 0); - rc = curl_url_set(urlp, CURLUPART_PATH, "/index.html", 0); - rc = curl_url_set(urlp, CURLUPART_PORT, "443", 0); - rc = curl_url_set(urlp, CURLUPART_QUERY, "name=john", 0); - rc = curl_url_set(urlp, CURLUPART_SCHEME, "https", 0); - rc = curl_url_set(urlp, CURLUPART_USER, "john", 0); - rc = curl_url_set(urlp, CURLUPART_ZONEID, "eth0", 0); -.fi - -Set parts are not URL encoded unless the user asks for it with the -\fICURLU_URLENCODE\fP flag. -.SH "CURLU_APPENDQUERY" -An application can append a string to the right end of the query part with the -\fICURLU_APPENDQUERY\fP flag to \fIcurl_url_set(3)\fP. - -Imagine a handle that holds the URL "https://example.com/?shoes=2". An -application can then add the string "hat=1" to the query part like this: - -.nf - rc = curl_url_set(urlp, CURLUPART_QUERY, "hat=1", CURLU_APPENDQUERY); -.fi - -It notices the lack of an ampersand (&) separator and injects one, and the -handle's full URL then equals "https://example.com/?shoes=2&hat=1". - -The appended string can of course also get URL encoded on add, and if asked to -URL encode, the encoding process skips the '=' character. For example, append -"candy=N&N" to what we already have, and URL encode it to deal with the -ampersand in the data: -.nf - rc = curl_url_set(urlp, CURLUPART_QUERY, "candy=N&N", - CURLU_APPENDQUERY | CURLU_URLENCODE); -.fi - -Now the URL looks like -.nf - https://example.com/?shoes=2&hat=1&candy=N%26N -.fi -.SH AVAILABILITY -The URL API was introduced in libcurl 7.62.0. - -A URL with a literal IPv6 address can be parsed even when IPv6 support is not -enabled. -.SH "SEE ALSO" -.BR curl_url (3), -.BR curl_url_cleanup (3), -.BR curl_url_dup (3), -.BR curl_url_get (3), -.BR curl_url_set (3), -.BR curl_url_strerror (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/libcurl-url.md b/docs/libcurl/libcurl-url.md new file mode 100644 index 000000000..a2948001a --- /dev/null +++ b/docs/libcurl/libcurl-url.md @@ -0,0 +1,162 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl +Section: 3 +Source: libcurl +See-also: + - CURLOPT_URL (3) + - curl_url (3) + - curl_url_cleanup (3) + - curl_url_dup (3) + - curl_url_get (3) + - curl_url_set (3) + - curl_url_strerror (3) +--- + +# NAME + +libcurl-url - URL interface overview + +# DESCRIPTION + +The URL interface provides functions for parsing and generating URLs. + +# INCLUDE + +You still only include in your code. + +# CREATE + +Create a handle that holds URL info and resources with curl_url(3): +~~~c + CURLU *h = curl_url(); +~~~ + +# CLEANUP + +When done with it, clean it up with curl_url_cleanup(3) +~~~c + curl_url_cleanup(h); +~~~ + +# DUPLICATE + +When you need a copy of a handle, just duplicate it with curl_url_dup(3): +~~~c + CURLU *nh = curl_url_dup(h); +~~~ + +# PARSING + +By setting a URL to the handle with curl_url_set(3), the URL is parsed +and stored in the handle. If the URL is not syntactically correct it returns +an error instead. +~~~c + rc = curl_url_set(h, CURLUPART_URL, + "https://example.com:449/foo/bar?name=moo", 0); +~~~ + +The zero in the fourth argument is a bitmask for changing specific features. + +If successful, this stores the URL in its individual parts within the handle. + +# REDIRECT + +When a handle already contains info about a URL, setting a relative URL makes +it "redirect" to that. +~~~c + rc = curl_url_set(h, CURLUPART_URL, "../test?another", 0); +~~~ + +# GET URL + +The **CURLU** handle represents a URL and you can easily extract that with +curl_url_get(3): +~~~c + char *url; + rc = curl_url_get(h, CURLUPART_URL, &url, 0); + curl_free(url); +~~~ +The zero in the fourth argument is a bitmask for changing specific features. + +# GET PARTS + +When a URL has been parsed or parts have been set, you can extract those +pieces from the handle at any time. + +~~~c + rc = curl_url_get(h, CURLUPART_FRAGMENT, &fragment, 0); + rc = curl_url_get(h, CURLUPART_HOST, &host, 0); + rc = curl_url_get(h, CURLUPART_PASSWORD, &password, 0); + rc = curl_url_get(h, CURLUPART_PATH, &path, 0); + rc = curl_url_get(h, CURLUPART_PORT, &port, 0); + rc = curl_url_get(h, CURLUPART_QUERY, &query, 0); + rc = curl_url_get(h, CURLUPART_SCHEME, &scheme, 0); + rc = curl_url_get(h, CURLUPART_USER, &user, 0); + rc = curl_url_get(h, CURLUPART_ZONEID, &zoneid, 0); +~~~ + +Extracted parts are not URL decoded unless the user also asks for it with the +*CURLU_URLDECODE* flag set in the fourth bitmask argument. + +Remember to free the returned string with curl_free(3) when you are done +with it! + +# SET PARTS + +A user set individual URL parts, either after having parsed a full URL or +instead of parsing such. + +~~~c + rc = curl_url_set(urlp, CURLUPART_FRAGMENT, "anchor", 0); + rc = curl_url_set(urlp, CURLUPART_HOST, "www.example.com", 0); + rc = curl_url_set(urlp, CURLUPART_PASSWORD, "doe", 0); + rc = curl_url_set(urlp, CURLUPART_PATH, "/index.html", 0); + rc = curl_url_set(urlp, CURLUPART_PORT, "443", 0); + rc = curl_url_set(urlp, CURLUPART_QUERY, "name=john", 0); + rc = curl_url_set(urlp, CURLUPART_SCHEME, "https", 0); + rc = curl_url_set(urlp, CURLUPART_USER, "john", 0); + rc = curl_url_set(urlp, CURLUPART_ZONEID, "eth0", 0); +~~~ + +Set parts are not URL encoded unless the user asks for it with the +*CURLU_URLENCODE* flag. + +# CURLU_APPENDQUERY + +An application can append a string to the right end of the query part with the +*CURLU_APPENDQUERY* flag to curl_url_set(3). + +Imagine a handle that holds the URL "https://example.com/?shoes=2". An +application can then add the string "hat=1" to the query part like this: + +~~~c + rc = curl_url_set(urlp, CURLUPART_QUERY, "hat=1", CURLU_APPENDQUERY); +~~~ + +It notices the lack of an ampersand (&) separator and injects one, and the +handle's full URL then equals "https://example.com/?shoes=2&hat=1". + +The appended string can of course also get URL encoded on add, and if asked to +URL encode, the encoding process skips the '=' character. For example, append +"candy=N&N" to what we already have, and URL encode it to deal with the +ampersand in the data: + +~~~c + rc = curl_url_set(urlp, CURLUPART_QUERY, "candy=N&N", + CURLU_APPENDQUERY | CURLU_URLENCODE); +~~~ + +Now the URL looks like + +~~~c + https://example.com/?shoes=2&hat=1&candy=N%26N +~~~ + +# AVAILABILITY + +The URL API was introduced in libcurl 7.62.0. + +A URL with a literal IPv6 address can be parsed even when IPv6 support is not +enabled. diff --git a/docs/libcurl/libcurl-ws.3 b/docs/libcurl/libcurl-ws.3 deleted file mode 100644 index 2a96b8bc4..000000000 --- a/docs/libcurl/libcurl-ws.3 +++ /dev/null @@ -1,118 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH libcurl 3 "10 Sep 2018" "libcurl" "libcurl" -.SH NAME -libcurl-ws \- WebSocket interface overview -.SH DESCRIPTION -The WebSocket interface provides functions for receiving and sending WebSocket -data. -.SH INCLUDE -You still only include in your code. -.SH SETUP -WebSocket is also often known as \fIWebSockets\fP, in plural. It is done by -upgrading a regular HTTP(S) GET request to a WebSocket connection. - -WebSocket is a TCP-like message-based communication protocol done over HTTP, -specified in RFC 6455. - -To initiate a WebSocket session with libcurl, setup an easy handle to use a -URL with a "WS://" or "WSS://" scheme. "WS" is for cleartext communication -over HTTP and "WSS" is for doing WebSocket securely over HTTPS. - -A WebSocket request is done as an HTTP/1 GET request with an "Upgrade -WebSocket" request header field. When the upgrade is accepted by the server, -it responds with a 101 Switching and then the client can speak WebSocket with -the server. The communication can happen in both directions at the same time. -.SH MESSAGES -WebSocket communication is message based. That means that both ends send and -receive entire messages, not streams like TCP. A WebSocket message is sent -over the wire in one or more frames. Each frame in a message can have a size -up to 2^63 bytes. - -libcurl delivers WebSocket data as frame fragments. It might send a whole -frame, but it might also deliver them in pieces depending on size and network -patterns. It makes sure to provide the API user about the exact specifics -about the fragment: type, offset, size and how much data there is pending to -arrive for the same frame. - -A message has an unknown size until the last frame header for the message has -been received since only frames have set sizes. -.SH "Raw mode" -libcurl can be told to speak WebSocket in "raw mode" by setting the -\fBCURLWS_RAW_MODE\fP bit to the \fICURLOPT_WS_OPTIONS(3)\fP option. - -Raw WebSocket means that libcurl passes on the data from the network without -parsing it leaving that entirely to the application. This mode assumes that -the user of this knows WebSocket and can parse and figure out the data all by -itself. - -This mode is intended for applications that already have a WebSocket -parser/engine that want to switch over to use libcurl for enabling WebSocket, -but keep parts of the existing software architecture. -.SH PING -WebSocket is designed to allow long-lived sessions and in order to keep the -connections alive, both ends can send PING messages for the other end to -respond with a PONG. - -libcurl automatically responds to server PING messages with a PONG. It does -not send any PING messages automatically. -.SH MODELS -Because of the many different ways WebSocket can be used, which is much more -flexible than limited to plain downloads or uploads, libcurl offers two -different API models to use it: - -1. Using a write callback with \fICURLOPT_WRITEFUNCTION(3)\fP much like other -downloads for when the traffic is download oriented. - -2. Using \fICURLOPT_CONNECT_ONLY(3)\fP and use the WebSocket recv/send -functions. -.SH "Callback model" -When a write callback is set and a WebSocket transfer is performed, the -callback is called to deliver all WebSocket data that arrives. - -The callback can then call \fIcurl_ws_meta(3)\fP to learn about the details of -the incoming data fragment. -.SH "CONNECT_ONLY model" -By setting \fICURLOPT_CONNECT_ONLY(3)\fP to \fB2L\fP, the transfer only -establishes and setups the WebSocket communication and then returns control -back to the application. - -Once such a setup has been successfully performed, the application can proceed -and use \fIcurl_ws_recv(3)\fP and \fIcurl_ws_send(3)\fP freely to exchange -WebSocket messages with the server. -.SH AVAILABILITY -The WebSocket API was introduced as experimental in 7.86.0 and is still -experimental today. - -It is only built-in if explicitly opted in at build time. We discourage use of -the WebSocket API in production because of its experimental state. We might -change API, ABI and behavior before this "goes live". -.SH "SEE ALSO" -.BR curl_easy_init (3), -.BR curl_ws_meta (3), -.BR curl_ws_recv (3), -.BR curl_ws_send (3), -.BR CURLOPT_CONNECT_ONLY (3), -.BR CURLOPT_WRITEFUNCTION (3), -.BR CURLOPT_WS_OPTIONS (3) diff --git a/docs/libcurl/libcurl-ws.md b/docs/libcurl/libcurl-ws.md new file mode 100644 index 000000000..40f7c039c --- /dev/null +++ b/docs/libcurl/libcurl-ws.md @@ -0,0 +1,123 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECT_ONLY (3) + - CURLOPT_WRITEFUNCTION (3) + - CURLOPT_WS_OPTIONS (3) + - curl_easy_init (3) + - curl_ws_meta (3) + - curl_ws_recv (3) + - curl_ws_send (3) +--- + +# NAME + +libcurl-ws - WebSocket interface overview + +# DESCRIPTION + +The WebSocket interface provides functions for receiving and sending WebSocket +data. + +# INCLUDE + +You still only include in your code. + +# SETUP + +WebSocket is also often known as *WebSockets*, in plural. It is done by +upgrading a regular HTTP(S) GET request to a WebSocket connection. + +WebSocket is a TCP-like message-based communication protocol done over HTTP, +specified in RFC 6455. + +To initiate a WebSocket session with libcurl, setup an easy handle to use a +URL with a "WS://" or "WSS://" scheme. "WS" is for cleartext communication +over HTTP and "WSS" is for doing WebSocket securely over HTTPS. + +A WebSocket request is done as an HTTP/1 GET request with an "Upgrade +WebSocket" request header field. When the upgrade is accepted by the server, +it responds with a 101 Switching and then the client can speak WebSocket with +the server. The communication can happen in both directions at the same time. + +# MESSAGES + +WebSocket communication is message based. That means that both ends send and +receive entire messages, not streams like TCP. A WebSocket message is sent +over the wire in one or more frames. Each frame in a message can have a size +up to 2^63 bytes. + +libcurl delivers WebSocket data as frame fragments. It might send a whole +frame, but it might also deliver them in pieces depending on size and network +patterns. It makes sure to provide the API user about the exact specifics +about the fragment: type, offset, size and how much data there is pending to +arrive for the same frame. + +A message has an unknown size until the last frame header for the message has +been received since only frames have set sizes. + +# Raw mode + +libcurl can be told to speak WebSocket in "raw mode" by setting the +**CURLWS_RAW_MODE** bit to the CURLOPT_WS_OPTIONS(3) option. + +Raw WebSocket means that libcurl passes on the data from the network without +parsing it leaving that entirely to the application. This mode assumes that +the user of this knows WebSocket and can parse and figure out the data all by +itself. + +This mode is intended for applications that already have a WebSocket +parser/engine that want to switch over to use libcurl for enabling WebSocket, +and keep parts of the existing software architecture. + +# PING + +WebSocket is designed to allow long-lived sessions and in order to keep the +connections alive, both ends can send PING messages for the other end to +respond with a PONG. + +libcurl automatically responds to server PING messages with a PONG. It does +not send any PING messages automatically. + +# MODELS + +Because of the many different ways WebSocket can be used, which is much more +flexible than limited to plain downloads or uploads, libcurl offers two +different API models to use it: + +1. Using a write callback with CURLOPT_WRITEFUNCTION(3) much like other +downloads for when the traffic is download oriented. + +2. Using CURLOPT_CONNECT_ONLY(3) and use the WebSocket recv/send +functions. + +# Callback model + +When a write callback is set and a WebSocket transfer is performed, the +callback is called to deliver all WebSocket data that arrives. + +The callback can then call curl_ws_meta(3) to learn about the details of +the incoming data fragment. + +# CONNECT_ONLY model + +By setting CURLOPT_CONNECT_ONLY(3) to **2L**, the transfer only +establishes and setups the WebSocket communication and then returns control +back to the application. + +Once such a setup has been successfully performed, the application can proceed +and use curl_ws_recv(3) and curl_ws_send(3) freely to exchange +WebSocket messages with the server. + +# AVAILABILITY + +The WebSocket API was introduced as experimental in 7.86.0 and is still +experimental today. + +It is only built-in if explicitly opted in at build time. We discourage use of +the WebSocket API in production because of its experimental state. We might +change API, ABI and behavior before this "goes live". diff --git a/docs/libcurl/libcurl.3 b/docs/libcurl/libcurl.3 deleted file mode 100644 index dd4163a7e..000000000 --- a/docs/libcurl/libcurl.3 +++ /dev/null @@ -1,228 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH libcurl 3 "March 19, 2002" "libcurl" "libcurl" -.SH NAME -libcurl \- client-side URL transfers -.SH DESCRIPTION -This is a short overview on how to use libcurl in your C programs. There are -specific man pages for each function mentioned in here. See -\fIlibcurl-easy(3)\fP, \fIlibcurl-multi(3)\fP, \fIlibcurl-share(3)\fP, -\fIlibcurl-url(3)\fP, \fIlibcurl-ws(3)\fP and \fIlibcurl-tutorial(3)\fP for -in-depth understanding on how to program with libcurl. - -There are many bindings available that bring libcurl access to your favorite -language. Look elsewhere for documentation on those. -.SH TRANSFERS -To transfer files, you create an "easy handle" using \fIcurl_easy_init(3)\fP -for a single individual transfer (in either direction). You then set your -desired set of options in that handle with \fIcurl_easy_setopt(3)\fP. Options -you set with \fIcurl_easy_setopt(3)\fP stick. They are then used for every -repeated use of this handle until you either change the option, or you reset -them all with \fIcurl_easy_reset(3)\fP. - -To actually transfer data you have the option of using the "easy" interface, -or the "multi" interface. - -The easy interface is a synchronous interface with which you call -\fIcurl_easy_perform(3)\fP and let it perform the transfer. When it is -completed, the function returns and you can continue. More details are found in -the \fIlibcurl-easy(3)\fP man page. - -The multi interface on the other hand is an asynchronous interface, that you -call and that performs only a little piece of the transfer on each invoke. It -is perfect if you want to do things while the transfer is in progress, or -similar. The multi interface allows you to select() on libcurl action, and -even to easily download multiple files simultaneously using a single -thread. See further details in the \fIlibcurl-multi(3)\fP man page. - -.SH "SUPPORT INTERFACES" -There is also a series of other helpful functions and interface families to -use, including these: -.RS -.IP curl_version_info() -gets detailed libcurl (and other used libraries) version info. See -\fIcurl_version_info(3)\fP -.IP curl_getdate() -converts a date string to time_t. See \fIcurl_getdate(3)\fP -.IP curl_easy_getinfo() -get information about a performed transfer. See \fIcurl_easy_getinfo(3)\fP -.IP curl_mime_addpart() -helps building an HTTP form POST. See \fIcurl_mime_addpart(3)\fP -.IP curl_slist_append() -builds a linked list. See \fIcurl_slist_append(3)\fP -.IP "Sharing data between transfers" -You can have multiple easy handles share certain data, even if they are used -in different threads. This magic is setup using the share interface, as -described in the \fIlibcurl-share(3)\fP man page. -.IP "URL Parsing" -URL parsing and manipulations. See \fIlibcurl-url(3)\fP -.IP "WebSocket communication" -See \fIlibcurl-ws(3)\fP -.RE - -.SH "LINKING WITH LIBCURL" -On unix-like machines, there is a tool named curl-config that gets installed -with the rest of the curl stuff when 'make install' is performed. - -curl-config is added to make it easier for applications to link with libcurl -and developers to learn about libcurl and how to use it. - -Run 'curl-config --libs' to get the (additional) linker options you need to -link with the particular version of libcurl you have installed. See the -\fIcurl-config(1)\fP man page for further details. - -Unix-like operating system that ship libcurl as part of their distributions -often do not provide the curl-config tool, but simply install the library and -headers in the common path for this purpose. - -Many Linux and similar systems use pkg-config to provide build and link -options about libraries and libcurl supports that as well. -.SH "LIBCURL SYMBOL NAMES" -All public functions in the libcurl interface are prefixed with 'curl_' (with -a lowercase c). You can find other functions in the library source code, but -other prefixes indicate that the functions are private and may change without -further notice in the next release. - -Only use documented functions and functionality! -.SH "PORTABILITY" -libcurl works -.B exactly -the same, on any of the platforms it compiles and builds on. -.SH "THREADS" -libcurl is thread safe but there are a few exceptions. Refer to -\fIlibcurl-thread(3)\fP for more information. - -.SH "PERSISTENT CONNECTIONS" -Persistent connections means that libcurl can reuse the same connection for -several transfers, if the conditions are right. - -libcurl always attempts to use persistent connections. Whenever you use -\fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP etc, libcurl -attempts to use an existing connection to do the transfer, and if none exists -it opens a new one that is subject for reuse on a possible following call to -\fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP. - -To allow libcurl to take full advantage of persistent connections, you should -do as many of your file transfers as possible using the same handle. - -If you use the easy interface, and you call \fIcurl_easy_cleanup(3)\fP, all -the possibly open connections held by libcurl are closed and forgotten. - -When you have created a multi handle and are using the multi interface, the -connection pool is instead kept in the multi handle so closing and creating -new easy handles to do transfers do not affect them. Instead all added easy -handles can take advantage of the single shared pool. -.SH "GLOBAL CONSTANTS" -There are a variety of constants that libcurl uses, mainly through its -internal use of other libraries, which are too complicated for the -library loader to set up. Therefore, a program must call a library -function after the program is loaded and running to finish setting up -the library code. For example, when libcurl is built for SSL -capability via the GNU TLS library, there is an elaborate tree inside -that library that describes the SSL protocol. - -\fIcurl_global_init(3)\fP is the function that you must call. This may -allocate resources (e.g. the memory for the GNU TLS tree mentioned above), so -the companion function \fIcurl_global_cleanup(3)\fP releases them. - -If libcurl was compiled with support for multiple SSL backends, the function -\fIcurl_global_sslset(3)\fP can be called before \fIcurl_global_init(3)\fP -to select the active SSL backend. - -The global constant functions are thread-safe since libcurl 7.84.0 if -\fIcurl_version_info(3)\fP has the CURL_VERSION_THREADSAFE feature bit set -(most platforms). Read \fIlibcurl-thread(3)\fP for thread safety guidelines. - -If the global constant functions are \fInot thread safe\fP, then you must -not call them when any other thread in the program is running. It -is not good enough that no other thread is using libcurl at the time, -because these functions internally call similar functions of other -libraries, and those functions are similarly thread-unsafe. You cannot -generally know what these libraries are, or whether other threads are -using them. - -If the global constant functions are \fInot thread safe\fP, then the basic rule -for constructing a program that uses libcurl is this: Call -\fIcurl_global_init(3)\fP, with a \fICURL_GLOBAL_ALL\fP argument, immediately -after the program starts, while it is still only one thread and before it uses -libcurl at all. Call \fIcurl_global_cleanup(3)\fP immediately before the -program exits, when the program is again only one thread and after its last -use of libcurl. - -It is not actually required that the functions be called at the beginning -and end of the program -- that is just usually the easiest way to do it. - -You can call both of these multiple times, as long as all calls meet -these requirements and the number of calls to each is the same. - -The global constant situation merits special consideration when the -code you are writing to use libcurl is not the main program, but rather -a modular piece of a program, e.g. another library. As a module, -your code does not know about other parts of the program -- it does not -know whether they use libcurl or not. And its code does not necessarily -run at the start and end of the whole program. - -A module like this must have global constant functions of its own, just like -\fIcurl_global_init(3)\fP and \fIcurl_global_cleanup(3)\fP. The module thus -has control at the beginning and end of the program and has a place to call -the libcurl functions. If multiple modules in the program use libcurl, they -all separately call the libcurl functions, and that is OK because only the -first \fIcurl_global_init(3)\fP and the last \fIcurl_global_cleanup(3)\fP in a -program change anything. (libcurl uses a reference count in static memory). - -In a C++ module, it is common to deal with the global constant situation by -defining a special class that represents the global constant environment of -the module. A program always has exactly one object of the class, in static -storage. That way, the program automatically calls the constructor of the -object as the program starts up and the destructor as it terminates. As the -author of this libcurl-using module, you can make the constructor call -\fIcurl_global_init(3)\fP and the destructor call \fIcurl_global_cleanup(3)\fP -and satisfy libcurl's requirements without your user having to think about it. -(Caveat: If you are initializing libcurl from a Windows DLL you should not -initialize it from \fIDllMain\fP or a static initializer because Windows holds -the loader lock during that time and it could cause a deadlock.) - -\fIcurl_global_init(3)\fP has an argument that tells what particular parts of -the global constant environment to set up. In order to successfully use any -value except \fICURL_GLOBAL_ALL\fP (which says to set up the whole thing), you -must have specific knowledge of internal workings of libcurl and all other -parts of the program of which it is part. - -A special part of the global constant environment is the identity of the -memory allocator. \fIcurl_global_init(3)\fP selects the system default memory -allocator, but you can use \fIcurl_global_init_mem(3)\fP to supply one of your -own. However, there is no way to use \fIcurl_global_init_mem(3)\fP in a -modular program -- all modules in the program that might use libcurl would -have to agree on one allocator. - -There is a failsafe in libcurl that makes it usable in simple situations -without you having to worry about the global constant environment at all: -\fIcurl_easy_init(3)\fP sets up the environment itself if it has not been done -yet. The resources it acquires to do so get released by the operating system -automatically when the program exits. - -This failsafe feature exists mainly for backward compatibility because there -was a time when the global functions did not exist. Because it is sufficient -only in the simplest of programs, it is not recommended for any program to -rely on it. diff --git a/docs/libcurl/libcurl.md b/docs/libcurl/libcurl.md new file mode 100644 index 000000000..1f7c97eaa --- /dev/null +++ b/docs/libcurl/libcurl.md @@ -0,0 +1,247 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl +Section: 3 +Source: libcurl +See-also: + - libcurl-easy (3) + - libcurl-multi (3) + - libcurl-security (3) + - libcurl-thread (3) +--- + +# NAME + +libcurl - client-side URL transfers + +# DESCRIPTION + +This is a short overview on how to use libcurl in your C programs. There are +specific man pages for each function mentioned in here. See +libcurl-easy(3), libcurl-multi(3), libcurl-share(3), +libcurl-url(3), libcurl-ws(3) and libcurl-tutorial(3) for +in-depth understanding on how to program with libcurl. + +There are many bindings available that bring libcurl access to your favorite +language. Look elsewhere for documentation on those. + +# TRANSFERS + +To transfer files, you create an "easy handle" using curl_easy_init(3) +for a single individual transfer (in either direction). You then set your +desired set of options in that handle with curl_easy_setopt(3). Options +you set with curl_easy_setopt(3) stick. They are then used for every +repeated use of this handle until you either change the option, or you reset +them all with curl_easy_reset(3). + +To actually transfer data you have the option of using the "easy" interface, +or the "multi" interface. + +The easy interface is a synchronous interface with which you call +curl_easy_perform(3) and let it perform the transfer. When it is +completed, the function returns and you can continue. More details are found in +the libcurl-easy(3) man page. + +The multi interface on the other hand is an asynchronous interface, that you +call and that performs only a little piece of the transfer on each invoke. It +is perfect if you want to do things while the transfer is in progress, or +similar. The multi interface allows you to select() on libcurl action, and +even to easily download multiple files simultaneously using a single +thread. See further details in the libcurl-multi(3) man page. + +# SUPPORT INTERFACES + +There is also a series of other helpful functions and interface families to +use, including these: + +## curl_version_info() + +gets detailed libcurl (and other used libraries) version info. See +curl_version_info(3) + +## curl_getdate() + +converts a date string to time_t. See curl_getdate(3) + +## curl_easy_getinfo() + +get information about a performed transfer. See curl_easy_getinfo(3) + +## curl_mime_addpart() + +helps building an HTTP form POST. See curl_mime_addpart(3) + +## curl_slist_append() + +builds a linked list. See curl_slist_append(3) + +## Sharing data between transfers + +You can have multiple easy handles share certain data, even if they are used +in different threads. This magic is setup using the share interface, as +described in the libcurl-share(3) man page. + +## URL Parsing + +URL parsing and manipulations. See libcurl-url(3) + +## WebSocket communication + +See libcurl-ws(3) + +# LINKING WITH LIBCURL + +On unix-like machines, there is a tool named curl-config that gets installed +with the rest of the curl stuff when 'make install' is performed. + +curl-config is added to make it easier for applications to link with libcurl +and developers to learn about libcurl and how to use it. + +Run 'curl-config --libs' to get the (additional) linker options you need to +link with the particular version of libcurl you have installed. See the +*curl-config(1)* man page for further details. + +Unix-like operating system that ship libcurl as part of their distributions +often do not provide the curl-config tool, but simply install the library and +headers in the common path for this purpose. + +Many Linux and similar systems use pkg-config to provide build and link +options about libraries and libcurl supports that as well. + +# LIBCURL SYMBOL NAMES + +All public functions in the libcurl interface are prefixed with 'curl_' (with +a lowercase c). You can find other functions in the library source code, but +other prefixes indicate that the functions are private and may change without +further notice in the next release. + +Only use documented functions and functionality! + +# PORTABILITY + +libcurl works +**exactly** +the same, on any of the platforms it compiles and builds on. + +# THREADS + +libcurl is thread safe but there are a few exceptions. Refer to +libcurl-thread(3) for more information. + +# PERSISTENT CONNECTIONS + +Persistent connections means that libcurl can reuse the same connection for +several transfers, if the conditions are right. + +libcurl always attempts to use persistent connections. Whenever you use +curl_easy_perform(3) or curl_multi_perform(3) etc, libcurl +attempts to use an existing connection to do the transfer, and if none exists +it opens a new one that is subject for reuse on a possible following call to +curl_easy_perform(3) or curl_multi_perform(3). + +To allow libcurl to take full advantage of persistent connections, you should +do as many of your file transfers as possible using the same handle. + +If you use the easy interface, and you call curl_easy_cleanup(3), all +the possibly open connections held by libcurl are closed and forgotten. + +When you have created a multi handle and are using the multi interface, the +connection pool is instead kept in the multi handle so closing and creating +new easy handles to do transfers do not affect them. Instead all added easy +handles can take advantage of the single shared pool. + +# GLOBAL CONSTANTS + +There are a variety of constants that libcurl uses, mainly through its +internal use of other libraries, which are too complicated for the +library loader to set up. Therefore, a program must call a library +function after the program is loaded and running to finish setting up +the library code. For example, when libcurl is built for SSL +capability via the GNU TLS library, there is an elaborate tree inside +that library that describes the SSL protocol. + +curl_global_init(3) is the function that you must call. This may +allocate resources (e.g. the memory for the GNU TLS tree mentioned above), so +the companion function curl_global_cleanup(3) releases them. + +If libcurl was compiled with support for multiple SSL backends, the function +curl_global_sslset(3) can be called before curl_global_init(3) +to select the active SSL backend. + +The global constant functions are thread-safe since libcurl 7.84.0 if +curl_version_info(3) has the CURL_VERSION_THREADSAFE feature bit set +(most platforms). Read libcurl-thread(3) for thread safety guidelines. + +If the global constant functions are *not thread safe*, then you must +not call them when any other thread in the program is running. It +is not good enough that no other thread is using libcurl at the time, +because these functions internally call similar functions of other +libraries, and those functions are similarly thread-unsafe. You cannot +generally know what these libraries are, or whether other threads are +using them. + +If the global constant functions are *not thread safe*, then the basic rule +for constructing a program that uses libcurl is this: Call +curl_global_init(3), with a *CURL_GLOBAL_ALL* argument, immediately +after the program starts, while it is still only one thread and before it uses +libcurl at all. Call curl_global_cleanup(3) immediately before the +program exits, when the program is again only one thread and after its last +use of libcurl. + +It is not actually required that the functions be called at the beginning +and end of the program -- that is just usually the easiest way to do it. + +You can call both of these multiple times, as long as all calls meet +these requirements and the number of calls to each is the same. + +The global constant situation merits special consideration when the code you +are writing to use libcurl is not the main program, but rather a modular piece +of a program, e.g. another library. As a module, your code does not know about +other parts of the program -- it does not know whether they use libcurl or +not. Its code does not necessarily run at the start and end of the whole +program. + +A module like this must have global constant functions of its own, just like +curl_global_init(3) and curl_global_cleanup(3). The module thus +has control at the beginning and end of the program and has a place to call +the libcurl functions. If multiple modules in the program use libcurl, they +all separately call the libcurl functions, and that is OK because only the +first curl_global_init(3) and the last curl_global_cleanup(3) in a +program change anything. (libcurl uses a reference count in static memory). + +In a C++ module, it is common to deal with the global constant situation by +defining a special class that represents the global constant environment of +the module. A program always has exactly one object of the class, in static +storage. That way, the program automatically calls the constructor of the +object as the program starts up and the destructor as it terminates. As the +author of this libcurl-using module, you can make the constructor call +curl_global_init(3) and the destructor call curl_global_cleanup(3) +and satisfy libcurl's requirements without your user having to think about it. +(Caveat: If you are initializing libcurl from a Windows DLL you should not +initialize it from *DllMain* or a static initializer because Windows holds +the loader lock during that time and it could cause a deadlock.) + +curl_global_init(3) has an argument that tells what particular parts of +the global constant environment to set up. In order to successfully use any +value except *CURL_GLOBAL_ALL* (which says to set up the whole thing), you +must have specific knowledge of internal workings of libcurl and all other +parts of the program of which it is part. + +A special part of the global constant environment is the identity of the +memory allocator. curl_global_init(3) selects the system default memory +allocator, but you can use curl_global_init_mem(3) to supply one of your +own. However, there is no way to use curl_global_init_mem(3) in a +modular program -- all modules in the program that might use libcurl would +have to agree on one allocator. + +There is a failsafe in libcurl that makes it usable in simple situations +without you having to worry about the global constant environment at all: +curl_easy_init(3) sets up the environment itself if it has not been done +yet. The resources it acquires to do so get released by the operating system +automatically when the program exits. + +This failsafe feature exists mainly for backward compatibility because there +was a time when the global functions did not exist. Because it is sufficient +only in the simplest of programs, it is not recommended for any program to +rely on it. diff --git a/docs/libcurl/mksymbolsmanpage.pl b/docs/libcurl/mksymbolsmanpage.pl index 3bc686949..d7b9a77e3 100755 --- a/docs/libcurl/mksymbolsmanpage.pl +++ b/docs/libcurl/mksymbolsmanpage.pl @@ -23,8 +23,6 @@ # * # *************************************************************************** -my $version="7.41.0"; - use POSIX qw(strftime); my @ts; if (defined($ENV{SOURCE_DATE_EPOCH})) { @@ -36,33 +34,21 @@ my $year = strftime "%Y", @ts; print <
, 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 -.\\" * -.\\" ************************************************************************** -.TH libcurl-symbols 3 "$date" "libcurl" "libcurl" -.SH NAME -libcurl-symbols \\- libcurl symbol version information -.SH "libcurl symbols" +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: libcurl-symbols +Section: 3 +Source: libcurl +See-also: + - libcurl (3) + - libcurl-easy (3) + - libcurl-multi (3) + - libcurl-security (3) + - libcurl-thread (3) +--- +# libcurl symbols + This man page details version information for public symbols provided in the libcurl header files. This lists the first version in which the symbol was introduced and for some symbols two additional information pieces: @@ -78,6 +64,224 @@ HEADER ; +sub nameref { + my ($n)=@_; + if($n =~ /^CURLOPT_/) { + if($n eq "CURLOPT_RTSPHEADER") { + $n = "CURLOPT_HTTPHEADER"; + } + elsif($n eq "CURLOPT_WRITEHEADER") { + $n = "CURLOPT_HEADERDATA"; + } + elsif($n eq "CURLOPT_WRITEINFO") { + ; # now obsolete + } + else { + return "$n(3)"; + } + } + elsif($n =~ /^CURLMOPT_/) { + return "$n(3)"; + } + elsif($n =~ /^CURLINFO_/) { + my %infotypes = ( + 'CURLINFO_TEXT' => 1, + 'CURLINFO_HEADER_IN' => 1, + 'CURLINFO_HEADER_OUT' => 1, + 'CURLINFO_DATA_IN' => 1, + 'CURLINFO_DATA_OUT' => 1, + 'CURLINFO_SSL_DATA_IN' => 1, + 'CURLINFO_SSL_DATA_OUT' => 1, + ); + if($infotypes{$n}) { + return "CURLOPT_DEBUGFUNCTION(3)"; + } + } + elsif($n =~ /^CURLALTSVC_/) { + return "CURLOPT_ALTSVC_CTRL(3)"; + } + elsif($n =~ /^CURLAUTH_/) { + return "CURLOPT_HTTPAUTH(3)"; + } + elsif($n =~ /^CURLFORM_/) { + return "curl_formadd(3)"; + } + elsif($n =~ /^CURLKH/) { + return "CURLOPT_SSH_KEYFUNCTION(3)"; + } + elsif($n =~ /^CURLE_/) { + return "libcurl-errors(3)"; + } + elsif($n =~ /^CURLM_/) { + return "libcurl-errors(3)"; + } + elsif($n =~ /^CURLUE_/) { + return "libcurl-errors(3)"; + } + elsif($n =~ /^CURLHE_/) { + return "libcurl-errors(3)"; + } + elsif($n =~ /^CURLSHE_/) { + return "libcurl-errors(3)"; + } + elsif($n =~ /^CURLPROTO_/) { + return "CURLINFO_PROTOCOL(3)"; + } + elsif($n =~ /^CURLPX_/) { + return "CURLINFO_PROXY_ERROR(3)"; + } + elsif($n =~ /^CURLPROXY_/) { + return "CURLOPT_PROXYTYPE(3)"; + } + elsif($n =~ /^CURLSSLBACKEND_/) { + return "curl_global_sslset(3)"; + } + elsif($n =~ /^CURLSSLOPT_/) { + return "CURLOPT_SSL_OPTIONS(3)"; + } + elsif($n =~ /^CURLSSLSET_/) { + return "curl_global_sslset(3)"; + } + elsif($n =~ /^CURLUPART_/) { + return "curl_url_get(3)"; + } + elsif($n =~ /^CURLU_/) { + return "curl_url_get(3)"; + } + elsif($n =~ /^CURLVERSION_/) { + return "curl_version_info(3)"; + } + elsif($n =~ /^CURLSHOPT_/) { + if($n eq "CURLSHOPT_NONE") { + $n = "curl_share_setopt"; + } + return "$n(3)"; + } + elsif($n =~ /^CURLWS_/) { + return "curl_ws_send(3)"; + } + elsif($n =~ /^CURL_FORMADD_/) { + return "curl_formadd(3)"; + } + elsif($n =~ /^CURL_HTTPPOST_/) { + return "curl_formadd(3)"; + } + elsif($n =~ /^CURL_GLOBAL_/) { + return "curl_global_init(3)"; + } + elsif($n =~ /^CURL_HTTP_VERSION_/) { + return "CURLOPT_HTTP_VERSION(3)"; + } + elsif($n =~ /^CURL_LOCK_/) { + return "CURLSHOPT_SHARE(3)"; + } + elsif($n =~ /^CURL_SSLVERSION_/) { + return "CURLOPT_SSLVERSION(3)"; + } + elsif($n =~ /^CURL_VERSION_/) { + return "curl_version_info(3)"; + } + elsif($n =~ /^CURL_RTSPREQ_/) { + return "CURLOPT_RTSP_REQUEST(3)"; + } + elsif($n =~ /^CURLH_/) { + return "curl_easy_header(3)"; + } + elsif($n =~ /^CURL_TRAILERFUNC_/) { + return "CURLOPT_TRAILERFUNCTION(3)"; + } + elsif($n =~ /^CURLOT_/) { + return "curl_easy_option_next(3)"; + } + elsif($n =~ /^CURLFINFOFLAG_/) { + return "CURLOPT_CHUNK_BGN_FUNCTION(3)"; + } + elsif($n =~ /^CURLFILETYPE_/) { + return "CURLOPT_CHUNK_BGN_FUNCTION(3)"; + } + elsif($n =~ /^CURL_CHUNK_BGN_FUNC_/) { + return "CURLOPT_CHUNK_BGN_FUNCTION(3)"; + } + elsif($n =~ /^CURL_CHUNK_END_FUNC_/) { + return "CURLOPT_CHUNK_END_FUNCTION(3)"; + } + elsif($n =~ /^CURLSSH_AUTH_/) { + return "CURLOPT_SSH_AUTH_TYPES(3)"; + } + elsif($n =~ /^CURL_POLL_/) { + return "CURLMOPT_SOCKETFUNCTION(3)"; + } + elsif($n =~ /^CURLMSG_/) { + return "curl_multi_info_read(3)"; + } + elsif($n =~ /^CURLFTPAUTH_/) { + return "CURLOPT_FTPSSLAUTH(3)"; + } + elsif($n =~ /^CURLFTPMETHOD_/) { + return "CURLOPT_FTP_FILEMETHOD(3)"; + } + elsif($n =~ /^CURLFTPSSL_/) { + return "CURLOPT_USE_SSL(3)"; + } + elsif($n =~ /^CURLFTP_CREATE_/) { + return "CURLOPT_FTP_CREATE_MISSING_DIRS(3)"; + } + elsif($n =~ /^CURLGSSAPI_DELEGATION_/) { + return "CURLOPT_GSSAPI_DELEGATION(3)"; + } + elsif($n =~ /^CURLHEADER_/) { + return "CURLOPT_HEADEROPT(3)"; + } + elsif($n =~ /^CURLHSTS_/) { + return "CURLOPT_HSTS_CTRL(3)"; + } + elsif($n =~ /^CURLIOCMD_/) { + return "CURLOPT_IOCTLFUNCTION(3)"; + } + elsif($n =~ /^CURLIOE_/) { + return "CURLOPT_IOCTLFUNCTION(3)"; + } + elsif($n =~ /^CURLMIMEOPT_/) { + return "CURLOPT_MIME_OPTIONS(3)"; + } + elsif($n =~ /^CURLPAUSE_/) { + return "curl_easy_pause(3)"; + } + elsif($n =~ /^CURLPIPE_/) { + return "CURLMOPT_PIPELINING(3)"; + } + elsif($n =~ /^CURLSOCKTYPE_/) { + return "CURLOPT_SOCKOPTFUNCTION(3)"; + } + elsif($n =~ /^CURLSTS_/) { + return "CURLOPT_HSTSREADFUNCTION(3)"; + } + elsif($n =~ /^CURLUSESSL_/) { + return "CURLOPT_USE_SSL(3)"; + } + elsif($n =~ /^CURL_CSELECT_/) { + return "curl_multi_socket_action(3)"; + } + elsif($n =~ /^CURL_FNMATCHFUNC_/) { + return "CURLOPT_FNMATCH_FUNCTION(3)"; + } + elsif($n =~ /^CURL_HET_/) { + return "CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS(3)"; + } + elsif($n =~ /^CURL_IPRESOLVE_/) { + return "CURLOPT_IPRESOLVE(3)"; + } + elsif($n =~ /^CURL_SEEKFUNC_/) { + return "CURLOPT_SEEKFUNCTION(3)"; + } + elsif($n =~ /^CURL_TIMECOND_/) { + return "CURLOPT_TIMECONDITION(3)"; + } + elsif($n =~ /^CURL_REDIR_POST_/) { + return "CURLOPT_POSTREDIR(3)"; + } +} + while() { if($_ =~ /^(CURL[A-Z0-9_.]*) *(.*)/i) { my ($symbol, $rest)=($1,$2); @@ -88,16 +292,20 @@ if($rest =~ s/^([0-9.]*) *//) { $dep = $1; } - if($rest =~ s/^([0-9.]*) *//) { + if($rest =~ s/^- *([0-9.]*)//) { $rem = $1; } - print ".IP $symbol\nIntroduced in $intro\n"; + print "\n## $symbol\nIntroduced in $intro."; if($dep) { - print "Deprecated since $dep\n"; + print " Deprecated since $dep."; } if($rem) { - print "Last used in $rem\n"; + print " Last used in $rem."; } + my $see = $rem || $dep ? "" : nameref($symbol); + if($see) { + print " See $see."; + } + print "\n"; } - } diff --git a/docs/libcurl/opts/CMakeLists.txt b/docs/libcurl/opts/CMakeLists.txt index 152a08a35..82844a225 100644 --- a/docs/libcurl/opts/CMakeLists.txt +++ b/docs/libcurl/opts/CMakeLists.txt @@ -26,10 +26,9 @@ transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc. include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") add_manual_pages(man_MANS) - -string(REPLACE ".3" ".html" HTMLPAGES "${man_MANS}") -string(REPLACE ".3" ".pdf" PDFPAGES "${man_MANS}") -add_custom_target(opts-html DEPENDS ${HTMLPAGES}) -add_custom_target(opts-pdf DEPENDS ${PDFPAGES}) -add_dependencies(html opts-html) -add_dependencies(pdf opts-pdf) +add_custom_target(opts-man DEPENDS ${man_MANS}) +add_dependencies(man opts-man) +if(NOT CURL_DISABLE_INSTALL) + install(FILES "$" + DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) +endif() diff --git a/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.3 b/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.3 deleted file mode 100644 index b1f5b9883..000000000 --- a/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_ACTIVESOCKET 3 "12 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_ACTIVESOCKET \- get the active socket -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_ACTIVESOCKET, - curl_socket_t *socket); -.fi -.SH 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, \fICURL_SOCKET_BAD\fP is returned. When you are finished working -with the socket, you must call \fIcurl_easy_cleanup(3)\fP 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 -\fICURLOPT_CONNECT_ONLY(3)\fP, which skips the transfer phase. - -\fICURLINFO_ACTIVESOCKET(3)\fP was added as a replacement for -\fICURLINFO_LASTSOCKET(3)\fP since that one is not working on all platforms. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - - /* Extract the socket from the curl handle */ - res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd); - - if(res != CURLE_OK) { - printf("Error: %s\\n", curl_easy_strerror(res)); - return 1; - } - } -} -.fi -.SH AVAILABILITY -Added in 7.45.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_LASTSOCKET (3), -.BR CURLOPT_CONNECT_ONLY (3) diff --git a/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.md b/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.md new file mode 100644 index 000000000..7e106ed0b --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_ACTIVESOCKET.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_ACTIVESOCKET - get the active socket + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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); + + /* Extract the socket from the curl handle */ + res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd); + + if(res != CURLE_OK) { + printf("Error: %s\n", curl_easy_strerror(res)); + return 1; + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.45.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.3 b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.3 deleted file mode 100644 index 977ef5736..000000000 --- a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_APPCONNECT_TIME 3 "28 Aug 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_APPCONNECT_TIME \- get the time until the SSL/SSH handshake is completed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_APPCONNECT_TIME, - double *timep); -.fi -.SH 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 \fICURLINFO_PRETRANSFER_TIME(3)\fP time, -except for cases such as HTTP pipelining where the pretransfer time can be -delayed due to waits in line for the pipeline and more. - -When a redirect is followed, the time from each request is added together. - -See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_APPCONNECT_TIME_T (3) diff --git a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.md b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.md new file mode 100644 index 000000000..17fb46580 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_APPCONNECT_TIME - get the time until the SSL/SSH handshake is completed + +# SYNOPSIS + +~~~c +#include + +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 pipelining where the pretransfer time can be +delayed due to waits in line for the pipeline 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 + +All + +# 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 + +Added in 7.19.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.3 b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.3 deleted file mode 100644 index 7a2ecff23..000000000 --- a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_APPCONNECT_TIME_T 3 "28 Apr 2018" "libcurl" "libcurl" -.SH NAME -CURLINFO_APPCONNECT_TIME_T \- time until the SSL/SSH handshake completed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_APPCONNECT_TIME_T, - curl_off_t *timep); -.fi -.SH 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 -\fICURLINFO_PRETRANSFER_TIME_T(3)\fP time, except for cases such as HTTP -pipelining where the pretransfer time can be delayed due to waits in line for -the pipeline and more. - -When a redirect is followed, the time from each request is added together. - -See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_APPCONNECT_TIME (3) diff --git a/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.md b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.md new file mode 100644 index 000000000..cc4f2b858 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_APPCONNECT_TIME_T.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_APPCONNECT_TIME_T - time until the SSL/SSH handshake completed + +# SYNOPSIS + +~~~c +#include + +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 +pipelining where the pretransfer time can be delayed due to waits in line for +the pipeline 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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CAINFO.3 b/docs/libcurl/opts/CURLINFO_CAINFO.3 deleted file mode 100644 index 61c3e14fe..000000000 --- a/docs/libcurl/opts/CURLINFO_CAINFO.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CAINFO 3 "20 May 2022" "libcurl" "libcurl" -.SH NAME -CURLINFO_CAINFO \- get the default built-in CA certificate path -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CAINFO, char **path); -.fi -.SH 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 \fICURLOPT_CAINFO(3)\fP -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 \fICURLOPT_CAINFO(3)\fP. - -This is a path identifying a single file containing CA certificates. - -The \fBpath\fP pointer is set to NULL if there is no default path. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.84.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CAPATH (3) diff --git a/docs/libcurl/opts/CURLINFO_CAINFO.md b/docs/libcurl/opts/CURLINFO_CAINFO.md new file mode 100644 index 000000000..44b253967 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CAINFO.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CAINFO - get the default built-in CA certificate path + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.84.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CAPATH.3 b/docs/libcurl/opts/CURLINFO_CAPATH.3 deleted file mode 100644 index 56f05d182..000000000 --- a/docs/libcurl/opts/CURLINFO_CAPATH.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CAPATH 3 "20 May 2022" "libcurl" "libcurl" -.SH NAME -CURLINFO_CAPATH \- get the default built-in CA path string -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CAPATH, char **path); -.fi -.SH 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 \fICURLOPT_CAPATH(3)\fP -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 \fICURLOPT_CAPATH(3)\fP. - -This is a path identifying a directory. - -The \fBpath\fP pointer is set to NULL if there is no default path. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.84.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CAINFO (3) diff --git a/docs/libcurl/opts/CURLINFO_CAPATH.md b/docs/libcurl/opts/CURLINFO_CAPATH.md new file mode 100644 index 000000000..46499e7f6 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CAPATH.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CAPATH - get the default built-in CA path string + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.84.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CERTINFO.3 b/docs/libcurl/opts/CURLINFO_CERTINFO.3 deleted file mode 100644 index 46e93ccd3..000000000 --- a/docs/libcurl/opts/CURLINFO_CERTINFO.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CERTINFO 3 "12 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CERTINFO \- get the TLS certificate chain -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO, - struct curl_certinfo **chainp); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIstruct curl_certinfo *\fP and it is set to point to a -struct that holds info about the server's certificate chain, assuming you had -\fICURLOPT_CERTINFO(3)\fP enabled when the request was made. - -.nf -struct curl_certinfo { - int num_of_certs; - struct curl_slist **certinfo; -}; -.fi - -The \fIcertinfo\fP struct member is an array of linked lists of certificate -information. The \fInum_of_certs\fP 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. -.SH PROTOCOLS -All TLS-based -.SH EXAMPLE -.nf -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); - } -} -.fi - -See also the \fIcertinfo.c\fP example. -.SH AVAILABILITY -This option is only working in libcurl built with OpenSSL, GnuTLS, Schannel or -Secure Transport. GnuTLS support added in 7.42.0. Schannel support added in -7.50.0. Secure Transport support added in 7.79.0. - -Added in 7.19.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CAPATH (3) diff --git a/docs/libcurl/opts/CURLINFO_CERTINFO.md b/docs/libcurl/opts/CURLINFO_CERTINFO.md new file mode 100644 index 000000000..d9cbc9306 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CERTINFO.md @@ -0,0 +1,101 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CERTINFO - get the TLS certificate chain + +# SYNOPSIS + +~~~c +#include + +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 + +All TLS-based + +# 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. + +# AVAILABILITY + +This option is only working in libcurl built with OpenSSL, GnuTLS, Schannel or +Secure Transport. GnuTLS support added in 7.42.0. Schannel support added in +7.50.0. Secure Transport support added in 7.79.0. + +Added in 7.19.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.3 b/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.3 deleted file mode 100644 index d59d16adb..000000000 --- a/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONDITION_UNMET 3 "1 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONDITION_UNMET \- get info on unmet time conditional or 304 HTTP response. -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONDITION_UNMET, - long *unmet); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the number 1 if the condition provided in -the previous request did not match (see \fICURLOPT_TIMECONDITION(3)\fP). 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. -.SH PROTOCOLS -HTTP and some -.SH EXAMPLE -.nf -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, - (long)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":""); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_TIMECONDITION (3), -.BR CURLOPT_TIMEVALUE (3) diff --git a/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md b/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md new file mode 100644 index 000000000..aca04f1c9 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONDITION_UNMET.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONDITION_UNMET - get info on unmet time conditional or 304 HTTP response. + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP and some + +# 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, + (long)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 + +Added in 7.19.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONNECT_TIME.3 b/docs/libcurl/opts/CURLINFO_CONNECT_TIME.3 deleted file mode 100644 index 299e2d520..000000000 --- a/docs/libcurl/opts/CURLINFO_CONNECT_TIME.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONNECT_TIME 3 "28 Aug 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONNECT_TIME \- get the time until connect -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME, double *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONNECT_TIME_T (3) diff --git a/docs/libcurl/opts/CURLINFO_CONNECT_TIME.md b/docs/libcurl/opts/CURLINFO_CONNECT_TIME.md new file mode 100644 index 000000000..1fde76699 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONNECT_TIME.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONNECT_TIME - get the time until connect + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.3 b/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.3 deleted file mode 100644 index d215839c2..000000000 --- a/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONNECT_TIME_T 3 "28 Apr 2018" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONNECT_TIME_T \- get the time until connect -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME_T, - curl_off_t *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONNECT_TIME (3), -.BR CURLOPT_CONNECTTIMEOUT (3) diff --git a/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.md b/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.md new file mode 100644 index 000000000..cd72cdd07 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONNECT_TIME_T.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONNECT_TIME_T - get the time until connect + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONN_ID.3 b/docs/libcurl/opts/CURLINFO_CONN_ID.3 deleted file mode 100644 index 1b9da9338..000000000 --- a/docs/libcurl/opts/CURLINFO_CONN_ID.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONN_ID 3 "07 June 2023" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONN_ID \- get the ID of the last connection used by the handle -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONN_ID, - curl_off_t *conn_id); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP 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. - -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 8.2.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_XFER_ID (3) diff --git a/docs/libcurl/opts/CURLINFO_CONN_ID.md b/docs/libcurl/opts/CURLINFO_CONN_ID.md new file mode 100644 index 000000000..d4791b42c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONN_ID.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONN_ID - get the ID of the last connection used by the handle + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 8.2.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.3 b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.3 deleted file mode 100644 index fbb89b223..000000000 --- a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONTENT_LENGTH_DOWNLOAD 3 "1 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONTENT_LENGTH_DOWNLOAD \- get content-length of download -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, - double *content_length); -.fi -.SH 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. Since 7.19.4, this returns --1 if the size is not known. - -\fICURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)\fP is a newer replacement that returns a more -sensible variable type. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.6.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONTENT_LENGTH_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.md b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.md new file mode 100644 index 000000000..1e01419bd --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONTENT_LENGTH_DOWNLOAD - get content-length of download + +# SYNOPSIS + +~~~c +#include + +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. Since 7.19.4, 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 + +HTTP(S) + +# 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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.6.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.3 b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.3 deleted file mode 100644 index f924df26d..000000000 --- a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONTENT_LENGTH_DOWNLOAD_T 3 "25 May 2017" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONTENT_LENGTH_DOWNLOAD_T \- get content-length of download -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, - curl_off_t *content_length); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP 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. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONTENT_LENGTH_UPLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.md b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.md new file mode 100644 index 000000000..15016c84c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONTENT_LENGTH_DOWNLOAD_T - get content-length of download + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3 b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3 deleted file mode 100644 index 418e3c720..000000000 --- a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONTENT_LENGTH_UPLOAD 3 "1 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONTENT_LENGTH_UPLOAD \- get the specified size of the upload -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD, - double *content_length); -.fi -.SH 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. - -\fICURLINFO_CONTENT_LENGTH_UPLOAD_T(3)\fP is a newer replacement that returns a -more sensible variable type. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.6.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.md b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.md new file mode 100644 index 000000000..c90e19e72 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONTENT_LENGTH_UPLOAD - get the specified size of the upload + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.6.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.3 b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.3 deleted file mode 100644 index 170c1080a..000000000 --- a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONTENT_LENGTH_UPLOAD_T 3 "25 May 2017" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONTENT_LENGTH_UPLOAD_T \- get the specified size of the upload -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD_T, - curl_off_t *content_length); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP to receive the specified size of the -upload. Stores -1 if the size is not known. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.md b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.md new file mode 100644 index 000000000..319a3345e --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONTENT_LENGTH_UPLOAD_T.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONTENT_LENGTH_UPLOAD_T - get the specified size of the upload + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3 b/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3 deleted file mode 100644 index 1045821b5..000000000 --- a/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_CONTENT_TYPE 3 "1 Sep 2015" "libcurl" "libcurl" -.SH NAME -CURLINFO_CONTENT_TYPE \- get Content-Type -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_TYPE, char **ct); -.fi -.SH 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 \fBct\fP pointer is set to NULL or pointing to private memory. You MUST -NOT free it - it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the -corresponding CURL handle. - -The modern way to get this header from a response is to instead use the -\fIcurl_easy_header(3)\fP function. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.9.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_header (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_HEADERFUNCTION (3) diff --git a/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.md b/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.md new file mode 100644 index 000000000..b87457251 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_CONTENT_TYPE.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_CONTENT_TYPE - get Content-Type + +# SYNOPSIS + +~~~c +#include + +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 set to NULL or pointing to private memory. You MUST +NOT free it - it gets freed 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 + +HTTP(S) + +# 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 + +Added in 7.9.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_COOKIELIST.3 b/docs/libcurl/opts/CURLINFO_COOKIELIST.3 deleted file mode 100644 index 02e2490eb..000000000 --- a/docs/libcurl/opts/CURLINFO_COOKIELIST.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_COOKIELIST 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_COOKIELIST \- get all known cookies -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_COOKIELIST, - struct curl_slist **cookies); -.fi -.SH 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 -\fIcurl_slist_free_all(3)\fP 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. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.14.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_COOKIELIST (3) diff --git a/docs/libcurl/opts/CURLINFO_COOKIELIST.md b/docs/libcurl/opts/CURLINFO_COOKIELIST.md new file mode 100644 index 000000000..60ac0f036 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_COOKIELIST.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_COOKIELIST - get all known cookies + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added in 7.14.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.3 b/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.3 deleted file mode 100644 index 50f028b57..000000000 --- a/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_EFFECTIVE_METHOD 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_EFFECTIVE_METHOD \- get the last used HTTP method -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_METHOD, - char **methodp); -.fi -.SH 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 \fBmethodp\fP pointer is NULL or points to private memory. You MUST NOT -free - it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the -corresponding CURL handle. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.72.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_FOLLOWLOCATION (3) diff --git a/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.md b/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.md new file mode 100644 index 000000000..da2e2a016 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_EFFECTIVE_METHOD.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_EFFECTIVE_METHOD - get the last used HTTP method + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the +corresponding CURL handle. + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.72.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.3 b/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.3 deleted file mode 100644 index 810e7873e..000000000 --- a/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_EFFECTIVE_URL 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_EFFECTIVE_URL \- get the last used URL -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_EFFECTIVE_URL, char **urlp); -.fi -.SH 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 \fICURLOPT_URL(3)\fP. - -The \fBurlp\fP pointer is NULL or points to private memory. You MUST NOT free -- it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_FOLLOWLOCATION (3) diff --git a/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.md b/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.md new file mode 100644 index 000000000..268ff2c67 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_EFFECTIVE_URL.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_EFFECTIVE_URL - get the last used URL + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_FILETIME.3 b/docs/libcurl/opts/CURLINFO_FILETIME.3 deleted file mode 100644 index ae08db367..000000000 --- a/docs/libcurl/opts/CURLINFO_FILETIME.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_FILETIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_FILETIME \- get the remote time of the retrieved document -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME, long *timep); -.fi -.SH 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 tell libcurl to collect this information before the transfer is made, -by using the \fICURLOPT_FILETIME(3)\fP option to \fIcurl_easy_setopt(3)\fP or -you this unconditionally gets a -1 back. - -Consider using \fICURLINFO_FILETIME_T(3)\fP to be able to extract dates beyond -the year 2038 on systems using 32 bit longs (Windows). -.SH PROTOCOLS -HTTP(S), FTP(S), SFTP -.SH EXAMPLE -.nf -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 >= 0)) { - time_t file_time = (time_t)filetime; - printf("filetime: %s", ctime(&file_time)); - } - } - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.5 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_FILETIME (3) diff --git a/docs/libcurl/opts/CURLINFO_FILETIME.md b/docs/libcurl/opts/CURLINFO_FILETIME.md new file mode 100644 index 000000000..77ef534b4 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_FILETIME.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_FILETIME - get the remote time of the retrieved document + +# SYNOPSIS + +~~~c +#include + +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 tell libcurl to collect this information before the transfer is made, +by using the CURLOPT_FILETIME(3) option to curl_easy_setopt(3) or +you this unconditionally gets a -1 back. + +Consider using CURLINFO_FILETIME_T(3) to be able to extract dates beyond +the year 2038 on systems using 32 bit longs (Windows). + +# PROTOCOLS + +HTTP(S), FTP(S), SFTP + +# 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 >= 0)) { + time_t file_time = (time_t)filetime; + printf("filetime: %s", ctime(&file_time)); + } + } + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.5 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_FILETIME_T.3 b/docs/libcurl/opts/CURLINFO_FILETIME_T.3 deleted file mode 100644 index 48ddc4163..000000000 --- a/docs/libcurl/opts/CURLINFO_FILETIME_T.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_FILETIME 3 "25 Jan 2018" libcurl libcurl -.SH NAME -CURLINFO_FILETIME_T \- get the remote time of the retrieved document -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T, - curl_off_t *timep); -.fi -.SH 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 \fICURLOPT_FILETIME(3)\fP option to \fIcurl_easy_setopt(3)\fP or -you unconditionally get a -1 back. - -This option is an alternative to \fICURLINFO_FILETIME(3)\fP to allow systems -with 32 bit long variables to extract dates outside of the 32bit timestamp -range. -.SH PROTOCOLS -HTTP(S), FTP(S), SFTP -.SH EXAMPLE -.nf -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 >= 0)) { - time_t file_time = (time_t)filetime; - printf("filetime: %s", ctime(&file_time)); - } - } - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.59.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_FILETIME (3) diff --git a/docs/libcurl/opts/CURLINFO_FILETIME_T.md b/docs/libcurl/opts/CURLINFO_FILETIME_T.md new file mode 100644 index 000000000..62c5f3cb0 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_FILETIME_T.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_FILETIME_T - get the remote time of the retrieved document + +# SYNOPSIS + +~~~c +#include + +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 to curl_easy_setopt(3) 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 32bit timestamp +range. + +# PROTOCOLS + +HTTP(S), FTP(S), SFTP + +# 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 >= 0)) { + time_t file_time = (time_t)filetime; + printf("filetime: %s", ctime(&file_time)); + } + } + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.59.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3 b/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3 deleted file mode 100644 index 8e0f1a23b..000000000 --- a/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_FTP_ENTRY_PATH 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_FTP_ENTRY_PATH \- get entry path in FTP server -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FTP_ENTRY_PATH, char **path); -.fi -.SH 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 server. This stores a NULL as pointer if -something is wrong. - -The \fBpath\fP pointer is NULL or points to private memory. You MUST NOT free -- it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -FTP(S) and SFTP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.4. Works for SFTP since 7.21.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3) diff --git a/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.md b/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.md new file mode 100644 index 000000000..344e1f174 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_FTP_ENTRY_PATH.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_FTP_ENTRY_PATH - get entry path in FTP server + +# SYNOPSIS + +~~~c +#include + +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 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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +FTP(S) and SFTP + +# 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); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.4. Works for SFTP since 7.21.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3 b/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3 deleted file mode 100644 index 2c9d8faed..000000000 --- a/docs/libcurl/opts/CURLINFO_HEADER_SIZE.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_HEADER_SIZE 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_HEADER_SIZE \- get size of retrieved headers -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HEADER_SIZE, long *sizep); -.fi -.SH 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 -\fICURLOPT_SUPPRESS_CONNECT_HEADERS(3)\fP. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_REQUEST_SIZE (3), -.BR CURLINFO_SIZE_DOWNLOAD (3) diff --git a/docs/libcurl/opts/CURLINFO_HEADER_SIZE.md b/docs/libcurl/opts/CURLINFO_HEADER_SIZE.md new file mode 100644 index 000000000..67ccfc232 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_HEADER_SIZE.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_HEADER_SIZE - get size of retrieved headers + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3 b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3 deleted file mode 100644 index 7ceb790b4..000000000 --- a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_HTTPAUTH_AVAIL 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_HTTPAUTH_AVAIL \- get available HTTP authentication methods -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTPAUTH_AVAIL, long *authp); -.fi -.SH 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 \fICURLOPT_HTTPAUTH(3)\fP option for -\fIcurl_easy_setopt(3)\fP. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added RFC 2617 in 7.10.8 -Added RFC 7616 in 7.57.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_PROXYAUTH_AVAIL (3), -.BR CURLOPT_HTTPAUTH (3) diff --git a/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md new file mode 100644 index 000000000..574e0a52b --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_HTTPAUTH_AVAIL.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_HTTPAUTH_AVAIL - get available HTTP authentication methods + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added RFC 2617 in 7.10.8 +Added RFC 7616 in 7.57.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3 b/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3 deleted file mode 100644 index b4b3ac3fe..000000000 --- a/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_HTTP_CONNECTCODE 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_HTTP_CONNECTCODE \- get the CONNECT response code -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_CONNECTCODE, long *p); -.fi -.SH 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. -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RESPONSE_CODE (3) diff --git a/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.md b/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.md new file mode 100644 index 000000000..ee3f0f65c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_HTTP_CONNECTCODE.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_HTTP_CONNECTCODE - get the CONNECT response code + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP + +# 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 + +Added in 7.10.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_HTTP_VERSION.3 b/docs/libcurl/opts/CURLINFO_HTTP_VERSION.3 deleted file mode 100644 index d4d4e8940..000000000 --- a/docs/libcurl/opts/CURLINFO_HTTP_VERSION.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_HTTP_VERSION 3 "11 May 2016" libcurl libcurl -.SH NAME -CURLINFO_HTTP_VERSION \- get the http version used in the connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_HTTP_VERSION, long *p); -.fi -.SH 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. -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.50.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RESPONSE_CODE (3) diff --git a/docs/libcurl/opts/CURLINFO_HTTP_VERSION.md b/docs/libcurl/opts/CURLINFO_HTTP_VERSION.md new file mode 100644 index 000000000..994d7712c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_HTTP_VERSION.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_HTTP_VERSION - get the http version used in the connection + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP + +# 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 + +Added in 7.50.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_LASTSOCKET.3 b/docs/libcurl/opts/CURLINFO_LASTSOCKET.3 deleted file mode 100644 index 88a7345a9..000000000 --- a/docs/libcurl/opts/CURLINFO_LASTSOCKET.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_LASTSOCKET 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_LASTSOCKET \- get the last socket used -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LASTSOCKET, long *socket); -.fi -.SH DESCRIPTION -Deprecated since 7.45.0. Use \fICURLINFO_ACTIVESOCKET(3)\fP 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 \fIcurl_easy_cleanup(3)\fP as usual and -let libcurl close the socket and cleanup other resources associated with the -handle. This is typically used in combination with -\fICURLOPT_CONNECT_ONLY(3)\fP. - -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 -\fICURLINFO_ACTIVESOCKET(3)\fP instead, if possible. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - - /* Extract the socket from the curl handle */ - res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd); - - if(res != CURLE_OK) { - printf("Error: %s\\n", curl_easy_strerror(res)); - return 1; - } - } -} -.fi -.SH AVAILABILITY -Added in 7.15.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_ACTIVESOCKET (3), -.BR CURLOPT_CONNECT_ONLY (3) diff --git a/docs/libcurl/opts/CURLINFO_LASTSOCKET.md b/docs/libcurl/opts/CURLINFO_LASTSOCKET.md new file mode 100644 index 000000000..b1619ebdb --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_LASTSOCKET.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_LASTSOCKET - get the last socket used + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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); + + /* Extract the socket from the curl handle */ + res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd); + + if(res != CURLE_OK) { + printf("Error: %s\n", curl_easy_strerror(res)); + return 1; + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_LOCAL_IP.3 b/docs/libcurl/opts/CURLINFO_LOCAL_IP.3 deleted file mode 100644 index 5501ba7f9..000000000 --- a/docs/libcurl/opts/CURLINFO_LOCAL_IP.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_LOCAL_IP 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_LOCAL_IP \- get local IP address of last connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_IP, char **ip); -.fi -.SH 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 \fBcurl\fP 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 \fBip\fP pointer is NULL or points to private memory. You MUST NOT free - -it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_PRIMARY_IP (3), -.BR CURLINFO_LOCAL_PORT (3) diff --git a/docs/libcurl/opts/CURLINFO_LOCAL_IP.md b/docs/libcurl/opts/CURLINFO_LOCAL_IP.md new file mode 100644 index 000000000..e70d0cf04 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_LOCAL_IP.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_LOCAL_IP - get local IP address of last connection + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +All + +# 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 + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_LOCAL_PORT.3 b/docs/libcurl/opts/CURLINFO_LOCAL_PORT.3 deleted file mode 100644 index 31617ac31..000000000 --- a/docs/libcurl/opts/CURLINFO_LOCAL_PORT.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_LOCAL_PORT 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_LOCAL_PORT \- get the latest local port number -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long *portp); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the local port number of the most recent -connection done with this \fBcurl\fP handle. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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; -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_LOCAL_IP (3), -.BR CURLINFO_PRIMARY_PORT (3) diff --git a/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md b/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md new file mode 100644 index 000000000..055fc2ee0 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLINFO_LOCAL_PORT +Section: 3 +Source: libcurl +See-also: + - CURLINFO_LOCAL_IP (3) + - CURLINFO_PRIMARY_PORT (3) + - curl_easy_getinfo (3) + - curl_easy_setopt (3) +--- + +# NAME + +CURLINFO_LOCAL_PORT - get the latest local port number + +# SYNOPSIS + +~~~c +#include + +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. + +# PROTOCOLS + +All + +# 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 + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.3 b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.3 deleted file mode 100644 index 4ad0e9522..000000000 --- a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_NAMELOOKUP_TIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_NAMELOOKUP_TIME \- get the name lookup time -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NAMELOOKUP_TIME, - double *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_NAMELOOKUP_TIME_T (3) diff --git a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.md b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.md new file mode 100644 index 000000000..8cf425e0f --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_NAMELOOKUP_TIME - get the name lookup time + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.3 b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.3 deleted file mode 100644 index 91be68a29..000000000 --- a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_NAMELOOKUP_TIME_T 3 "28 Apr 2018" libcurl libcurl -.SH NAME -CURLINFO_NAMELOOKUP_TIME_T \- get the name lookup time in microseconds -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NAMELOOKUP_TIME_T, - curl_off_t *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_NAMELOOKUP_TIME (3) diff --git a/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.md b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.md new file mode 100644 index 000000000..a3fd4dd84 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_NAMELOOKUP_TIME_T.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_NAMELOOKUP_TIME_T - get the name lookup time in microseconds + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3 b/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3 deleted file mode 100644 index b151f1e26..000000000 --- a/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_NUM_CONNECTS 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_NUM_CONNECTS \- get number of created connections -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NUM_CONNECTS, long *nump); -.fi -.SH 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 \fICURLINFO_REDIRECT_COUNT(3)\fP you are able to know -how many times libcurl successfully reused existing connection(s) or not. See -the connection options of \fIcurl_easy_setopt(3)\fP to see how libcurl tries -to make persistent connections to save time. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.3 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3) diff --git a/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.md b/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.md new file mode 100644 index 000000000..5127a0a32 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_NUM_CONNECTS.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLINFO_NUM_CONNECTS +Section: 3 +Source: libcurl +See-also: + - curl_easy_getinfo (3) + - curl_easy_setopt (3) +--- + +# NAME + +CURLINFO_NUM_CONNECTS - get number of created connections + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.12.3 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_OS_ERRNO.3 b/docs/libcurl/opts/CURLINFO_OS_ERRNO.3 deleted file mode 100644 index cafeb68a1..000000000 --- a/docs/libcurl/opts/CURLINFO_OS_ERRNO.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_OS_ERRNO 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_OS_ERRNO \- get errno number from last connect failure -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop); -.fi -.SH 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. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3) diff --git a/docs/libcurl/opts/CURLINFO_OS_ERRNO.md b/docs/libcurl/opts/CURLINFO_OS_ERRNO.md new file mode 100644 index 000000000..3fb69b43c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_OS_ERRNO.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLINFO_OS_ERRNO +Section: 3 +Source: libcurl +See-also: + - curl_easy_getinfo (3) + - curl_easy_setopt (3) +--- + +# NAME + +CURLINFO_OS_ERRNO - get errno number from last connect failure + +# SYNOPSIS + +~~~c +#include + +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. + +# PROTOCOLS + +All + +# 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 + +Added in 7.12.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.3 b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.3 deleted file mode 100644 index 01f90f214..000000000 --- a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PRETRANSFER_TIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_PRETRANSFER_TIME \- get the time until the file transfer start -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME, - double *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONNECT_TIME_T (3), -.BR CURLINFO_PRETRANSFER_TIME_T (3) diff --git a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.md b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.md new file mode 100644 index 000000000..8eda23a3c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PRETRANSFER_TIME - get the time until the file transfer start + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.3 b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.3 deleted file mode 100644 index f05543446..000000000 --- a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PRETRANSFER_TIME_T 3 "28 Apr 2018" libcurl libcurl -.SH NAME -CURLINFO_PRETRANSFER_TIME_T \- get the time until the file transfer start -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRETRANSFER_TIME_T, - curl_off_t *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONNECT_TIME (3), -.BR CURLINFO_PRETRANSFER_TIME_T (3) diff --git a/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.md b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.md new file mode 100644 index 000000000..50c515f3a --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PRETRANSFER_TIME_T.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PRETRANSFER_TIME_T - get the time until the file transfer start + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PRIMARY_IP.3 b/docs/libcurl/opts/CURLINFO_PRIMARY_IP.3 deleted file mode 100644 index 597a797ec..000000000 --- a/docs/libcurl/opts/CURLINFO_PRIMARY_IP.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PRIMARY_IP 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_PRIMARY_IP \- get IP address of last connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_IP, char **ip); -.fi -.SH 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 -\fBcurl\fP 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 \fBip\fP pointer is NULL or points to private memory. You MUST NOT free - -it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -All network based ones -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.19.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_LOCAL_IP (3), -.BR CURLINFO_LOCAL_PORT (3), -.BR CURLINFO_PRIMARY_PORT (3) diff --git a/docs/libcurl/opts/CURLINFO_PRIMARY_IP.md b/docs/libcurl/opts/CURLINFO_PRIMARY_IP.md new file mode 100644 index 000000000..115113f3f --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PRIMARY_IP.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PRIMARY_IP - get IP address of last connection + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +All network based ones + +# 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 + +Added in 7.19.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.3 b/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.3 deleted file mode 100644 index 51d2b746f..000000000 --- a/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PRIMARY_PORT 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_PRIMARY_PORT \- get the latest destination port number -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_PORT, long *portp); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the destination port of the most recent -connection done with this \fBcurl\fP 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. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_LOCAL_PORT (3), -.BR CURLINFO_PRIMARY_IP (3) diff --git a/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md b/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md new file mode 100644 index 000000000..3d90b64ed --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PRIMARY_PORT - get the latest destination port number + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PRIVATE.3 b/docs/libcurl/opts/CURLINFO_PRIVATE.3 deleted file mode 100644 index 2c63e3e48..000000000 --- a/docs/libcurl/opts/CURLINFO_PRIVATE.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PRIVATE 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_PRIVATE \- get the private pointer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIVATE, char **private); -.fi -.SH DESCRIPTION -Pass a pointer to a char pointer to receive the pointer to the private data -associated with the curl handle (set with the \fICURLOPT_PRIVATE(3)\fP). -Please note that for internal reasons, the value is returned as a char -pointer, although effectively being a 'void *'. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.3 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_PRIVATE (3) diff --git a/docs/libcurl/opts/CURLINFO_PRIVATE.md b/docs/libcurl/opts/CURLINFO_PRIVATE.md new file mode 100644 index 000000000..127049f7e --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PRIVATE.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PRIVATE - get the private pointer + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.10.3 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PROTOCOL.3 b/docs/libcurl/opts/CURLINFO_PROTOCOL.3 deleted file mode 100644 index aac7e9f3f..000000000 --- a/docs/libcurl/opts/CURLINFO_PROTOCOL.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PROTOCOL 3 "23 November 2016" libcurl libcurl -.SH NAME -CURLINFO_PROTOCOL \- get the protocol used in the connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROTOCOL, long *p); -.fi -.SH DESCRIPTION -This option is deprecated. We strongly recommend using -\fICURLINFO_SCHEME(3)\fP 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 the CURLPROTO_* values: - -.nf -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 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0. Deprecated since 7.85.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RESPONSE_CODE (3) diff --git a/docs/libcurl/opts/CURLINFO_PROTOCOL.md b/docs/libcurl/opts/CURLINFO_PROTOCOL.md new file mode 100644 index 000000000..9dfb2970f --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PROTOCOL.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PROTOCOL - get the protocol used in the connection + +# SYNOPSIS + +~~~c +#include + +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 the CURLPROTO_* 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 + +All + +# 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); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0. Deprecated since 7.85.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.3 b/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.3 deleted file mode 100644 index 3d6e54948..000000000 --- a/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PROXYAUTH_AVAIL 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_PROXYAUTH_AVAIL \- get available HTTP proxy authentication methods -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXYAUTH_AVAIL, - long *authp); -.fi -.SH 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 \fICURLOPT_PROXYAUTH(3)\fP option for -\fIcurl_easy_setopt(3)\fP. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added RFC 2617 in 7.10.8 -Added RFC 7616 in 7.57.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_HTTPAUTH_AVAIL (3) diff --git a/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md b/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md new file mode 100644 index 000000000..0e9dbdcb5 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PROXYAUTH_AVAIL.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PROXYAUTH_AVAIL - get available HTTP proxy authentication methods + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added RFC 2617 in 7.10.8 +Added RFC 7616 in 7.57.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PROXY_ERROR.3 b/docs/libcurl/opts/CURLINFO_PROXY_ERROR.3 deleted file mode 100644 index f4ce84918..000000000 --- a/docs/libcurl/opts/CURLINFO_PROXY_ERROR.3 +++ /dev/null @@ -1,109 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PROXY_ERROR 3 "3 Aug 2020" libcurl libcurl -.SH NAME -CURLINFO_PROXY_ERROR \- get the detailed (SOCKS) proxy error -.SH SYNOPSIS -.nf -#include - -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); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive a detailed error code when the most recent -transfer returned a \fBCURLE_PROXY\fP error. That error code matches the -\fBCURLproxycode\fP set. - -The error code is zero (\fBCURLPX_OK\fP) if no response code was available. -.SH PROTOCOLS -All that can be done over SOCKS -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.73.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RESPONSE_CODE (3), -.BR libcurl-errors (3) diff --git a/docs/libcurl/opts/CURLINFO_PROXY_ERROR.md b/docs/libcurl/opts/CURLINFO_PROXY_ERROR.md new file mode 100644 index 000000000..01113c740 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PROXY_ERROR.md @@ -0,0 +1,105 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PROXY_ERROR - get the detailed (SOCKS) proxy error + +# SYNOPSIS + +~~~c +#include + +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 + +All that can be done over SOCKS + +# 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 + +Added in 7.73.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.3 b/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.3 deleted file mode 100644 index c2a311a2a..000000000 --- a/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_PROXY_SSL_VERIFYRESULT 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLINFO_PROXY_SSL_VERIFYRESULT \- get the result of the proxy certificate verification -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PROXY_SSL_VERIFYRESULT, - long *result); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the result of the certificate verification -that was requested (using the \fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP -option. This is only used for HTTPS proxies. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT, &verifyresult); - printf("The peer verification said %s\\n", verifyresult? - "fine" : "bad"); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SSL_VERIFYRESULT (3) diff --git a/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md b/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md new file mode 100644 index 000000000..d97f5e78e --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_PROXY_SSL_VERIFYRESULT - get the result of the proxy certificate verification + +# SYNOPSIS + +~~~c +#include + +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. + +# PROTOCOLS + +All + +# 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_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT, &verifyresult); + printf("The peer verification said %s\n", verifyresult? + "fine" : "bad"); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_QUEUE_TIME_T.md b/docs/libcurl/opts/CURLINFO_QUEUE_TIME_T.md new file mode 100644 index 000000000..00454e752 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_QUEUE_TIME_T.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_QUEUE_TIME_T - time this transfer was queued + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 8.6.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.3 b/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.3 deleted file mode 100644 index a0017d706..000000000 --- a/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REDIRECT_COUNT 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_REDIRECT_COUNT \- get the number of redirects -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_COUNT, - long *countp); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the total number of redirections that were -actually followed. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.9.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLOPT_FOLLOWLOCATION (3) diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.md b/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.md new file mode 100644 index 000000000..aa75bdb22 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REDIRECT_COUNT.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REDIRECT_COUNT - get the number of redirects + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added in 7.9.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.3 b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.3 deleted file mode 100644 index ece2055c0..000000000 --- a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REDIRECT_TIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_REDIRECT_TIME \- get the time for all redirection steps -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_TIME, - double *timep); -.fi -.SH 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. \fICURLINFO_REDIRECT_TIME(3)\fP contains -the complete execution time for multiple redirections. - -See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.9.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLINFO_REDIRECT_TIME_T (3), -.BR CURLINFO_REDIRECT_URL (3) diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.md b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.md new file mode 100644 index 000000000..26d9af2a0 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REDIRECT_TIME - get the time for all redirection steps + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.9.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.3 b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.3 deleted file mode 100644 index cbda42035..000000000 --- a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REDIRECT_TIME_T 3 "28 Apr 2018" libcurl libcurl -.SH NAME -CURLINFO_REDIRECT_TIME_T \- get the time for all redirection steps -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_TIME_T, - curl_off_t *timep); -.fi -.SH 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. -\fICURLINFO_REDIRECT_TIME_T(3)\fP holds the complete execution time for -multiple redirections. - -See also the TIMES overview in the \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLINFO_REDIRECT_TIME (3), -.BR CURLINFO_REDIRECT_URL (3) diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.md b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.md new file mode 100644 index 000000000..f4ee71089 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REDIRECT_TIME_T.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REDIRECT_TIME_T - get the time for all redirection steps + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_URL.3 b/docs/libcurl/opts/CURLINFO_REDIRECT_URL.3 deleted file mode 100644 index 61422f6db..000000000 --- a/docs/libcurl/opts/CURLINFO_REDIRECT_URL.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REDIRECT_URL 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_REDIRECT_URL \- get the URL a redirect would go to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REDIRECT_URL, char **urlp); -.fi -.SH DESCRIPTION -Pass a pointer to a char pointer to receive the URL a redirect \fIwould\fP -take you to if you would enable \fICURLOPT_FOLLOWLOCATION(3)\fP. 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 \fICURLOPT_MAXREDIRS(3)\fP limit prevented a -redirect to happen (since 7.54.1). -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.18.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLINFO_REDIRECT_TIME_T (3), -.BR CURLOPT_FOLLOWLOCATION (3) diff --git a/docs/libcurl/opts/CURLINFO_REDIRECT_URL.md b/docs/libcurl/opts/CURLINFO_REDIRECT_URL.md new file mode 100644 index 000000000..8d7fc5c10 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REDIRECT_URL.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REDIRECT_URL - get the URL a redirect would go to + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added in 7.18.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REFERER.3 b/docs/libcurl/opts/CURLINFO_REFERER.3 deleted file mode 100644 index 550ccf9ae..000000000 --- a/docs/libcurl/opts/CURLINFO_REFERER.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REFERER 3 "11 Feb 2021" libcurl libcurl -.SH NAME -CURLINFO_REFERER \- get the referrer header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REFERER, char **hdrp); -.fi -.SH DESCRIPTION -Pass in a pointer to a char pointer and get the referrer header. - -The \fBhdrp\fP pointer is NULL or points to private memory you MUST NOT free - -it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.76.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_header (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_REFERER (3) diff --git a/docs/libcurl/opts/CURLINFO_REFERER.md b/docs/libcurl/opts/CURLINFO_REFERER.md new file mode 100644 index 000000000..fabc652a7 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REFERER.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REFERER - get the used referrer request header + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.76.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.3 b/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.3 deleted file mode 100644 index 9f7029107..000000000 --- a/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_REQUEST_SIZE 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_REQUEST_SIZE \- get size of sent request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_REQUEST_SIZE, long *sizep); -.fi -.SH 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 \fICURLOPT_FOLLOWLOCATION(3)\fP is enabled. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_HEADER_SIZE (3), -.BR CURLINFO_SIZE_DOWNLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.md b/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.md new file mode 100644 index 000000000..444f4ec23 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_REQUEST_SIZE.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_REQUEST_SIZE - get size of sent request + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.3 b/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.3 deleted file mode 100644 index c006a1580..000000000 --- a/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RESPONSE_CODE 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_RESPONSE_CODE \- get the last response code -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RESPONSE_CODE, long *codep); -.fi -.SH 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 -\fICURLINFO_HTTP_CONNECTCODE(3)\fP and not this. -.SH PROTOCOLS -HTTP, FTP, SMTP and LDAP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1. -Support for SMTP responses added in 7.25.0, for OpenLDAP in 7.81.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_HTTP_CONNECTCODE (3) diff --git a/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.md b/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.md new file mode 100644 index 000000000..43cf8378d --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RESPONSE_CODE.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RESPONSE_CODE - get the last response code + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP, FTP, SMTP and LDAP + +# 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); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.8. CURLINFO_HTTP_CODE was added in 7.4.1. +Support for SMTP responses added in 7.25.0, for OpenLDAP in 7.81.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RETRY_AFTER.3 b/docs/libcurl/opts/CURLINFO_RETRY_AFTER.3 deleted file mode 100644 index 5a7450ccb..000000000 --- a/docs/libcurl/opts/CURLINFO_RETRY_AFTER.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RETRY_AFTER 3 "6 Aug 2019" libcurl libcurl -.SH NAME -CURLINFO_RETRY_AFTER \- returns the Retry-After retry delay -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RETRY_AFTER, - curl_off_t *retry); -.fi -.SH 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 -\fICURLINFO_RETRY_AFTER(3)\fP always returns the number of seconds to wait - -or zero if there was no header or the header could not be parsed. -.SH DEFAULT -Returns zero delay if there was no header. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.66.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_header (3), -.BR CURLOPT_HEADERFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLINFO_RETRY_AFTER.md b/docs/libcurl/opts/CURLINFO_RETRY_AFTER.md new file mode 100644 index 000000000..adc120077 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RETRY_AFTER.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RETRY_AFTER - returns the Retry-After retry delay + +# SYNOPSIS + +~~~c +#include + +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. + +# DEFAULT + +Returns zero delay if there was no header. + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.66.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.3 b/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.3 deleted file mode 100644 index bd8ec271e..000000000 --- a/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RTSP_CLIENT_CSEQ 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_RTSP_CLIENT_CSEQ \- get the next RTSP client CSeq -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_CLIENT_CSEQ, - long *cseq); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the next CSeq that is expected to be used -by the application. -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RTSP_CSEQ_RECV (3), -.BR CURLINFO_RTSP_SERVER_CSEQ (3) diff --git a/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.md b/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.md new file mode 100644 index 000000000..8b515b427 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RTSP_CLIENT_CSEQ.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RTSP_CLIENT_CSEQ - get the next RTSP client CSeq + +# SYNOPSIS + +~~~c +#include + +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 + +RTSP + +# 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 + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.3 b/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.3 deleted file mode 100644 index dc840a847..000000000 --- a/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RTSP_CSEQ_RECV 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_RTSP_CSEQ_RECV \- get the recently received CSeq -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_CSEQ_RECV, long *cseq); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the most recently received CSeq from the -server. If your application encounters a \fICURLE_RTSP_CSEQ_ERROR\fP then you -may wish to troubleshoot and/or fix the CSeq mismatch by peeking at this -value. -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RTSP_SERVER_CSEQ (3) diff --git a/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.md b/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.md new file mode 100644 index 000000000..9eb813aa4 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RTSP_CSEQ_RECV.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RTSP_CSEQ_RECV - get the recently received CSeq + +# SYNOPSIS + +~~~c +#include + +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 + +RTSP + +# 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 + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.3 b/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.3 deleted file mode 100644 index 8cf052261..000000000 --- a/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RTSP_SERVER_CSEQ 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_RTSP_SERVER_CSEQ \- get the next RTSP server CSeq -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_SERVER_CSEQ, - long *cseq); -.fi -.SH 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. -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RTSP_CSEQ_RECV (3) diff --git a/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.md b/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.md new file mode 100644 index 000000000..7826f8a3c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RTSP_SERVER_CSEQ.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RTSP_SERVER_CSEQ - get the next RTSP server CSeq + +# SYNOPSIS + +~~~c +#include + +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 + +RTSP + +# 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 + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.3 b/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.3 deleted file mode 100644 index fe1e3fd0d..000000000 --- a/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_RTSP_SESSION_ID 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_RTSP_SESSION_ID \- get RTSP session ID -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_RTSP_SESSION_ID, char **id); -.fi -.SH 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 \fBid\fP pointer is NULL or points to private memory. You MUST NOT free - -it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the corresponding -CURL handle. -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_RTSP_CSEQ_RECV (3) diff --git a/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.md b/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.md new file mode 100644 index 000000000..402a122f8 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_RTSP_SESSION_ID.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_RTSP_SESSION_ID - get RTSP session ID + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the corresponding +CURL handle. + +# PROTOCOLS + +RTSP + +# 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 + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SCHEME.3 b/docs/libcurl/opts/CURLINFO_SCHEME.3 deleted file mode 100644 index 018866a68..000000000 --- a/docs/libcurl/opts/CURLINFO_SCHEME.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SCHEME 3 "23 November 2016" libcurl libcurl -.SH NAME -CURLINFO_SCHEME \- get the URL scheme (sometimes called protocol) used in the connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SCHEME, char **scheme); -.fi -.SH 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 \fBhandle\fP. - -The \fBscheme\fP pointer is NULL or points to private memory. You MUST NOT -free - it gets freed when you call \fIcurl_easy_cleanup(3)\fP on the -corresponding CURL handle. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_EFFECTIVE_URL (3), -.BR CURLINFO_PROTOCOL (3), -.BR CURLINFO_RESPONSE_CODE (3) diff --git a/docs/libcurl/opts/CURLINFO_SCHEME.md b/docs/libcurl/opts/CURLINFO_SCHEME.md new file mode 100644 index 000000000..db567fc98 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SCHEME.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SCHEME - get the URL scheme (sometimes called protocol) used in the connection + +# SYNOPSIS + +~~~c +#include + +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 gets freed when you call curl_easy_cleanup(3) on the +corresponding CURL handle. + +# PROTOCOLS + +All + +# 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 + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.3 b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.3 deleted file mode 100644 index 7ac1f9231..000000000 --- a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SIZE_DOWNLOAD 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_SIZE_DOWNLOAD \- get the number of downloaded bytes -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD, double *dlp); -.fi -.SH 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. - -\fICURLINFO_SIZE_DOWNLOAD_T(3)\fP is a newer replacement that returns a more -sensible variable type. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_DOWNLOAD_T (3), -.BR CURLINFO_SIZE_UPLOAD_T (3), -.BR CURLOPT_MAXFILESIZE (3) diff --git a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.md b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.md new file mode 100644 index 000000000..ff19908cf --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SIZE_DOWNLOAD - get the number of downloaded bytes + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.4.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.3 b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.3 deleted file mode 100644 index 5e424f235..000000000 --- a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SIZE_DOWNLOAD_T 3 "25 May 2017" libcurl libcurl -.SH NAME -CURLINFO_SIZE_DOWNLOAD_T \- get the number of downloaded bytes -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_DOWNLOAD_T, - curl_off_t *dlp); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP 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. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_DOWNLOAD (3), -.BR CURLINFO_SIZE_UPLOAD_T (3), -.BR CURLOPT_MAXFILESIZE (3) diff --git a/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.md b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.md new file mode 100644 index 000000000..f5468db9d --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SIZE_DOWNLOAD_T.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SIZE_DOWNLOAD_T - get the number of downloaded bytes + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.3 b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.3 deleted file mode 100644 index ba01b3119..000000000 --- a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SIZE_UPLOAD 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_SIZE_UPLOAD \- get the number of uploaded bytes -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_UPLOAD, - double *uploadp); -.fi -.SH DESCRIPTION -Pass a pointer to a double to receive the total amount of bytes that were -uploaded. - -\fICURLINFO_SIZE_UPLOAD_T(3)\fP is a newer replacement that returns a more -sensible variable type. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_DOWNLOAD_T (3), -.BR CURLINFO_SIZE_UPLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.md b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.md new file mode 100644 index 000000000..175fe718d --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SIZE_UPLOAD - get the number of uploaded bytes + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.4.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.3 b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.3 deleted file mode 100644 index 24230c046..000000000 --- a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SIZE_UPLOAD_T 3 "25 May 2017" libcurl libcurl -.SH NAME -CURLINFO_SIZE_UPLOAD_T \- get the number of uploaded bytes -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SIZE_UPLOAD_T, - curl_off_t *uploadp); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP to receive the total amount of bytes that -were uploaded. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_DOWNLOAD_T (3), -.BR CURLINFO_SIZE_UPLOAD (3) - diff --git a/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.md b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.md new file mode 100644 index 000000000..29874f9fd --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SIZE_UPLOAD_T.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SIZE_UPLOAD_T - get the number of uploaded bytes + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.3 b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.3 deleted file mode 100644 index 7c277d51d..000000000 --- a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SPEED_DOWNLOAD 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_SPEED_DOWNLOAD \- get download speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_DOWNLOAD, - double *speed); -.fi -.SH DESCRIPTION -Pass a pointer to a double to receive the average download speed that curl -measured for the complete download. Measured in bytes/second. - -\fICURLINFO_SPEED_DOWNLOAD_T(3)\fP is a newer replacement that returns a more -sensible variable type. -.SH PROTOCOLS -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_UPLOAD_T (3), -.BR CURLINFO_SPEED_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.md b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.md new file mode 100644 index 000000000..fe0766939 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SPEED_DOWNLOAD - get download speed + +# SYNOPSIS + +~~~c +#include + +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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.4.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.3 b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.3 deleted file mode 100644 index b17d28281..000000000 --- a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SPEED_DOWNLOAD_T 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_SPEED_DOWNLOAD_T \- get download speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_DOWNLOAD_T, - curl_off_t *speed); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP to receive the average download speed -that curl measured for the complete download. Measured in bytes/second. -.SH PROTOCOLS -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SIZE_UPLOAD_T (3), -.BR CURLINFO_SPEED_UPLOAD_T (3) - diff --git a/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.md b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.md new file mode 100644 index 000000000..c8bc2f867 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SPEED_DOWNLOAD_T.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SPEED_DOWNLOAD_T - get download speed + +# SYNOPSIS + +~~~c +#include + +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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.3 b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.3 deleted file mode 100644 index c42f3b517..000000000 --- a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SPEED_UPLOAD 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_SPEED_UPLOAD \- get upload speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_UPLOAD, double *speed); -.fi -.SH DESCRIPTION -Pass a pointer to a double to receive the average upload speed that curl -measured for the complete upload. Measured in bytes/second. - -\fICURLINFO_SPEED_UPLOAD_T(3)\fP is a newer replacement that returns a more -sensible variable type. -.SH PROTOCOLS -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1. Deprecated since 7.55.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SPEED_DOWNLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.md b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.md new file mode 100644 index 000000000..11ce92923 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SPEED_UPLOAD - get upload speed + +# SYNOPSIS + +~~~c +#include + +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); + } + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.4.1. Deprecated since 7.55.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.3 b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.3 deleted file mode 100644 index f2bf1d735..000000000 --- a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SPEED_UPLOAD_T 3 "25 May 2017" libcurl libcurl -.SH NAME -CURLINFO_SPEED_UPLOAD_T \- get upload speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SPEED_UPLOAD_T, - curl_off_t *speed); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP to receive the average upload speed that -curl measured for the complete upload. Measured in bytes/second. -.SH PROTOCOLS -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_SPEED_DOWNLOAD_T (3) diff --git a/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.md b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.md new file mode 100644 index 000000000..178e9a526 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SPEED_UPLOAD_T.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SPEED_UPLOAD_T - get upload speed + +# SYNOPSIS + +~~~c +#include + +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 + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SSL_ENGINES.3 b/docs/libcurl/opts/CURLINFO_SSL_ENGINES.3 deleted file mode 100644 index 03db5bbb4..000000000 --- a/docs/libcurl/opts/CURLINFO_SSL_ENGINES.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SSL_ENGINES 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_SSL_ENGINES \- get an slist of OpenSSL crypto-engines -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SSL_ENGINES, - struct curl_slist **engine_list); -.fi -.SH 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. \fBNOTE:\fP you must call \fIcurl_slist_free_all(3)\fP -on the list pointer once you are done with it, as libcurl does not free this -data for you. -.SH PROTOCOLS -All TLS based ones. -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.3. Available in OpenSSL builds with "engine" support. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLOPT_SSLENGINE (3) diff --git a/docs/libcurl/opts/CURLINFO_SSL_ENGINES.md b/docs/libcurl/opts/CURLINFO_SSL_ENGINES.md new file mode 100644 index 000000000..9dbb0a1d1 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SSL_ENGINES.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SSL_ENGINES - get an slist of OpenSSL crypto-engines + +# SYNOPSIS + +~~~c +#include + +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 + +All TLS based ones. + +# 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 + +Added in 7.12.3. Available in OpenSSL builds with "engine" support. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.3 b/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.3 deleted file mode 100644 index cf881ec81..000000000 --- a/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_SSL_VERIFYRESULT 3 "1 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_SSL_VERIFYRESULT \- get the result of the certificate verification -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_SSL_VERIFYRESULT, - long *result); -.fi -.SH DESCRIPTION -Pass a pointer to a long to receive the result of the server SSL certificate -verification that was requested (using the \fICURLOPT_SSL_VERIFYPEER(3)\fP -option). - -0 is a positive result. Non-zero is an error. -.SH PROTOCOLS -All using TLS -.SH EXAMPLE -.nf -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_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &verifyresult); - printf("The peer verification said %s\\n", verifyresult? - "BAAAD":"fine"); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.5. Only set by the OpenSSL/libressl/boringssl and GnuTLS backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_PROXY_SSL_VERIFYRESULT (3) diff --git a/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.md b/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.md new file mode 100644 index 000000000..fdc38f016 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_SSL_VERIFYRESULT.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_SSL_VERIFYRESULT - get the result of the certificate verification + +# SYNOPSIS + +~~~c +#include + +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 + +All using TLS + +# 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_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &verifyresult); + printf("The peer verification said %s\n", verifyresult? + "BAAAD":"fine"); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.5. Only set by the OpenSSL/libressl/boringssl and GnuTLS backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.3 b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.3 deleted file mode 100644 index c9879d2e5..000000000 --- a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_STARTTRANSFER_TIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_STARTTRANSFER_TIME \- get the time until the first byte is received -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_STARTTRANSFER_TIME, - double *timep); -.fi -.SH 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 -\fICURLINFO_PRETRANSFER_TIME(3)\fP 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.9.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_STARTTRANSFER_TIME_T (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.md b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.md new file mode 100644 index 000000000..d7c1f0884 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_STARTTRANSFER_TIME - get the time until the first byte is received + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.9.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.3 b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.3 deleted file mode 100644 index 7638f115e..000000000 --- a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_STARTTRANSFER_TIME_T 3 "28 Apr 2018" libcurl libcurl -.SH NAME -CURLINFO_STARTTRANSFER_TIME_T \- get the time until the first byte is received -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_STARTTRANSFER_TIME_T, - curl_off_t *timep); -.fi -.SH 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 -\fICURLINFO_PRETRANSFER_TIME_T(3)\fP 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_STARTTRANSFER_TIME (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.md b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.md new file mode 100644 index 000000000..481c7f5bd --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_STARTTRANSFER_TIME_T.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_STARTTRANSFER_TIME_T - get the time until the first byte is received + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 b/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 deleted file mode 100644 index 60d648552..000000000 --- a/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_TLS_SESSION 3 "12 Sep 2015" libcurl libcurl -.SH NAME -CURLINFO_TLS_SESSION \- get TLS session info -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION, - struct curl_tlssessioninfo **session); -.SH DESCRIPTION -\fBThis option has been superseded\fP by \fICURLINFO_TLS_SSL_PTR(3)\fP which -was added in 7.48.0. The only reason you would use this option instead is if -you could be using a version of libcurl earlier than 7.48.0. - -This option is exactly the same as \fICURLINFO_TLS_SSL_PTR(3)\fP except in the -case of OpenSSL. If the session \fIbackend\fP is CURLSSLBACKEND_OPENSSL the -session \fIinternals\fP pointer varies depending on the option: - -\fICURLINFO_TLS_SESSION(3)\fP OpenSSL session \fIinternals\fP is \fBSSL_CTX *\fP. - -\fICURLINFO_TLS_SSL_PTR(3)\fP OpenSSL session \fIinternals\fP is \fBSSL *\fP. - -You can obtain an \fBSSL_CTX\fP pointer from an SSL pointer using OpenSSL -function \fISSL_get_SSL_CTX(3)\fP. Therefore unless you need compatibility -with older versions of libcurl use \fICURLINFO_TLS_SSL_PTR(3)\fP. Refer to -that document for more information. -.SH PROTOCOLS -All TLS-based -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.34.0. Deprecated since 7.48.0 and supported OpenSSL, GnuTLS, and -NSS only up until this version was released. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_TLS_SSL_PTR (3) diff --git a/docs/libcurl/opts/CURLINFO_TLS_SESSION.md b/docs/libcurl/opts/CURLINFO_TLS_SESSION.md new file mode 100644 index 000000000..98cc2d67c --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_TLS_SESSION.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_TLS_SESSION - get TLS session info + +# SYNOPSIS + +~~~c +#include + +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) which +was added in 7.48.0. The only reason you would use this option instead is if +you could be using a version of libcurl earlier than 7.48.0. + +This option is exactly the same as CURLINFO_TLS_SSL_PTR(3) except in the +case of OpenSSL. If the session *backend* is CURLSSLBACKEND_OPENSSL the +session *internals* pointer varies depending on the option: + +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. + +# PROTOCOLS + +All TLS-based + +# 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); + } +} +~~~ + +# AVAILABILITY + +Added in 7.34.0. Deprecated since 7.48.0 and supported OpenSSL, GnuTLS, and +NSS only up until this version was released. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 b/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 deleted file mode 100644 index 8c5f2525e..000000000 --- a/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 +++ /dev/null @@ -1,165 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_TLS_SSL_PTR 3 "23 Feb 2016" libcurl libcurl -.SH NAME -CURLINFO_TLS_SESSION, CURLINFO_TLS_SSL_PTR \- get TLS session info -.SH SYNOPSIS -.nf -#include - -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); -.SH DESCRIPTION -Pass a pointer to a \fIstruct curl_tlssessioninfo *\fP. The pointer is -initialized to refer to a \fIstruct curl_tlssessioninfo *\fP 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 \fBLIMITATIONS\fP section. - -.nf -struct curl_tlssessioninfo { - curl_sslbackend backend; - void *internals; -}; -.fi - -The \fIbackend\fP struct member is one of the defines in the CURLSSLBACKEND_* -series: CURLSSLBACKEND_NONE (when built without TLS support), -CURLSSLBACKEND_WOLFSSL, CURLSSLBACKEND_SECURETRANSPORT, CURLSSLBACKEND_GNUTLS, -CURLSSLBACKEND_MBEDTLS, CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL, -CURLSSLBACKEND_SCHANNEL or CURLSSLBACKEND_MESALINK. (Note that the OpenSSL -forks are all reported as just OpenSSL here.) - -The \fIinternals\fP struct member points to a TLS library specific pointer for -the active ("in use") SSL connection, with the following underlying types: -.RS -.IP GnuTLS -\fBgnutls_session_t\fP -.IP NSS -\fBPRFileDesc *\fP -.IP OpenSSL -\fICURLINFO_TLS_SESSION(3)\fP: \fBSSL_CTX *\fP - -\fICURLINFO_TLS_SSL_PTR(3)\fP: \fBSSL *\fP -.RE -Since 7.48.0 the \fIinternals\fP member can point to these other SSL backends -as well: -.RS -.IP mbedTLS -\fBmbedTLS_ssl_context *\fP -.IP "Secure Channel" -\fBCtxtHandle *\fP -.IP "Secure Transport" -\fBSSLContext *\fP -.IP "wolfSSL" -\fBSSL *\fP -.RE - -If the \fIinternals\fP 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. \fIcurl_easy_perform(3)\fP has -returned). -.SH 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 -\fICURLOPT_USE_SSL(3)\fP. Though you can to retrieve the SSL pointer, it's -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 -\fICURLOPT_SSL_CTX_FUNCTION(3)\fP 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 -.SH PROTOCOLS -All TLS-based -.SH EXAMPLE -.nf -#include -#include - -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; -} -.fi -.SH AVAILABILITY -Added in 7.48.0. - -This option supersedes \fICURLINFO_TLS_SESSION(3)\fP which was added in 7.34.0. -This option is exactly the same as that option except in the case of OpenSSL. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_TLS_SESSION (3) diff --git a/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.md b/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.md new file mode 100644 index 000000000..4fc246adf --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.md @@ -0,0 +1,174 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_TLS_SESSION, CURLINFO_TLS_SSL_PTR - get TLS session info + +# SYNOPSIS + +~~~c +#include + +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 the defines in the CURLSSLBACKEND_* +series: CURLSSLBACKEND_NONE (when built without TLS support), +CURLSSLBACKEND_WOLFSSL, CURLSSLBACKEND_SECURETRANSPORT, CURLSSLBACKEND_GNUTLS, +CURLSSLBACKEND_MBEDTLS, CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL, +CURLSSLBACKEND_SCHANNEL or CURLSSLBACKEND_MESALINK. (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** + +## NSS + +**PRFileDesc *** + +## 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 *** + +## Secure Transport + +**SSLContext *** + +## 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 + +All TLS-based + +# EXAMPLE + +~~~c +#include +#include + +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; +} +~~~ + +# AVAILABILITY + +Added in 7.48.0. + +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. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_TOTAL_TIME.3 b/docs/libcurl/opts/CURLINFO_TOTAL_TIME.3 deleted file mode 100644 index c5519fcb0..000000000 --- a/docs/libcurl/opts/CURLINFO_TOTAL_TIME.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_TOTAL_TIME 3 "28 Aug 2015" libcurl libcurl -.SH NAME -CURLINFO_TOTAL_TIME \- get total time of previous transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME, double *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.4.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_TOTAL_TIME_T (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLINFO_TOTAL_TIME.md b/docs/libcurl/opts/CURLINFO_TOTAL_TIME.md new file mode 100644 index 000000000..c6af1694e --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_TOTAL_TIME.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_TOTAL_TIME - get total time of previous transfer + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.4.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.3 b/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.3 deleted file mode 100644 index 54a0d547c..000000000 --- a/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_TOTAL_TIME_T 3 "28 Apr 2018" libcurl libcurl -.SH NAME -CURLINFO_TOTAL_TIME_T \- get total time of previous transfer in microseconds -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TOTAL_TIME_T, - curl_off_t *timep); -.fi -.SH 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 \fIcurl_easy_getinfo(3)\fP man page. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_TOTAL_TIME (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.md b/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.md new file mode 100644 index 000000000..488d5d3aa --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_TOTAL_TIME_T.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_TOTAL_TIME_T - get total time of previous transfer in microseconds + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLINFO_XFER_ID.3 b/docs/libcurl/opts/CURLINFO_XFER_ID.3 deleted file mode 100644 index b166b20bf..000000000 --- a/docs/libcurl/opts/CURLINFO_XFER_ID.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLINFO_XFER_ID 3 "07 June 2023" "libcurl" "libcurl" -.SH NAME -CURLINFO_XFER_ID \- get the ID of a transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_XFER_ID, - curl_off_t *xfer_id); -.fi -.SH DESCRIPTION -Pass a pointer to a \fIcurl_off_t\fP 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. - -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); - } - } - } -} -.fi -.SH AVAILABILITY -Added in 8.2.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR curl_easy_setopt (3), -.BR CURLINFO_CONN_ID (3) diff --git a/docs/libcurl/opts/CURLINFO_XFER_ID.md b/docs/libcurl/opts/CURLINFO_XFER_ID.md new file mode 100644 index 000000000..b32a46b12 --- /dev/null +++ b/docs/libcurl/opts/CURLINFO_XFER_ID.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLINFO_XFER_ID - get the ID of a transfer + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# 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 + +Added in 8.2.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3 b/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3 deleted file mode 100644 index 932e33397..000000000 --- a/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE \- chunk length threshold for pipelining -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, - long size); -.fi -.SH DESCRIPTION -No function since pipelining was removed in 7.62.0. - -Pass a long with a \fBsize\fP in bytes. If a transfer in a pipeline is -currently processing a chunked (Transfer-encoding: chunked) request with a -current chunk length larger than \fICURLMOPT_CHUNK_LENGTH_PENALTY_SIZE(3)\fP, -that pipeline is not considered for additional requests, even if it is shorter -than \fICURLMOPT_MAX_PIPELINE_LENGTH(3)\fP. -.SH DEFAULT -The default value is 0, which means that the penalization is inactive. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - long maxchunk = 10000; - curl_multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, maxchunk); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE (3), -.BR CURLMOPT_MAX_PIPELINE_LENGTH (3), -.BR CURLMOPT_PIPELINING (3) diff --git a/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.md b/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.md new file mode 100644 index 000000000..127f4dd06 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE - chunk length threshold for pipelining + +# SYNOPSIS + +~~~c +#include + +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 + +The default value is 0, which means that the penalization is inactive. + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURLM *m = curl_multi_init(); + long maxchunk = 10000; + curl_multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, maxchunk); +} +~~~ + +# AVAILABILITY + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3 b/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3 deleted file mode 100644 index 30bbe99ec..000000000 --- a/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3 +++ /dev/null @@ -1,62 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE \- size threshold for pipelining penalty -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, - long size); -.fi -.SH DESCRIPTION -No function since pipelining was removed in 7.62.0. - -Pass a long with a \fBsize\fP in bytes. If a transfer in a pipeline is -currently processing a request with a Content-Length larger than this -\fICURLMOPT_CONTENT_LENGTH_PENALTY_SIZE(3)\fP, that pipeline is not considered -for additional requests, even if it is shorter than -\fICURLMOPT_MAX_PIPELINE_LENGTH(3)\fP. -.SH DEFAULT -The default value is 0, which means that the size penalization is inactive. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - long maxlength = 10000; - curl_multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, maxlength); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE (3) diff --git a/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.md b/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.md new file mode 100644 index 000000000..d3e7abaf0 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.md @@ -0,0 +1,60 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE - size threshold for pipelining penalty + +# SYNOPSIS + +~~~c +#include + +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 + +The default value is 0, which means that the size penalization is inactive. + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURLM *m = curl_multi_init(); + long maxlength = 10000; + curl_multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, maxlength); +} +~~~ + +# AVAILABILITY + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.3 b/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.3 deleted file mode 100644 index e0d75f2d5..000000000 --- a/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_MAXCONNECTS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLMOPT_MAXCONNECTS \- size of connection cache -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max); -.fi -.SH DESCRIPTION -Pass a long indicating the \fBmax\fP. The set number is used as the maximum -amount of simultaneously open connections that libcurl may keep in its -connection cache after completed 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 can prevent the cache size from growing beyond the -limit set by you. - -When the cache is full, curl closes the oldest one in the cache to prevent the -number of open connections from increasing. - -This option is for the multi handle's use only, when using the easy interface -you should instead use the \fICURLOPT_MAXCONNECTS(3)\fP option. - -See \fICURLMOPT_MAX_TOTAL_CONNECTIONS(3)\fP for limiting the number of active -connections. - -.SH DEFAULT -See DESCRIPTION -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - /* only keep 10 connections in the cache */ - curl_multi_setopt(m, CURLMOPT_MAXCONNECTS, 10L); -} -.fi -.SH AVAILABILITY -Added in 7.16.3 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3), -.BR CURLOPT_MAXCONNECTS (3) diff --git a/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.md b/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.md new file mode 100644 index 000000000..9a5457fa5 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_MAXCONNECTS.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLMOPT_MAXCONNECTS +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_MAX_HOST_CONNECTIONS (3) + - CURLOPT_MAXCONNECTS (3) +--- + +# NAME + +CURLMOPT_MAXCONNECTS - size of connection cache + +# SYNOPSIS + +~~~c +#include + +CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAXCONNECTS, long max); +~~~ + +# DESCRIPTION + +Pass a long indicating the **max**. The set number is used as the maximum +amount of simultaneously open connections that libcurl may keep in its +connection cache after completed 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 can prevent the cache size from growing beyond the +limit set by you. + +When the cache is full, curl closes the oldest one in the cache to prevent the +number of open 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. + +# DEFAULT + +See DESCRIPTION + +# PROTOCOLS + +All + +# 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 + +Added in 7.16.3 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.3 b/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.3 deleted file mode 100644 index 7b5741e58..000000000 --- a/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_MAX_CONCURRENT_STREAMS 3 "06 Nov 2019" libcurl libcurl -.SH NAME -CURLMOPT_MAX_CONCURRENT_STREAMS \- max concurrent streams for http2 -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_CONCURRENT_STREAMS, - long max); -.fi -.SH DESCRIPTION -Pass a long indicating the \fBmax\fP. 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. -.SH DEFAULT -100 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - /* max concurrent streams 200 */ - curl_multi_setopt(m, CURLMOPT_MAX_CONCURRENT_STREAMS, 200L); -} -.fi -.SH AVAILABILITY -Added in 7.67.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_MAXCONNECTS (3), -.BR CURLOPT_MAXCONNECTS (3) diff --git a/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.md b/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.md new file mode 100644 index 000000000..247199444 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_MAX_CONCURRENT_STREAMS.md @@ -0,0 +1,59 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLMOPT_MAX_CONCURRENT_STREAMS +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_MAXCONNECTS (3) + - CURLOPT_MAXCONNECTS (3) +--- + +# NAME + +CURLMOPT_MAX_CONCURRENT_STREAMS - max concurrent streams for http2 + +# SYNOPSIS + +~~~c +#include + +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 + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURLM *m = curl_multi_init(); + /* max concurrent streams 200 */ + curl_multi_setopt(m, CURLMOPT_MAX_CONCURRENT_STREAMS, 200L); +} +~~~ + +# AVAILABILITY + +Added in 7.67.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.3 b/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.3 deleted file mode 100644 index fb0f6787c..000000000 --- a/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_MAX_HOST_CONNECTIONS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLMOPT_MAX_HOST_CONNECTIONS \- max number of connections to a single host -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_HOST_CONNECTIONS, - long max); -.fi -.SH DESCRIPTION -Pass a long to indicate \fBmax\fP. The set number is used as the maximum -amount of simultaneously open connections to a single host (a host being the -same as a host name + port number pair). For each new session to a host, -libcurl might open a new connection up to the limit set by -\fICURLMOPT_MAX_HOST_CONNECTIONS(3)\fP. When the limit is reached, new -sessions are kept pending until a connection becomes available. - -The default \fBmax\fP 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. When that -happens, the \fICURLOPT_TIMEOUT_MS(3)\fP timeout is inclusive of the waiting -time, meaning that if you set a too narrow timeout in such a case the transfer -might never even start before it times out. - -Even in the queued up situation, the \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP -timeout is however treated as a per-connect timeout. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_MAXCONNECTS (3), -.BR CURLMOPT_MAX_TOTAL_CONNECTIONS (3) diff --git a/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.md b/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.md new file mode 100644 index 000000000..75c4768f6 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_MAX_HOST_CONNECTIONS.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_MAX_HOST_CONNECTIONS - max number of connections to a single host + +# SYNOPSIS + +~~~c +#include + +CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_HOST_CONNECTIONS, + long max); +~~~ + +# DESCRIPTION + +Pass a long to indicate **max**. The set number is used as the maximum amount +of simultaneously open connections to a single host (a host being the same as +a hostname + port number pair). For each new session to a 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. When that +happens, the CURLOPT_TIMEOUT_MS(3) timeout is inclusive of the waiting +time, meaning that if you set a too narrow timeout in such a case the transfer +might never even start before it times out. + +Even in the queued up situation, the CURLOPT_CONNECTTIMEOUT_MS(3) +timeout is however treated as a per-connect timeout. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.3 b/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.3 deleted file mode 100644 index 9f2c6ffbe..000000000 --- a/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_MAX_PIPELINE_LENGTH 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_MAX_PIPELINE_LENGTH \- maximum number of requests in a pipeline -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_PIPELINE_LENGTH, - long max); -.fi -.SH DESCRIPTION -No function since pipelining was removed in 7.62.0. - -Pass a long. The set \fBmax\fP 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 \fICURLMOPT_MAX_HOST_CONNECTIONS(3)\fP), 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 \fICURLMOPT_MAX_HOST_CONNECTIONS(3)\fP * -\fICURLMOPT_MAX_PIPELINE_LENGTH(3)\fP. -.SH DEFAULT -5 -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - /* set a more conservative pipe length */ - curl_multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3) diff --git a/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.md b/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.md new file mode 100644 index 000000000..bad638e5f --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_MAX_PIPELINE_LENGTH.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_MAX_PIPELINE_LENGTH - maximum number of requests in a pipeline + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# 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 + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.3 b/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.3 deleted file mode 100644 index 130822f56..000000000 --- a/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_MAX_TOTAL_CONNECTIONS 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_MAX_TOTAL_CONNECTIONS \- max simultaneously open connections -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, - long amount); -.fi -.SH DESCRIPTION -Pass a long for the \fBamount\fP. 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 -\fICURLMOPT_MAX_TOTAL_CONNECTIONS(3)\fP. When the limit is reached, new -sessions are held pending until there are available connections. If -\fICURLMOPT_PIPELINING(3)\fP 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. When that -happens, the \fICURLOPT_TIMEOUT_MS(3)\fP timeout is counted inclusive of the -waiting time, meaning that if you set a too narrow timeout in such a case the -transfer might never even start before it times out. - -Even in the queued up situation, the \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP -timeout is however treated as a per-connect timeout. -.SH DEFAULT -The default value is 0, which means that there is no limit. It is then simply -controlled by the number of easy handles added. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - /* never do more than 15 connections */ - curl_multi_setopt(m, CURLMOPT_MAX_TOTAL_CONNECTIONS, 15L); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_MAXCONNECTS (3), -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3) diff --git a/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.md b/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.md new file mode 100644 index 000000000..859bb2ad5 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_MAX_TOTAL_CONNECTIONS.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_MAX_TOTAL_CONNECTIONS - max simultaneously open connections + +# SYNOPSIS + +~~~c +#include + +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). When the limit is reached, new +sessions are held pending until there are available connections. 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. When that +happens, the CURLOPT_TIMEOUT_MS(3) timeout is counted inclusive of the +waiting time, meaning that if you set a too narrow timeout in such a case the +transfer might never even start before it times out. + +Even in the queued up situation, the CURLOPT_CONNECTTIMEOUT_MS(3) +timeout is however treated as a per-connect timeout. + +# DEFAULT + +The default value is 0, which means that there is no limit. It is then simply +controlled by the number of easy handles added. + +# PROTOCOLS + +All + +# 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 + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING.3 b/docs/libcurl/opts/CURLMOPT_PIPELINING.3 deleted file mode 100644 index 88777320f..000000000 --- a/docs/libcurl/opts/CURLMOPT_PIPELINING.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_PIPELINING 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLMOPT_PIPELINING \- enable HTTP pipelining and multiplexing -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING, long bitmask); -.fi -.SH DESCRIPTION -Pass in the correct value in the \fBbitmask\fP 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. - -.IP CURLPIPE_NOTHING (0) -Default, which means doing no attempts at multiplexing. -.IP CURLPIPE_HTTP1 (1) -This bit is deprecated and has no effect since version 7.62.0. -.IP 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. -.SH DEFAULT -Since 7.62.0, \fBCURLPIPE_MULTIPLEX\fP is enabled by default. - -Before that, default was \fBCURLPIPE_NOTHING\fP. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURLM *m = curl_multi_init(); - /* try HTTP/2 multiplexing */ - curl_multi_setopt(m, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); -} -.fi -.SH AVAILABILITY -Added in 7.16.0. Multiplex support bit added in 7.43.0. HTTP/1 Pipelining -support was disabled in 7.62.0. -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE (3), -.BR CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE (3), -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3), -.BR CURLMOPT_MAX_PIPELINE_LENGTH (3), -.BR CURLMOPT_MAXCONNECTS (3), -.BR CURLMOPT_PIPELINING_SITE_BL (3) diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING.md b/docs/libcurl/opts/CURLMOPT_PIPELINING.md new file mode 100644 index 000000000..3df71b54f --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_PIPELINING.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_PIPELINING - enable HTTP pipelining and multiplexing + +# SYNOPSIS + +~~~c +#include + +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) + +Default, which means doing 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 + +Since 7.62.0, **CURLPIPE_MULTIPLEX** is enabled by default. + +Before that, default was **CURLPIPE_NOTHING**. + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURLM *m = curl_multi_init(); + /* try HTTP/2 multiplexing */ + curl_multi_setopt(m, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); +} +~~~ + +# AVAILABILITY + +Added in 7.16.0. Multiplex support bit added in 7.43.0. HTTP/1 Pipelining +support was disabled in 7.62.0. + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.3 b/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.3 deleted file mode 100644 index b59232fb8..000000000 --- a/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_PIPELINING_SERVER_BL 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_PIPELINING_SERVER_BL \- pipelining server block list -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING_SERVER_BL, - char **servers); -.fi -.SH DESCRIPTION -No function since pipelining was removed in 7.62.0. - -Pass a \fBservers\fP 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. -.SH DEFAULT -The default value is NULL, which means that there is no block list. -.SH PROTOCOLS -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLMOPT_PIPELINING_SITE_BL (3) diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.md b/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.md new file mode 100644 index 000000000..226700806 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_PIPELINING_SERVER_BL.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_PIPELINING_SERVER_BL - pipelining server block list + +# SYNOPSIS + +~~~c +#include + +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 + +The default value is 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 + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.3 b/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.3 deleted file mode 100644 index 2bbfbfe26..000000000 --- a/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_PIPELINING_SITE_BL 3 "4 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_PIPELINING_SITE_BL \- pipelining host block list -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PIPELINING_SITE_BL, - char **hosts); -.fi -.SH DESCRIPTION -No function since pipelining was removed in 7.62.0. - -Pass a \fBhosts\fP 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. -.SH DEFAULT -The default value is NULL, which means that there is no block list. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.30.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLMOPT_PIPELINING_SERVER_BL (3) diff --git a/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.md b/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.md new file mode 100644 index 000000000..a212c4f63 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_PIPELINING_SITE_BL.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_PIPELINING_SITE_BL - pipelining host block list + +# SYNOPSIS + +~~~c +#include + +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 + +The default value is NULL, which means that there is no block list. + +# PROTOCOLS + +HTTP(S) + +# 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 + +Added in 7.30.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_PUSHDATA.3 b/docs/libcurl/opts/CURLMOPT_PUSHDATA.3 deleted file mode 100644 index 8ff04bbe0..000000000 --- a/docs/libcurl/opts/CURLMOPT_PUSHDATA.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_PUSHDATA 3 "1 Jun 2015" libcurl libcurl -.SH NAME -CURLMOPT_PUSHDATA \- pointer to pass to push callback -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_PUSHDATA, void *pointer); -.fi -.SH DESCRIPTION -Set a \fIpointer\fP to pass as the last argument to the -\fICURLMOPT_PUSHFUNCTION(3)\fP callback. The pointer is not touched or used by -libcurl itself, only passed on to the callback function. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -#include - -/* only allow pushes for file names 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); -} -.fi -.SH AVAILABILITY -Added in 7.44.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLMOPT_PUSHFUNCTION (3), -.BR CURLOPT_PIPEWAIT (3), -.BR RFC 7540 diff --git a/docs/libcurl/opts/CURLMOPT_PUSHDATA.md b/docs/libcurl/opts/CURLMOPT_PUSHDATA.md new file mode 100644 index 000000000..23e8785f2 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_PUSHDATA.md @@ -0,0 +1,87 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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 +--- + +# NAME + +CURLMOPT_PUSHDATA - pointer to pass to push callback + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) + +# EXAMPLE + +~~~c +#include + +/* only allow pushes for file names 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 + +Added in 7.44.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3 b/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3 deleted file mode 100644 index e1a96218f..000000000 --- a/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.3 +++ /dev/null @@ -1,139 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_PUSHFUNCTION 3 "1 Jun 2015" libcurl libcurl -.SH NAME -CURLMOPT_PUSHFUNCTION \- callback that approves or denies server pushes -.SH SYNOPSIS -.nf -#include - -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); -.fi -.SH 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. -.SH CALLBACK DESCRIPTION -The callback gets its arguments like this: - -\fIparent\fP 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. - -\fIeasy\fP is a newly created handle that represents this upcoming transfer. - -\fInum_headers\fP is the number of name+value pairs that was received and can -be accessed - -\fIheaders\fP 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. - -\fIclientp\fP is the pointer set with \fICURLMOPT_PUSHDATA(3)\fP - -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: \fIcurl_pushheader_byname(3)\fP and -\fIcurl_pushheader_bynum(3)\fP. 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 \fIcurl_easy_header(3)\fP, -introduced in later libcurl versions. -.SH CALLBACK RETURN VALUE -.IP "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. -.IP "CURL_PUSH_DENY (1)" -The callback denies the stream and no data reaches the application, the easy -handle is destroyed by libcurl. -.IP "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) -.IP * -All other return codes are reserved for future use. -.SH DEFAULT -NULL, no callback -.SH PROTOCOLS -HTTP(S) (HTTP/2 only) -.SH EXAMPLE -.nf -#include - -/* only allow pushes for file names 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); -} -.fi -.SH AVAILABILITY -Added in 7.44.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PUSHDATA (3), -.BR CURLMOPT_PIPELINING (3), -.BR CURLOPT_PIPEWAIT (3), -.BR RFC 7540 diff --git a/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.md b/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.md new file mode 100644 index 000000000..903ac06fb --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_PUSHFUNCTION.md @@ -0,0 +1,148 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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 +--- + +# NAME + +CURLMOPT_PUSHFUNCTION - callback that approves or denies server pushes + +# SYNOPSIS + +~~~c +#include + +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 + +HTTP(S) (HTTP/2 only) + +# EXAMPLE + +~~~c +#include + +/* only allow pushes for file names 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 + +Added in 7.44.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_SOCKETDATA.3 b/docs/libcurl/opts/CURLMOPT_SOCKETDATA.3 deleted file mode 100644 index aeb04daba..000000000 --- a/docs/libcurl/opts/CURLMOPT_SOCKETDATA.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_SOCKETDATA 3 "3 Nov 2014" libcurl libcurl -.SH NAME -CURLMOPT_SOCKETDATA \- custom pointer passed to the socket callback -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETDATA, void *pointer); -.SH DESCRIPTION -A data \fIpointer\fP to pass to the socket callback set with the -\fICURLMOPT_SOCKETFUNCTION(3)\fP option. - -This pointer is not touched by libcurl but is only passed in as the socket -callbacks's \fBclientp\fP argument. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.15.4 -.SH RETURN VALUE -Returns CURLM_OK. -.SH "SEE ALSO" -.BR curl_multi_socket_action (3), -.BR CURLMOPT_SOCKETFUNCTION (3), -.BR CURLMOPT_TIMERFUNCTION (3) diff --git a/docs/libcurl/opts/CURLMOPT_SOCKETDATA.md b/docs/libcurl/opts/CURLMOPT_SOCKETDATA.md new file mode 100644 index 000000000..f4de8c331 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_SOCKETDATA.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_SOCKETDATA - custom pointer passed to the socket callback + +# SYNOPSIS + +~~~c +#include + +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 +callbacks's **clientp** argument. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# 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 + +Added in 7.15.4 + +# RETURN VALUE + +Returns CURLM_OK. diff --git a/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.3 b/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.3 deleted file mode 100644 index 701715dd2..000000000 --- a/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_SOCKETFUNCTION 3 "3 Nov 2016" libcurl libcurl -.SH NAME -CURLMOPT_SOCKETFUNCTION \- callback informed about what to wait for -.SH SYNOPSIS -.nf -#include - -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); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -When the \fIcurl_multi_socket_action(3)\fP 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 -\fBsocket_callback\fP. 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 \fIcurl_multi_socket_action(3)\fP. -.SH "CALLBACK ARGUMENTS" -\fIeasy\fP identifies the specific transfer for which this update is related. - -\fIs\fP is the specific socket this function invocation concerns. If the -\fBwhat\fP 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 \fBwhat\fP 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, \fBall\fP transfers currently in progress in this -multi handle are aborted and made to fail. - -\fBclientp\fP is set with \fICURLMOPT_SOCKETDATA(3)\fP. - -\fBsocketp\fP is set with \fIcurl_multi_assign(3)\fP or NULL. - -The \fBwhat\fP parameter informs the callback on the status of the given -socket. It can hold one of these values: -.IP CURL_POLL_IN -Wait for incoming data. For the socket to become readable. -.IP CURL_POLL_OUT -Wait for outgoing data. For the socket to become writable. -.IP CURL_POLL_INOUT -Wait for incoming and outgoing data. For the socket to become readable or -writable. -.IP CURL_POLL_REMOVE -The specified socket/file descriptor is no longer used by libcurl for any -active transfer. It might soon be added again. -.SH DEFAULT -NULL (no callback) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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); -} -.fi -.SH AVAILABILITY -Added in 7.15.4 -.SH RETURN VALUE -Returns CURLM_OK. -.SH "SEE ALSO" -.BR curl_multi_socket_action (3), -.BR CURLMOPT_SOCKETDATA (3), -.BR CURLMOPT_TIMERFUNCTION (3) diff --git a/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md b/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md new file mode 100644 index 000000000..5b34db5f3 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md @@ -0,0 +1,135 @@ +--- +c: Copyright (C) Daniel Stenberg, , 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) +--- + +# NAME + +CURLMOPT_SOCKETFUNCTION - callback informed about what to wait for + +# SYNOPSIS + +~~~c +#include + +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). + +# CALLBACK ARGUMENTS + +*easy* identifies the specific transfer for which this update is related. + +*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 + +All + +# 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 + +Added in 7.15.4 + +# RETURN VALUE + +Returns CURLM_OK. diff --git a/docs/libcurl/opts/CURLMOPT_TIMERDATA.3 b/docs/libcurl/opts/CURLMOPT_TIMERDATA.3 deleted file mode 100644 index b3f853d23..000000000 --- a/docs/libcurl/opts/CURLMOPT_TIMERDATA.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_TIMERDATA 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLMOPT_TIMERDATA \- custom pointer to pass to timer callback -.SH SYNOPSIS -.nf -#include - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer); -.SH DESCRIPTION -A data \fBpointer\fP to pass to the timer callback set with the -\fICURLMOPT_TIMERFUNCTION(3)\fP option. - -This pointer is not touched by libcurl but is only be passed in to the timer -callbacks's \fBclientp\fP argument. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int timerfunc(CURLM *multi, long timeout_ms, void *clientp) -{ - struct priv *mydata = clientp; - printf("our ptr: %p\\n", mydata->custom); - - if(timeout_ms) { - /* this is the new single timeout to wait for */ - } - else { - /* delete the timeout, nothing to wait for now */ - } -} - -int main(void) -{ - struct priv mydata; - CURLM *multi = curl_multi_init(); - curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc); - curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata); -} -.fi -.SH AVAILABILITY -Added in 7.16.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_TIMERFUNCTION (3), -.BR CURLMOPT_SOCKETFUNCTION (3) diff --git a/docs/libcurl/opts/CURLMOPT_TIMERDATA.md b/docs/libcurl/opts/CURLMOPT_TIMERDATA.md new file mode 100644 index 000000000..13bbd925b --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_TIMERDATA.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLMOPT_TIMERDATA +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_SOCKETFUNCTION (3) + - CURLMOPT_TIMERFUNCTION (3) +--- + +# NAME + +CURLMOPT_TIMERDATA - custom pointer to pass to timer callback + +# SYNOPSIS + +~~~c +#include + +CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer); +~~~ + +# DESCRIPTION + +A data **pointer** to pass to the timer callback set with the +CURLMOPT_TIMERFUNCTION(3) option. + +This pointer is not touched by libcurl but is only be passed in to the timer +callbacks's **clientp** argument. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int timerfunc(CURLM *multi, long timeout_ms, void *clientp) +{ + struct priv *mydata = clientp; + printf("our ptr: %p\n", mydata->custom); + + if(timeout_ms) { + /* this is the new single timeout to wait for */ + } + else { + /* delete the timeout, nothing to wait for now */ + } +} + +int main(void) +{ + struct priv mydata; + CURLM *multi = curl_multi_init(); + curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc); + curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata); +} +~~~ + +# AVAILABILITY + +Added in 7.16.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.3 b/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.3 deleted file mode 100644 index 69ad15167..000000000 --- a/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLMOPT_TIMERFUNCTION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLMOPT_TIMERFUNCTION \- callback to receive timeout values -.SH SYNOPSIS -.nf -#include - -int timer_callback(CURLM *multi, /* multi handle */ - long timeout_ms, /* timeout in number of ms */ - void *clientp); /* private callback pointer */ - -CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERFUNCTION, timer_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -Certain features, such as timeouts and retries, require you to call libcurl -even when there is no activity on the file descriptors. - -Your callback function \fBtimer_callback\fP should install a non-repeating -timer with an expire time of \fBtimeout_ms\fP milliseconds. When that timer -fires, call either \fIcurl_multi_socket_action(3)\fP or -\fIcurl_multi_perform(3)\fP, depending on which interface you use. - -A \fBtimeout_ms\fP value of -1 passed to this callback means you should delete -the timer. All other values are valid expire times in number of milliseconds. - -The \fBtimer_callback\fP is called when the timeout expire time is changed. - -The \fBclientp\fP pointer is set with \fICURLMOPT_TIMERDATA(3)\fP. - -The timer callback should return 0 on success, and -1 on error. If this -callback returns error, \fBall\fP transfers currently in progress in this -multi handle are aborted and made to fail. - -This callback can be used instead of, or in addition to, -\fIcurl_multi_timeout(3)\fP. - -\fBWARNING:\fP do not call libcurl directly from within the callback itself -when the \fBtimeout_ms\fP value is zero, since it risks triggering an -unpleasant recursive behavior that immediately calls another call to the -callback with a zero timeout... -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int timerfunc(CURLM *multi, long timeout_ms, void *clientp) -{ - struct priv *mydata = clientp; - printf("our ptr: %p\\n", mydata->custom); - - if(timeout_ms) { - /* this is the new single timeout to wait for */ - } - else { - /* delete the timeout, nothing to wait for now */ - } -} - -int main(void) -{ - struct priv mydata; - CURLM *multi = curl_multi_init(); - curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc); - curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata); -} -.fi -.SH AVAILABILITY -Added in 7.16.0 -.SH RETURN VALUE -Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_TIMERDATA (3), -.BR CURLMOPT_SOCKETFUNCTION (3) diff --git a/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.md b/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.md new file mode 100644 index 000000000..83a8fe7e0 --- /dev/null +++ b/docs/libcurl/opts/CURLMOPT_TIMERFUNCTION.md @@ -0,0 +1,103 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLMOPT_TIMERFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_SOCKETFUNCTION (3) + - CURLMOPT_TIMERDATA (3) +--- + +# NAME + +CURLMOPT_TIMERFUNCTION - callback to receive timeout values + +# SYNOPSIS + +~~~c +#include + +int timer_callback(CURLM *multi, /* multi handle */ + long timeout_ms, /* timeout in number of ms */ + void *clientp); /* private callback pointer */ + +CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERFUNCTION, timer_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +Certain features, such as timeouts and retries, require you to call libcurl +even when there is no activity on the file descriptors. + +Your callback function **timer_callback** should install a non-repeating +timer with an expire time of **timeout_ms** milliseconds. When that timer +fires, call either curl_multi_socket_action(3) or +curl_multi_perform(3), depending on which interface you use. + +A **timeout_ms** value of -1 passed to this callback means you should delete +the timer. All other values are valid expire times in number of milliseconds. + +The **timer_callback** is called when the timeout expire time is changed. + +The **clientp** pointer is set with CURLMOPT_TIMERDATA(3). + +The timer 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. + +This callback can be used instead of, or in addition to, +curl_multi_timeout(3). + +**WARNING:** do not call libcurl directly from within the callback itself +when the **timeout_ms** value is zero, since it risks triggering an +unpleasant recursive behavior that immediately calls another call to the +callback with a zero timeout... + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int timerfunc(CURLM *multi, long timeout_ms, void *clientp) +{ + struct priv *mydata = clientp; + printf("our ptr: %p\n", mydata->custom); + + if(timeout_ms) { + /* this is the new single timeout to wait for */ + } + else { + /* delete the timeout, nothing to wait for now */ + } +} + +int main(void) +{ + struct priv mydata; + CURLM *multi = curl_multi_init(); + curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc); + curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata); +} +~~~ + +# AVAILABILITY + +Added in 7.16.0 + +# RETURN VALUE + +Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.3 b/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.3 deleted file mode 100644 index 0e89be55f..000000000 --- a/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ABSTRACT_UNIX_SOCKET 3 "08 Jan 2017" libcurl libcurl -.SH NAME -CURLOPT_ABSTRACT_UNIX_SOCKET \- abstract Unix domain socket -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ABSTRACT_UNIX_SOCKET, - char *path); -.fi -.SH DESCRIPTION -Enables the use of an abstract Unix domain socket instead of establishing a -TCP connection to a host. The parameter should be a char * to a -null-terminated string holding the path of the socket. The path is set to -\fIpath\fP prefixed by a NULL byte. This is the convention for abstract -sockets, however it should be stressed that the path passed to this function -should not contain a leading NULL byte. - -On non-supporting platforms, the abstract address is interpreted as an empty -string and fails gracefully, generating a runtime error. - -This option shares the same semantics as \fICURLOPT_UNIX_SOCKET_PATH(3)\fP in -which documentation more details can be found. Internally, these two options -share the same storage and therefore only one of them can be set per handle. -.SH DEFAULT -Default is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_ABSTRACT_UNIX_SOCKET, "/tmp/foo.sock"); - curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.53.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_UNIX_SOCKET_PATH (3), -.BR unix (7) diff --git a/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.md b/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.md new file mode 100644 index 000000000..33d2b7bcc --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ABSTRACT_UNIX_SOCKET.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ABSTRACT_UNIX_SOCKET +Section: 3 +Source: libcurl +See-also: + - CURLOPT_UNIX_SOCKET_PATH (3) + - unix (7) +--- + +# NAME + +CURLOPT_ABSTRACT_UNIX_SOCKET - abstract Unix domain socket + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ABSTRACT_UNIX_SOCKET, + char *path); +~~~ + +# DESCRIPTION + +Enables the use of an abstract Unix domain socket instead of establishing a +TCP connection to a host. The parameter should be a char * to a +null-terminated string holding the path of the socket. The path is set to +*path* prefixed by a NULL byte. This is the convention for abstract +sockets, however it should be stressed that the path passed to this function +should not contain a leading NULL byte. + +On non-supporting platforms, the abstract address is interpreted as an empty +string and fails gracefully, generating a runtime error. + +This option shares the same semantics as CURLOPT_UNIX_SOCKET_PATH(3) in +which documentation more details can be found. Internally, these two options +share the same storage and therefore only one of them can be set per handle. + +# DEFAULT + +Default is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_ABSTRACT_UNIX_SOCKET, "/tmp/foo.sock"); + curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.53.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.3 b/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.3 deleted file mode 100644 index b93142599..000000000 --- a/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ACCEPTTIMEOUT_MS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_ACCEPTTIMEOUT_MS \- timeout waiting for FTP server to connect back -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPTTIMEOUT_MS, long ms); -.fi -.SH DESCRIPTION -Pass a long telling libcurl the maximum number of milliseconds to wait for a -server to connect back to libcurl when an active FTP connection is used. -.SH DEFAULT -60000 milliseconds -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/path/file"); - - /* wait no more than 5 seconds for FTP server responses */ - curl_easy_setopt(curl, CURLOPT_ACCEPTTIMEOUT_MS, 5000L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.24.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT_MS (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.md new file mode 100644 index 000000000..77615d886 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ACCEPTTIMEOUT_MS.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ACCEPTTIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT_MS (3) + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_ACCEPTTIMEOUT_MS - timeout waiting for FTP server to connect back + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPTTIMEOUT_MS, long ms); +~~~ + +# DESCRIPTION + +Pass a long telling libcurl the maximum number of milliseconds to wait for a +server to connect back to libcurl when an active FTP connection is used. + +# DEFAULT + +60000 milliseconds + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/path/file"); + + /* wait no more than 5 seconds for FTP server responses */ + curl_easy_setopt(curl, CURLOPT_ACCEPTTIMEOUT_MS, 5000L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.24.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.3 b/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.3 deleted file mode 100644 index 230b6b07f..000000000 --- a/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ACCEPT_ENCODING 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_ACCEPT_ENCODING \- automatic decompression of HTTP downloads -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPT_ENCODING, char *enc); -.fi -.SH DESCRIPTION -Pass a char * argument specifying what encoding you would like. - -Sets the contents of the Accept-Encoding: header sent in an HTTP request, and -enables decoding of a response when a Content-Encoding: header is received. - -libcurl potentially supports several different compressed encodings depending -on what support that has been built-in. - -To aid applications not having to bother about what specific algorithms this -particular libcurl build supports, libcurl allows a zero-length string to be -set ("") to ask for an Accept-Encoding: header to be used that contains all -built-in supported encodings. - -Alternatively, you can specify exactly the encoding or list of encodings you -want in the response. The following encodings are supported: \fIidentity\fP, -meaning non-compressed, \fIdeflate\fP which requests the server to compress -its response using the zlib algorithm, \fIgzip\fP which requests the gzip -algorithm, (since curl 7.57.0) \fIbr\fP which is brotli and (since curl -7.72.0) \fIzstd\fP which is zstd. Provide them in the string as a -comma-separated list of accepted encodings, like: \fB"br, gzip, deflate"\fP. - -Set \fICURLOPT_ACCEPT_ENCODING(3)\fP to NULL to explicitly disable it, which -makes libcurl not send an Accept-Encoding: header and not decompress received -contents automatically. - -You can also opt to just include the Accept-Encoding: header in your request -with \fICURLOPT_HTTPHEADER(3)\fP but then there is no automatic decompressing -when receiving data. - -This is a request, not an order; the server may or may not do it. This option -must be set (to any non-NULL value) or else any unsolicited encoding done by -the server is ignored. - -Servers might respond with Content-Encoding even without getting a -Accept-Encoding: in the request. Servers might respond with a different -Content-Encoding than what was asked for in the request. - -The Content-Length: servers send for a compressed response is supposed to -indicate the length of the compressed content so when auto decoding is enabled -it may not match the sum of bytes reported by the write callbacks (although, -sending the length of the non-compressed content is a common server mistake). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* enable all supported built-in compressions */ - curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -This option was called CURLOPT_ENCODING before 7.21.6 - -The specific libcurl you are using must have been built with zlib to be able to -decompress gzip and deflate responses, with the brotli library to -decompress brotli responses and with the zstd library to decompress zstd -responses. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_CONTENT_DECODING (3), -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_TRANSFER_ENCODING (3) diff --git a/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.md b/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.md new file mode 100644 index 000000000..9bba40d9d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ACCEPT_ENCODING.md @@ -0,0 +1,110 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ACCEPT_ENCODING +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPHEADER (3) + - CURLOPT_HTTP_CONTENT_DECODING (3) + - CURLOPT_TRANSFER_ENCODING (3) +--- + +# NAME + +CURLOPT_ACCEPT_ENCODING - automatic decompression of HTTP downloads + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ACCEPT_ENCODING, char *enc); +~~~ + +# DESCRIPTION + +Pass a char pointer argument specifying what encoding you would like. + +Sets the contents of the Accept-Encoding: header sent in an HTTP request, and +enables decoding of a response when a Content-Encoding: header is received. + +libcurl potentially supports several different compressed encodings depending +on what support that has been built-in. + +To aid applications not having to bother about what specific algorithms this +particular libcurl build supports, libcurl allows a zero-length string to be +set ("") to ask for an Accept-Encoding: header to be used that contains all +built-in supported encodings. + +Alternatively, you can specify exactly the encoding or list of encodings you +want in the response. The following encodings are supported: *identity*, +meaning non-compressed, *deflate* which requests the server to compress +its response using the zlib algorithm, *gzip* which requests the gzip +algorithm, (since curl 7.57.0) *br* which is brotli and (since curl +7.72.0) *zstd* which is zstd. Provide them in the string as a +comma-separated list of accepted encodings, like: **"br, gzip, deflate"**. + +Set CURLOPT_ACCEPT_ENCODING(3) to NULL to explicitly disable it, which +makes libcurl not send an Accept-Encoding: header and not decompress received +contents automatically. + +You can also opt to just include the Accept-Encoding: header in your request +with CURLOPT_HTTPHEADER(3) but then there is no automatic decompressing +when receiving data. + +This is a request, not an order; the server may or may not do it. This option +must be set (to any non-NULL value) or else any unsolicited encoding done by +the server is ignored. + +Servers might respond with Content-Encoding even without getting a +Accept-Encoding: in the request. Servers might respond with a different +Content-Encoding than what was asked for in the request. + +The Content-Length: servers send for a compressed response is supposed to +indicate the length of the compressed content so when auto decoding is enabled +it may not match the sum of bytes reported by the write callbacks (although, +sending the length of the non-compressed content is a common server mistake). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* enable all supported built-in compressions */ + curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +This option was called CURLOPT_ENCODING before 7.21.6 + +The specific libcurl you are using must have been built with zlib to be able to +decompress gzip and deflate responses, with the brotli library to +decompress brotli responses and with the zstd library to decompress zstd +responses. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.3 b/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.3 deleted file mode 100644 index eea7f8847..000000000 --- a/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ADDRESS_SCOPE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_ADDRESS_SCOPE \- scope id for IPv6 addresses -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ADDRESS_SCOPE, long scope); -.fi -.SH DESCRIPTION -Pass a long specifying the scope id value to use when connecting to IPv6 addresses. -.SH DEFAULT -0 -.SH PROTOCOLS -All, when using IPv6 -.SH EXAMPLE -.nf -#include /* for if_nametoindex() */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - long my_scope_id; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - my_scope_id = if_nametoindex("eth0"); - curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id); - ret = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value. -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.md b/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.md new file mode 100644 index 000000000..78526bd39 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ADDRESS_SCOPE.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ADDRESS_SCOPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_ADDRESS_SCOPE - scope id for IPv6 addresses + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ADDRESS_SCOPE, long scope); +~~~ + +# DESCRIPTION + +Pass a long specifying the scope id value to use when connecting to IPv6 addresses. + +# DEFAULT + +0 + +# PROTOCOLS + +All, when using IPv6 + +# EXAMPLE + +~~~c +#include /* for if_nametoindex() */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + long my_scope_id; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + my_scope_id = if_nametoindex("eth0"); + curl_easy_setopt(curl, CURLOPT_ADDRESS_SCOPE, my_scope_id); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. +Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value. diff --git a/docs/libcurl/opts/CURLOPT_ALTSVC.3 b/docs/libcurl/opts/CURLOPT_ALTSVC.3 deleted file mode 100644 index 5af38437d..000000000 --- a/docs/libcurl/opts/CURLOPT_ALTSVC.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ALTSVC 3 "5 Feb 2019" libcurl libcurl -.SH NAME -CURLOPT_ALTSVC \- alt-svc cache file name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC, char *filename); -.fi -.SH DESCRIPTION -Pass in a pointer to a \fIfilename\fP to instruct libcurl to use that file as -the Alt-Svc cache to read existing cache contents from and possibly also write -it back to after a transfer, unless \fBCURLALTSVC_READONLYFILE\fP is set in -\fICURLOPT_ALTSVC_CTRL(3)\fP. - -Specify a blank file name ("") to make libcurl not load from a file at all. -.SH DEFAULT -NULL. The alt-svc cache is not read nor written to file. -.SH PROTOCOLS -HTTPS -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1); - curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt"); - curl_easy_perform(curl); - } -} -.fi -.SH "FILE FORMAT" -A text based file with one line per alt-svc entry and each line consists of -nine space-separated fields. - -An example line could look like - - h2 www.example 8443 h3 second.example 443 "20190808 06:18:37" 1 0 - -The fields of that line are: - -.IP h2 -ALPN id for the source origin -.IP www.example -Host name for the source origin -.IP 8443 -Port number for the source origin -.IP h3 -ALPN id for the destination host -.IP second.example -Host name for the destination host -.IP 443 -Port number for the destination host -.IP 2019* -Expiration date and time of this entry within double quotes. The date format -is "YYYYMMDD HH:MM:SS" and the time zone is GMT. -.IP 1 -Boolean (1 or 0) if "persist" was set for this entry -.IP 0 -Integer priority value (not currently used) -.SH AVAILABILITY -Added in 7.64.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ALTSVC_CTRL (3), -.BR CURLOPT_CONNECT_TO (3), -.BR CURLOPT_COOKIEFILE (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_ALTSVC.md b/docs/libcurl/opts/CURLOPT_ALTSVC.md new file mode 100644 index 000000000..6f6408474 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ALTSVC.md @@ -0,0 +1,111 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ALTSVC +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ALTSVC_CTRL (3) + - CURLOPT_CONNECT_TO (3) + - CURLOPT_COOKIEFILE (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_ALTSVC - alt-svc cache file name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC, char *filename); +~~~ + +# DESCRIPTION + +Pass in a pointer to a *filename* to instruct libcurl to use that file as +the Alt-Svc cache to read existing cache contents from and possibly also write +it back to after a transfer, unless **CURLALTSVC_READONLYFILE** is set in +CURLOPT_ALTSVC_CTRL(3). + +Specify a blank filename ("") to make libcurl not load from a file at all. + +# DEFAULT + +NULL. The alt-svc cache is not read nor written to file. + +# PROTOCOLS + +HTTPS + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, CURLALTSVC_H1); + curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt"); + curl_easy_perform(curl); + } +} +~~~ + +# FILE FORMAT + +A text based file with one line per alt-svc entry and each line consists of +nine space-separated fields. + +An example line could look like + + h2 www.example.com 8443 h3 second.example.com 443 "20190808 06:18:37" 1 0 + +The fields of that line are: + +## h2 + +ALPN id for the source origin + +## www.example.comp + +Hostname for the source origin + +## 8443 + +Port number for the source origin + +## h3 + +ALPN id for the destination host + +## second.example.com + +Hostname for the destination host + +## 443 + +Port number for the destination host + +## 2019* + +Expiration date and time of this entry within double quotes. The date format +is "YYYYMMDD HH:MM:SS" and the time zone is GMT. + +## 1 + +Boolean (1 or 0) if "persist" was set for this entry + +## 0 + +Integer priority value (not currently used) + +# AVAILABILITY + +Added in 7.64.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.3 b/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.3 deleted file mode 100644 index 5ba91c440..000000000 --- a/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ALTSVC_CTRL 3 "5 Feb 2019" libcurl libcurl -.SH NAME -CURLOPT_ALTSVC_CTRL \- control alt-svc behavior -.SH SYNOPSIS -.nf -#include - -#define CURLALTSVC_READONLYFILE (1<<2) -#define CURLALTSVC_H1 (1<<3) -#define CURLALTSVC_H2 (1<<4) -#define CURLALTSVC_H3 (1<<5) - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC_CTRL, long bitmask); -.fi -.SH DESCRIPTION -Populate the long \fIbitmask\fP with the correct set of features to instruct -libcurl how to handle Alt-Svc for the transfers using this handle. - -libcurl only accepts Alt-Svc headers over a secure transport, meaning -HTTPS. It also only completes a request to an alternative origin if that -origin is properly hosted over HTTPS. These requirements are there to make -sure both the source and the destination are legitimate. - -Alternative services are only used when setting up new connections. If there -exists an existing connection to the host in the connection pool, then that is -preferred. - -Setting any bit enables the alt-svc engine. -.IP "CURLALTSVC_READONLYFILE" -Do not write the alt-svc cache back to the file specified with -\fICURLOPT_ALTSVC(3)\fP even if it gets updated. By default a file specified -with that option is read and written to as deemed necessary. -.IP "CURLALTSVC_H1" -Accept alternative services offered over HTTP/1.1. -.IP "CURLALTSVC_H2" -Accept alternative services offered over HTTP/2. This is only used if libcurl -was also built to actually support HTTP/2, otherwise this bit is ignored. -.IP "CURLALTSVC_H3" -Accept alternative services offered over HTTP/3. This is only used if libcurl -was also built to actually support HTTP/3, otherwise this bit is ignored. -.SH DEFAULT -Alt-Svc handling is disabled by default. If \fICURLOPT_ALTSVC(3)\fP is set, -\fICURLOPT_ALTSVC_CTRL(3)\fP has a default value corresponding to -CURLALTSVC_H1 | CURLALTSVC_H2 | CURLALTSVC_H3 - the HTTP/2 and HTTP/3 bits are -only set if libcurl was built with support for those versions. -.SH PROTOCOLS -HTTPS -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)CURLALTSVC_H1); - curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.64.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ALTSVC (3), -.BR CURLOPT_CONNECT_TO (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.md b/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.md new file mode 100644 index 000000000..538fc801a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.md @@ -0,0 +1,97 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ALTSVC_CTRL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ALTSVC (3) + - CURLOPT_CONNECT_TO (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_ALTSVC_CTRL - control alt-svc behavior + +# SYNOPSIS + +~~~c +#include + +#define CURLALTSVC_READONLYFILE (1<<2) +#define CURLALTSVC_H1 (1<<3) +#define CURLALTSVC_H2 (1<<4) +#define CURLALTSVC_H3 (1<<5) + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC_CTRL, long bitmask); +~~~ + +# DESCRIPTION + +Populate the long *bitmask* with the correct set of features to instruct +libcurl how to handle Alt-Svc for the transfers using this handle. + +libcurl only accepts Alt-Svc headers over a secure transport, meaning +HTTPS. It also only completes a request to an alternative origin if that +origin is properly hosted over HTTPS. These requirements are there to make +sure both the source and the destination are legitimate. + +Alternative services are only used when setting up new connections. If there +exists an existing connection to the host in the connection pool, then that is +preferred. + +Setting any bit enables the alt-svc engine. + +## CURLALTSVC_READONLYFILE + +Do not write the alt-svc cache back to the file specified with +CURLOPT_ALTSVC(3) even if it gets updated. By default a file specified +with that option is read and written to as deemed necessary. + +## CURLALTSVC_H1 + +Accept alternative services offered over HTTP/1.1. + +## CURLALTSVC_H2 + +Accept alternative services offered over HTTP/2. This is only used if libcurl +was also built to actually support HTTP/2, otherwise this bit is ignored. + +## CURLALTSVC_H3 + +Accept alternative services offered over HTTP/3. This is only used if libcurl +was also built to actually support HTTP/3, otherwise this bit is ignored. + +# DEFAULT + +Alt-Svc handling is disabled by default. If CURLOPT_ALTSVC(3) is set, +CURLOPT_ALTSVC_CTRL(3) has a default value corresponding to +CURLALTSVC_H1 | CURLALTSVC_H2 | CURLALTSVC_H3 - the HTTP/2 and HTTP/3 bits are +only set if libcurl was built with support for those versions. + +# PROTOCOLS + +HTTPS + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_ALTSVC_CTRL, (long)CURLALTSVC_H1); + curl_easy_setopt(curl, CURLOPT_ALTSVC, "altsvc-cache.txt"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.64.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_APPEND.3 b/docs/libcurl/opts/CURLOPT_APPEND.3 deleted file mode 100644 index 0830c1a50..000000000 --- a/docs/libcurl/opts/CURLOPT_APPEND.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_APPEND 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_APPEND \- append to the remote file -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_APPEND, long append); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to append to the remote file -instead of overwrite it. This is only useful when uploading to an FTP site. -.SH DEFAULT -0 (disabled) -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(curl, CURLOPT_APPEND, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -This option was known as CURLOPT_FTPAPPEND up to 7.16.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DIRLISTONLY (3), -.BR CURLOPT_RESUME_FROM (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_APPEND.md b/docs/libcurl/opts/CURLOPT_APPEND.md new file mode 100644 index 000000000..d507c3812 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_APPEND.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_APPEND +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DIRLISTONLY (3) + - CURLOPT_RESUME_FROM (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_APPEND - append to the remote file + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_APPEND, long append); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to append to the remote file +instead of overwrite it. This is only useful when uploading to an FTP site. + +# DEFAULT + +0 (disabled) + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(curl, CURLOPT_APPEND, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +This option was known as CURLOPT_FTPAPPEND up to 7.16.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_AUTOREFERER.3 b/docs/libcurl/opts/CURLOPT_AUTOREFERER.3 deleted file mode 100644 index 5f94efc00..000000000 --- a/docs/libcurl/opts/CURLOPT_AUTOREFERER.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_AUTOREFERER 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_AUTOREFERER \- automatically update the referer header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AUTOREFERER, long autorefer); -.fi -.SH DESCRIPTION -Pass a long parameter set to 1 to enable this. When enabled, libcurl -automatically sets the Referer: header field in HTTP requests to the full URL -when it follows a Location: redirect to a new destination. - -The automatic referer is set to the full previous URL even when redirects are -done cross-origin or following redirects to insecure protocols. This is -considered a minor privacy leak by some. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* follow redirects */ - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - - /* set Referer: automatically when following redirects */ - curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_EFFECTIVE_URL (3), -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLOPT_FOLLOWLOCATION (3), -.BR CURLOPT_REFERER (3) diff --git a/docs/libcurl/opts/CURLOPT_AUTOREFERER.md b/docs/libcurl/opts/CURLOPT_AUTOREFERER.md new file mode 100644 index 000000000..d201a71ad --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_AUTOREFERER.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_AUTOREFERER +Section: 3 +Source: libcurl +See-also: + - CURLINFO_EFFECTIVE_URL (3) + - CURLINFO_REDIRECT_URL (3) + - CURLINFO_REFERER (3) + - CURLOPT_FOLLOWLOCATION (3) + - CURLOPT_REFERER (3) +--- + +# NAME + +CURLOPT_AUTOREFERER - automatically update the referer header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AUTOREFERER, long autorefer); +~~~ + +# DESCRIPTION + +Pass a long parameter set to 1 to enable this. When enabled, libcurl +automatically sets the Referer: header field in HTTP requests to the full URL +when it follows a Location: redirect to a new destination. + +The automatic referer is set to the full previous URL even when redirects are +done cross-origin or following redirects to insecure protocols. This is +considered a minor privacy leak by some. + +With CURLINFO_REFERER(3), applications can extract the actually used +referer header after the transfer. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* follow redirects */ + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + /* set Referer: automatically when following redirects */ + curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_AWS_SIGV4.3 b/docs/libcurl/opts/CURLOPT_AWS_SIGV4.3 deleted file mode 100644 index 0cea12d02..000000000 --- a/docs/libcurl/opts/CURLOPT_AWS_SIGV4.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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.haxx.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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_AWS_SIGV4 3 "03 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_AWS_SIGV4 \- V4 signature -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AWS_SIGV4, char *param); -.fi -.SH DESCRIPTION -Provides AWS V4 signature authentication on HTTP(S) header. -.PP -Pass a char * that is the collection of specific arguments are used for -creating outgoing authentication headers. The format of the \fIparam\fP -option is: -.IP provider1[:provider2[:region[:service]]] -.IP provider1,\ provider2 -The providers arguments are used for generating some authentication parameters -such as "Algorithm", "date", "request type" and "signed headers". -.IP region -The argument is a geographic area of a resources collection. -It is extracted from the host name specified in the URL if omitted. -.IP service -The argument is a function provided by a cloud. -It is extracted from the host name specified in the URL if omitted. -.PP -NOTE: This call set \fICURLOPT_HTTPAUTH(3)\fP to CURLAUTH_AWS_SIGV4. -Calling \fICURLOPT_HTTPAUTH(3)\fP with CURLAUTH_AWS_SIGV4 is the same -as calling this with \fB"aws:amz"\fP in parameter. -.PP -Example with "Test:Try", when curl uses the algorithm, it generates -\fB"TEST-HMAC-SHA256"\fP for "Algorithm", \fB"x-try-date"\fP and -\fB"X-Try-Date"\fP for "date", \fB"test4_request"\fP for "request type", -\fB"SignedHeaders=content-type;host;x-try-date"\fP for "signed headers" -.PP -If you use just "test", instead of "test:try", test is used for every -generated string. -.SH DEFAULT -By default, the value of this parameter is NULL. -Calling \fICURLOPT_HTTPAUTH(3)\fP with CURLAUTH_AWS_SIGV4 is the same -as calling this with \fB"aws:amz"\fP in parameter. -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, - "https://service.region.example.com/uri"); - curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2"); - - /* service and region can also be set in CURLOPT_AWS_SIGV4 */ - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/uri"); - curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, - "provider1:provider2:region:service"); - - curl_easy_setopt(curl, CURLOPT_USERPWD, "MY_ACCESS_KEY:MY_SECRET_KEY"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.75.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH NOTES -This option overrides the other auth types you might have set in -\fICURLOPT_HTTPAUTH(3)\fP which should be highlighted as this makes this auth -method special. This method cannot be combined with other auth types. -.PP -A sha256 checksum of the request payload is used as input to the signature -calculation. For POST requests, this is a checksum of the provided -\fICURLOPT_POSTFIELDS(3)\fP. Otherwise, it's the checksum of an empty buffer. -For requests like PUT, you can provide your own checksum in an HTTP header named -\fBx-provider2-content-sha256\fP. -.PP -For \fBaws:s3\fP, a \fBx-amz-content-sha256\fP header is added to every request -if not already present. For s3 requests with unknown payload, this header takes -the special value "UNSIGNED-PAYLOAD". -.SH "SEE ALSO" -.BR CURLOPT_HEADEROPT (3), -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_PROXYAUTH (3) diff --git a/docs/libcurl/opts/CURLOPT_AWS_SIGV4.md b/docs/libcurl/opts/CURLOPT_AWS_SIGV4.md new file mode 100644 index 000000000..e19741aa6 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_AWS_SIGV4.md @@ -0,0 +1,118 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_AWS_SIGV4 +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADEROPT (3) + - CURLOPT_HTTPAUTH (3) + - CURLOPT_HTTPHEADER (3) + - CURLOPT_PROXYAUTH (3) +--- + +# NAME + +CURLOPT_AWS_SIGV4 - V4 signature + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AWS_SIGV4, char *param); +~~~ + +# DESCRIPTION + +Provides AWS V4 signature authentication on HTTP(S) header. + +Pass a char pointer that is the collection of specific arguments are used for +creating outgoing authentication headers. The format of the *param* option +is: + +## provider1[:provider2[:region[:service]]] + +## provider1, provider2 + +The providers arguments are used for generating some authentication parameters +such as "Algorithm", "date", "request type" and "signed headers". + +## region + +The argument is a geographic area of a resources collection. +It is extracted from the hostname specified in the URL if omitted. + +## service + +The argument is a function provided by a cloud. It is extracted from the +hostname specified in the URL if omitted. + +NOTE: This call set CURLOPT_HTTPAUTH(3) to CURLAUTH_AWS_SIGV4. +Calling CURLOPT_HTTPAUTH(3) with CURLAUTH_AWS_SIGV4 is the same +as calling this with **"aws:amz"** in parameter. + +Example with "Test:Try", when curl uses the algorithm, it generates +**"TEST-HMAC-SHA256"** for "Algorithm", **"x-try-date"** and +**"X-Try-Date"** for "date", **"test4_request"** for "request type", +**"SignedHeaders=content-type;host;x-try-date"** for "signed headers" + +If you use just "test", instead of "test:try", test is used for every +generated string. + +# DEFAULT + +By default, the value of this parameter is NULL. +Calling CURLOPT_HTTPAUTH(3) with CURLAUTH_AWS_SIGV4 is the same +as calling this with **"aws:amz"** in parameter. + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, + "https://service.region.example.com/uri"); + curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2"); + + /* service and region can also be set in CURLOPT_AWS_SIGV4 */ + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/uri"); + curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, + "provider1:provider2:region:service"); + + curl_easy_setopt(curl, CURLOPT_USERPWD, "MY_ACCESS_KEY:MY_SECRET_KEY"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.75.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. + +# NOTES + +This option overrides the other auth types you might have set in +CURLOPT_HTTPAUTH(3) which should be highlighted as this makes this auth +method special. This method cannot be combined with other auth types. + +A sha256 checksum of the request payload is used as input to the signature +calculation. For POST requests, this is a checksum of the provided +CURLOPT_POSTFIELDS(3). Otherwise, it is the checksum of an empty buffer. For +requests like PUT, you can provide your own checksum in an HTTP header named +**x-provider2-content-sha256**. + +For **aws:s3**, a **x-amz-content-sha256** header is added to every request +if not already present. For s3 requests with unknown payload, this header takes +the special value "UNSIGNED-PAYLOAD". diff --git a/docs/libcurl/opts/CURLOPT_BUFFERSIZE.3 b/docs/libcurl/opts/CURLOPT_BUFFERSIZE.3 deleted file mode 100644 index f90c77295..000000000 --- a/docs/libcurl/opts/CURLOPT_BUFFERSIZE.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_BUFFERSIZE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_BUFFERSIZE \- receive buffer size -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_BUFFERSIZE, long size); -.fi -.SH DESCRIPTION -Pass a long specifying your preferred \fIsize\fP (in bytes) for the receive -buffer in libcurl. The main point of this would be that the write callback -gets called more often and with smaller chunks. Secondly, for some protocols, -there is a benefit of having a larger buffer for performance. - -This is just treated as a request, not an order. You cannot be guaranteed to -actually get the given size. - -This buffer size is by default \fICURL_MAX_WRITE_SIZE\fP (16kB). The maximum -buffer size allowed to be set is \fICURL_MAX_READ_SIZE\fP (10MB). The minimum -buffer size allowed to be set is 1024. - -DO NOT set this option on a handle that is currently used for an active -transfer as that may lead to unintended consequences. - -The maximum size was 512kB until 7.88.0. -.SH DEFAULT -CURL_MAX_WRITE_SIZE (16kB) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin"); - - /* ask libcurl to allocate a larger receive buffer */ - curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10. Growing the buffer was added in 7.53.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_MAXFILESIZE (3), -.BR CURLOPT_UPLOAD_BUFFERSIZE (3), -.BR CURLOPT_WRITEFUNCTION (3) - diff --git a/docs/libcurl/opts/CURLOPT_BUFFERSIZE.md b/docs/libcurl/opts/CURLOPT_BUFFERSIZE.md new file mode 100644 index 000000000..1faebeef5 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_BUFFERSIZE.md @@ -0,0 +1,79 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_BUFFERSIZE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAXFILESIZE (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) + - CURLOPT_UPLOAD_BUFFERSIZE (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_BUFFERSIZE - receive buffer size + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_BUFFERSIZE, long size); +~~~ + +# DESCRIPTION + +Pass a long specifying your preferred *size* (in bytes) for the receive buffer +in libcurl. The main point of this would be that the write callback gets +called more often and with smaller chunks. Secondly, for some protocols, there +is a benefit of having a larger buffer for performance. + +This is just treated as a request, not an order. You cannot be guaranteed to +actually get the given size. + +This buffer size is by default *CURL_MAX_WRITE_SIZE* (16kB). The maximum +buffer size allowed to be set is *CURL_MAX_READ_SIZE* (10MB). The minimum +buffer size allowed to be set is 1024. + +DO NOT set this option on a handle that is currently used for an active +transfer as that may lead to unintended consequences. + +The maximum size was 512kB until 7.88.0. + +# DEFAULT + +CURL_MAX_WRITE_SIZE (16kB) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin"); + + /* ask libcurl to allocate a larger receive buffer */ + curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 120000L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10. Growing the buffer was added in 7.53.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CAINFO.3 b/docs/libcurl/opts/CURLOPT_CAINFO.3 deleted file mode 100644 index f4e151eff..000000000 --- a/docs/libcurl/opts/CURLOPT_CAINFO.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CAINFO 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CAINFO \- path to Certificate Authority (CA) bundle -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a file holding one or more -certificates to verify the peer with. - -If \fICURLOPT_SSL_VERIFYPEER(3)\fP is zero and you avoid verifying the -server's certificate, \fICURLOPT_CAINFO(3)\fP need not even indicate an -accessible file. - -This option is by default set to the system path where libcurl's CA -certificate bundle is assumed to be stored, as established at build time. - -(iOS and macOS) When curl uses Secure Transport this option is supported. If -the option is not set, then curl uses the certificates in the system and user -Keychain to verify the peer. - -(Schannel) This option is supported for Schannel in Windows 7 or later but we -recommend not using it until Windows 8 since it works better starting then. -If the option is not set, then curl uses the certificates in the Windows' -store of root certificates (the default for Schannel). - -The application does not have to keep the string around after setting this -option. - -The default value for this can be figured out with \fICURLINFO_CAINFO(3)\fP. -.SH DEFAULT -Built-in system specific. When curl is built with Secure Transport or -Schannel, this option is not set by default. -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem"); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -For the SSL engines that do not support certificate files the -\fICURLOPT_CAINFO(3)\fP option is ignored. Schannel support added in libcurl -7.60. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_CAINFO (3), -.BR CURLOPT_CA_CACHE_TIMEOUT (3), -.BR CURLOPT_CAINFO_BLOB (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_CAINFO.md b/docs/libcurl/opts/CURLOPT_CAINFO.md new file mode 100644 index 000000000..c46073ff8 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CAINFO.md @@ -0,0 +1,87 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CAINFO +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CAINFO (3) + - CURLOPT_CAINFO_BLOB (3) + - CURLOPT_CAPATH (3) + - CURLOPT_CA_CACHE_TIMEOUT (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_CAINFO - path to Certificate Authority (CA) bundle + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO, char *path); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a file holding one or +more certificates to verify the peer with. + +If CURLOPT_SSL_VERIFYPEER(3) is zero and you avoid verifying the +server's certificate, CURLOPT_CAINFO(3) need not even indicate an +accessible file. + +This option is by default set to the system path where libcurl's CA +certificate bundle is assumed to be stored, as established at build time. + +(iOS and macOS) When curl uses Secure Transport this option is supported. If +the option is not set, then curl uses the certificates in the system and user +Keychain to verify the peer. + +(Schannel) This option is supported for Schannel in Windows 7 or later but we +recommend not using it until Windows 8 since it works better starting then. +If the option is not set, then curl uses the certificates in the Windows' +store of root certificates (the default for Schannel). + +The application does not have to keep the string around after setting this +option. + +The default value for this can be figured out with CURLINFO_CAINFO(3). + +# DEFAULT + +Built-in system specific. When curl is built with Secure Transport or +Schannel, this option is not set by default. + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/certs/cabundle.pem"); + curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +For the SSL engines that do not support certificate files the +CURLOPT_CAINFO(3) option is ignored. Schannel support added in libcurl +7.60. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.3 b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.3 deleted file mode 100644 index db3bed941..000000000 --- a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CAINFO_BLOB 3 "31 March 2021" libcurl libcurl -.SH NAME -CURLOPT_CAINFO_BLOB \- Certificate Authority (CA) bundle in PEM format -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO_BLOB, - struct curl_blob *stblob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure, which contains information (pointer -and size) about a memory block with binary data of PEM encoded content holding -one or more certificates to verify the HTTPS server with. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -If \fICURLOPT_SSL_VERIFYPEER(3)\fP is zero and you avoid verifying the -server's certificate, \fICURLOPT_CAINFO_BLOB(3)\fP is not needed. - -This option overrides \fICURLOPT_CAINFO(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -#include - -int main(void) -{ - char *strpem; /* strpem must point to a PEM string */ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - blob.data = strpem; - blob.len = strlen(strpem); - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.77.0. - -This option is supported by the BearSSL (since 7.79.0), mbedTLS (since 7.81.0), -rustls (since 7.82.0), wolfSSL (since 8.2.0), OpenSSL, Secure Transport and Schannel backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3) diff --git a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md new file mode 100644 index 000000000..be30446ff --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md @@ -0,0 +1,84 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CAINFO_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAPATH (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_CAINFO_BLOB - Certificate Authority (CA) bundle in PEM format + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAINFO_BLOB, + struct curl_blob *stblob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure, which contains information (pointer +and size) about a memory block with binary data of PEM encoded content holding +one or more certificates to verify the HTTPS server with. + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +If CURLOPT_SSL_VERIFYPEER(3) is zero and you avoid verifying the +server's certificate, CURLOPT_CAINFO_BLOB(3) is not needed. + +This option overrides CURLOPT_CAINFO(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +#include + +int main(void) +{ + char *strpem; /* strpem must point to a PEM string */ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + blob.data = strpem; + blob.len = strlen(strpem); + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.77.0. + +This option is supported by the BearSSL (since 7.79.0), mbedTLS (since +7.81.0), rustls (since 7.82.0), wolfSSL (since 8.2.0), OpenSSL, Secure +Transport and Schannel backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_CAPATH.3 b/docs/libcurl/opts/CURLOPT_CAPATH.3 deleted file mode 100644 index 8288ee334..000000000 --- a/docs/libcurl/opts/CURLOPT_CAPATH.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CAPATH 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CAPATH \- directory holding CA certificates -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAPATH, char *capath); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a directory holding multiple -CA certificates to verify the peer with. If libcurl is built against OpenSSL, -the certificate directory must be prepared using the OpenSSL c_rehash utility. -This makes sense only when used in combination with the -\fICURLOPT_SSL_VERIFYPEER(3)\fP option. - -The \fICURLOPT_CAPATH(3)\fP function apparently does not work in Windows due -to some limitation in OpenSSL. - -The application does not have to keep the string around after setting this -option. - -The default value for this can be figured out with \fICURLINFO_CAPATH(3)\fP. -.SH DEFAULT -A default path detected at build time. -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_CAPATH, "/etc/cert-dir"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option is supported by the OpenSSL, GnuTLS and mbedTLS (since 7.56.0) -backends. -.SH RETURN VALUE -CURLE_OK if supported; or an error such as: - -CURLE_NOT_BUILT_IN - Not supported by the SSL backend - -CURLE_UNKNOWN_OPTION - -CURLE_OUT_OF_MEMORY -.SH "SEE ALSO" -.BR CURLINFO_CAPATH (3), -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_CAPATH.md b/docs/libcurl/opts/CURLOPT_CAPATH.md new file mode 100644 index 000000000..ff1362f52 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CAPATH.md @@ -0,0 +1,79 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CAPATH +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CAPATH (3) + - CURLOPT_CAINFO (3) + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_CAPATH - directory holding CA certificates + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CAPATH, char *capath); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a directory holding +multiple CA certificates to verify the peer with. If libcurl is built against +OpenSSL, the certificate directory must be prepared using the OpenSSL c_rehash +utility. This makes sense only when used in combination with the +CURLOPT_SSL_VERIFYPEER(3) option. + +The CURLOPT_CAPATH(3) function apparently does not work in Windows due +to some limitation in OpenSSL. + +The application does not have to keep the string around after setting this +option. + +The default value for this can be figured out with CURLINFO_CAPATH(3). + +# DEFAULT + +A default path detected at build time. + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_CAPATH, "/etc/cert-dir"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option is supported by the OpenSSL, GnuTLS and mbedTLS (since 7.56.0) +backends. + +# RETURN VALUE + +CURLE_OK if supported; or an error such as: + +CURLE_NOT_BUILT_IN - Not supported by the SSL backend + +CURLE_UNKNOWN_OPTION + +CURLE_OUT_OF_MEMORY diff --git a/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.3 b/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.3 deleted file mode 100644 index 8c2635120..000000000 --- a/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CA_CACHE_TIMEOUT 3 "21 Dec 2022" libcurl libcurl -.SH NAME -CURLOPT_CA_CACHE_TIMEOUT \- life-time for cached certificate stores -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CA_CACHE_TIMEOUT, long age); -.fi -.SH DESCRIPTION -Pass a long, this sets the timeout in seconds. This tells libcurl the maximum -time any cached certificate store it has in memory may be kept and reused for -new connections. Once the timeout has expired, a subsequent fetch requiring a -certificate has to reload it. - -Building a certificate store from a \fICURLOPT_CAINFO(3)\fP file is a slow -operation so curl may cache the generated certificate store internally to speed -up future connections. - -Set to zero to completely disable caching, or set to -1 to retain the cached -store remain forever. By default, libcurl caches this info for 24 hours. -.SH DEFAULT -86400 (24 hours) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* only reuse certificate stores for a short time */ - curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L); - - res = curl_easy_perform(curl); - - /* in this second request, the cache is not used if more than - sixty seconds passed since the previous connection */ - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option was added in curl 7.87.0. - -This option is supported by OpenSSL and its forks (since 7.87.0) and Schannel -(since 8.5.0). -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAINFO_BLOB (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3) diff --git a/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.md b/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.md new file mode 100644 index 000000000..ef52f976d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CA_CACHE_TIMEOUT.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CA_CACHE_TIMEOUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAINFO_BLOB (3) + - CURLOPT_CAPATH (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_CA_CACHE_TIMEOUT - life-time for cached certificate stores + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CA_CACHE_TIMEOUT, long age); +~~~ + +# DESCRIPTION + +Pass a long, this sets the timeout in seconds. This tells libcurl the maximum +time any cached certificate store it has in memory may be kept and reused for +new connections. Once the timeout has expired, a subsequent fetch requiring a +certificate has to reload it. + +Building a certificate store from a CURLOPT_CAINFO(3) file is a slow +operation so curl may cache the generated certificate store internally to speed +up future connections. + +Set to zero to completely disable caching, or set to -1 to retain the cached +store remain forever. By default, libcurl caches this info for 24 hours. + +# DEFAULT + +86400 (24 hours) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* only reuse certificate stores for a short time */ + curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 60L); + + res = curl_easy_perform(curl); + + /* in this second request, the cache is not used if more than + sixty seconds passed since the previous connection */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option was added in curl 7.87.0. + +This option is supported by OpenSSL and its forks (since 7.87.0) and Schannel +(since 8.5.0). + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_CERTINFO.3 b/docs/libcurl/opts/CURLOPT_CERTINFO.3 deleted file mode 100644 index 7b2013407..000000000 --- a/docs/libcurl/opts/CURLOPT_CERTINFO.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CERTINFO 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CERTINFO \- request SSL certificate information -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CERTINFO, long certinfo); -.fi -.SH DESCRIPTION -Pass a long set to 1 to enable libcurl's certificate chain info gatherer. With -this enabled, libcurl extracts lots of information and data about the -certificates in the certificate chain used in the SSL connection. This data -may then be retrieved after a transfer using \fIcurl_easy_getinfo(3)\fP and -its option \fICURLINFO_CERTINFO(3)\fP. -.SH DEFAULT -0 -.SH PROTOCOLS -All TLS-based -.SH EXAMPLE -.nf -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) { - struct curl_certinfo *ci; - res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci); - - if(!res) { - int i; - 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); - } -} -.fi -.SH AVAILABILITY -This option is supported by the OpenSSL, GnuTLS, Schannel and Secure -Transport backends. Schannel support added in 7.50.0. Secure Transport support -added in 7.79.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_CAINFO (3), -.BR CURLINFO_CAPATH (3), -.BR CURLINFO_CERTINFO (3), -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_CERTINFO.md b/docs/libcurl/opts/CURLOPT_CERTINFO.md new file mode 100644 index 000000000..a69e1e950 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CERTINFO.md @@ -0,0 +1,90 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CERTINFO +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CAINFO (3) + - CURLINFO_CAPATH (3) + - CURLINFO_CERTINFO (3) + - CURLOPT_CAINFO (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_CERTINFO - request SSL certificate information + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CERTINFO, long certinfo); +~~~ + +# DESCRIPTION + +Pass a long set to 1 to enable libcurl's certificate chain info gatherer. With +this enabled, libcurl extracts lots of information and data about the +certificates in the certificate chain used in the SSL connection. This data +may then be retrieved after a transfer using curl_easy_getinfo(3) and +its option CURLINFO_CERTINFO(3). + +# DEFAULT + +0 + +# PROTOCOLS + +All TLS-based + +# 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) { + struct curl_certinfo *ci; + res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci); + + if(!res) { + int i; + 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); + } +} +~~~ + +# AVAILABILITY + +This option is supported by the OpenSSL, GnuTLS, Schannel and Secure +Transport backends. Schannel support added in 7.50.0. Secure Transport support +added in 7.79.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.3 deleted file mode 100644 index 88f3768c9..000000000 --- a/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.3 +++ /dev/null @@ -1,153 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CHUNK_BGN_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CHUNK_BGN_FUNCTION \- callback before a transfer with FTP wildcard match -.SH SYNOPSIS -.nf -#include - -struct curl_fileinfo { - char *filename; - curlfiletype filetype; - time_t time; /* always zero! */ - unsigned int perm; - int uid; - int gid; - curl_off_t size; - long int hardlinks; - - struct { - /* If some of these fields is not NULL, it is a pointer to b_data. */ - char *time; - char *perm; - char *user; - char *group; - char *target; /* pointer to the target filename of a symlink */ - } strings; - - unsigned int flags; - - /* used internally */ - char *b_data; - size_t b_size; - size_t b_used; -}; - -long chunk_bgn_callback(const void *transfer_info, void *ptr, - int remains); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_BGN_FUNCTION, - chunk_bgn_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl before a part of the stream is -going to be transferred (if the transfer supports chunks). - -The \fItransfer_info\fP pointer points to a \fBcurl_fileinfo\fP struct with -details about the file that is about to get transferred. - -This callback makes sense only when using the \fICURLOPT_WILDCARDMATCH(3)\fP -option for now. - -The target of transfer_info parameter is a "feature depended" structure. For -the FTP wildcard download, the target is \fBcurl_fileinfo\fP structure (see -\fIcurl/curl.h\fP). The parameter \fIptr\fP is a pointer given by -\fICURLOPT_CHUNK_DATA(3)\fP. The parameter remains contains number of chunks -remaining per the transfer. If the feature is not available, the parameter has -zero value. - -Return \fICURL_CHUNK_BGN_FUNC_OK\fP if everything is fine, -\fICURL_CHUNK_BGN_FUNC_SKIP\fP if you want to skip the concrete chunk or -\fICURL_CHUNK_BGN_FUNC_FAIL\fP to tell libcurl to stop if some error occurred. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -#include - -struct callback_data { - FILE *output; -}; - -static long file_is_coming(struct curl_fileinfo *finfo, - void *ptr, - int remains) -{ - struct callback_data *data = ptr; - printf("%3d %40s %10luB ", remains, finfo->filename, - (unsigned long)finfo->size); - - switch(finfo->filetype) { - case CURLFILETYPE_DIRECTORY: - printf(" DIR\\n"); - break; - case CURLFILETYPE_FILE: - printf("FILE "); - break; - default: - printf("OTHER\\n"); - break; - } - - if(finfo->filetype == CURLFILETYPE_FILE) { - /* do not transfer files >= 50B */ - if(finfo->size > 50) { - printf("SKIPPED\\n"); - return CURL_CHUNK_BGN_FUNC_SKIP; - } - - data->output = fopen(finfo->filename, "wb"); - if(!data->output) { - return CURL_CHUNK_BGN_FUNC_FAIL; - } - } - - return CURL_CHUNK_BGN_FUNC_OK; -} - -int main() -{ - /* data for callback */ - struct callback_data callback_info; - - CURL *curl = curl_easy_init(); - - /* callback is called before download of concrete file started */ - curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming); - curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); -} -.fi -.SH AVAILABILITY -This was added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CHUNK_END_FUNCTION (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.md b/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.md new file mode 100644 index 000000000..a208c9bbe --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CHUNK_BGN_FUNCTION.md @@ -0,0 +1,152 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CHUNK_BGN_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CHUNK_END_FUNCTION (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_CHUNK_BGN_FUNCTION - callback before a transfer with FTP wildcard match + +# SYNOPSIS + +~~~c +#include + +struct curl_fileinfo { + char *filename; + curlfiletype filetype; + time_t time; /* always zero! */ + unsigned int perm; + int uid; + int gid; + curl_off_t size; + long int hardlinks; + + struct { + /* If some of these fields is not NULL, it is a pointer to b_data. */ + char *time; + char *perm; + char *user; + char *group; + char *target; /* pointer to the target filename of a symlink */ + } strings; + + unsigned int flags; + + /* used internally */ + char *b_data; + size_t b_size; + size_t b_used; +}; + +long chunk_bgn_callback(const void *transfer_info, void *ptr, + int remains); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_BGN_FUNCTION, + chunk_bgn_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl before a part of the stream is +going to be transferred (if the transfer supports chunks). + +The *transfer_info* pointer points to a **curl_fileinfo** struct with +details about the file that is about to get transferred. + +This callback makes sense only when using the CURLOPT_WILDCARDMATCH(3) +option for now. + +The target of transfer_info parameter is a "feature depended" structure. For +the FTP wildcard download, the target is **curl_fileinfo** structure (see +*curl/curl.h*). The parameter *ptr* is a pointer given by +CURLOPT_CHUNK_DATA(3). The parameter remains contains number of chunks +remaining per the transfer. If the feature is not available, the parameter has +zero value. + +Return *CURL_CHUNK_BGN_FUNC_OK* if everything is fine, +*CURL_CHUNK_BGN_FUNC_SKIP* if you want to skip the concrete chunk or +*CURL_CHUNK_BGN_FUNC_FAIL* to tell libcurl to stop if some error occurred. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +#include + +struct callback_data { + FILE *output; +}; + +static long file_is_coming(struct curl_fileinfo *finfo, + void *ptr, + int remains) +{ + struct callback_data *data = ptr; + printf("%3d %40s %10luB ", remains, finfo->filename, + (unsigned long)finfo->size); + + switch(finfo->filetype) { + case CURLFILETYPE_DIRECTORY: + printf(" DIR\n"); + break; + case CURLFILETYPE_FILE: + printf("FILE "); + break; + default: + printf("OTHER\n"); + break; + } + + if(finfo->filetype == CURLFILETYPE_FILE) { + /* do not transfer files >= 50B */ + if(finfo->size > 50) { + printf("SKIPPED\n"); + return CURL_CHUNK_BGN_FUNC_SKIP; + } + + data->output = fopen(finfo->filename, "wb"); + if(!data->output) { + return CURL_CHUNK_BGN_FUNC_FAIL; + } + } + + return CURL_CHUNK_BGN_FUNC_OK; +} + +int main() +{ + /* data for callback */ + struct callback_data callback_info; + + CURL *curl = curl_easy_init(); + + /* callback is called before download of concrete file started */ + curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming); + curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); +} +~~~ + +# AVAILABILITY + +This was added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3 b/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3 deleted file mode 100644 index a4e35244d..000000000 --- a/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CHUNK_DATA 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CHUNK_DATA \- pointer passed to the FTP chunk callbacks -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the ptr -argument to the \fICURLOPT_CHUNK_BGN_FUNCTION(3)\fP and -\fICURLOPT_CHUNK_END_FUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -#include - -struct callback_data { - FILE *output; -}; - -static long file_is_coming(struct curl_fileinfo *finfo, - void *ptr, - int remains) -{ - struct callback_data *data = ptr; - printf("%3d %40s %10luB ", remains, finfo->filename, - (unsigned long)finfo->size); - - switch(finfo->filetype) { - case CURLFILETYPE_DIRECTORY: - printf(" DIR\\n"); - break; - case CURLFILETYPE_FILE: - printf("FILE "); - break; - default: - printf("OTHER\\n"); - break; - } - - if(finfo->filetype == CURLFILETYPE_FILE) { - /* do not transfer files >= 50B */ - if(finfo->size > 50) { - printf("SKIPPED\\n"); - return CURL_CHUNK_BGN_FUNC_SKIP; - } - - data->output = fopen(finfo->filename, "wb"); - if(!data->output) { - return CURL_CHUNK_BGN_FUNC_FAIL; - } - } - - return CURL_CHUNK_BGN_FUNC_OK; -} - -int main() -{ - /* data for callback */ - struct callback_data callback_info; - - CURL *curl = curl_easy_init(); - - /* callback is called before download of concrete file started */ - curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming); - curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CHUNK_BGN_FUNCTION (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_DATA.md b/docs/libcurl/opts/CURLOPT_CHUNK_DATA.md new file mode 100644 index 000000000..3640ec8df --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CHUNK_DATA.md @@ -0,0 +1,102 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CHUNK_DATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CHUNK_BGN_FUNCTION (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_CHUNK_DATA - pointer passed to the FTP chunk callbacks + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the ptr +argument to the CURLOPT_CHUNK_BGN_FUNCTION(3) and +CURLOPT_CHUNK_END_FUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +#include + +struct callback_data { + FILE *output; +}; + +static long file_is_coming(struct curl_fileinfo *finfo, + void *ptr, + int remains) +{ + struct callback_data *data = ptr; + printf("%3d %40s %10luB ", remains, finfo->filename, + (unsigned long)finfo->size); + + switch(finfo->filetype) { + case CURLFILETYPE_DIRECTORY: + printf(" DIR\n"); + break; + case CURLFILETYPE_FILE: + printf("FILE "); + break; + default: + printf("OTHER\n"); + break; + } + + if(finfo->filetype == CURLFILETYPE_FILE) { + /* do not transfer files >= 50B */ + if(finfo->size > 50) { + printf("SKIPPED\n"); + return CURL_CHUNK_BGN_FUNC_SKIP; + } + + data->output = fopen(finfo->filename, "wb"); + if(!data->output) { + return CURL_CHUNK_BGN_FUNC_FAIL; + } + } + + return CURL_CHUNK_BGN_FUNC_OK; +} + +int main() +{ + /* data for callback */ + struct callback_data callback_info; + + CURL *curl = curl_easy_init(); + + /* callback is called before download of concrete file started */ + curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming); + curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); +} +~~~ + +# AVAILABILITY + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.3 deleted file mode 100644 index c6bf88e45..000000000 --- a/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CHUNK_END_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CHUNK_END_FUNCTION \- callback after a transfer with FTP wildcard match -.SH SYNOPSIS -.nf -#include - -long chunk_end_callback(void *ptr); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION, - chunk_end_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This function gets called by libcurl as soon as a part of the stream has been -transferred (or skipped). - -Return \fICURL_CHUNK_END_FUNC_OK\fP if everything is fine or -\fBCURL_CHUNK_END_FUNC_FAIL\fP to tell the lib to stop if some error occurred. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -#include - -struct callback_data { - FILE *output; -}; - -static long file_is_downloaded(struct callback_data *data) -{ - if(data->output) { - fclose(data->output); - data->output = 0x0; - } - return CURL_CHUNK_END_FUNC_OK; -} - -int main() -{ - /* data for callback */ - struct callback_data callback_info; - - CURL *curl = curl_easy_init(); - - curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded); - curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CHUNK_BGN_FUNCTION (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.md b/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.md new file mode 100644 index 000000000..2d67afe20 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CHUNK_END_FUNCTION.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CHUNK_END_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CHUNK_BGN_FUNCTION (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_CHUNK_END_FUNCTION - callback after a transfer with FTP wildcard match + +# SYNOPSIS + +~~~c +#include + +long chunk_end_callback(void *ptr); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION, + chunk_end_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This function gets called by libcurl as soon as a part of the stream has been +transferred (or skipped). + +Return *CURL_CHUNK_END_FUNC_OK* if everything is fine or +**CURL_CHUNK_END_FUNC_FAIL** to tell the lib to stop if some error occurred. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +#include + +struct callback_data { + FILE *output; +}; + +static long file_is_downloaded(struct callback_data *data) +{ + if(data->output) { + fclose(data->output); + data->output = 0x0; + } + return CURL_CHUNK_END_FUNC_OK; +} + +int main() +{ + /* data for callback */ + struct callback_data callback_info; + + CURL *curl = curl_easy_init(); + + curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded); + curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); +} +~~~ + +# AVAILABILITY + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.3 b/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.3 deleted file mode 100644 index d1f870575..000000000 --- a/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CLOSESOCKETDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CLOSESOCKETDATA \- pointer passed to the socket close callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETDATA, - void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that remains untouched by libcurl and passed as the first -argument in the closesocket callback set with -\fICURLOPT_CLOSESOCKETFUNCTION(3)\fP. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All except file: -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int closesocket(void *clientp, curl_socket_t item) -{ - struct priv *my = clientp; - printf("our ptr: %p\\n", my->custom); - - printf("libcurl wants to close %d now\\n", (int)item); - return 0; -} - -int main(void) -{ - struct priv myown; - CURL *curl = curl_easy_init(); - - /* call this function to close sockets */ - curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); - curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown); - - curl_easy_perform(curl); - curl_easy_cleanup(curl); -} -.fi -.SH AVAILABILITY -Added in 7.21.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CLOSESOCKETFUNCTION (3), -.BR CURLOPT_OPENSOCKETFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.md b/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.md new file mode 100644 index 000000000..2dd74777b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CLOSESOCKETDATA.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CLOSESOCKETDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CLOSESOCKETFUNCTION (3) + - CURLOPT_OPENSOCKETFUNCTION (3) +--- + +# NAME + +CURLOPT_CLOSESOCKETDATA - pointer passed to the socket close callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETDATA, + void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that remains untouched by libcurl and passed as the first +argument in the closesocket callback set with +CURLOPT_CLOSESOCKETFUNCTION(3). + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All except file: + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int closesocket(void *clientp, curl_socket_t item) +{ + struct priv *my = clientp; + printf("our ptr: %p\n", my->custom); + + printf("libcurl wants to close %d now\n", (int)item); + return 0; +} + +int main(void) +{ + struct priv myown; + CURL *curl = curl_easy_init(); + + /* call this function to close sockets */ + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown); + + curl_easy_perform(curl); + curl_easy_cleanup(curl); +} +~~~ + +# AVAILABILITY + +Added in 7.21.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.3 b/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.3 deleted file mode 100644 index fb81f696f..000000000 --- a/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CLOSESOCKETFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CLOSESOCKETFUNCTION \- callback to socket close replacement -.SH SYNOPSIS -.nf -#include - -int closesocket_callback(void *clientp, curl_socket_t item); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETFUNCTION, - closesocket_callback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl instead of the \fIclose(3)\fP or -\fIclosesocket(3)\fP call when sockets are closed (not for any other file -descriptors). This is pretty much the reverse to the -\fICURLOPT_OPENSOCKETFUNCTION(3)\fP option. Return 0 to signal success and 1 -if there was an error. - -The \fIclientp\fP pointer is set with -\fICURLOPT_CLOSESOCKETDATA(3)\fP. \fIitem\fP is the socket libcurl wants to be -closed. -.SH DEFAULT -By default libcurl uses the standard socket close function. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int closesocket(void *clientp, curl_socket_t item) -{ - struct priv *my = clientp; - printf("our ptr: %p\\n", my->custom); - - printf("libcurl wants to close %d now\\n", (int)item); - return 0; -} - -int main(void) -{ - struct priv myown; - CURL *curl = curl_easy_init(); - - /* call this function to close sockets */ - curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); - curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown); - - curl_easy_perform(curl); - curl_easy_cleanup(curl); -} -.fi -.SH AVAILABILITY -Added in 7.21.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CLOSESOCKETDATA (3), -.BR CURLOPT_OPENSOCKETFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.md b/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.md new file mode 100644 index 000000000..e93e28c1e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CLOSESOCKETFUNCTION.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CLOSESOCKETFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CLOSESOCKETDATA (3) + - CURLOPT_OPENSOCKETFUNCTION (3) +--- + +# NAME + +CURLOPT_CLOSESOCKETFUNCTION - callback to socket close replacement + +# SYNOPSIS + +~~~c +#include + +int closesocket_callback(void *clientp, curl_socket_t item); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETFUNCTION, + closesocket_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl instead of the *close(3)* or +*closesocket(3)* call when sockets are closed (not for any other file +descriptors). This is pretty much the reverse to the +CURLOPT_OPENSOCKETFUNCTION(3) option. Return 0 to signal success and 1 +if there was an error. + +The *clientp* pointer is set with +CURLOPT_CLOSESOCKETDATA(3). *item* is the socket libcurl wants to be +closed. + +# DEFAULT + +By default libcurl uses the standard socket close function. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int closesocket(void *clientp, curl_socket_t item) +{ + struct priv *my = clientp; + printf("our ptr: %p\n", my->custom); + + printf("libcurl wants to close %d now\n", (int)item); + return 0; +} + +int main(void) +{ + struct priv myown; + CURL *curl = curl_easy_init(); + + /* call this function to close sockets */ + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &myown); + + curl_easy_perform(curl); + curl_easy_cleanup(curl); +} +~~~ + +# AVAILABILITY + +Added in 7.21.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3 b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3 deleted file mode 100644 index 1d4a2ed54..000000000 --- a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONNECTTIMEOUT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONNECTTIMEOUT \- timeout for the connect phase -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT, long timeout); -.fi -.SH DESCRIPTION -Pass a long. It should contain the maximum time in seconds that you allow the -connection phase to the server to take. This timeout only limits the -connection phase, it has no impact once it has connected. Set to zero to -switch to the default built-in connection timeout - 300 seconds. See also the -\fICURLOPT_TIMEOUT(3)\fP option. - -\fICURLOPT_CONNECTTIMEOUT_MS(3)\fP is the same function but set in milliseconds. - -If both \fICURLOPT_CONNECTTIMEOUT(3)\fP and \fICURLOPT_CONNECTTIMEOUT_MS(3)\fP -are set, the value set last is used. - -The "connection phase" is considered complete when the requested TCP, TLS or -QUIC handshakes are done. - -The connection timeout set with \fICURLOPT_CONNECTTIMEOUT(3)\fP is included in -the general all-covering \fICURLOPT_TIMEOUT(3)\fP. - -With \fICURLOPT_CONNECTTIMEOUT(3)\fP set to 3 and \fICURLOPT_TIMEOUT(3)\fP set -to 5, the operation can never last longer than 5 seconds, and the connection -phase cannot last longer than 3 seconds. - -With \fICURLOPT_CONNECTTIMEOUT(3)\fP set to 4 and \fICURLOPT_TIMEOUT(3)\fP set -to 2, the operation can never last longer than 2 seconds. Including the -connection phase. - -This option may cause libcurl to use the SIGALRM signal to timeout system -calls on builds not using asynch DNS. In unix-like systems, this might cause -signals to be used unless \fICURLOPT_NOSIGNAL(3)\fP is set. -.SH DEFAULT -300 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* complete connection within 10 seconds */ - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative -value or a value that when converted to milliseconds is too large. -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT_MS (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.md b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.md new file mode 100644 index 000000000..07513fdee --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT.md @@ -0,0 +1,89 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONNECTTIMEOUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT_MS (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_CONNECTTIMEOUT - timeout for the connect phase + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT, long timeout); +~~~ + +# DESCRIPTION + +Pass a long. It should contain the maximum time in seconds that you allow the +connection phase to the server to take. This timeout only limits the +connection phase, it has no impact once it has connected. Set to zero to +switch to the default built-in connection timeout - 300 seconds. See also the +CURLOPT_TIMEOUT(3) option. + +CURLOPT_CONNECTTIMEOUT_MS(3) is the same function but set in milliseconds. + +If both CURLOPT_CONNECTTIMEOUT(3) and CURLOPT_CONNECTTIMEOUT_MS(3) +are set, the value set last is used. + +The "connection phase" is considered complete when the requested TCP, TLS or +QUIC handshakes are done. + +The connection timeout set with CURLOPT_CONNECTTIMEOUT(3) is included in +the general all-covering CURLOPT_TIMEOUT(3). + +With CURLOPT_CONNECTTIMEOUT(3) set to 3 and CURLOPT_TIMEOUT(3) set +to 5, the operation can never last longer than 5 seconds, and the connection +phase cannot last longer than 3 seconds. + +With CURLOPT_CONNECTTIMEOUT(3) set to 4 and CURLOPT_TIMEOUT(3) set +to 2, the operation can never last longer than 2 seconds. Including the +connection phase. + +This option may cause libcurl to use the SIGALRM signal to timeout system +calls on builds not using asynch DNS. In unix-like systems, this might cause +signals to be used unless CURLOPT_NOSIGNAL(3) is set. + +# DEFAULT + +300 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* complete connection within 10 seconds */ + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative +value or a value that when converted to milliseconds is too large. diff --git a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.3 b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.3 deleted file mode 100644 index 67c0097ef..000000000 --- a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONNECTTIMEOUT_MS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONNECTTIMEOUT_MS \- timeout for the connect phase -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT_MS, - long timeout); -.fi -.SH DESCRIPTION -Pass a long. It should contain the maximum time in milliseconds that you allow -the connection phase to the server to take. - -See \fICURLOPT_CONNECTTIMEOUT(3)\fP for details. -.SH DEFAULT -300000 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* complete connection within 10000 milliseconds */ - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.md new file mode 100644 index 000000000..b8508e7de --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONNECTTIMEOUT_MS.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONNECTTIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_CONNECTTIMEOUT_MS - timeout for the connect phase + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT_MS, + long timeout); +~~~ + +# DESCRIPTION + +Pass a long. It should contain the maximum time in milliseconds that you allow +the connection phase to the server to take. + +See CURLOPT_CONNECTTIMEOUT(3) for details. + +# DEFAULT + +300000 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* complete connection within 10000 milliseconds */ + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.3 b/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.3 deleted file mode 100644 index 014c5f2cf..000000000 --- a/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONNECT_ONLY 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONNECT_ONLY \- stop when connected to target server -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_ONLY, long only); -.fi -.SH DESCRIPTION -Pass a long. If the parameter equals 1, it tells the library to perform all -the required proxy authentication and connection setup, but no data transfer, -and then return. - -The option can be used to simply test a connection to a server, but is more -useful when used with the \fICURLINFO_ACTIVESOCKET(3)\fP option to -\fIcurl_easy_getinfo(3)\fP as the library can set up the connection and then -the application can obtain the most recently used socket for special data -transfers. - -Since 7.86.0, this option can be set to '2' and if HTTP or WebSocket are used, -libcurl performs the request and reads all response headers before handing -over control to the application. - -Transfers marked connect only do not reuse any existing connections and -connections marked connect only are not allowed to get reused. - -If the connect only transfer is done using the multi interface, the particular -easy handle must remain added to the multi handle for as long as the -application wants to use it. Once it has been removed with -\fIcurl_multi_remove_handle(3)\fP, \fIcurl_easy_send(3)\fP and -\fIcurl_easy_recv(3)\fP do not function. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP, SMTP, POP3 and IMAP. For WS and WSS starting in 7.86.0. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); - ret = curl_easy_perform(curl); - if(ret == CURLE_OK) { - /* only connected! */ - } - } -} -.fi -.SH AVAILABILITY -Added in 7.15.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_recv (3), -.BR curl_easy_send (3), -.BR CURLOPT_HTTPPROXYTUNNEL (3), -.BR CURLOPT_VERBOSE (3) diff --git a/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.md b/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.md new file mode 100644 index 000000000..3312936af --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONNECT_ONLY.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONNECT_ONLY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_VERBOSE (3) + - curl_easy_recv (3) + - curl_easy_send (3) +--- + +# NAME + +CURLOPT_CONNECT_ONLY - stop when connected to target server + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_ONLY, long only); +~~~ + +# DESCRIPTION + +Pass a long. If the parameter equals 1, it tells the library to perform all +the required proxy authentication and connection setup, but no data transfer, +and then return. + +The option can be used to simply test a connection to a server, but is more +useful when used with the CURLINFO_ACTIVESOCKET(3) option to +curl_easy_getinfo(3) as the library can set up the connection and then +the application can obtain the most recently used socket for special data +transfers. + +Since 7.86.0, this option can be set to '2' and if HTTP or WebSocket are used, +libcurl performs the request and reads all response headers before handing +over control to the application. + +Transfers marked connect only do not reuse any existing connections and +connections marked connect only are not allowed to get reused. + +If the connect only transfer is done using the multi interface, the particular +easy handle must remain added to the multi handle for as long as the +application wants to use it. Once it has been removed with +curl_multi_remove_handle(3), curl_easy_send(3) and +curl_easy_recv(3) do not function. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP, SMTP, POP3 and IMAP. For WS and WSS starting in 7.86.0. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); + ret = curl_easy_perform(curl); + if(ret == CURLE_OK) { + /* only connected! */ + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CONNECT_TO.3 b/docs/libcurl/opts/CURLOPT_CONNECT_TO.3 deleted file mode 100644 index e0a45031b..000000000 --- a/docs/libcurl/opts/CURLOPT_CONNECT_TO.3 +++ /dev/null @@ -1,119 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONNECT_TO 3 "10 April 2016" libcurl libcurl -.SH NAME -CURLOPT_CONNECT_TO \- connect to a specific host and port instead of the URL's host and port -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_TO, - struct curl_slist *connect_to); -.fi -.SH DESCRIPTION -Pass a pointer to a linked list of strings with "connect to" information to -use for establishing network connections with this handle. The linked list -should be a fully valid list of \fBstruct curl_slist\fP structs properly -filled in. Use \fIcurl_slist_append(3)\fP to create the list and -\fIcurl_slist_free_all(3)\fP to clean up an entire list. - -Each single string should be written using the format -HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT where HOST is the host of the -request, PORT is the port of the request, CONNECT-TO-HOST is the host name to -connect to, and CONNECT-TO-PORT is the port to connect to. - -The first string that matches the request's host and port is used. - -Dotted numerical IP addresses are supported for HOST and CONNECT-TO-HOST. -A numerical IPv6 address must be written within [brackets]. - -Any of the four values may be empty. When the HOST or PORT is empty, the host -or port always match (the request's host or port is ignored). When -CONNECT-TO-HOST or CONNECT-TO-PORT is empty, the "connect to" feature is -disabled for the host or port, and the request's host or port are used to -establish the network connection. - -This option is suitable to direct the request at a specific server, e.g. at a -specific cluster node in a cluster of servers. - -The "connect to" host and port are only used to establish the network -connection. They do NOT affect the host and port that are used for TLS/SSL -(e.g. SNI, certificate verification) or for the application protocols. - -In contrast to \fICURLOPT_RESOLVE(3)\fP, the option -\fICURLOPT_CONNECT_TO(3)\fP does not pre-populate the DNS cache and therefore -it does not affect future transfers of other easy handles that have been added -to the same multi handle. - -The "connect to" host and port are ignored if they are equal to the host and -the port in the request URL, because connecting to the host and the port in -the request URL is the default behavior. - -If an HTTP proxy is used for a request having a special "connect to" host or -port, and the "connect to" host or port differs from the request's host and -port, the HTTP proxy is automatically switched to tunnel mode for this -specific request. This is necessary because it is not possible to connect to a -specific host or port in normal (non-tunnel) mode. - -When this option is passed to \fIcurl_easy_setopt(3)\fP, libcurl does not copy -the list so you \fBmust\fP keep it around until you no longer use this -\fIhandle\fP for a transfer before you call \fIcurl_slist_free_all(3)\fP on -the list. - -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl; - struct curl_slist *connect_to = NULL; - connect_to = curl_slist_append(NULL, "example.com::server1.example.com:"); - - curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to); - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } - - curl_slist_free_all(connect_to); -} -.fi -.SH AVAILABILITY -Added in 7.49.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FOLLOWLOCATION (3), -.BR CURLOPT_HTTPPROXYTUNNEL (3), -.BR CURLOPT_RESOLVE (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_CONNECT_TO.md b/docs/libcurl/opts/CURLOPT_CONNECT_TO.md new file mode 100644 index 000000000..8aea3ffa9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONNECT_TO.md @@ -0,0 +1,114 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONNECT_TO +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FOLLOWLOCATION (3) + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_RESOLVE (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_CONNECT_TO - connect to another host and port instead + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECT_TO, + struct curl_slist *connect_to); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of strings with "connect to" information to +use for establishing network connections with this handle. The linked list +should be a fully valid list of **struct curl_slist** structs properly filled +in. Use curl_slist_append(3) to create the list and curl_slist_free_all(3) to +clean up an entire list. + +Each single string should be written using the format +HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT where HOST is the host of the +request, PORT is the port of the request, CONNECT-TO-HOST is the hostname to +connect to, and CONNECT-TO-PORT is the port to connect to. + +The first string that matches the request's host and port is used. + +Dotted numerical IP addresses are supported for HOST and CONNECT-TO-HOST. +A numerical IPv6 address must be written within [brackets]. + +Any of the four values may be empty. When the HOST or PORT is empty, the host +or port always match (the request's host or port is ignored). When +CONNECT-TO-HOST or CONNECT-TO-PORT is empty, the "connect to" feature is +disabled for the host or port, and the request's host or port are used to +establish the network connection. + +This option is suitable to direct the request at a specific server, e.g. at a +specific cluster node in a cluster of servers. + +The "connect to" host and port are only used to establish the network +connection. They do NOT affect the host and port that are used for TLS/SSL +(e.g. SNI, certificate verification) or for the application protocols. + +In contrast to CURLOPT_RESOLVE(3), the option CURLOPT_CONNECT_TO(3) does not +pre-populate the DNS cache and therefore it does not affect future transfers +of other easy handles that have been added to the same multi handle. + +The "connect to" host and port are ignored if they are equal to the host and +the port in the request URL, because connecting to the host and the port in +the request URL is the default behavior. + +If an HTTP proxy is used for a request having a special "connect to" host or +port, and the "connect to" host or port differs from the request's host and +port, the HTTP proxy is automatically switched to tunnel mode for this +specific request. This is necessary because it is not possible to connect to a +specific host or port in normal (non-tunnel) mode. + +When this option is passed to curl_easy_setopt(3), libcurl does not copy the +list so you **must** keep it around until you no longer use this *handle* for +a transfer before you call curl_slist_free_all(3) on the list. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl; + struct curl_slist *connect_to = NULL; + connect_to = curl_slist_append(NULL, "example.com::server1.example.com:"); + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to); + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + curl_slist_free_all(connect_to); +} +~~~ + +# AVAILABILITY + +Added in 7.49.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.3 deleted file mode 100644 index 2baf5f46f..000000000 --- a/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.3 +++ /dev/null @@ -1,111 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONV_FROM_NETWORK_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONV_FROM_NETWORK_FUNCTION \- convert data from network to host encoding -.SH SYNOPSIS -.nf -#include - -CURLcode conv_callback(char *ptr, size_t length); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_FROM_NETWORK_FUNCTION, - conv_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -Applies to non-ASCII platforms. \fIcurl_version_info(3)\fP returns the -\fBCURL_VERSION_CONV\fP feature bit set if this option is provided. - -The data to be converted is in a buffer pointed to by the \fIptr\fP parameter. -The amount of data to convert is indicated by the \fIlength\fP parameter. The -converted data overlays the input data in the buffer pointed to by the ptr -parameter. \fICURLE_OK\fP must be returned upon successful conversion. A -CURLcode return value defined by curl.h, such as \fICURLE_CONV_FAILED\fP, -should be returned if an error was encountered. - -\fICURLOPT_CONV_FROM_NETWORK_FUNCTION(3)\fP converts to host encoding from the -network encoding. It is used when commands or ASCII data are received over -the network. - -If you set a callback pointer to NULL, or do not set it at all, the built-in -libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl -was built, and no callback has been established, the conversion returns the -\fBCURLE_CONV_REQD\fP error code. - -If \fBHAVE_ICONV\fP is defined, \fBCURL_ICONV_CODESET_OF_HOST\fP must also be -defined. For example: - - \&#define CURL_ICONV_CODESET_OF_HOST "IBM-1047" - -The iconv code in libcurl defaults the network and UTF8 codeset names as -follows: - - \&#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" - - \&#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" - -You need to override these definitions if they are different on your system. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP, SMTP, IMAP, POP3 -.SH EXAMPLE -.nf -static CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length) -{ - int rc = 0; - - /* in-place convert 'buffer' from ASCII to EBCDIC */ - - if(rc == 0) { - /* success */ - return CURLE_OK; - } - else { - return CURLE_CONV_FAILED; - } -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - - /* use platform-specific functions for codeset conversions */ - curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION, - my_conv_from_ascii_to_ebcdic); -} -.fi -.SH AVAILABILITY -Not available and deprecated since 7.82.0. - -Available only if \fBCURL_DOES_CONVERSIONS\fP was defined when libcurl was -built. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CONV_FROM_UTF8_FUNCTION (3), -.BR CURLOPT_CONV_TO_NETWORK_FUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.md b/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.md new file mode 100644 index 000000000..7460a1e90 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONV_FROM_NETWORK_FUNCTION.md @@ -0,0 +1,114 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONV_FROM_NETWORK_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONV_FROM_UTF8_FUNCTION (3) + - CURLOPT_CONV_TO_NETWORK_FUNCTION (3) +--- + +# NAME + +CURLOPT_CONV_FROM_NETWORK_FUNCTION - convert data from network to host encoding + +# SYNOPSIS + +~~~c +#include + +CURLcode conv_callback(char *ptr, size_t length); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_FROM_NETWORK_FUNCTION, + conv_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +Applies to non-ASCII platforms. curl_version_info(3) returns the +**CURL_VERSION_CONV** feature bit set if this option is provided. + +The data to be converted is in a buffer pointed to by the *ptr* parameter. +The amount of data to convert is indicated by the *length* parameter. The +converted data overlays the input data in the buffer pointed to by the ptr +parameter. *CURLE_OK* must be returned upon successful conversion. A +CURLcode return value defined by curl.h, such as *CURLE_CONV_FAILED*, +should be returned if an error was encountered. + +CURLOPT_CONV_FROM_NETWORK_FUNCTION(3) converts to host encoding from the +network encoding. It is used when commands or ASCII data are received over the +network. + +If you set a callback pointer to NULL, or do not set it at all, the built-in +libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl +was built, and no callback has been established, the conversion returns the +**CURLE_CONV_REQD** error code. + +If **HAVE_ICONV** is defined, **CURL_ICONV_CODESET_OF_HOST** must also be +defined. For example: + +~~~c +#define CURL_ICONV_CODESET_OF_HOST "IBM-1047" +~~~ + +The iconv code in libcurl defaults the network and UTF8 codeset names as +follows: + +~~~ +#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" + +#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" +~~~ + +You need to override these definitions if they are different on your system. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP, SMTP, IMAP, POP3 + +# EXAMPLE + +~~~c +static CURLcode my_conv_from_ascii_to_ebcdic(char *buffer, size_t length) +{ + int rc = 0; + + /* in-place convert 'buffer' from ASCII to EBCDIC */ + + if(rc == 0) { + /* success */ + return CURLE_OK; + } + else { + return CURLE_CONV_FAILED; + } +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + + /* use platform-specific functions for codeset conversions */ + curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION, + my_conv_from_ascii_to_ebcdic); +} +~~~ + +# AVAILABILITY + +Not available and deprecated since 7.82.0. + +Available only if **CURL_DOES_CONVERSIONS** was defined when libcurl was +built. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.3 deleted file mode 100644 index e6ab8bf5b..000000000 --- a/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONV_FROM_UTF8_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONV_FROM_UTF8_FUNCTION \- convert data from UTF8 to host encoding -.SH SYNOPSIS -.nf -#include - -CURLcode conv_callback(char *ptr, size_t length); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_FROM_UTF8_FUNCTION, - conv_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -Applies to non-ASCII platforms. \fIcurl_version_info(3)\fP returns the -CURL_VERSION_CONV feature bit set if this option is provided. - -The data to be converted is in a buffer pointed to by the \fIptr\fP parameter. -The amount of data to convert is indicated by the \fIlength\fP parameter. The -converted data overlays the input data in the buffer pointed to by the ptr -parameter. \fICURLE_OK\fP must be returned upon successful conversion. A -CURLcode return value defined by curl.h, such as \fICURLE_CONV_FAILED\fP, -should be returned if an error was encountered. - -\fICURLOPT_CONV_FROM_UTF8_FUNCTION(3)\fP converts to host encoding from UTF8 -encoding. It is required only for SSL processing. - -If you set a callback pointer to NULL, or do not set it at all, the built-in -libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl -was built, and no callback has been established, the conversion returns the -CURLE_CONV_REQD error code. - -If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined. -For example: - - \&#define CURL_ICONV_CODESET_OF_HOST "IBM-1047" - -The iconv code in libcurl defaults the network and UTF8 codeset names as -follows: - - \&#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" - - \&#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" - -You need to override these definitions if they are different on your system. -.SH DEFAULT -NULL -.SH PROTOCOLS -TLS-based protocols. -.SH EXAMPLE -.nf -static CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length) -{ - int rc = 0; - /* in-place convert 'buffer' from UTF-8 to EBCDIC */ - if(rc == 0) { - /* success */ - return CURLE_OK; - } - else { - return CURLE_CONV_FAILED; - } -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION, - my_conv_from_utf8_to_ebcdic); -} -.fi -.SH AVAILABILITY -Not available and deprecated since 7.82.0. - -Available only if \fBCURL_DOES_CONVERSIONS\fP was defined when libcurl was -built. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CONV_FROM_NETWORK_FUNCTION (3), -.BR CURLOPT_CONV_TO_NETWORK_FUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.md b/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.md new file mode 100644 index 000000000..1f7d704e9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONV_FROM_UTF8_FUNCTION.md @@ -0,0 +1,107 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONV_FROM_UTF8_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONV_FROM_NETWORK_FUNCTION (3) + - CURLOPT_CONV_TO_NETWORK_FUNCTION (3) +--- + +# NAME + +CURLOPT_CONV_FROM_UTF8_FUNCTION - convert data from UTF8 to host encoding + +# SYNOPSIS + +~~~c +#include + +CURLcode conv_callback(char *ptr, size_t length); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_FROM_UTF8_FUNCTION, + conv_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +Applies to non-ASCII platforms. curl_version_info(3) returns the +CURL_VERSION_CONV feature bit set if this option is provided. + +The data to be converted is in a buffer pointed to by the *ptr* parameter. +The amount of data to convert is indicated by the *length* parameter. The +converted data overlays the input data in the buffer pointed to by the ptr +parameter. *CURLE_OK* must be returned upon successful conversion. A +CURLcode return value defined by curl.h, such as *CURLE_CONV_FAILED*, +should be returned if an error was encountered. + +CURLOPT_CONV_FROM_UTF8_FUNCTION(3) converts to host encoding from UTF8 +encoding. It is required only for SSL processing. + +If you set a callback pointer to NULL, or do not set it at all, the built-in +libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl +was built, and no callback has been established, the conversion returns the +CURLE_CONV_REQD error code. + +If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined. +For example: +~~~c + #define CURL_ICONV_CODESET_OF_HOST "IBM-1047" +~~~ + +The iconv code in libcurl defaults the network and UTF8 codeset names as +follows: +~~~c +#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" + +#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" +~~~ + +You need to override these definitions if they are different on your system. + +# DEFAULT + +NULL + +# PROTOCOLS + +TLS-based protocols. + +# EXAMPLE + +~~~c +static CURLcode my_conv_from_utf8_to_ebcdic(char *buffer, size_t length) +{ + int rc = 0; + /* in-place convert 'buffer' from UTF-8 to EBCDIC */ + if(rc == 0) { + /* success */ + return CURLE_OK; + } + else { + return CURLE_CONV_FAILED; + } +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION, + my_conv_from_utf8_to_ebcdic); +} +~~~ + +# AVAILABILITY + +Not available and deprecated since 7.82.0. + +Available only if **CURL_DOES_CONVERSIONS** was defined when libcurl was +built. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.3 deleted file mode 100644 index e2dc7d606..000000000 --- a/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.3 +++ /dev/null @@ -1,108 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CONV_TO_NETWORK_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CONV_TO_NETWORK_FUNCTION \- convert data to network from host encoding -.SH SYNOPSIS -.nf -#include - -CURLcode conv_callback(char *ptr, size_t length); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_TO_NETWORK_FUNCTION, - conv_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -Applies to non-ASCII platforms. \fIcurl_version_info(3)\fP returns the -CURL_VERSION_CONV feature bit set if this option is provided. - -The data to be converted is in a buffer pointed to by the \fIptr\fP parameter. -The amount of data to convert is indicated by the \fIlength\fP parameter. The -converted data overlays the input data in the buffer pointed to by the ptr -parameter. \fICURLE_OK\fP must be returned upon successful conversion. A -CURLcode return value defined by curl.h, such as \fICURLE_CONV_FAILED\fP, -should be returned if an error was encountered. - -\fICURLOPT_CONV_TO_NETWORK_FUNCTION(3)\fP converts from host encoding to the -network encoding. It is used when commands or ASCII data are sent over the -network. - -If you set a callback pointer to NULL, or do not set it at all, the built-in -libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl -was built, and no callback has been established, the conversion returns the -CURLE_CONV_REQD error code. - -If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined. -For example: - - \&#define CURL_ICONV_CODESET_OF_HOST "IBM-1047" - -The iconv code in libcurl defaults the network and UTF8 codeset names as -follows: - - \&#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" - - \&#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" - -You need to override these definitions if they are different on your system. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP, SMTP, IMAP, POP3 -.SH EXAMPLE -.nf -static CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length) -{ - int rc = 0; - /* in-place convert 'buffer' from EBCDIC to ASCII */ - if(rc == 0) { - /* success */ - return CURLE_OK; - } - else { - return CURLE_CONV_FAILED; - } -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - - curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION, - my_conv_from_ebcdic_to_ascii); -} -.fi -.SH AVAILABILITY -Not available and deprecated since 7.82.0. - -Available only if \fBCURL_DOES_CONVERSIONS\fP was defined when libcurl was -built. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CONV_FROM_NETWORK_FUNCTION (3), -.BR CURLOPT_CONV_FROM_UTF8_FUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.md b/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.md new file mode 100644 index 000000000..13d9da867 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CONV_TO_NETWORK_FUNCTION.md @@ -0,0 +1,110 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CONV_TO_NETWORK_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONV_FROM_NETWORK_FUNCTION (3) + - CURLOPT_CONV_FROM_UTF8_FUNCTION (3) +--- + +# NAME + +CURLOPT_CONV_TO_NETWORK_FUNCTION - convert data to network from host encoding + +# SYNOPSIS + +~~~c +#include + +CURLcode conv_callback(char *ptr, size_t length); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONV_TO_NETWORK_FUNCTION, + conv_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +Applies to non-ASCII platforms. curl_version_info(3) returns the +CURL_VERSION_CONV feature bit set if this option is provided. + +The data to be converted is in a buffer pointed to by the *ptr* parameter. +The amount of data to convert is indicated by the *length* parameter. The +converted data overlays the input data in the buffer pointed to by the ptr +parameter. *CURLE_OK* must be returned upon successful conversion. A CURLcode +return value defined by curl.h, such as *CURLE_CONV_FAILED*, should be +returned if an error was encountered. + +CURLOPT_CONV_TO_NETWORK_FUNCTION(3) converts from host encoding to the +network encoding. It is used when commands or ASCII data are sent over the +network. + +If you set a callback pointer to NULL, or do not set it at all, the built-in +libcurl iconv functions are used. If HAVE_ICONV was not defined when libcurl +was built, and no callback has been established, the conversion returns the +CURLE_CONV_REQD error code. + +If HAVE_ICONV is defined, CURL_ICONV_CODESET_OF_HOST must also be defined. +For example: +~~~c +define CURL_ICONV_CODESET_OF_HOST "IBM-1047" +~~~ + +The iconv code in libcurl defaults the network and UTF8 codeset names as +follows: + +~~~c +#define CURL_ICONV_CODESET_OF_NETWORK "ISO8859-1" + +#define CURL_ICONV_CODESET_FOR_UTF8 "UTF-8" +~~~ + +You need to override these definitions if they are different on your system. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP, SMTP, IMAP, POP3 + +# EXAMPLE + +~~~c +static CURLcode my_conv_from_ebcdic_to_ascii(char *buffer, size_t length) +{ + int rc = 0; + /* in-place convert 'buffer' from EBCDIC to ASCII */ + if(rc == 0) { + /* success */ + return CURLE_OK; + } + else { + return CURLE_CONV_FAILED; + } +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + + curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION, + my_conv_from_ebcdic_to_ascii); +} +~~~ + +# AVAILABILITY + +Not available and deprecated since 7.82.0. + +Available only if **CURL_DOES_CONVERSIONS** was defined when libcurl was +built. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_COOKIE.3 b/docs/libcurl/opts/CURLOPT_COOKIE.3 deleted file mode 100644 index e21d54c5f..000000000 --- a/docs/libcurl/opts/CURLOPT_COOKIE.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COOKIE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COOKIE \- HTTP Cookie header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIE, char *cookie); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It is used to set one -or more cookies in the HTTP request. The format of the string should be -NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie -should contain. - -To set multiple cookies, set them all using a single option concatenated like -this: "name1=content1; name2=content2;" etc. - -This option sets the cookie header explicitly in the outgoing request(s). If -multiple requests are done due to authentication, followed redirections or -similar, they all get this cookie passed on. - -The cookies set by this option are separate from the internal cookie storage -held by the cookie engine and they are not be modified by it. If you enable -the cookie engine and either you have imported a cookie of the same name -(e.g. 'foo') or the server has set one, it has no effect on the cookies you -set here. A request to the server sends both the 'foo' held by the cookie -engine and the 'foo' held by this option. To set a cookie that is instead held -by the cookie engine and can be modified by the server use -\fICURLOPT_COOKIELIST(3)\fP. - -Using this option multiple times makes the last set string override the -previous ones. - -This option does not enable the cookie engine. Use \fICURLOPT_COOKIEFILE(3)\fP -or \fICURLOPT_COOKIEJAR(3)\fP to enable parsing and sending cookies -automatically. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, no cookies -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;"); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -If HTTP is enabled -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_COOKIELIST (3), -.BR CURLOPT_COOKIEFILE (3), -.BR CURLOPT_COOKIEJAR (3), -.BR CURLOPT_COOKIELIST (3), -.BR CURLOPT_HTTPHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_COOKIE.md b/docs/libcurl/opts/CURLOPT_COOKIE.md new file mode 100644 index 000000000..4e2955d8a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COOKIE.md @@ -0,0 +1,97 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COOKIE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_COOKIELIST (3) + - CURLOPT_COOKIEFILE (3) + - CURLOPT_COOKIEJAR (3) + - CURLOPT_COOKIELIST (3) + - CURLOPT_HTTPHEADER (3) +--- + +# NAME + +CURLOPT_COOKIE - HTTP Cookie header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIE, char *cookie); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It is used to set one +or more cookies in the HTTP request. The format of the string should be +NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie +should contain. + +To set multiple cookies, set them all using a single option concatenated like +this: "name1=content1; name2=content2;" etc. + +This option sets the cookie header explicitly in the outgoing request(s). If +multiple requests are done due to authentication, followed redirections or +similar, they all get this cookie passed on. + +The cookies set by this option are separate from the internal cookie storage +held by the cookie engine and they are not be modified by it. If you enable +the cookie engine and either you have imported a cookie of the same name +(e.g. 'foo') or the server has set one, it has no effect on the cookies you +set here. A request to the server sends both the 'foo' held by the cookie +engine and the 'foo' held by this option. To set a cookie that is instead held +by the cookie engine and can be modified by the server use +CURLOPT_COOKIELIST(3). + +Using this option multiple times makes the last set string override the +previous ones. + +This option does not enable the cookie engine. Use CURLOPT_COOKIEFILE(3) +or CURLOPT_COOKIEJAR(3) to enable parsing and sending cookies +automatically. + +The application does not have to keep the string around after setting this +option. + +If libcurl is built with PSL (*Public Suffix List*) support, it detects and +discards cookies that are specified for such suffix domains that should not be +allowed to have cookies. If libcurl is *not* built with PSL support, it has no +ability to stop super cookies. PSL support is identified by the +**CURL_VERSION_PSL** feature bit returned by curl_version_info(3). + +# DEFAULT + +NULL, no cookies + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_COOKIE, "tool=curl; fun=yes;"); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +If HTTP is enabled + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_COOKIEFILE.3 b/docs/libcurl/opts/CURLOPT_COOKIEFILE.3 deleted file mode 100644 index e1d5dbd96..000000000 --- a/docs/libcurl/opts/CURLOPT_COOKIEFILE.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COOKIEFILE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COOKIEFILE \- file name to read cookies from -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEFILE, char *filename); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It should point to -the file name of your file holding cookie data to read. The cookie data can be -in either the old Netscape / Mozilla cookie data format or just regular HTTP -headers (Set-Cookie style) dumped to a file. - -It also enables the cookie engine, making libcurl parse and send cookies on -subsequent requests with this handle. - -By passing the empty string ("") to this option, you enable the cookie engine -without reading any initial cookies. If you tell libcurl the file name is "-" -(just a single minus sign), libcurl instead reads from stdin. - -This option only \fBreads\fP cookies. To make libcurl write cookies to file, -see \fICURLOPT_COOKIEJAR(3)\fP. - -If you read cookies from a plain HTTP headers file and it does not specify a -domain in the Set-Cookie line, then the cookie is not sent since the cookie -domain cannot match the target URL's. To address this, set a domain in -Set-Cookie line (doing that includes subdomains) or preferably: use the -Netscape format. - -If you use this option multiple times, you add more files to read cookies -from. - -The application does not have to keep the string around after setting this -option. - -Setting this option to NULL (since 7.77.0) explicitly disables the cookie -engine and clears the list of files to read cookies from. -.SH SECURITY -This document previously mentioned how specifying a non-existing file can also -enable the cookie engine. While true, we strongly advise against using that -method as it is too hard to be sure that files that stay that way in the long -run. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* get cookies from an existing file */ - curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH "Cookie file format" -The cookie file format and general cookie concepts in curl are described -online here: https://curl.se/docs/http-cookies.html -.SH AVAILABILITY -As long as HTTP is supported -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_COOKIE (3), -.BR CURLOPT_COOKIEJAR (3), -.BR CURLOPT_COOKIESESSION (3) diff --git a/docs/libcurl/opts/CURLOPT_COOKIEFILE.md b/docs/libcurl/opts/CURLOPT_COOKIEFILE.md new file mode 100644 index 000000000..87dce1b1a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COOKIEFILE.md @@ -0,0 +1,103 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COOKIEFILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COOKIE (3) + - CURLOPT_COOKIEJAR (3) + - CURLOPT_COOKIESESSION (3) +--- + +# NAME + +CURLOPT_COOKIEFILE - filename to read cookies from + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEFILE, char *filename); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It should point to +the filename of your file holding cookie data to read. The cookie data can be +in either the old Netscape / Mozilla cookie data format or just regular HTTP +headers (Set-Cookie style) dumped to a file. + +It also enables the cookie engine, making libcurl parse and send cookies on +subsequent requests with this handle. + +By passing the empty string ("") to this option, you enable the cookie engine +without reading any initial cookies. If you tell libcurl the filename is "-" +(just a single minus sign), libcurl instead reads from stdin. + +This option only **reads** cookies. To make libcurl write cookies to file, +see CURLOPT_COOKIEJAR(3). + +If you read cookies from a plain HTTP headers file and it does not specify a +domain in the Set-Cookie line, then the cookie is not sent since the cookie +domain cannot match the target URL's. To address this, set a domain in +Set-Cookie line (doing that includes subdomains) or preferably: use the +Netscape format. + +If you use this option multiple times, you add more files to read cookies +from. + +The application does not have to keep the string around after setting this +option. + +Setting this option to NULL (since 7.77.0) explicitly disables the cookie +engine and clears the list of files to read cookies from. + +# SECURITY + +This document previously mentioned how specifying a non-existing file can also +enable the cookie engine. While true, we strongly advise against using that +method as it is too hard to be sure that files that stay that way in the long +run. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* get cookies from an existing file */ + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# Cookie file format + +The cookie file format and general cookie concepts in curl are described +online here: https://curl.se/docs/http-cookies.html + +# AVAILABILITY + +As long as HTTP is supported + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_COOKIEJAR.3 b/docs/libcurl/opts/CURLOPT_COOKIEJAR.3 deleted file mode 100644 index f8d75bea4..000000000 --- a/docs/libcurl/opts/CURLOPT_COOKIEJAR.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COOKIEJAR 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COOKIEJAR \- file name to store cookies to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEJAR, char *filename); -.fi -.SH DESCRIPTION -Pass a \fIfilename\fP as a char *, null-terminated. This makes libcurl write -all internally known cookies to the specified file when -\fIcurl_easy_cleanup(3)\fP is called. If no cookies are kept in memory at that -time, no file is created. Specify "-" as filename to instead have the cookies -written to stdout. Using this option also enables cookies for this session, so -if you for example follow a redirect it makes matching cookies get sent -accordingly. - -Note that libcurl does not read any cookies from the cookie jar specified with -this option. To read cookies from a file, use \fICURLOPT_COOKIEFILE(3)\fP. - -If the cookie jar file cannot be created or written to (when the -\fIcurl_easy_cleanup(3)\fP is called), libcurl does not and cannot report an -error for this. Using \fICURLOPT_VERBOSE(3)\fP or -\fICURLOPT_DEBUGFUNCTION(3)\fP displays a warning, but that is the only -visible feedback you get about this possibly lethal situation. - -Cookies are imported in the Set-Cookie format without a domain name are not -exported by this option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* export cookies to this file when closing the handle */ - curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "/tmp/cookies.txt"); - - res = curl_easy_perform(curl); - - /* close the handle, write the cookies! */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_COOKIE (3), -.BR CURLOPT_COOKIEFILE (3), -.BR CURLOPT_COOKIELIST (3) diff --git a/docs/libcurl/opts/CURLOPT_COOKIEJAR.md b/docs/libcurl/opts/CURLOPT_COOKIEJAR.md new file mode 100644 index 000000000..ec0d273eb --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COOKIEJAR.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COOKIEJAR +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COOKIE (3) + - CURLOPT_COOKIEFILE (3) + - CURLOPT_COOKIELIST (3) +--- + +# NAME + +CURLOPT_COOKIEJAR - filename to store cookies to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIEJAR, char *filename); +~~~ + +# DESCRIPTION + +Pass a *filename* as a char *, null-terminated. This makes libcurl write +all internally known cookies to the specified file when +curl_easy_cleanup(3) is called. If no cookies are kept in memory at that +time, no file is created. Specify "-" as filename to instead have the cookies +written to stdout. Using this option also enables cookies for this session, so +if you for example follow a redirect it makes matching cookies get sent +accordingly. + +Note that libcurl does not read any cookies from the cookie jar specified with +this option. To read cookies from a file, use CURLOPT_COOKIEFILE(3). + +If the cookie jar file cannot be created or written to (when the +curl_easy_cleanup(3) is called), libcurl does not and cannot report an +error for this. Using CURLOPT_VERBOSE(3) or +CURLOPT_DEBUGFUNCTION(3) displays a warning, but that is the only +visible feedback you get about this possibly lethal situation. + +Cookies are imported in the Set-Cookie format without a domain name are not +exported by this option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* export cookies to this file when closing the handle */ + curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "/tmp/cookies.txt"); + + res = curl_easy_perform(curl); + + /* close the handle, write the cookies! */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_COOKIELIST.3 b/docs/libcurl/opts/CURLOPT_COOKIELIST.3 deleted file mode 100644 index 41862311a..000000000 --- a/docs/libcurl/opts/CURLOPT_COOKIELIST.3 +++ /dev/null @@ -1,131 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COOKIELIST 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COOKIELIST \- add to or manipulate cookies held in memory -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIELIST, - char *cookie); -.SH DESCRIPTION -Pass a char * to a \fIcookie\fP string. - -Such a cookie can be either a single line in Netscape / Mozilla format or just -regular HTTP-style header (Set-Cookie: ...) format. This option also enables -the cookie engine. This adds that single cookie to the internal cookie store. - -We strongly advice against loading cookies from a HTTP header file, as that is -an inferior data exchange format. - -Exercise caution if you are using this option and multiple transfers may -occur. If you use the Set-Cookie format and the string does not specify a -domain, then the cookie is sent for any domain (even after redirects are -followed) and cannot be modified by a server-set cookie. If a server sets a -cookie of the same name (or maybe you have imported one) then both are sent on -future transfers to that server, likely not what you intended. To address -these issues set a domain in Set-Cookie (doing that includes subdomains) or -much better: use the Netscape file format. - -Additionally, there are commands available that perform actions if you pass in -these exact strings: -.IP ALL -erases all cookies held in memory - -.IP SESS -erases all session cookies held in memory - -.IP FLUSH -writes all known cookies to the file specified by \fICURLOPT_COOKIEJAR(3)\fP - -.IP RELOAD -loads all cookies from the files specified by \fICURLOPT_COOKIEFILE(3)\fP - -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -/* an inline import of a cookie in Netscape format. */ - -#define SEP "\\t" /* Tab separates the fields */ - -int main(void) -{ - char *my_cookie = - "example.com" /* Hostname */ - SEP "FALSE" /* Include subdomains */ - SEP "/" /* Path */ - SEP "FALSE" /* Secure */ - SEP "0" /* Expiry in epoch time format. 0 == Session */ - SEP "foo" /* Name */ - SEP "bar"; /* Value */ - - CURL *curl = curl_easy_init(); - if(curl) { - /* my_cookie is imported immediately via CURLOPT_COOKIELIST. */ - curl_easy_setopt(curl, CURLOPT_COOKIELIST, my_cookie); - - /* The list of cookies in cookies.txt are not be imported until right - before a transfer is performed. Cookies in the list that have the same - hostname, path and name as in my_cookie are skipped. That is because - libcurl has already imported my_cookie and it's considered a "live" - cookie. A live cookie is not replaced by one read from a file. - */ - curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt"); /* import */ - - /* Cookies are exported after curl_easy_cleanup is called. The server - may have added, deleted or modified cookies by then. The cookies that - were skipped on import are not exported. - */ - curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt"); /* export */ - - curl_easy_perform(curl); /* cookies imported from cookies.txt */ - - curl_easy_cleanup(curl); /* cookies exported to cookies.txt */ - } -} -.fi -.SH "Cookie file format" -The cookie file format and general cookie concepts in curl are described -online here: https://curl.se/docs/http-cookies.html -.SH AVAILABILITY -\fBALL\fP was added in 7.14.1 - -\fBSESS\fP was added in 7.15.4 - -\fBFLUSH\fP was added in 7.17.1 - -\fBRELOAD\fP was added in 7.39.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_COOKIELIST (3), -.BR CURLOPT_COOKIE (3), -.BR CURLOPT_COOKIEFILE (3), -.BR CURLOPT_COOKIEJAR (3) diff --git a/docs/libcurl/opts/CURLOPT_COOKIELIST.md b/docs/libcurl/opts/CURLOPT_COOKIELIST.md new file mode 100644 index 000000000..4c17bd4bc --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COOKIELIST.md @@ -0,0 +1,136 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COOKIELIST +Section: 3 +Source: libcurl +See-also: + - CURLINFO_COOKIELIST (3) + - CURLOPT_COOKIE (3) + - CURLOPT_COOKIEFILE (3) + - CURLOPT_COOKIEJAR (3) +--- + +# NAME + +CURLOPT_COOKIELIST - add to or manipulate cookies held in memory + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIELIST, + char *cookie); +~~~ + +# DESCRIPTION + +Pass a char pointer to a *cookie* string. + +Such a cookie can be either a single line in Netscape / Mozilla format or just +regular HTTP-style header (Set-Cookie: ...) format. This option also enables +the cookie engine. This adds that single cookie to the internal cookie store. + +We strongly advice against loading cookies from an HTTP header file, as that +is an inferior data exchange format. + +Exercise caution if you are using this option and multiple transfers may +occur. If you use the Set-Cookie format and the string does not specify a +domain, then the cookie is sent for any domain (even after redirects are +followed) and cannot be modified by a server-set cookie. If a server sets a +cookie of the same name (or maybe you have imported one) then both are sent on +future transfers to that server, likely not what you intended. To address +these issues set a domain in Set-Cookie (doing that includes subdomains) or +much better: use the Netscape file format. + +Additionally, there are commands available that perform actions if you pass in +these exact strings: + +## ALL + +erases all cookies held in memory + +## SESS + +erases all session cookies held in memory + +## FLUSH + +writes all known cookies to the file specified by CURLOPT_COOKIEJAR(3) + +## RELOAD + +loads all cookies from the files specified by CURLOPT_COOKIEFILE(3) + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +/* an inline import of a cookie in Netscape format. */ + +#define SEP "\t" /* Tab separates the fields */ + +int main(void) +{ + char *my_cookie = + "example.com" /* Hostname */ + SEP "FALSE" /* Include subdomains */ + SEP "/" /* Path */ + SEP "FALSE" /* Secure */ + SEP "0" /* Expiry in epoch time format. 0 == Session */ + SEP "foo" /* Name */ + SEP "bar"; /* Value */ + + CURL *curl = curl_easy_init(); + if(curl) { + /* my_cookie is imported immediately via CURLOPT_COOKIELIST. */ + curl_easy_setopt(curl, CURLOPT_COOKIELIST, my_cookie); + + /* The list of cookies in cookies.txt are not be imported until right + before a transfer is performed. Cookies in the list that have the same + hostname, path and name as in my_cookie are skipped. That is because + libcurl has already imported my_cookie and it's considered a "live" + cookie. A live cookie is not replaced by one read from a file. + */ + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt"); /* import */ + + /* Cookies are exported after curl_easy_cleanup is called. The server + may have added, deleted or modified cookies by then. The cookies that + were skipped on import are not exported. + */ + curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt"); /* export */ + + curl_easy_perform(curl); /* cookies imported from cookies.txt */ + + curl_easy_cleanup(curl); /* cookies exported to cookies.txt */ + } +} +~~~ + +# Cookie file format + +The cookie file format and general cookie concepts in curl are described +online here: https://curl.se/docs/http-cookies.html + +# AVAILABILITY + +**ALL** was added in 7.14.1 + +**SESS** was added in 7.15.4 + +**FLUSH** was added in 7.17.1 + +**RELOAD** was added in 7.39.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_COOKIESESSION.3 b/docs/libcurl/opts/CURLOPT_COOKIESESSION.3 deleted file mode 100644 index b8894d0fe..000000000 --- a/docs/libcurl/opts/CURLOPT_COOKIESESSION.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COOKIESESSION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COOKIESESSION \- start a new cookie session -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init); -.fi -.SH DESCRIPTION -Pass a long set to 1 to mark this as a new cookie "session". It forces libcurl -to ignore all cookies it is about to load that are "session cookies" from the -previous session. By default, libcurl always loads all cookies, independent if -they are session cookies or not. Session cookies are cookies without expiry -date and they are meant to be alive and existing for this "session" only. - -A "session" is usually defined in browser land for as long as you have your -browser up, more or less. libcurl needs the application to use this option to -tell it when a new session starts, otherwise it assumes everything is still in -the same session. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* new "session", do not load session cookies */ - curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L); - - /* get the (non session) cookies from this file */ - curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_COOKIE (3), -.BR CURLOPT_COOKIEFILE (3), -.BR CURLOPT_COOKIEJAR (3) diff --git a/docs/libcurl/opts/CURLOPT_COOKIESESSION.md b/docs/libcurl/opts/CURLOPT_COOKIESESSION.md new file mode 100644 index 000000000..6f49f025c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COOKIESESSION.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COOKIESESSION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COOKIE (3) + - CURLOPT_COOKIEFILE (3) + - CURLOPT_COOKIEJAR (3) +--- + +# NAME + +CURLOPT_COOKIESESSION - start a new cookie session + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COOKIESESSION, long init); +~~~ + +# DESCRIPTION + +Pass a long set to 1 to mark this as a new cookie "session". It forces libcurl +to ignore all cookies it is about to load that are "session cookies" from the +previous session. By default, libcurl always loads all cookies, independent if +they are session cookies or not. Session cookies are cookies without expiry +date and they are meant to be alive and existing for this "session" only. + +A "session" is usually defined in browser land for as long as you have your +browser up, more or less. libcurl needs the application to use this option to +tell it when a new session starts, otherwise it assumes everything is still in +the same session. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* new "session", do not load session cookies */ + curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L); + + /* get the (non session) cookies from this file */ + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.3 b/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.3 deleted file mode 100644 index 447c66833..000000000 --- a/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_COPYPOSTFIELDS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_COPYPOSTFIELDS \- have libcurl copy data to POST -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COPYPOSTFIELDS, char *data); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be the full \fIdata\fP to post in a -HTTP POST operation. It behaves as the \fICURLOPT_POSTFIELDS(3)\fP option, but -the original data is instead copied by the library, allowing the application -to overwrite the original data after setting this option. - -Because data are copied, care must be taken when using this option in -conjunction with \fICURLOPT_POSTFIELDSIZE(3)\fP or -\fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP: If the size has not been set prior to -\fICURLOPT_COPYPOSTFIELDS(3)\fP, the data is assumed to be a null-terminated -string; else the stored size informs the library about the byte count to -copy. In any case, the size must not be changed after -\fICURLOPT_COPYPOSTFIELDS(3)\fP, unless another \fICURLOPT_POSTFIELDS(3)\fP or -\fICURLOPT_COPYPOSTFIELDS(3)\fP option is issued. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - char local_buffer[1024]="data to send"; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* size of the data to copy from the buffer and send in the request */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L); - - /* send data from the local stack */ - curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.17.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_POSTFIELDSIZE (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.md b/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.md new file mode 100644 index 000000000..911e08181 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_COPYPOSTFIELDS.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_COPYPOSTFIELDS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MIMEPOST (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_POSTFIELDSIZE (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_COPYPOSTFIELDS - have libcurl copy data to POST + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_COPYPOSTFIELDS, char *data); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be the full *data* to post in a +HTTP POST operation. It behaves as the CURLOPT_POSTFIELDS(3) option, but the +original data is instead copied by the library, allowing the application to +overwrite the original data after setting this option. + +Because data are copied, care must be taken when using this option in +conjunction with CURLOPT_POSTFIELDSIZE(3) or +CURLOPT_POSTFIELDSIZE_LARGE(3): If the size has not been set prior to +CURLOPT_COPYPOSTFIELDS(3), the data is assumed to be a null-terminated +string; else the stored size informs the library about the byte count to +copy. In any case, the size must not be changed after +CURLOPT_COPYPOSTFIELDS(3), unless another CURLOPT_POSTFIELDS(3) or +CURLOPT_COPYPOSTFIELDS(3) option is issued. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + char local_buffer[1024]="data to send"; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* size of the data to copy from the buffer and send in the request */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L); + + /* send data from the local stack */ + curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, local_buffer); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.17.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_CRLF.3 b/docs/libcurl/opts/CURLOPT_CRLF.3 deleted file mode 100644 index b758f2985..000000000 --- a/docs/libcurl/opts/CURLOPT_CRLF.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CRLF 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CRLF \- CRLF conversion -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CRLF, long conv); -.fi -.SH DESCRIPTION -Pass a long. If the value is set to 1 (one), libcurl converts Unix newlines to -CRLF newlines on transfers. Disable this option again by setting the value to -0 (zero). - -This is a legacy option of questionable use. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); - curl_easy_setopt(curl, CURLOPT_CRLF, 1L); - ret = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -SMTP since 7.40.0, other protocols since they were introduced -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CONV_FROM_NETWORK_FUNCTION (3), -.BR CURLOPT_CONV_TO_NETWORK_FUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_CRLF.md b/docs/libcurl/opts/CURLOPT_CRLF.md new file mode 100644 index 000000000..1766c3312 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CRLF.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CRLF +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONV_FROM_NETWORK_FUNCTION (3) + - CURLOPT_CONV_TO_NETWORK_FUNCTION (3) +--- + +# NAME + +CURLOPT_CRLF - CRLF conversion + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CRLF, long conv); +~~~ + +# DESCRIPTION + +Pass a long. If the value is set to 1 (one), libcurl converts Unix newlines to +CRLF newlines on transfers. Disable this option again by setting the value to +0 (zero). + +This is a legacy option of questionable use. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); + curl_easy_setopt(curl, CURLOPT_CRLF, 1L); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +SMTP since 7.40.0, other protocols since they were introduced + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_CRLFILE.3 b/docs/libcurl/opts/CURLOPT_CRLFILE.3 deleted file mode 100644 index 30a6ad1ad..000000000 --- a/docs/libcurl/opts/CURLOPT_CRLFILE.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CRLFILE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CRLFILE \- Certificate Revocation List file -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CRLFILE, char *file); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a \fIfile\fP with the -concatenation of CRL (in PEM format) to use in the certificate validation that -occurs during the SSL exchange. - -When curl is built to use GnuTLS, there is no way to influence the use of CRL -passed to help in the verification process. - -When libcurl is built with OpenSSL support, X509_V_FLAG_CRL_CHECK and -X509_V_FLAG_CRL_CHECK_ALL are both set, requiring CRL check against all the -elements of the certificate chain if a CRL file is passed. Also note that -\fICURLOPT_CRLFILE(3)\fP implies \fBCURLSSLOPT_NO_PARTIALCHAIN\fP (see -\fICURLOPT_SSL_OPTIONS(3)\fP) since curl 7.71.0 due to an OpenSSL bug. - -This option makes sense only when used in combination with the -\fICURLOPT_SSL_VERIFYPEER(3)\fP option. - -A specific error code (\fICURLE_SSL_CRL_BADFILE\fP) is defined with the -option. It is returned when the SSL exchange fails because the CRL file cannot -be loaded. A failure in certificate verification due to a revocation -information found in the CRL does not trigger this specific error. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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_CRLFILE, "/etc/certs/crl.pem"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_CRLFILE (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_CRLFILE.md b/docs/libcurl/opts/CURLOPT_CRLFILE.md new file mode 100644 index 000000000..b800f8ce3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CRLFILE.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CRLFILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_CRLFILE (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_CRLFILE - Certificate Revocation List file + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CRLFILE, char *file); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a *file* with the +concatenation of CRL (in PEM format) to use in the certificate validation that +occurs during the SSL exchange. + +When curl is built to use GnuTLS, there is no way to influence the use of CRL +passed to help in the verification process. + +When libcurl is built with OpenSSL support, X509_V_FLAG_CRL_CHECK and +X509_V_FLAG_CRL_CHECK_ALL are both set, requiring CRL check against all the +elements of the certificate chain if a CRL file is passed. Also note that +CURLOPT_CRLFILE(3) implies **CURLSSLOPT_NO_PARTIALCHAIN** (see +CURLOPT_SSL_OPTIONS(3)) since curl 7.71.0 due to an OpenSSL bug. + +This option makes sense only when used in combination with the +CURLOPT_SSL_VERIFYPEER(3) option. + +A specific error code (*CURLE_SSL_CRL_BADFILE*) is defined with the option. It +is returned when the SSL exchange fails because the CRL file cannot be +loaded. A failure in certificate verification due to a revocation information +found in the CRL does not trigger this specific error. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based 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_CRLFILE, "/etc/certs/crl.pem"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_CURLU.3 b/docs/libcurl/opts/CURLOPT_CURLU.3 deleted file mode 100644 index 34e9c53b4..000000000 --- a/docs/libcurl/opts/CURLOPT_CURLU.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CURLU 3 "28 Oct 2018" libcurl libcurl -.SH NAME -CURLOPT_CURLU \- URL in URL handle format -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CURLU, CURLU *pointer); -.fi -.SH DESCRIPTION -Pass in a pointer to the \fIURL\fP handle to work with. The parameter should -be a \fICURLU *\fP. Setting \fICURLOPT_CURLU(3)\fP explicitly overrides -\fICURLOPT_URL(3)\fP. - -\fICURLOPT_URL(3)\fP or \fICURLOPT_CURLU(3)\fP \fBmust\fP be set before a -transfer is started. - -libcurl uses this handle and its contents read-only and does not change its -contents. An application can update the contents of the URL handle after a -transfer is done and if the same handle is used in a subsequent request the -updated contents is used. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - CURLU *urlp = curl_url(); - if(curl) { - CURLcode res; - CURLUcode ret; - ret = curl_url_set(urlp, CURLUPART_URL, "https://example.com", 0); - - curl_easy_setopt(curl, CURLOPT_CURLU, urlp); - - res = curl_easy_perform(curl); - - curl_url_cleanup(urlp); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.63.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_url (3), -.BR curl_url_cleanup (3), -.BR curl_url_dup (3), -.BR curl_url_get (3), -.BR curl_url_set (3), -.BR curl_url_strerror (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_CURLU.md b/docs/libcurl/opts/CURLOPT_CURLU.md new file mode 100644 index 000000000..a3eeb5c9b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CURLU.md @@ -0,0 +1,79 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CURLU +Section: 3 +Source: libcurl +See-also: + - CURLOPT_URL (3) + - curl_url (3) + - curl_url_cleanup (3) + - curl_url_dup (3) + - curl_url_get (3) + - curl_url_set (3) + - curl_url_strerror (3) +--- + +# NAME + +CURLOPT_CURLU - URL in URL handle format + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CURLU, CURLU *pointer); +~~~ + +# DESCRIPTION + +Pass in a pointer to the *URL* handle to work with. The parameter should be a +*CURLU pointer*. Setting CURLOPT_CURLU(3) explicitly overrides +CURLOPT_URL(3). + +CURLOPT_URL(3) or CURLOPT_CURLU(3) **must** be set before a +transfer is started. + +libcurl uses this handle and its contents read-only and does not change its +contents. An application can update the contents of the URL handle after a +transfer is done and if the same handle is used in a subsequent request the +updated contents is used. + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + CURLU *urlp = curl_url(); + if(curl) { + CURLcode res; + CURLUcode ret; + ret = curl_url_set(urlp, CURLUPART_URL, "https://example.com", 0); + + curl_easy_setopt(curl, CURLOPT_CURLU, urlp); + + res = curl_easy_perform(curl); + + curl_url_cleanup(urlp); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.63.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.3 b/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.3 deleted file mode 100644 index 6a1f0eeeb..000000000 --- a/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_CUSTOMREQUEST 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_CUSTOMREQUEST \- custom request method -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *method); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. - -When you change the request \fImethod\fP by setting -\fICURLOPT_CUSTOMREQUEST(3)\fP to something, you do not actually change how -libcurl behaves or acts in regards to the particular request method, it only -changes the actual string sent in the request. - -libcurl passes on the verbatim string in its request without any filter or -other safe guards. That includes white space and control characters. - -Restore to the internal default by setting this to NULL. - -This option can be used to specify the request: -.IP HTTP -Instead of GET or HEAD when performing HTTP based requests. This is -particularly useful, for example, for performing an HTTP DELETE request. - -For example: - -When you tell libcurl to do a HEAD request, but then specify a GET though a -custom request libcurl still acts as if it sent a HEAD. To switch to a proper -HEAD use \fICURLOPT_NOBODY(3)\fP, to switch to a proper POST use -\fICURLOPT_POST(3)\fP or \fICURLOPT_POSTFIELDS(3)\fP and to switch to a proper -GET use \fICURLOPT_HTTPGET(3)\fP. - -Many people have wrongly used this option to replace the entire request with -their own, including multiple headers and POST contents. While that might work -in many cases, it might cause libcurl to send invalid requests and it could -possibly confuse the remote server badly. Use \fICURLOPT_POST(3)\fP and -\fICURLOPT_POSTFIELDS(3)\fP to set POST data. Use \fICURLOPT_HTTPHEADER(3)\fP -to replace or extend the set of headers sent by libcurl. Use -\fICURLOPT_HTTP_VERSION(3)\fP to change HTTP version. - -.IP FTP -Instead of LIST and NLST when performing FTP directory listings. -.IP IMAP -Instead of LIST when issuing IMAP based requests. -.IP POP3 -Instead of LIST and RETR when issuing POP3 based requests. - -For example: - -When you tell libcurl to use a custom request it behaves like a LIST or RETR -command was sent where it expects data to be returned by the server. As such -\fICURLOPT_NOBODY(3)\fP should be used when specifying commands such as -\fBDELE\fP and \fBNOOP\fP for example. -.IP SMTP -Instead of a \fBHELP\fP or \fBVRFY\fP when issuing SMTP based requests. - -For example: - -Normally a multi line response is returned which can be used, in conjunction -with \fICURLOPT_MAIL_RCPT(3)\fP, to specify an EXPN request. If the -\fICURLOPT_NOBODY(3)\fP option is specified then the request can be used to -issue \fBNOOP\fP and \fBRSET\fP commands. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP, FTP, IMAP, POP3 and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* DELETE the given path */ - curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -IMAP is supported since 7.30.0, POP3 since 7.26.0 and SMTP since 7.34.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_EFFECTIVE_METHOD (3), -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_NOBODY (3), -.BR CURLOPT_REQUEST_TARGET (3) diff --git a/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.md b/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.md new file mode 100644 index 000000000..c4d4ec210 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_CUSTOMREQUEST.md @@ -0,0 +1,130 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_CUSTOMREQUEST +Section: 3 +Source: libcurl +See-also: + - CURLINFO_EFFECTIVE_METHOD (3) + - CURLOPT_HTTPHEADER (3) + - CURLOPT_NOBODY (3) + - CURLOPT_REQUEST_TARGET (3) +--- + +# NAME + +CURLOPT_CUSTOMREQUEST - custom request method + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *method); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. + +When changing the request *method* by setting CURLOPT_CUSTOMREQUEST(3), you +do not actually change how libcurl behaves or acts: you only change the actual +string sent in the request. + +libcurl passes on the verbatim string in its request without any filter or +other safe guards. That includes white space and control characters. + +Restore to the internal default by setting this to NULL. + +This option can be used to specify the request: + +## HTTP + +Instead of GET or HEAD when performing HTTP based requests. This is +particularly useful, for example, for performing an HTTP DELETE request. + +For example: + +When you tell libcurl to do a HEAD request, but then specify a GET though a +custom request libcurl still acts as if it sent a HEAD. To switch to a proper +HEAD use CURLOPT_NOBODY(3), to switch to a proper POST use +CURLOPT_POST(3) or CURLOPT_POSTFIELDS(3) and to switch to a proper +GET use CURLOPT_HTTPGET(3). + +Many people have wrongly used this option to replace the entire request with +their own, including multiple headers and POST contents. While that might work +in many cases, it might cause libcurl to send invalid requests and it could +possibly confuse the remote server badly. Use CURLOPT_POST(3) and +CURLOPT_POSTFIELDS(3) to set POST data. Use CURLOPT_HTTPHEADER(3) +to replace or extend the set of headers sent by libcurl. Use +CURLOPT_HTTP_VERSION(3) to change HTTP version. + +## FTP + +Instead of LIST and NLST when performing FTP directory listings. + +## IMAP + +Instead of LIST when issuing IMAP based requests. + +## POP3 + +Instead of LIST and RETR when issuing POP3 based requests. + +For example: + +When you tell libcurl to use a custom request it behaves like a LIST or RETR +command was sent where it expects data to be returned by the server. As such +CURLOPT_NOBODY(3) should be used when specifying commands such as +**DELE** and **NOOP** for example. + +## SMTP + +Instead of a **HELP** or **VRFY** when issuing SMTP based requests. + +For example: + +Normally a multi line response is returned which can be used, in conjunction +with CURLOPT_MAIL_RCPT(3), to specify an EXPN request. If the +CURLOPT_NOBODY(3) option is specified then the request can be used to +issue **NOOP** and **RSET** commands. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP, FTP, IMAP, POP3 and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* DELETE the given path */ + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +IMAP is supported since 7.30.0, POP3 since 7.26.0 and SMTP since 7.34.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_DEBUGDATA.3 b/docs/libcurl/opts/CURLOPT_DEBUGDATA.3 deleted file mode 100644 index 1b569e983..000000000 --- a/docs/libcurl/opts/CURLOPT_DEBUGDATA.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DEBUGDATA 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DEBUGDATA \- pointer passed to the debug callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP to whatever you want passed in to your -\fICURLOPT_DEBUGFUNCTION(3)\fP in the last void * argument. This pointer is -not used by libcurl, it is only passed to the callback. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct data { - void *custom; -}; - -static int my_trace(CURL *handle, curl_infotype type, - char *data, size_t size, - void *clientp) -{ - struct data *mine = clientp; - printf("our ptr: %p\\n", mine->custom); - - /* output debug info */ -} - -int main(void) -{ - CURL *curl; - CURLcode res; - struct data my_tracedata; - - curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); - - curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &my_tracedata); - - /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - res = curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } - return 0; -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_DEBUGDATA.md b/docs/libcurl/opts/CURLOPT_DEBUGDATA.md new file mode 100644 index 000000000..cac58d99d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DEBUGDATA.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DEBUGDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_DEBUGDATA - pointer passed to the debug callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* to whatever you want passed in to your +CURLOPT_DEBUGFUNCTION(3) in the last void * argument. This pointer is +not used by libcurl, it is only passed to the callback. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct data { + void *custom; +}; + +static int my_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *clientp) +{ + struct data *mine = clientp; + printf("our ptr: %p\n", mine->custom); + + /* output debug info */ +} + +int main(void) +{ + CURL *curl; + CURLcode res; + struct data my_tracedata; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + + curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &my_tracedata); + + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.3 b/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.3 deleted file mode 100644 index 78c9e76a3..000000000 --- a/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.3 +++ /dev/null @@ -1,205 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DEBUGFUNCTION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DEBUGFUNCTION \- debug callback -.SH SYNOPSIS -.nf -#include - -typedef enum { - CURLINFO_TEXT = 0, - CURLINFO_HEADER_IN, /* 1 */ - CURLINFO_HEADER_OUT, /* 2 */ - CURLINFO_DATA_IN, /* 3 */ - CURLINFO_DATA_OUT, /* 4 */ - CURLINFO_SSL_DATA_IN, /* 5 */ - CURLINFO_SSL_DATA_OUT, /* 6 */ - CURLINFO_END -} curl_infotype; - -int debug_callback(CURL *handle, - curl_infotype type, - char *data, - size_t size, - void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGFUNCTION, - debug_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -\fICURLOPT_DEBUGFUNCTION(3)\fP replaces the standard debug function used when -\fICURLOPT_VERBOSE(3)\fP is in effect. This callback receives debug -information, as specified in the \fItype\fP argument. This function must -return 0. The \fIdata\fP pointed to by the char * passed to this function is -not null-terminated, but is exactly of the \fIsize\fP as told by the -\fIsize\fP argument. - -The \fIclientp\fP argument is the pointer set with \fICURLOPT_DEBUGDATA(3)\fP. - -Available \fBcurl_infotype\fP values: -.RS -.IP CURLINFO_TEXT -The data is informational text. -.IP CURLINFO_HEADER_IN -The data is header (or header-like) data received from the peer. -.IP CURLINFO_HEADER_OUT -The data is header (or header-like) data sent to the peer. -.IP CURLINFO_DATA_IN -The data is the unprocessed protocol data received from the peer. Even if the -data is encoded or compressed, it is not not provided decoded nor decompressed -to this callback. If you need the data in decoded and decompressed form, use -\fICURLOPT_WRITEFUNCTION(3)\fP. -.IP CURLINFO_DATA_OUT -The data is protocol data sent to the peer. -.IP CURLINFO_SSL_DATA_OUT -The data is SSL/TLS (binary) data sent to the peer. -.IP CURLINFO_SSL_DATA_IN -The data is SSL/TLS (binary) data received from the peer. -.RE - -WARNING: This callback may be called with the curl \fIhandle\fP set to an -internal handle. (Added in 8.4.0) - -If you need to distinguish your curl \fIhandle\fP from internal handles then -set \fICURLOPT_PRIVATE(3)\fP on your handle. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -static -void dump(const char *text, - FILE *stream, unsigned char *ptr, size_t size) -{ - size_t i; - size_t c; - unsigned int width = 0x10; - - fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\\n", - text, (long)size, (long)size); - - for(i = 0; i < size; i += width) { - fprintf(stream, "%4.4lx: ", (long)i); - - /* show hex to the left */ - for(c = 0; c < width; c++) { - if(i + c < size) - fprintf(stream, "%02x ", ptr[i + c]); - else - fputs(" ", stream); - } - - /* show data on the right */ - for(c = 0; (c < width) && (i + c < size); c++) { - char x = (ptr[i + c] >= 0x20 && ptr[i + c] < 0x80) ? ptr[i + c] : '.'; - fputc(x, stream); - } - - fputc('\\n', stream); /* newline */ - } -} - -static -int my_trace(CURL *handle, curl_infotype type, - char *data, size_t size, - void *clientp) -{ - const char *text; - (void)handle; /* prevent compiler warning */ - (void)clientp; - - switch(type) { - case CURLINFO_TEXT: - fputs("== Info: ", stderr); - fwrite(data, size, 1, stderr); - default: /* in case a new one is introduced to shock us */ - return 0; - - case CURLINFO_HEADER_OUT: - text = "=> Send header"; - break; - case CURLINFO_DATA_OUT: - text = "=> Send data"; - break; - case CURLINFO_SSL_DATA_OUT: - text = "=> Send SSL data"; - break; - case CURLINFO_HEADER_IN: - text = "<= Recv header"; - break; - case CURLINFO_DATA_IN: - text = "<= Recv data"; - break; - case CURLINFO_SSL_DATA_IN: - text = "<= Recv SSL data"; - break; - } - - dump(text, stderr, (unsigned char *)data, size); - return 0; -} - -int main(void) -{ - CURL *curl; - CURLcode res; - - curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); - - /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - - /* example.com is redirected, so we tell libcurl to follow redirection */ - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - res = curl_easy_perform(curl); - /* Check for errors */ - if(res != CURLE_OK) - fprintf(stderr, "curl_easy_perform() failed: %s\\n", - curl_easy_strerror(res)); - - /* always cleanup */ - curl_easy_cleanup(curl); - } - return 0; -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR curl_global_trace (3), -.BR CURLINFO_CONN_ID (3), -.BR CURLINFO_XFER_ID (3), -.BR CURLOPT_DEBUGDATA (3), -.BR CURLOPT_VERBOSE (3) diff --git a/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.md b/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.md new file mode 100644 index 000000000..1acf963ca --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DEBUGFUNCTION.md @@ -0,0 +1,216 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DEBUGFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CONN_ID (3) + - CURLINFO_XFER_ID (3) + - CURLOPT_DEBUGDATA (3) + - CURLOPT_VERBOSE (3) + - curl_global_trace (3) +--- + +# NAME + +CURLOPT_DEBUGFUNCTION - debug callback + +# SYNOPSIS + +~~~c +#include + +typedef enum { + CURLINFO_TEXT = 0, + CURLINFO_HEADER_IN, /* 1 */ + CURLINFO_HEADER_OUT, /* 2 */ + CURLINFO_DATA_IN, /* 3 */ + CURLINFO_DATA_OUT, /* 4 */ + CURLINFO_SSL_DATA_IN, /* 5 */ + CURLINFO_SSL_DATA_OUT, /* 6 */ + CURLINFO_END +} curl_infotype; + +int debug_callback(CURL *handle, + curl_infotype type, + char *data, + size_t size, + void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEBUGFUNCTION, + debug_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +CURLOPT_DEBUGFUNCTION(3) replaces the standard debug function used when +CURLOPT_VERBOSE(3) is in effect. This callback receives debug +information, as specified in the *type* argument. This function must +return 0. The *data* pointed to by the char * passed to this function is +not null-terminated, but is exactly of the *size* as told by the +*size* argument. + +The *clientp* argument is the pointer set with CURLOPT_DEBUGDATA(3). + +Available **curl_infotype** values: + +## CURLINFO_TEXT + +The data is informational text. + +## CURLINFO_HEADER_IN + +The data is header (or header-like) data received from the peer. + +## CURLINFO_HEADER_OUT + +The data is header (or header-like) data sent to the peer. + +## CURLINFO_DATA_IN + +The data is the unprocessed protocol data received from the peer. Even if the +data is encoded or compressed, it is not not provided decoded nor decompressed +to this callback. If you need the data in decoded and decompressed form, use +CURLOPT_WRITEFUNCTION(3). + +## CURLINFO_DATA_OUT + +The data is protocol data sent to the peer. + +## CURLINFO_SSL_DATA_OUT + +The data is SSL/TLS (binary) data sent to the peer. + +## CURLINFO_SSL_DATA_IN + +The data is SSL/TLS (binary) data received from the peer. + +WARNING: This callback may be called with the curl *handle* set to an +internal handle. (Added in 8.4.0) + +If you need to distinguish your curl *handle* from internal handles then +set CURLOPT_PRIVATE(3) on your handle. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +static +void dump(const char *text, + FILE *stream, unsigned char *ptr, size_t size) +{ + size_t i; + size_t c; + unsigned int width = 0x10; + + fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n", + text, (long)size, (long)size); + + for(i = 0; i < size; i += width) { + fprintf(stream, "%4.4lx: ", (long)i); + + /* show hex to the left */ + for(c = 0; c < width; c++) { + if(i + c < size) + fprintf(stream, "%02x ", ptr[i + c]); + else + fputs(" ", stream); + } + + /* show data on the right */ + for(c = 0; (c < width) && (i + c < size); c++) { + char x = (ptr[i + c] >= 0x20 && ptr[i + c] < 0x80) ? ptr[i + c] : '.'; + fputc(x, stream); + } + + fputc('\n', stream); /* newline */ + } +} + +static +int my_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *clientp) +{ + const char *text; + (void)handle; /* prevent compiler warning */ + (void)clientp; + + switch(type) { + case CURLINFO_TEXT: + fputs("== Info: ", stderr); + fwrite(data, size, 1, stderr); + default: /* in case a new one is introduced to shock us */ + return 0; + + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "=> Send SSL data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "<= Recv SSL data"; + break; + } + + dump(text, stderr, (unsigned char *)data, size); + return 0; +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* example.com is redirected, so we tell libcurl to follow redirection */ + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.3 b/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.3 deleted file mode 100644 index ef7b24e96..000000000 --- a/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DEFAULT_PROTOCOL 3 "18 Aug 2015" libcurl libcurl -.SH NAME -CURLOPT_DEFAULT_PROTOCOL \- default protocol to use if the URL is missing a -scheme name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEFAULT_PROTOCOL, - char *protocol); -.fi -.SH DESCRIPTION -This option tells libcurl to use \fIprotocol\fP if the URL is missing a scheme -name. - -Use one of these protocol (scheme) names: - -dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, -pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp - -An unknown or unsupported protocol causes error -\fICURLE_UNSUPPORTED_PROTOCOL\fP when libcurl parses a URL without a -scheme. Parsing happens when \fIcurl_easy_perform(3)\fP or -\fIcurl_multi_perform(3)\fP is called. The protocol set supported by libcurl -vary depending on how it was built. Use \fIcurl_version_info(3)\fP if you need -a list of protocol names supported by the build of libcurl that you are using. - -This option does not change the default proxy protocol (http). - -Without this option libcurl would make a guess based on the host, see -\fICURLOPT_URL(3)\fP for details. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL (make a guess based on the host) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* set a URL without a scheme */ - curl_easy_setopt(curl, CURLOPT_URL, "example.com"); - - /* set the default protocol (scheme) for schemeless URLs */ - curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.45.0 -.SH RETURN VALUE -CURLE_OK if the option is supported. - -CURLE_OUT_OF_MEMORY if there was insufficient heap space. - -CURLE_UNKNOWN_OPTION if the option is not supported. -.SH "SEE ALSO" -.BR CURLINFO_PROTOCOL (3), -.BR CURLINFO_SCHEME (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.md b/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.md new file mode 100644 index 000000000..88468f718 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DEFAULT_PROTOCOL.md @@ -0,0 +1,89 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DEFAULT_PROTOCOL +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PROTOCOL (3) + - CURLINFO_SCHEME (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_DEFAULT_PROTOCOL - default protocol to use if the URL is missing a +scheme name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DEFAULT_PROTOCOL, + char *protocol); +~~~ + +# DESCRIPTION + +This option tells libcurl to use *protocol* if the URL is missing a scheme +name. + +Use one of these protocol (scheme) names: + +dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, +pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp + +An unknown or unsupported protocol causes error +*CURLE_UNSUPPORTED_PROTOCOL* when libcurl parses a URL without a +scheme. Parsing happens when curl_easy_perform(3) or +curl_multi_perform(3) is called. The protocol set supported by libcurl +vary depending on how it was built. Use curl_version_info(3) if you need +a list of protocol names supported by the build of libcurl that you are using. + +This option does not change the default proxy protocol (http). + +Without this option libcurl would make a guess based on the host, see +CURLOPT_URL(3) for details. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL (make a guess based on the host) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* set a URL without a scheme */ + curl_easy_setopt(curl, CURLOPT_URL, "example.com"); + + /* set the default protocol (scheme) for schemeless URLs */ + curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.45.0 + +# RETURN VALUE + +CURLE_OK if the option is supported. + +CURLE_OUT_OF_MEMORY if there was insufficient heap space. + +CURLE_UNKNOWN_OPTION if the option is not supported. diff --git a/docs/libcurl/opts/CURLOPT_DIRLISTONLY.3 b/docs/libcurl/opts/CURLOPT_DIRLISTONLY.3 deleted file mode 100644 index 62dac240c..000000000 --- a/docs/libcurl/opts/CURLOPT_DIRLISTONLY.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DIRLISTONLY 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DIRLISTONLY \- ask for names only in a directory listing -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DIRLISTONLY, long listonly); -.fi -.SH DESCRIPTION -For FTP and SFTP based URLs a parameter set to 1 tells the library to list the -names of files in a directory, rather than performing a full directory listing -that would normally include file sizes, dates etc. - -For POP3 a parameter of 1 tells the library to list the email message or -messages on the POP3 server. This can be used to change the default behavior -of libcurl, when combined with a URL that contains a message ID, to perform a -"scan listing" which can then be used to determine the size of an email. - -Note: For FTP this causes a NLST command to be sent to the FTP server. Beware -that some FTP servers list only files in their response to NLST; they might not -include subdirectories and symbolic links. - -Setting this option to 1 also implies a directory listing even if the URL -does not end with a slash, which otherwise is necessary. - -Do not use this option if you also use \fICURLOPT_WILDCARDMATCH(3)\fP as it -effectively breaks that feature. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -FTP, SFTP and POP3 -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/"); - - /* list only */ - curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option was known as CURLOPT_FTPLISTONLY up to 7.16.4. POP3 is supported -since 7.21.5. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_DIRLISTONLY.md b/docs/libcurl/opts/CURLOPT_DIRLISTONLY.md new file mode 100644 index 000000000..29635622c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DIRLISTONLY.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DIRLISTONLY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CUSTOMREQUEST (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_DIRLISTONLY - ask for names only in a directory listing + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DIRLISTONLY, long listonly); +~~~ + +# DESCRIPTION + +For FTP and SFTP based URLs a parameter set to 1 tells the library to list the +names of files in a directory, rather than performing a full directory listing +that would normally include file sizes, dates etc. + +For POP3 a parameter of 1 tells the library to list the email message or +messages on the POP3 server. This can be used to change the default behavior +of libcurl, when combined with a URL that contains a message ID, to perform a +"scan listing" which can then be used to determine the size of an email. + +Note: For FTP this causes a NLST command to be sent to the FTP server. Beware +that some FTP servers list only files in their response to NLST; they might +not include subdirectories and symbolic links. + +Setting this option to 1 also implies a directory listing even if the URL +does not end with a slash, which otherwise is necessary. + +Do not use this option if you also use CURLOPT_WILDCARDMATCH(3) as it +effectively breaks that feature. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +FTP, SFTP and POP3 + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/"); + + /* list only */ + curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option was known as CURLOPT_FTPLISTONLY up to 7.16.4. POP3 is supported +since 7.21.5. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.3 b/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.3 deleted file mode 100644 index 077fbd8db..000000000 --- a/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DISALLOW_USERNAME_IN_URL 3 "30 May 2018" libcurl libcurl -.SH NAME -CURLOPT_DISALLOW_USERNAME_IN_URL \- disallow specifying username in the URL -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DISALLOW_USERNAME_IN_URL, - long disallow); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to not allow URLs that include a -username. - -This is the equivalent to the \fICURLU_DISALLOW_USER\fP flag for the -\fIcurl_url_set(3)\fP function. -.SH DEFAULT -0 (disabled) - user names are allowed by default. -.SH PROTOCOLS -Several -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_DISALLOW_USERNAME_IN_URL, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. - -\fIcurl_easy_perform(3)\fP returns CURLE_LOGIN_DENIED if this option is -enabled and a URL containing a username is specified. -.SH "SEE ALSO" -.BR curl_url_set (3), -.BR CURLOPT_PROTOCOLS (3), -.BR CURLOPT_URL (3), -.BR libcurl-security (3) diff --git a/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.md b/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.md new file mode 100644 index 000000000..ddaaace89 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DISALLOW_USERNAME_IN_URL.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DISALLOW_USERNAME_IN_URL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROTOCOLS (3) + - CURLOPT_URL (3) + - curl_url_set (3) + - libcurl-security (3) +--- + +# NAME + +CURLOPT_DISALLOW_USERNAME_IN_URL - disallow specifying username in the URL + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DISALLOW_USERNAME_IN_URL, + long disallow); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to not allow URLs that include a +username. + +This is the equivalent to the *CURLU_DISALLOW_USER* flag for the +curl_url_set(3) function. + +# DEFAULT + +0 (disabled) - user names are allowed by default. + +# PROTOCOLS + +Several + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_DISALLOW_USERNAME_IN_URL, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.61.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. + +curl_easy_perform(3) returns CURLE_LOGIN_DENIED if this option is +enabled and a URL containing a username is specified. diff --git a/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.3 b/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.3 deleted file mode 100644 index 2cdb3967a..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_CACHE_TIMEOUT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_CACHE_TIMEOUT \- life-time for DNS cache entries -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_CACHE_TIMEOUT, long age); -.fi -.SH DESCRIPTION -Pass a long, this sets the timeout in seconds. Name resolve results are kept -in memory and used for this number of seconds. Set to zero to completely -disable caching, or set to -1 to make the cached entries remain forever. By -default, libcurl caches this info for 60 seconds. - -We recommend users not to tamper with this option unless strictly necessary. -If you do, be careful of using large values that can make the cache size grow -significantly if many different host names are used within that timeout -period. - -The name resolve functions of various libc implementations do not re-read name -server information unless explicitly told so (for example, by calling -\fIres_init(3)\fP). This may cause libcurl to keep using the older server even -if DHCP has updated the server info, and this may look like a DNS cache issue -to the casual libcurl-app user. - -DNS entries have a "TTL" property but libcurl does not use that. This DNS -cache timeout is entirely speculative that a name resolves to the same address -for a small amount of time into the future. - -Since version 8.1.0, libcurl prunes entries from the DNS cache if it exceeds -30,000 entries no matter which timeout value is used. -.SH DEFAULT -60 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* only reuse addresses for a short time */ - curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 2L); - - res = curl_easy_perform(curl); - - /* in this second request, the cache is not be used if more than - two seconds have passed since the previous name resolve */ - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT_MS (3), -.BR CURLOPT_DNS_SERVERS (3), -.BR CURLOPT_DNS_USE_GLOBAL_CACHE (3), -.BR CURLOPT_MAXAGE_CONN (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.md b/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.md new file mode 100644 index 000000000..0199f525a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_CACHE_TIMEOUT.md @@ -0,0 +1,90 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_CACHE_TIMEOUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT_MS (3) + - CURLOPT_DNS_SERVERS (3) + - CURLOPT_DNS_USE_GLOBAL_CACHE (3) + - CURLOPT_MAXAGE_CONN (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_DNS_CACHE_TIMEOUT - life-time for DNS cache entries + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_CACHE_TIMEOUT, long age); +~~~ + +# DESCRIPTION + +Pass a long, this sets the timeout in seconds. Name resolve results are kept +in memory and used for this number of seconds. Set to zero to completely +disable caching, or set to -1 to make the cached entries remain forever. By +default, libcurl caches this info for 60 seconds. + +We recommend users not to tamper with this option unless strictly necessary. +If you do, be careful of using large values that can make the cache size grow +significantly if many different host names are used within that timeout +period. + +The name resolve functions of various libc implementations do not re-read name +server information unless explicitly told so (for example, by calling +*res_init(3)*). This may cause libcurl to keep using the older server even +if DHCP has updated the server info, and this may look like a DNS cache issue +to the casual libcurl-app user. + +DNS entries have a "TTL" property but libcurl does not use that. This DNS +cache timeout is entirely speculative that a name resolves to the same address +for a small amount of time into the future. + +Since version 8.1.0, libcurl prunes entries from the DNS cache if it exceeds +30,000 entries no matter which timeout value is used. + +# DEFAULT + +60 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* only reuse addresses for a short time */ + curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, 2L); + + res = curl_easy_perform(curl); + + /* in this second request, the cache is not be used if more than + two seconds have passed since the previous name resolve */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.3 b/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.3 deleted file mode 100644 index dfeabb386..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_INTERFACE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_INTERFACE \- interface to speak DNS over -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_INTERFACE, char *ifname); -.fi -.SH DESCRIPTION -Pass a char * as parameter. Set the name of the network interface that the DNS -resolver should bind to. This must be an interface name (not an address). Set -this option to NULL to use the default setting (do not bind to a specific -interface). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All protocols except file:// - protocols that resolve host names. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_DNS_INTERFACE, "eth0"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.33.0. This option also requires that libcurl was built with a -resolver backend that supports this operation. The c-ares backend is the only -such one. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, -or CURLE_NOT_BUILT_IN if support was disabled at compile-time. -.SH "SEE ALSO" -.BR CURLOPT_DNS_LOCAL_IP4 (3), -.BR CURLOPT_DNS_LOCAL_IP6 (3), -.BR CURLOPT_DNS_SERVERS (3), -.BR CURLOPT_INTERFACE (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.md b/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.md new file mode 100644 index 000000000..070bdc5af --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_INTERFACE.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_INTERFACE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_LOCAL_IP4 (3) + - CURLOPT_DNS_LOCAL_IP6 (3) + - CURLOPT_DNS_SERVERS (3) + - CURLOPT_INTERFACE (3) +--- + +# NAME + +CURLOPT_DNS_INTERFACE - interface to speak DNS over + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_INTERFACE, char *ifname); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter. Set the name of the network interface that +the DNS resolver should bind to. This must be an interface name (not an +address). Set this option to NULL to use the default setting (do not bind to a +specific interface). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All protocols except file:// - protocols that resolve host names. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_DNS_INTERFACE, "eth0"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.33.0. This option also requires that libcurl was built with a +resolver backend that supports this operation. The c-ares backend is the only +such one. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, +or CURLE_NOT_BUILT_IN if support was disabled at compile-time. diff --git a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.3 b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.3 deleted file mode 100644 index 6f8ad2cf8..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_LOCAL_IP4 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_LOCAL_IP4 \- IPv4 address to bind DNS resolves to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP4, char *address); -.fi -.SH DESCRIPTION -Set the local IPv4 \fIaddress\fP that the resolver should bind to. The -argument should be of type char * and contain a single numerical IPv4 address -as a string. Set this option to NULL to use the default setting (do not bind -to a specific IP address). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.14"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option requires that libcurl was built with a resolver backend that -supports this operation. The c-ares backend is the only such one. - -Added in 7.33.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, -CURLE_NOT_BUILT_IN if support was disabled at compile-time, or -CURLE_BAD_FUNCTION_ARGUMENT when given a bad address. -.SH "SEE ALSO" -.BR CURLOPT_DNS_INTERFACE (3), -.BR CURLOPT_DNS_LOCAL_IP6 (3), -.BR CURLOPT_DNS_SERVERS (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.md b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.md new file mode 100644 index 000000000..69af83b6b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP4.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_LOCAL_IP4 +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_INTERFACE (3) + - CURLOPT_DNS_LOCAL_IP6 (3) + - CURLOPT_DNS_SERVERS (3) +--- + +# NAME + +CURLOPT_DNS_LOCAL_IP4 - IPv4 address to bind DNS resolves to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP4, char *address); +~~~ + +# DESCRIPTION + +Set the local IPv4 *address* that the resolver should bind to. The argument +should be of type char * and contain a single numerical IPv4 address as a +string. Set this option to NULL to use the default setting (do not bind to a +specific IP address). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP4, "192.168.0.14"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option requires that libcurl was built with a resolver backend that +supports this operation. The c-ares backend is the only such one. + +Added in 7.33.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, +CURLE_NOT_BUILT_IN if support was disabled at compile-time, or +CURLE_BAD_FUNCTION_ARGUMENT when given a bad address. diff --git a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.3 b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.3 deleted file mode 100644 index 78ffbf95b..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_LOCAL_IP6 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_LOCAL_IP6 \- IPv6 address to bind DNS resolves to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP6, char *address); -.fi -.SH DESCRIPTION -Set the local IPv6 \fIaddress\fP that the resolver should bind to. The -argument should be of type char * and contain a single IPv6 address as a -string. Set this option to NULL to use the default setting (do not bind to a -specific IP address). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP6, "fe80::a9ff:fe46:b619"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option requires that libcurl was built with a resolver backend that -supports this operation. The c-ares backend is the only such one. - -Added in 7.33.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, -CURLE_NOT_BUILT_IN if support was disabled at compile-time, or -CURLE_BAD_FUNCTION_ARGUMENT when given a bad address. -.SH "SEE ALSO" -.BR CURLOPT_DNS_INTERFACE (3), -.BR CURLOPT_DNS_LOCAL_IP4 (3), -.BR CURLOPT_DNS_SERVERS (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.md b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.md new file mode 100644 index 000000000..fb04ee899 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_LOCAL_IP6.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_LOCAL_IP6 +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_INTERFACE (3) + - CURLOPT_DNS_LOCAL_IP4 (3) + - CURLOPT_DNS_SERVERS (3) +--- + +# NAME + +CURLOPT_DNS_LOCAL_IP6 - IPv6 address to bind DNS resolves to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_LOCAL_IP6, char *address); +~~~ + +# DESCRIPTION + +Set the local IPv6 *address* that the resolver should bind to. The argument +should be of type char * and contain a single IPv6 address as a string. Set +this option to NULL to use the default setting (do not bind to a specific IP +address). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_DNS_LOCAL_IP6, "fe80::a9ff:fe46:b619"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option requires that libcurl was built with a resolver backend that +supports this operation. The c-ares backend is the only such one. + +Added in 7.33.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, +CURLE_NOT_BUILT_IN if support was disabled at compile-time, or +CURLE_BAD_FUNCTION_ARGUMENT when given a bad address. diff --git a/docs/libcurl/opts/CURLOPT_DNS_SERVERS.3 b/docs/libcurl/opts/CURLOPT_DNS_SERVERS.3 deleted file mode 100644 index c8e160a7d..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_SERVERS.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_SERVERS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_SERVERS \- DNS servers to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char *servers); -.fi -.SH DESCRIPTION -Pass a char * that is the list of DNS servers to be used instead of the system -default. The format of the dns servers option is: - -host[:port][,host[:port]]... - -For example: - -192.168.1.100,192.168.1.101,3.4.5.6 - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL - use system default -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, - "192.168.1.100:53,192.168.1.101"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option requires that libcurl was built with a resolver backend that -supports this operation. The c-ares backend is the only such one. - -Added in 7.24.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, -CURLE_NOT_BUILT_IN if support was disabled at compile-time, -CURLE_BAD_FUNCTION_ARGUMENT when given an invalid server list, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_DNS_LOCAL_IP4 (3), -.BR CURLOPT_DNS_LOCAL_IP6 (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_SERVERS.md b/docs/libcurl/opts/CURLOPT_DNS_SERVERS.md new file mode 100644 index 000000000..998257c79 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_SERVERS.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_SERVERS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_DNS_LOCAL_IP4 (3) + - CURLOPT_DNS_LOCAL_IP6 (3) +--- + +# NAME + +CURLOPT_DNS_SERVERS - DNS servers to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SERVERS, char *servers); +~~~ + +# DESCRIPTION + +Pass a char pointer that is the list of DNS servers to be used instead of the +system default. The format of the dns servers option is: + +host[:port][,host[:port]]... + +For example: + +192.168.1.100,192.168.1.101,3.4.5.6 + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL - use system default + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, + "192.168.1.100:53,192.168.1.101"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option requires that libcurl was built with a resolver backend that +supports this operation. The c-ares backend is the only such one. + +Added in 7.24.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, +CURLE_NOT_BUILT_IN if support was disabled at compile-time, +CURLE_BAD_FUNCTION_ARGUMENT when given an invalid server list, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.3 b/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.3 deleted file mode 100644 index cc6934d1d..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_SHUFFLE_ADDRESSES 3 "3 March 2018" libcurl libcurl -.SH NAME -CURLOPT_DNS_SHUFFLE_ADDRESSES \- shuffle IP addresses for hostname -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SHUFFLE_ADDRESSES, long onoff); -.fi -.SH DESCRIPTION -Pass a long set to 1 to enable this option. - -When a name is resolved and more than one IP address is returned, this -function shuffles the order of all returned addresses so that they are used in -a random order. This is similar to the ordering behavior of the legacy -gethostbyname function which is no longer used on most platforms. - -Addresses are not reshuffled if name resolution is completed using the DNS -cache. \fICURLOPT_DNS_CACHE_TIMEOUT(3)\fP can be used together with this -option to reduce DNS cache timeout or disable caching entirely if frequent -reshuffling is needed. - -Since the addresses returned are randomly reordered, the order is not in -accordance with RFC 3484 or any other deterministic order that may be -generated by the system's name resolution implementation. This may have -performance impacts and may cause IPv4 to be used before IPv6 or vice versa. -.SH DEFAULT -0 (disabled) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L); - - curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.60.0 -.SH RETURN VALUE -CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. -.SH "SEE ALSO" -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_IPRESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.md b/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.md new file mode 100644 index 000000000..f15abc9c7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_SHUFFLE_ADDRESSES.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_SHUFFLE_ADDRESSES +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_IPRESOLVE (3) +--- + +# NAME + +CURLOPT_DNS_SHUFFLE_ADDRESSES - shuffle IP addresses for hostname + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_SHUFFLE_ADDRESSES, long onoff); +~~~ + +# DESCRIPTION + +Pass a long set to 1 to enable this option. + +When a name is resolved and more than one IP address is returned, this +function shuffles the order of all returned addresses so that they are used in +a random order. This is similar to the ordering behavior of the legacy +gethostbyname function which is no longer used on most platforms. + +Addresses are not reshuffled if name resolution is completed using the DNS +cache. CURLOPT_DNS_CACHE_TIMEOUT(3) can be used together with this +option to reduce DNS cache timeout or disable caching entirely if frequent +reshuffling is needed. + +Since the addresses returned are randomly reordered, the order is not in +accordance with RFC 3484 or any other deterministic order that may be +generated by the system's name resolution implementation. This may have +performance impacts and may cause IPv4 to be used before IPv6 or vice versa. + +# DEFAULT + +0 (disabled) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L); + + curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.60.0 + +# RETURN VALUE + +CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. diff --git a/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.3 b/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.3 deleted file mode 100644 index 184147b49..000000000 --- a/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DNS_USE_GLOBAL_CACHE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_DNS_USE_GLOBAL_CACHE \- global DNS cache -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_USE_GLOBAL_CACHE, - long enable); -.fi -.SH DESCRIPTION -Has no function since 7.62.0. Do not use! - -Pass a long. If the \fIenable\fP value is 1, it tells curl to use a global DNS -cache that survives between easy handle creations and deletions. This is not -thread-safe and this uses a global variable. - -See \fICURLOPT_SHARE(3)\fP and \fIcurl_share_init(3)\fP for the correct way to -share DNS cache between transfers. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* switch off the use of a global, thread unsafe, cache */ - curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L); - ret = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} - -.fi -.SH AVAILABILITY -Deprecated since 7.11.1. Function removed in 7.62.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_SHARE (3) diff --git a/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.md b/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.md new file mode 100644 index 000000000..dfbc22916 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DNS_USE_GLOBAL_CACHE.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DNS_USE_GLOBAL_CACHE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_SHARE (3) +--- + +# NAME + +CURLOPT_DNS_USE_GLOBAL_CACHE - global DNS cache + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DNS_USE_GLOBAL_CACHE, + long enable); +~~~ + +# DESCRIPTION + +Has no function since 7.62.0. Do not use! + +Pass a long. If the *enable* value is 1, it tells curl to use a global DNS +cache that survives between easy handle creations and deletions. This is not +thread-safe and this uses a global variable. + +See CURLOPT_SHARE(3) and curl_share_init(3) for the correct way to +share DNS cache between transfers. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* switch off the use of a global, thread unsafe, cache */ + curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} + +~~~ + +# AVAILABILITY + +Deprecated since 7.11.1. Function removed in 7.62.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.3 b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.3 deleted file mode 100644 index 0bcd87b71..000000000 --- a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DOH_SSL_VERIFYHOST 3 "11 Feb 2021" libcurl libcurl -.SH NAME -CURLOPT_DOH_SSL_VERIFYHOST \- verify the host name in the DoH SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYHOST, - long verify); -.fi -.SH DESCRIPTION -Pass a long set to 2L as asking curl to \fIverify\fP the DoH (DNS-over-HTTPS) -server's certificate name fields against the host name. - -This option is the DoH equivalent of \fICURLOPT_SSL_VERIFYHOST(3)\fP and -only affects requests to the DoH server. - -When \fICURLOPT_DOH_SSL_VERIFYHOST(3)\fP is 2, the SSL certificate provided by -the DoH server must indicate that the server name is the same as the server -name to which you meant to connect to, or the connection fails. - -Curl considers the DoH server the intended one when the Common Name field or a -Subject Alternate Name field in the certificate matches the host name in the -DoH URL to which you told Curl to connect. - -When the \fIverify\fP value is set to 1L it is treated the same as 2L. However -for consistency with the other \fIVERIFYHOST\fP options we suggest use 2 and -not 1. - -When the \fIverify\fP value is set to 0L, the connection succeeds regardless of -the names used in the certificate. Use that ability with caution! - -See also \fICURLOPT_DOH_SSL_VERIFYPEER(3)\fP to verify the digital signature -of the DoH server certificate. -.SH DEFAULT -2 -.SH PROTOCOLS -DoH -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_DOH_URL, - "https://cloudflare-dns.com/dns-query"); - - /* Disable host name verification of the DoH server */ - curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYHOST, 0L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.76.0 - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DOH_SSL_VERIFYPEER (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.md b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.md new file mode 100644 index 000000000..051e6be53 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYHOST.md @@ -0,0 +1,90 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DOH_SSL_VERIFYHOST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DOH_SSL_VERIFYPEER (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_DOH_SSL_VERIFYHOST - verify the hostname in the DoH SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYHOST, + long verify); +~~~ + +# DESCRIPTION + +Pass a long set to 2L as asking curl to *verify* the DoH (DNS-over-HTTPS) +server's certificate name fields against the hostname. + +This option is the DoH equivalent of CURLOPT_SSL_VERIFYHOST(3) and +only affects requests to the DoH server. + +When CURLOPT_DOH_SSL_VERIFYHOST(3) is 2, the SSL certificate provided by +the DoH server must indicate that the server name is the same as the server +name to which you meant to connect to, or the connection fails. + +Curl considers the DoH server the intended one when the Common Name field or a +Subject Alternate Name field in the certificate matches the hostname in the +DoH URL to which you told Curl to connect. + +When the *verify* value is set to 1L it is treated the same as 2L. However +for consistency with the other *VERIFYHOST* options we suggest use 2 and +not 1. + +When the *verify* value is set to 0L, the connection succeeds regardless of +the names used in the certificate. Use that ability with caution! + +See also CURLOPT_DOH_SSL_VERIFYPEER(3) to verify the digital signature +of the DoH server certificate. + +# DEFAULT + +2 + +# PROTOCOLS + +DoH + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_DOH_URL, + "https://cloudflare-dns.com/dns-query"); + + /* Disable host name verification of the DoH server */ + curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYHOST, 0L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.76.0 + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.3 b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.3 deleted file mode 100644 index d894871d4..000000000 --- a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DOH_SSL_VERIFYPEER 3 "11 Feb 2021" libcurl libcurl -.SH NAME -CURLOPT_DOH_SSL_VERIFYPEER \- verify the DoH SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYPEER, - long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1L to enable or 0L to disable. - -This option tells curl to verify the authenticity of the DoH (DNS-over-HTTPS) -server's certificate. A value of 1 means curl verifies; 0 (zero) means it -does not. - -This option is the DoH equivalent of \fICURLOPT_SSL_VERIFYPEER(3)\fP and -only affects requests to the DoH server. - -When negotiating a TLS or SSL connection, the server sends a certificate -indicating its identity. Curl verifies whether the certificate is authentic, -i.e. that you can trust that the server is who the certificate says it is. -This trust is based on a chain of digital signatures, rooted in certification -authority (CA) certificates you supply. curl uses a default bundle of CA -certificates (the path for that is determined at build time) and you can -specify alternate certificates with the \fICURLOPT_CAINFO(3)\fP option -or the \fICURLOPT_CAPATH(3)\fP option. - -When \fICURLOPT_DOH_SSL_VERIFYPEER(3)\fP is enabled, and the verification -fails to prove that the certificate is authentic, the connection fails. When -the option is zero, the peer certificate verification succeeds regardless. - -Authenticating the certificate is not enough to be sure about the server. You -typically also want to ensure that the server is the server you mean to be -talking to. Use \fICURLOPT_DOH_SSL_VERIFYHOST(3)\fP for that. The check -that the host name in the certificate is valid for the host name you are -connecting to is done independently of the -\fICURLOPT_DOH_SSL_VERIFYPEER(3)\fP option. - -WARNING: disabling verification of the certificate allows bad guys to -man-in-the-middle the communication without you knowing it. Disabling -verification makes the communication insecure. Just having encryption on a -transfer is not enough as you cannot be sure that you are communicating with -the correct end-point. -.SH DEFAULT -1 -.SH PROTOCOLS -DoH -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_DOH_URL, - "https://cloudflare-dns.com/dns-query"); - - /* Disable certificate verification of the DoH server */ - curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYPEER, 0L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.76.0 - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_DOH_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.md b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.md new file mode 100644 index 000000000..e2a5a5e69 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYPEER.md @@ -0,0 +1,102 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DOH_SSL_VERIFYPEER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAPATH (3) + - CURLOPT_DOH_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_DOH_SSL_VERIFYPEER - verify the DoH SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYPEER, + long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1L to enable or 0L to disable. + +This option tells curl to verify the authenticity of the DoH (DNS-over-HTTPS) +server's certificate. A value of 1 means curl verifies; 0 (zero) means it +does not. + +This option is the DoH equivalent of CURLOPT_SSL_VERIFYPEER(3) and +only affects requests to the DoH server. + +When negotiating a TLS or SSL connection, the server sends a certificate +indicating its identity. Curl verifies whether the certificate is authentic, +i.e. that you can trust that the server is who the certificate says it is. +This trust is based on a chain of digital signatures, rooted in certification +authority (CA) certificates you supply. curl uses a default bundle of CA +certificates (the path for that is determined at build time) and you can +specify alternate certificates with the CURLOPT_CAINFO(3) option or the +CURLOPT_CAPATH(3) option. + +When CURLOPT_DOH_SSL_VERIFYPEER(3) is enabled, and the verification fails to +prove that the certificate is authentic, the connection fails. When the option +is zero, the peer certificate verification succeeds regardless. + +Authenticating the certificate is not enough to be sure about the server. You +typically also want to ensure that the server is the server you mean to be +talking to. Use CURLOPT_DOH_SSL_VERIFYHOST(3) for that. The check that the +hostname in the certificate is valid for the hostname you are connecting to +is done independently of the CURLOPT_DOH_SSL_VERIFYPEER(3) option. + +WARNING: disabling verification of the certificate allows bad guys to +man-in-the-middle the communication without you knowing it. Disabling +verification makes the communication insecure. Just having encryption on a +transfer is not enough as you cannot be sure that you are communicating with +the correct end-point. + +# DEFAULT + +1 + +# PROTOCOLS + +DoH + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_DOH_URL, + "https://cloudflare-dns.com/dns-query"); + + /* Disable certificate verification of the DoH server */ + curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYPEER, 0L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.76.0 + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.3 b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.3 deleted file mode 100644 index cde868e36..000000000 --- a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DOH_SSL_VERIFYSTATUS 3 "11 Feb 2021" libcurl libcurl -.SH NAME -CURLOPT_DOH_SSL_VERIFYSTATUS \- verify the DoH SSL certificate's status -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYSTATUS, - long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1 to enable or 0 to disable. - -This option determines whether libcurl verifies the status of the DoH -(DNS-over-HTTPS) server cert using the "Certificate Status Request" TLS -extension (aka. OCSP stapling). - -This option is the DoH equivalent of \fICURLOPT_SSL_VERIFYSTATUS(3)\fP and -only affects requests to the DoH server. - -If this option is enabled and the server does not support the TLS extension, -the verification fails. -.SH DEFAULT -0 -.SH PROTOCOLS -DoH -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_DOH_URL, - "https://cloudflare-dns.com/dns-query"); - - /* Ask for OCSP stapling when verifying the DoH server */ - curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYSTATUS, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.76.0. This option is currently only supported by the OpenSSL, and -GnuTLS TLS backends. -.SH RETURN VALUE -Returns CURLE_OK if OCSP stapling is supported by the SSL backend, otherwise -returns CURLE_NOT_BUILT_IN. -.SH "SEE ALSO" -.BR CURLOPT_DOH_SSL_VERIFYHOST (3), -.BR CURLOPT_DOH_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYSTATUS (3) diff --git a/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.md b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.md new file mode 100644 index 000000000..19489986b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DOH_SSL_VERIFYSTATUS.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DOH_SSL_VERIFYSTATUS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DOH_SSL_VERIFYHOST (3) + - CURLOPT_DOH_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYSTATUS (3) +--- + +# NAME + +CURLOPT_DOH_SSL_VERIFYSTATUS - verify the DoH SSL certificate's status + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_SSL_VERIFYSTATUS, + long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1 to enable or 0 to disable. + +This option determines whether libcurl verifies the status of the DoH +(DNS-over-HTTPS) server cert using the "Certificate Status Request" TLS +extension (aka. OCSP stapling). + +This option is the DoH equivalent of CURLOPT_SSL_VERIFYSTATUS(3) and +only affects requests to the DoH server. + +If this option is enabled and the server does not support the TLS extension, +the verification fails. + +# DEFAULT + +0 + +# PROTOCOLS + +DoH + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_DOH_URL, + "https://cloudflare-dns.com/dns-query"); + + /* Ask for OCSP stapling when verifying the DoH server */ + curl_easy_setopt(curl, CURLOPT_DOH_SSL_VERIFYSTATUS, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.76.0. This option is currently only supported by the OpenSSL, and +GnuTLS TLS backends. + +# RETURN VALUE + +Returns CURLE_OK if OCSP stapling is supported by the SSL backend, otherwise +returns CURLE_NOT_BUILT_IN. diff --git a/docs/libcurl/opts/CURLOPT_DOH_URL.3 b/docs/libcurl/opts/CURLOPT_DOH_URL.3 deleted file mode 100644 index 35dbed04a..000000000 --- a/docs/libcurl/opts/CURLOPT_DOH_URL.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_DOH_URL 3 "18 Jun 2018" libcurl libcurl -.SH NAME -CURLOPT_DOH_URL \- provide the DNS-over-HTTPS URL -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL); -.fi -.SH DESCRIPTION -Pass in a pointer to a \fIURL\fP for the DoH server to use for name -resolving. The parameter should be a char * to a null-terminated string which -must be URL-encoded in the following format: "https://host:port/path". It MUST -specify an HTTPS URL. - -libcurl does not validate the syntax or use this variable until the transfer -is issued. Even if you set a crazy value here, \fIcurl_easy_setopt(3)\fP still -returns \fICURLE_OK\fP. - -curl sends POST requests to the given DNS-over-HTTPS URL. - -To find the DoH server itself, which might be specified using a name, libcurl -uses the default name lookup function. You can bootstrap that by providing the -address for the DoH server with \fICURLOPT_RESOLVE(3)\fP. - -Disable DoH use again by setting this option to NULL. -.SH "INHERIT OPTIONS" -DoH lookups use SSL and some SSL settings from your transfer are inherited, -like \fICURLOPT_SSL_CTX_FUNCTION(3)\fP. - -The hostname and peer certificate verification settings are not inherited but -can be controlled separately via \fICURLOPT_DOH_SSL_VERIFYHOST(3)\fP and -\fICURLOPT_DOH_SSL_VERIFYPEER(3)\fP. - -A set \fICURLOPT_OPENSOCKETFUNCTION(3)\fP callback is not inherited. -.SH "KNOWN BUGS" -Even when DoH is set to be used with this option, there are still some name -resolves that are performed without it, using the default name resolver -mechanism. This includes name resolves done for \fICURLOPT_INTERFACE(3)\fP, -\fICURLOPT_FTPPORT(3)\fP, a proxy type set to \fBCURLPROXY_SOCKS4\fP or -\fBCURLPROXY_SOCKS5\fP and probably some more. -.SH DEFAULT -NULL - there is no default DoH URL. If this option is not set, libcurl uses -the default name resolver. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.62.0 -.SH RETURN VALUE -Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient -heap space. - -Note that \fIcurl_easy_setopt(3)\fP does immediately parse the given string so -when given a bad DoH URL, libcurl might not detect the problem until it later -tries to resolve a name with it. -.SH "SEE ALSO" -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_RESOLVE (3), -.BR CURLOPT_VERBOSE (3) diff --git a/docs/libcurl/opts/CURLOPT_DOH_URL.md b/docs/libcurl/opts/CURLOPT_DOH_URL.md new file mode 100644 index 000000000..a2e46b4c0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_DOH_URL.md @@ -0,0 +1,96 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_DOH_URL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_RESOLVE (3) + - CURLOPT_VERBOSE (3) +--- + +# NAME + +CURLOPT_DOH_URL - provide the DNS-over-HTTPS URL + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DOH_URL, char *URL); +~~~ + +# DESCRIPTION + +Pass in a pointer to a *URL* for the DoH server to use for name resolving. The +parameter should be a char pointer to a null-terminated string which must be a +valid and correct HTTPS URL. + +libcurl does not validate the syntax or use this variable until the transfer +is issued. Even if you set a crazy value here, curl_easy_setopt(3) still +returns *CURLE_OK*. + +curl sends POST requests to the given DNS-over-HTTPS URL. + +To find the DoH server itself, which might be specified using a name, libcurl +uses the default name lookup function. You can bootstrap that by providing the +address for the DoH server with CURLOPT_RESOLVE(3). + +Disable DoH use again by setting this option to NULL. + +# INHERIT OPTIONS + +DoH lookups use SSL and some SSL settings from your transfer are inherited, +like CURLOPT_SSL_CTX_FUNCTION(3). + +The hostname and peer certificate verification settings are not inherited but +can be controlled separately via CURLOPT_DOH_SSL_VERIFYHOST(3) and +CURLOPT_DOH_SSL_VERIFYPEER(3). + +A set CURLOPT_OPENSOCKETFUNCTION(3) callback is not inherited. + +# KNOWN BUGS + +Even when DoH is set to be used with this option, there are still some name +resolves that are performed without it, using the default name resolver +mechanism. This includes name resolves done for CURLOPT_INTERFACE(3), +CURLOPT_FTPPORT(3), a proxy type set to **CURLPROXY_SOCKS4** or +**CURLPROXY_SOCKS5** and probably some more. + +# DEFAULT + +NULL - there is no default DoH URL. If this option is not set, libcurl uses +the default name resolver. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://dns.example.com"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.62.0 + +# RETURN VALUE + +Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient +heap space. + +Note that curl_easy_setopt(3) does immediately parse the given string so +when given a bad DoH URL, libcurl might not detect the problem until it later +tries to resolve a name with it. diff --git a/docs/libcurl/opts/CURLOPT_EGDSOCKET.3 b/docs/libcurl/opts/CURLOPT_EGDSOCKET.3 deleted file mode 100644 index 099acd8c5..000000000 --- a/docs/libcurl/opts/CURLOPT_EGDSOCKET.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_EGDSOCKET 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_EGDSOCKET \- EGD socket path -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_EGDSOCKET, char *path); -.fi -.SH DESCRIPTION -Deprecated option. It serves no purpose anymore. - -Pass a char * to the null-terminated path name to the Entropy Gathering Daemon -socket. It is used to seed the random engine for TLS. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_EGDSOCKET, "/var/egd.socket"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built with TLS enabled. Only the OpenSSL backend uses this, and only with -OpenSSL versions before 1.1.0. - -This option was deprecated in 7.84.0. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_RANDOM_FILE (3) diff --git a/docs/libcurl/opts/CURLOPT_EGDSOCKET.md b/docs/libcurl/opts/CURLOPT_EGDSOCKET.md new file mode 100644 index 000000000..a472f5ea5 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_EGDSOCKET.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_EGDSOCKET +Section: 3 +Source: libcurl +See-also: + - CURLOPT_RANDOM_FILE (3) +--- + +# NAME + +CURLOPT_EGDSOCKET - EGD socket path + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_EGDSOCKET, char *path); +~~~ + +# DESCRIPTION + +Deprecated option. It serves no purpose anymore. + +Pass a char pointer to the null-terminated path name to the Entropy Gathering +Daemon socket. It is used to seed the random engine for TLS. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_EGDSOCKET, "/var/egd.socket"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built with TLS enabled. Only the OpenSSL backend uses this, and only with +OpenSSL versions before 1.1.0. + +This option was deprecated in 7.84.0. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3 b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3 deleted file mode 100644 index 76180cba8..000000000 --- a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ERRORBUFFER 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_ERRORBUFFER \- error buffer for error messages -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ERRORBUFFER, char *buf); -.fi -.SH DESCRIPTION -Pass a char * to a buffer that libcurl may use to store human readable error -messages on failures or problems. This may be more helpful than just the -return code from \fIcurl_easy_perform(3)\fP and related functions. The buffer -must be at least \fBCURL_ERROR_SIZE\fP bytes big. - -You must keep the associated buffer available until libcurl no longer needs -it. Failing to do so might cause odd behavior or even crashes. libcurl might -need it until you call \fIcurl_easy_cleanup(3)\fP or you set the same option -again to use a different pointer. - -Do not rely on the contents of the buffer unless an error code was returned. -Since 7.60.0 libcurl initializes the contents of the error buffer to an empty -string before performing the transfer. For earlier versions if an error code -was returned but there was no error detail then the buffer was untouched. - -Consider \fICURLOPT_VERBOSE(3)\fP and \fICURLOPT_DEBUGFUNCTION(3)\fP to better -debug and trace why errors happen. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -#include /* for strlen() */ -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - char errbuf[CURL_ERROR_SIZE]; - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* provide a buffer to store errors in */ - curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); - - /* set the error buffer as empty before performing a request */ - errbuf[0] = 0; - - /* perform the request */ - res = curl_easy_perform(curl); - - /* if the request did not complete correctly, show the error - information. if no detailed error information was written to errbuf - show the more generic information from curl_easy_strerror instead. - */ - if(res != CURLE_OK) { - size_t len = strlen(errbuf); - fprintf(stderr, "\\nlibcurl: (%d) ", res); - if(len) - fprintf(stderr, "%s%s", errbuf, - ((errbuf[len - 1] != '\\n') ? "\\n" : "")); - else - fprintf(stderr, "%s\\n", curl_easy_strerror(res)); - } - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR curl_easy_strerror (3), -.BR curl_multi_strerror (3), -.BR curl_share_strerror (3), -.BR curl_url_strerror (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_VERBOSE (3) diff --git a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.md b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.md new file mode 100644 index 000000000..ed5d361ef --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.md @@ -0,0 +1,101 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ERRORBUFFER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_VERBOSE (3) + - curl_easy_strerror (3) + - curl_multi_strerror (3) + - curl_share_strerror (3) + - curl_url_strerror (3) +--- + +# NAME + +CURLOPT_ERRORBUFFER - error buffer for error messages + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ERRORBUFFER, char *buf); +~~~ + +# DESCRIPTION + +Pass a char pointer to a buffer that libcurl may use to store human readable +error messages on failures or problems. This may be more helpful than just the +return code from curl_easy_perform(3) and related functions. The buffer must +be at least **CURL_ERROR_SIZE** bytes big. + +You must keep the associated buffer available until libcurl no longer needs +it. Failing to do so might cause odd behavior or even crashes. libcurl might +need it until you call curl_easy_cleanup(3) or you set the same option +again to use a different pointer. + +Do not rely on the contents of the buffer unless an error code was returned. +Since 7.60.0 libcurl initializes the contents of the error buffer to an empty +string before performing the transfer. For earlier versions if an error code +was returned but there was no error detail then the buffer was untouched. + +Consider CURLOPT_VERBOSE(3) and CURLOPT_DEBUGFUNCTION(3) to better +debug and trace why errors happen. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +#include /* for strlen() */ +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + char errbuf[CURL_ERROR_SIZE]; + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* provide a buffer to store errors in */ + curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); + + /* set the error buffer as empty before performing a request */ + errbuf[0] = 0; + + /* perform the request */ + res = curl_easy_perform(curl); + + /* if the request did not complete correctly, show the error + information. if no detailed error information was written to errbuf + show the more generic information from curl_easy_strerror instead. + */ + if(res != CURLE_OK) { + size_t len = strlen(errbuf); + fprintf(stderr, "\nlibcurl: (%d) ", res); + if(len) + fprintf(stderr, "%s%s", errbuf, + ((errbuf[len - 1] != '\n') ? "\n" : "")); + else + fprintf(stderr, "%s\n", curl_easy_strerror(res)); + } + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.3 b/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.3 deleted file mode 100644 index 987092232..000000000 --- a/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_EXPECT_100_TIMEOUT_MS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_EXPECT_100_TIMEOUT_MS \- timeout for Expect: 100-continue response -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_EXPECT_100_TIMEOUT_MS, - long milliseconds); -.SH DESCRIPTION -Pass a long to tell libcurl the number of \fImilliseconds\fP to wait for a -server response with the HTTP status 100 (Continue), 417 (Expectation Failed) -or similar after sending an HTTP request containing an Expect: 100-continue -header. If this times out before a response is received, the request body is -sent anyway. -.SH DEFAULT -1000 milliseconds -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* wait 3 seconds for 100-continue */ - curl_easy_setopt(curl, CURLOPT_EXPECT_100_TIMEOUT_MS, 3000L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.36.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPPOST (3), -.BR CURLOPT_POST (3) diff --git a/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.md new file mode 100644 index 000000000..9458cfc63 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_EXPECT_100_TIMEOUT_MS.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_EXPECT_100_TIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPOST (3) + - CURLOPT_POST (3) +--- + +# NAME + +CURLOPT_EXPECT_100_TIMEOUT_MS - timeout for Expect: 100-continue response + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_EXPECT_100_TIMEOUT_MS, + long milliseconds); +~~~ + +# DESCRIPTION + +Pass a long to tell libcurl the number of *milliseconds* to wait for a +server response with the HTTP status 100 (Continue), 417 (Expectation Failed) +or similar after sending an HTTP request containing an Expect: 100-continue +header. If this times out before a response is received, the request body is +sent anyway. + +# DEFAULT + +1000 milliseconds + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* wait 3 seconds for 100-continue */ + curl_easy_setopt(curl, CURLOPT_EXPECT_100_TIMEOUT_MS, 3000L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.36.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FAILONERROR.3 b/docs/libcurl/opts/CURLOPT_FAILONERROR.3 deleted file mode 100644 index 539517125..000000000 --- a/docs/libcurl/opts/CURLOPT_FAILONERROR.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FAILONERROR 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FAILONERROR \- request failure on HTTP response >= 400 -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FAILONERROR, long fail); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to fail the request if the HTTP -code returned is equal to or larger than 400. The default action would be to -return the page normally, ignoring that code. - -This method is not fail-safe and there are occasions where non-successful -response codes slip through, especially when authentication is involved -(response codes 401 and 407). - -You might get some amounts of headers transferred before this situation is -detected, like when a "100-continue" is received as a response to a POST/PUT -and a 401 or 407 is received immediately afterwards. - -When this option is used and an error is detected, it causes the connection to -get closed and \fICURLE_HTTP_RETURNED_ERROR\fP is returned. -.SH DEFAULT -0, do not fail on error -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); - ret = curl_easy_perform(curl); - if(ret == CURLE_HTTP_RETURNED_ERROR) { - /* an HTTP response error problem */ - } - } -} -.fi -.SH AVAILABILITY -Along with HTTP. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_RESPONSE_CODE (3), -.BR CURLOPT_HTTP200ALIASES (3), -.BR CURLOPT_KEEP_SENDING_ON_ERROR (3) diff --git a/docs/libcurl/opts/CURLOPT_FAILONERROR.md b/docs/libcurl/opts/CURLOPT_FAILONERROR.md new file mode 100644 index 000000000..7ea5cedc6 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FAILONERROR.md @@ -0,0 +1,74 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FAILONERROR +Section: 3 +Source: libcurl +See-also: + - CURLINFO_RESPONSE_CODE (3) + - CURLOPT_HTTP200ALIASES (3) + - CURLOPT_KEEP_SENDING_ON_ERROR (3) +--- + +# NAME + +CURLOPT_FAILONERROR - request failure on HTTP response >= 400 + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FAILONERROR, long fail); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to fail the request if the HTTP +code returned is equal to or larger than 400. The default action would be to +return the page normally, ignoring that code. + +This method is not fail-safe and there are occasions where non-successful +response codes slip through, especially when authentication is involved +(response codes 401 and 407). + +You might get some amounts of headers transferred before this situation is +detected, like when a "100-continue" is received as a response to a POST/PUT +and a 401 or 407 is received immediately afterwards. + +When this option is used and an error is detected, it causes the connection to +get closed and *CURLE_HTTP_RETURNED_ERROR* is returned. + +# DEFAULT + +0, do not fail on error + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); + ret = curl_easy_perform(curl); + if(ret == CURLE_HTTP_RETURNED_ERROR) { + /* an HTTP response error problem */ + } + } +} +~~~ + +# AVAILABILITY + +Along with HTTP. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FILETIME.3 b/docs/libcurl/opts/CURLOPT_FILETIME.3 deleted file mode 100644 index 39ce7a25b..000000000 --- a/docs/libcurl/opts/CURLOPT_FILETIME.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FILETIME 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FILETIME \- get the modification time of the remote resource -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime); -.fi -.SH DESCRIPTION -Pass a long. If it is 1, libcurl attempts to get the modification time of the -remote document in this operation. This requires that the remote server sends -the time or replies to a time querying command. The \fIcurl_easy_getinfo(3)\fP -function with the \fICURLINFO_FILETIME(3)\fP argument can be used after a -transfer to extract the received time (if any). -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP(S), FTP(S), SFTP, FILE, SMB(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html"); - /* Ask for filetime */ - curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); - res = curl_easy_perform(curl); - if(CURLE_OK == res) { - long filetime; - res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); - if((CURLE_OK == res) && (filetime >= 0)) { - time_t file_time = (time_t)filetime; - printf("filetime: %s", ctime(&file_time)); - } - } - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always, for SFTP since 7.49.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR curl_easy_getinfo (3), -.BR CURLINFO_FILETIME (3) diff --git a/docs/libcurl/opts/CURLOPT_FILETIME.md b/docs/libcurl/opts/CURLOPT_FILETIME.md new file mode 100644 index 000000000..013449105 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FILETIME.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FILETIME +Section: 3 +Source: libcurl +See-also: + - CURLINFO_FILETIME (3) + - curl_easy_getinfo (3) +--- + +# NAME + +CURLOPT_FILETIME - get the modification time of the remote resource + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime); +~~~ + +# DESCRIPTION + +Pass a long. If it is 1, libcurl attempts to get the modification time of the +remote document in this operation. This requires that the remote server sends +the time or replies to a time querying command. The curl_easy_getinfo(3) +function with the CURLINFO_FILETIME(3) argument can be used after a +transfer to extract the received time (if any). + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP(S), FTP(S), SFTP, FILE, SMB(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html"); + /* Ask for filetime */ + curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); + res = curl_easy_perform(curl); + if(CURLE_OK == res) { + long filetime; + res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); + if((CURLE_OK == res) && (filetime >= 0)) { + time_t file_time = (time_t)filetime; + printf("filetime: %s", ctime(&file_time)); + } + } + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always, for SFTP since 7.49.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.3 b/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.3 deleted file mode 100644 index 89ca2d039..000000000 --- a/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FNMATCH_DATA 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FNMATCH_DATA \- pointer passed to the fnmatch callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA, - void *pointer); -.SH DESCRIPTION -Pass a pointer that is untouched by libcurl and passed as the ptr argument to -the \fICURLOPT_FNMATCH_FUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -extern int string_match(const char *s1, const char *s2); - -struct local_stuff { - void *custom; -}; - -static int my_fnmatch(void *clientp, - const char *pattern, const char *string) -{ - struct local_stuff *my = clientp; - printf("my ptr: %p\\n", my->custom); - - if(string_match(pattern, string)) - return CURL_FNMATCHFUNC_MATCH; - else - return CURL_FNMATCHFUNC_NOMATCH; -} - -int main(void) -{ - struct local_stuff local_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*"); - curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); - curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch); - curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FNMATCH_FUNCTION (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.md b/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.md new file mode 100644 index 000000000..48b60723a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FNMATCH_DATA.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FNMATCH_DATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FNMATCH_FUNCTION (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_FNMATCH_DATA - pointer passed to the fnmatch callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA, + void *pointer); +~~~ + +# DESCRIPTION + +Pass a pointer that is untouched by libcurl and passed as the ptr argument to +the CURLOPT_FNMATCH_FUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +extern int string_match(const char *s1, const char *s2); + +struct local_stuff { + void *custom; +}; + +static int my_fnmatch(void *clientp, + const char *pattern, const char *string) +{ + struct local_stuff *my = clientp; + printf("my ptr: %p\n", my->custom); + + if(string_match(pattern, string)) + return CURL_FNMATCHFUNC_MATCH; + else + return CURL_FNMATCHFUNC_NOMATCH; +} + +int main(void) +{ + struct local_stuff local_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*"); + curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); + curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch); + curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.3 deleted file mode 100644 index 7dc835766..000000000 --- a/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FNMATCH_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FNMATCH_FUNCTION \- wildcard match callback -.SH SYNOPSIS -.nf -#include - -int fnmatch_callback(void *ptr, - const char *pattern, - const char *string); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_FUNCTION, - fnmatch_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback is used for wildcard matching. - -Return \fICURL_FNMATCHFUNC_MATCH\fP if pattern matches the string, -\fICURL_FNMATCHFUNC_NOMATCH\fP if not or \fICURL_FNMATCHFUNC_FAIL\fP if an -error occurred. -.SH DEFAULT -NULL == an internal function for wildcard matching. -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -extern int string_match(const char *s1, const char *s2); - -struct local_stuff { - void *custom; -}; -static int my_fnmatch(void *clientp, - const char *pattern, const char *string) -{ - struct local_stuff *data = clientp; - printf("my pointer: %p\\n", data->custom); - if(string_match(pattern, string)) - return CURL_FNMATCHFUNC_MATCH; - else - return CURL_FNMATCHFUNC_NOMATCH; -} - -int main(void) -{ - struct local_stuff local_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*"); - curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); - curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch); - curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_FNMATCH_DATA (3), -.BR CURLOPT_WILDCARDMATCH (3) diff --git a/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.md b/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.md new file mode 100644 index 000000000..8ed13bfe6 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FNMATCH_FUNCTION.md @@ -0,0 +1,88 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FNMATCH_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_FNMATCH_DATA (3) + - CURLOPT_WILDCARDMATCH (3) +--- + +# NAME + +CURLOPT_FNMATCH_FUNCTION - wildcard match callback + +# SYNOPSIS + +~~~c +#include + +int fnmatch_callback(void *ptr, + const char *pattern, + const char *string); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_FUNCTION, + fnmatch_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback is used for wildcard matching. + +Return *CURL_FNMATCHFUNC_MATCH* if pattern matches the string, +*CURL_FNMATCHFUNC_NOMATCH* if not or *CURL_FNMATCHFUNC_FAIL* if an +error occurred. + +# DEFAULT + +NULL == an internal function for wildcard matching. + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +extern int string_match(const char *s1, const char *s2); + +struct local_stuff { + void *custom; +}; +static int my_fnmatch(void *clientp, + const char *pattern, const char *string) +{ + struct local_stuff *data = clientp; + printf("my pointer: %p\n", data->custom); + if(string_match(pattern, string)) + return CURL_FNMATCHFUNC_MATCH; + else + return CURL_FNMATCHFUNC_NOMATCH; +} + +int main(void) +{ + struct local_stuff local_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*"); + curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); + curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch); + curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.3 b/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.3 deleted file mode 100644 index a78ea3305..000000000 --- a/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FOLLOWLOCATION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FOLLOWLOCATION \- follow HTTP 3xx redirects -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FOLLOWLOCATION, long enable); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to follow any Location: header -redirects that a HTTP server sends in a 30x response. The Location: header can -specify a relative or an absolute URL to follow. - -libcurl issues another request for the new URL and follows subsequent new -Location: redirects all the way until no more such headers are returned or the -maximum limit is reached. \fICURLOPT_MAXREDIRS(3)\fP is used to limit the -number of redirects libcurl follows. - -libcurl restricts what protocols it automatically follow redirects to. The -accepted target protocols are set with \fICURLOPT_REDIR_PROTOCOLS(3)\fP. By -default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects. - -When following a redirect, the specific 30x response code also dictates which -request method libcurl uses in the subsequent request: For 301, 302 and 303 -responses libcurl switches method from POST to GET unless -\fICURLOPT_POSTREDIR(3)\fP instructs libcurl otherwise. All other redirect -response codes make libcurl use the same method again. - -For users who think the existing location following is too naive, too simple -or just lacks features, it is easy to instead implement your own redirect -follow logic with the use of \fIcurl_easy_getinfo(3)\fP's -\fICURLINFO_REDIRECT_URL(3)\fP option instead of using -\fICURLOPT_FOLLOWLOCATION(3)\fP. -.SH NOTE -Since libcurl changes method or not based on the specific HTTP response code, -setting \fICURLOPT_CUSTOMREQUEST(3)\fP while following redirects may change -what libcurl would otherwise do and if not that carefully may even make it -misbehave since \fICURLOPT_CUSTOMREQUEST(3)\fP overrides the method libcurl -would otherwise select internally. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* example.com is redirected, so we tell libcurl to follow redirection */ - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLOPT_POSTREDIR (3), -.BR CURLOPT_PROTOCOLS (3), -.BR CURLOPT_REDIR_PROTOCOLS (3) diff --git a/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md b/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md new file mode 100644 index 000000000..9309dff21 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md @@ -0,0 +1,93 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FOLLOWLOCATION +Section: 3 +Source: libcurl +See-also: + - CURLINFO_REDIRECT_COUNT (3) + - CURLINFO_REDIRECT_URL (3) + - CURLOPT_POSTREDIR (3) + - CURLOPT_PROTOCOLS (3) + - CURLOPT_REDIR_PROTOCOLS (3) +--- + +# NAME + +CURLOPT_FOLLOWLOCATION - follow HTTP 3xx redirects + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FOLLOWLOCATION, long enable); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to follow any Location: header +redirects that an HTTP server sends in a 30x response. The Location: header +can specify a relative or an absolute URL to follow. + +libcurl issues another request for the new URL and follows subsequent new +Location: redirects all the way until no more such headers are returned or the +maximum limit is reached. CURLOPT_MAXREDIRS(3) is used to limit the +number of redirects libcurl follows. + +libcurl restricts what protocols it automatically follow redirects to. The +accepted target protocols are set with CURLOPT_REDIR_PROTOCOLS(3). By +default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects. + +When following a redirect, the specific 30x response code also dictates which +request method libcurl uses in the subsequent request: For 301, 302 and 303 +responses libcurl switches method from POST to GET unless +CURLOPT_POSTREDIR(3) instructs libcurl otherwise. All other redirect +response codes make libcurl use the same method again. + +For users who think the existing location following is too naive, too simple +or just lacks features, it is easy to instead implement your own redirect +follow logic with the use of curl_easy_getinfo(3)'s +CURLINFO_REDIRECT_URL(3) option instead of using +CURLOPT_FOLLOWLOCATION(3). + +# NOTE + +Since libcurl changes method or not based on the specific HTTP response code, +setting CURLOPT_CUSTOMREQUEST(3) while following redirects may change +what libcurl would otherwise do and if not that carefully may even make it +misbehave since CURLOPT_CUSTOMREQUEST(3) overrides the method libcurl +would otherwise select internally. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* example.com is redirected, so we tell libcurl to follow redirection */ + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FORBID_REUSE.3 b/docs/libcurl/opts/CURLOPT_FORBID_REUSE.3 deleted file mode 100644 index 52d800d67..000000000 --- a/docs/libcurl/opts/CURLOPT_FORBID_REUSE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FORBID_REUSE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FORBID_REUSE \- make connection get closed at once after use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close); -.fi -.SH DESCRIPTION -Pass a long. Set \fIclose\fP to 1 to make libcurl explicitly close the -connection when done with the transfer. Normally, libcurl keeps all -connections alive when done with one transfer in case a succeeding one follows -that can reuse them. This option should be used with caution and only if you -understand what it does as it can seriously impact performance. - -Set to 0 to have libcurl keep the connection open for possible later reuse -(default behavior). -.SH DEFAULT -0 -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L); - curl_easy_perform(curl); - - /* this second transfer may not reuse the same connection */ - curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_FRESH_CONNECT (3), -.BR CURLOPT_MAXCONNECTS (3), -.BR CURLOPT_MAXLIFETIME_CONN (3) diff --git a/docs/libcurl/opts/CURLOPT_FORBID_REUSE.md b/docs/libcurl/opts/CURLOPT_FORBID_REUSE.md new file mode 100644 index 000000000..0e8a20607 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FORBID_REUSE.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FORBID_REUSE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FRESH_CONNECT (3) + - CURLOPT_MAXCONNECTS (3) + - CURLOPT_MAXLIFETIME_CONN (3) +--- + +# NAME + +CURLOPT_FORBID_REUSE - make connection get closed at once after use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FORBID_REUSE, long close); +~~~ + +# DESCRIPTION + +Pass a long. Set *close* to 1 to make libcurl explicitly close the +connection when done with the transfer. Normally, libcurl keeps all +connections alive when done with one transfer in case a succeeding one follows +that can reuse them. This option should be used with caution and only if you +understand what it does as it can seriously impact performance. + +Set to 0 to have libcurl keep the connection open for possible later reuse +(default behavior). + +# DEFAULT + +0 + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L); + curl_easy_perform(curl); + + /* this second transfer may not reuse the same connection */ + curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.3 b/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.3 deleted file mode 100644 index 00e4addf9..000000000 --- a/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FRESH_CONNECT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FRESH_CONNECT \- force a new connection to be used -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FRESH_CONNECT, long fresh); -.fi -.SH DESCRIPTION -Pass a long. Set to 1 to make the next transfer use a new (fresh) connection -by force instead of trying to reuse an existing one. This option should be -used with caution and only if you understand what it does as it may impact -performance negatively. - -Related functionality is \fICURLOPT_FORBID_REUSE(3)\fP which makes sure the -connection is closed after use so that it cannot be reused. - -Set \fIfresh\fP to 0 to have libcurl attempt reusing an existing connection -(default behavior). -.SH DEFAULT -0 -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L); - /* this transfer must use a new connection, not reuse an existing */ - curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_FORBID_REUSE (3), -.BR CURLOPT_MAXAGE_CONN (3), -.BR CURLOPT_MAXLIFETIME_CONN (3) diff --git a/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.md b/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.md new file mode 100644 index 000000000..ccb85270d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FRESH_CONNECT.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FRESH_CONNECT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FORBID_REUSE (3) + - CURLOPT_MAXAGE_CONN (3) + - CURLOPT_MAXLIFETIME_CONN (3) +--- + +# NAME + +CURLOPT_FRESH_CONNECT - force a new connection to be used + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FRESH_CONNECT, long fresh); +~~~ + +# DESCRIPTION + +Pass a long. Set to 1 to make the next transfer use a new (fresh) connection +by force instead of trying to reuse an existing one. This option should be +used with caution and only if you understand what it does as it may impact +performance negatively. + +Related functionality is CURLOPT_FORBID_REUSE(3) which makes sure the +connection is closed after use so that it cannot be reused. + +Set *fresh* to 0 to have libcurl attempt reusing an existing connection +(default behavior). + +# DEFAULT + +0 + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L); + /* this transfer must use a new connection, not reuse an existing */ + curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_FTPPORT.3 b/docs/libcurl/opts/CURLOPT_FTPPORT.3 deleted file mode 100644 index ad7f2be53..000000000 --- a/docs/libcurl/opts/CURLOPT_FTPPORT.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTPPORT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTPPORT \- make FTP transfer active -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It specifies that the -FTP transfer should be made actively and the given string is used to get the -IP address to use for the FTP PORT instruction. - -The PORT instruction tells the remote server to do a TCP connect to our -specified IP address. The string may be a plain IP address, a host name, a -network interface name (under Unix) or just a '-' symbol to let the library -use your system's default IP address. Default FTP operations are passive, and -does not use the PORT command. - -The address can be followed by a ':' to specify a port, optionally followed by -a '-' to specify a port range. If the port specified is 0, the operating -system picks a free port. If a range is provided and all ports in the range -are not available, libcurl reports CURLE_FTP_PORT_FAILED for the -handle. Invalid port/range settings are ignored. IPv6 addresses followed by a -port or port range have to be in brackets. IPv6 addresses without port/range -specifier can be in brackets. - -Examples with specified ports: - -.nf - eth0:0 - 192.168.1.2:32000-33000 - curl.se:32123 - [::1]:1234-4567 -.fi - -We strongly advise against specifying the address with a name, as it causes -libcurl to do a blocking name resolve call to retrieve the IP address. That -name resolve operation does \fBnot\fP use DNS-over-HTTPS even if -\fICURLOPT_DOH_URL(3)\fP is set. - -Using anything else than "-" for this option should typically only be done if -you have special knowledge and confirmation that it works. - -You disable PORT again and go back to using the passive version by setting -this option to NULL. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/old-server/file.txt"); - curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Port range support was added in 7.19.5 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_FTP_USE_EPRT (3), -.BR CURLOPT_FTP_USE_EPSV (3) diff --git a/docs/libcurl/opts/CURLOPT_FTPPORT.md b/docs/libcurl/opts/CURLOPT_FTPPORT.md new file mode 100644 index 000000000..8e8710b07 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTPPORT.md @@ -0,0 +1,99 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTPPORT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_USE_EPRT (3) + - CURLOPT_FTP_USE_EPSV (3) +--- + +# NAME + +CURLOPT_FTPPORT - make FTP transfer active + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It specifies that the +FTP transfer should be made actively and the given string is used to get the +IP address to use for the FTP PORT instruction. + +The PORT instruction tells the remote server to do a TCP connect to our +specified IP address. The string may be a plain IP address, a hostname, a +network interface name (under Unix) or just a '-' symbol to let the library +use your system's default IP address. Default FTP operations are passive, and +does not use the PORT command. + +The address can be followed by a ':' to specify a port, optionally followed by +a '-' to specify a port range. If the port specified is 0, the operating +system picks a free port. If a range is provided and all ports in the range +are not available, libcurl reports CURLE_FTP_PORT_FAILED for the +handle. Invalid port/range settings are ignored. IPv6 addresses followed by a +port or port range have to be in brackets. IPv6 addresses without port/range +specifier can be in brackets. + +Examples with specified ports: + +~~~c + eth0:0 + 192.168.1.2:32000-33000 + curl.se:32123 + [::1]:1234-4567 +~~~ + +We strongly advise against specifying the address with a name, as it causes +libcurl to do a blocking name resolve call to retrieve the IP address. That +name resolve operation does **not** use DNS-over-HTTPS even if +CURLOPT_DOH_URL(3) is set. + +Using anything else than "-" for this option should typically only be done if +you have special knowledge and confirmation that it works. + +You disable PORT again and go back to using the passive version by setting +this option to NULL. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/old-server/file.txt"); + curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Port range support was added in 7.19.5 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.3 b/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.3 deleted file mode 100644 index 96b6e9d7f..000000000 --- a/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTPSSLAUTH 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTPSSLAUTH \- order in which to attempt TLS vs SSL -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPSSLAUTH, long order); -.fi -.SH DESCRIPTION -Pass a long using one of the values from below, to alter how libcurl issues -\&"AUTH TLS" or "AUTH SSL" when FTP over SSL is activated. This is only -interesting if \fICURLOPT_USE_SSL(3)\fP is also set. - -Possible \fIorder\fP values: -.IP CURLFTPAUTH_DEFAULT -Allow libcurl to decide. -.IP CURLFTPAUTH_SSL -Try "AUTH SSL" first, and only if that fails try "AUTH TLS". -.IP CURLFTPAUTH_TLS -Try "AUTH TLS" first, and only if that fails try "AUTH SSL". -.SH DEFAULT -CURLFTPAUTH_DEFAULT -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY); - /* funny server, ask for SSL before TLS */ - curl_easy_setopt(curl, CURLOPT_FTPSSLAUTH, (long)CURLFTPAUTH_SSL); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_USE_SSL (3), -.BR CURLOPT_FTP_SSL_CCC (3) diff --git a/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.md b/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.md new file mode 100644 index 000000000..a6ddf2f7a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTPSSLAUTH.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTPSSLAUTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_SSL_CCC (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_FTPSSLAUTH - order in which to attempt TLS vs SSL + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPSSLAUTH, long order); +~~~ + +# DESCRIPTION + +Pass a long using one of the values from below, to alter how libcurl issues +"AUTH TLS" or "AUTH SSL" when FTP over SSL is activated. This is only +interesting if CURLOPT_USE_SSL(3) is also set. + +Possible *order* values: + +## CURLFTPAUTH_DEFAULT + +Allow libcurl to decide. + +## CURLFTPAUTH_SSL + +Try "AUTH SSL" first, and only if that fails try "AUTH TLS". + +## CURLFTPAUTH_TLS + +Try "AUTH TLS" first, and only if that fails try "AUTH SSL". + +# DEFAULT + +CURLFTPAUTH_DEFAULT + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY); + /* funny server, ask for SSL before TLS */ + curl_easy_setopt(curl, CURLOPT_FTPSSLAUTH, (long)CURLFTPAUTH_SSL); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.12.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.3 b/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.3 deleted file mode 100644 index 0b0513c5c..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_ACCOUNT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_ACCOUNT \- account info for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_ACCOUNT, char *account); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string (or NULL to disable). When an FTP -server asks for "account data" after user name and password has been provided, -this data is sent off using the ACCT command. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - - curl_easy_setopt(curl, CURLOPT_FTP_ACCOUNT, "human-resources"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.13.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.md b/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.md new file mode 100644 index 000000000..f8941953b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_ACCOUNT.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_ACCOUNT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PASSWORD (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_FTP_ACCOUNT - account info for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_ACCOUNT, char *account); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string (or NULL to disable). When an FTP +server asks for "account data" after user name and password has been provided, +this data is sent off using the ACCT command. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + + curl_easy_setopt(curl, CURLOPT_FTP_ACCOUNT, "human-resources"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.13.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.3 b/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.3 deleted file mode 100644 index d89a13ac6..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_ALTERNATIVE_TO_USER 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_ALTERNATIVE_TO_USER \- command to use instead of USER with FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_ALTERNATIVE_TO_USER, - char *cmd); -.SH DESCRIPTION -Pass a char * as parameter, pointing to a string which is used to authenticate -if the usual FTP "USER user" and "PASS password" negotiation fails. This is -currently only known to be required when connecting to Tumbleweed's Secure -Transport FTPS server using client certificates for authentication. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER, "two users"); - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.5 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_FTP_ACCOUNT (3), -.BR CURLOPT_FTP_SKIP_PASV_IP (3), -.BR CURLOPT_SERVER_RESPONSE_TIMEOUT (3), -.BR CURLOPT_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.md b/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.md new file mode 100644 index 000000000..70f451d84 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_ALTERNATIVE_TO_USER.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_ALTERNATIVE_TO_USER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_ACCOUNT (3) + - CURLOPT_FTP_SKIP_PASV_IP (3) + - CURLOPT_SERVER_RESPONSE_TIMEOUT (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_FTP_ALTERNATIVE_TO_USER - command to use instead of USER with FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_ALTERNATIVE_TO_USER, + char *cmd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, pointing to a string which is used to +authenticate if the usual FTP "USER user" and "PASS password" negotiation +fails. This is currently only known to be required when connecting to +Tumbleweed's Secure Transport FTPS server using client certificates for +authentication. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_FTP_ALTERNATIVE_TO_USER, "two users"); + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.5 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.3 b/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.3 deleted file mode 100644 index 4d4142967..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_CREATE_MISSING_DIRS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_CREATE_MISSING_DIRS \- create missing directories for FTP and SFTP -.SH SYNOPSIS -.nf -#include - -typedef enum { - CURLFTP_CREATE_DIR_NONE, - CURLFTP_CREATE_DIR, - CURLFTP_CREATE_DIR_RETRY -} curl_ftpcreatedir; - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_CREATE_MISSING_DIRS, - long create); -.SH DESCRIPTION -Pass a long telling libcurl to \fIcreate\fP the dir. If the value is -\fICURLFTP_CREATE_DIR\fP (1), libcurl may create any remote directory that it -fails to "move" into. - -For FTP requests, that means a CWD command fails. CWD being the command that -changes working directory. - -For SFTP requests, libcurl may create the remote directory if it cannot obtain -a handle to the target-location. The creation fails if a file of the same name -as the directory to create already exists or lack of permissions prevents -creation. - -Setting \fIcreate\fP to \fICURLFTP_CREATE_DIR_RETRY\fP (2), tells libcurl to -retry the CWD command again if the subsequent \fBMKD\fP command fails. This is -especially useful if you are doing many simultaneous connections against the -same server and they all have this option enabled, as then CWD may first fail -but then another connection does \fBMKD\fP before this connection and thus -\fBMKD\fP fails but trying CWD works! -.SH DEFAULT -CURLFTP_CREATE_DIR_NONE (0) -.SH PROTOCOLS -FTP and SFTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/non-existing/new.txt"); - curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, - (long)CURLFTP_CREATE_DIR_RETRY); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.7. SFTP support added in 7.16.3. The retry option was added in -7.19.4. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the -create value is not. -.SH "SEE ALSO" -.BR CURLOPT_FTP_FILEMETHOD (3), -.BR CURLOPT_FTP_USE_EPSV (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.md b/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.md new file mode 100644 index 000000000..07b6f68fd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_CREATE_MISSING_DIRS.md @@ -0,0 +1,88 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_CREATE_MISSING_DIRS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_FILEMETHOD (3) + - CURLOPT_FTP_USE_EPSV (3) +--- + +# NAME + +CURLOPT_FTP_CREATE_MISSING_DIRS - create missing directories for FTP and SFTP + +# SYNOPSIS + +~~~c +#include + +typedef enum { + CURLFTP_CREATE_DIR_NONE, + CURLFTP_CREATE_DIR, + CURLFTP_CREATE_DIR_RETRY +} curl_ftpcreatedir; + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_CREATE_MISSING_DIRS, + long create); +~~~ + +# DESCRIPTION + +Pass a long telling libcurl to *create* the dir. If the value is +*CURLFTP_CREATE_DIR* (1), libcurl may create any remote directory that it +fails to "move" into. + +For FTP requests, that means a CWD command fails. CWD being the command that +changes working directory. + +For SFTP requests, libcurl may create the remote directory if it cannot obtain +a handle to the target-location. The creation fails if a file of the same name +as the directory to create already exists or lack of permissions prevents +creation. + +Setting *create* to *CURLFTP_CREATE_DIR_RETRY* (2), tells libcurl to +retry the CWD command again if the subsequent **MKD** command fails. This is +especially useful if you are doing many simultaneous connections against the +same server and they all have this option enabled, as then CWD may first fail +but then another connection does **MKD** before this connection and thus +**MKD** fails but trying CWD works! + +# DEFAULT + +CURLFTP_CREATE_DIR_NONE (0) + +# PROTOCOLS + +FTP and SFTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/non-existing/new.txt"); + curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, + (long)CURLFTP_CREATE_DIR_RETRY); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.7. SFTP support added in 7.16.3. The retry option was added in +7.19.4. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the +create value is not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.3 b/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.3 deleted file mode 100644 index afd3a00da..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_FILEMETHOD 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_FILEMETHOD \- select directory traversing method for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_FILEMETHOD, - long method); -.SH DESCRIPTION -Pass a long telling libcurl which \fImethod\fP to use to reach a file on a -FTP(S) server. - -This option exists because some server implementations are not compliant to -what the standards say should work. - -The argument should be one of the following alternatives: -.IP CURLFTPMETHOD_MULTICWD -libcurl does a single CWD operation for each path part in the given URL. For -deep hierarchies this means many commands. This is how RFC 1738 says it should -be done. This is the default but the slowest behavior. -.IP CURLFTPMETHOD_NOCWD -libcurl makes no CWD at all. libcurl does SIZE, RETR, STOR etc and gives a -full path to the server for all these commands. This is the fastest behavior -since it skips having to change directories. -.IP CURLFTPMETHOD_SINGLECWD -libcurl does one CWD with the full target directory and then operates on the -file \&"normally" (like in the multicwd case). This is somewhat more standards -compliant than 'nocwd' but without the full penalty of 'multicwd'. -.SH DEFAULT -CURLFTPMETHOD_MULTICWD -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt"); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, - (long)CURLFTPMETHOD_SINGLECWD); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DIRLISTONLY (3), -.BR CURLOPT_FTP_SKIP_PASV_IP (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md b/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md new file mode 100644 index 000000000..34b55d659 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_FILEMETHOD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DIRLISTONLY (3) + - CURLOPT_FTP_SKIP_PASV_IP (3) +--- + +# NAME + +CURLOPT_FTP_FILEMETHOD - select directory traversing method for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_FILEMETHOD, + long method); +~~~ + +# DESCRIPTION + +Pass a long telling libcurl which *method* to use to reach a file on a +FTP(S) server. + +This option exists because some server implementations are not compliant to +what the standards say should work. + +The argument should be one of the following alternatives: + +## CURLFTPMETHOD_MULTICWD + +libcurl does a single CWD operation for each path part in the given URL. For +deep hierarchies this means many commands. This is how RFC 1738 says it should +be done. This is the default but the slowest behavior. + +## CURLFTPMETHOD_NOCWD + +libcurl makes no CWD at all. libcurl does SIZE, RETR, STOR etc and gives a +full path to the server for all these commands. This is the fastest behavior +since it skips having to change directories. + +## CURLFTPMETHOD_SINGLECWD + +libcurl does one CWD with the full target directory and then operates on the +file &"normally" (like in the multicwd case). This is somewhat more standards +compliant than 'nocwd' but without the full penalty of 'multicwd'. + +# DEFAULT + +CURLFTPMETHOD_MULTICWD + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt"); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, + (long)CURLFTPMETHOD_SINGLECWD); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.3 b/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.3 deleted file mode 100644 index 9b6453bdc..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_SKIP_PASV_IP 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_SKIP_PASV_IP \- ignore the IP address in the PASV response -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_SKIP_PASV_IP, long skip); -.fi -.SH DESCRIPTION -Pass a long. If \fIskip\fP is set to 1, it instructs libcurl to not use the IP -address the server suggests in its 227-response to libcurl's PASV command when -libcurl connects the data connection. Instead libcurl reuses the same IP -address it already uses for the control connection. It still uses the port -number from the 227-response. - -This option allows libcurl to work around broken server installations or funny -network setups that due to NATs, firewalls or incompetence report the wrong IP -address. Setting this option also reduces the risk for various sorts of client -abuse by malicious servers. - -This option has no effect if PORT, EPRT or EPSV is used instead of PASV. -.SH DEFAULT -1 since 7.74.0, was 0 before then. -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); - - /* please ignore the IP in the PASV response */ - curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L); - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.14.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FTPPORT (3), -.BR CURLOPT_FTP_USE_EPRT (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.md b/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.md new file mode 100644 index 000000000..bea622ac7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_SKIP_PASV_IP.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_SKIP_PASV_IP +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTPPORT (3) + - CURLOPT_FTP_USE_EPRT (3) +--- + +# NAME + +CURLOPT_FTP_SKIP_PASV_IP - ignore the IP address in the PASV response + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_SKIP_PASV_IP, long skip); +~~~ + +# DESCRIPTION + +Pass a long. If *skip* is set to 1, it instructs libcurl to not use the IP +address the server suggests in its 227-response to libcurl's PASV command when +libcurl connects the data connection. Instead libcurl reuses the same IP +address it already uses for the control connection. It still uses the port +number from the 227-response. + +This option allows libcurl to work around broken server installations or funny +network setups that due to NATs, firewalls or incompetence report the wrong IP +address. Setting this option also reduces the risk for various sorts of client +abuse by malicious servers. + +This option has no effect if PORT, EPRT or EPSV is used instead of PASV. + +# DEFAULT + +1 since 7.74.0, was 0 before then. + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); + + /* please ignore the IP in the PASV response */ + curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L); + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.14.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.3 b/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.3 deleted file mode 100644 index a8d39881c..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_SSL_CCC 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_SSL_CCC \- switch off SSL again with FTP after auth -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_SSL_CCC, - long how); -.fi -.SH DESCRIPTION -If enabled, this option makes libcurl use CCC (Clear Command Channel). It -shuts down the SSL/TLS layer after authenticating. The rest of the control -channel communication remains unencrypted. This allows NAT routers to follow -the FTP transaction. Pass a long using one of the values below -.IP CURLFTPSSL_CCC_NONE -do not attempt to use CCC. -.IP CURLFTPSSL_CCC_PASSIVE -Do not initiate the shutdown, but wait for the server to do it. Do not send a -reply. -.IP CURLFTPSSL_CCC_ACTIVE -Initiate the shutdown and wait for a reply. -.SH DEFAULT -CURLFTPSSL_CCC_NONE -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_CONTROL); - /* go back to clear-text FTP after authenticating */ - curl_easy_setopt(curl, CURLOPT_FTP_SSL_CCC, (long)CURLFTPSSL_CCC_ACTIVE); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FTPSSLAUTH (3), -.BR CURLOPT_PROTOCOLS_STR (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.md b/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.md new file mode 100644 index 000000000..71947c36e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_SSL_CCC.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_SSL_CCC +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTPSSLAUTH (3) + - CURLOPT_PROTOCOLS_STR (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_FTP_SSL_CCC - switch off SSL again with FTP after auth + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_SSL_CCC, + long how); +~~~ + +# DESCRIPTION + +If enabled, this option makes libcurl use CCC (Clear Command Channel). It +shuts down the SSL/TLS layer after authenticating. The rest of the control +channel communication remains unencrypted. This allows NAT routers to follow +the FTP transaction. Pass a long using one of the values below + +## CURLFTPSSL_CCC_NONE + +do not attempt to use CCC. + +## CURLFTPSSL_CCC_PASSIVE + +Do not initiate the shutdown, but wait for the server to do it. Do not send a +reply. + +## CURLFTPSSL_CCC_ACTIVE + +Initiate the shutdown and wait for a reply. + +# DEFAULT + +CURLFTPSSL_CCC_NONE + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_CONTROL); + /* go back to clear-text FTP after authenticating */ + curl_easy_setopt(curl, CURLOPT_FTP_SSL_CCC, (long)CURLFTPSSL_CCC_ACTIVE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.3 b/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.3 deleted file mode 100644 index 8731bd6c5..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_USE_EPRT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_USE_EPRT \- use EPRT for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPRT, long enabled); -.fi -.SH DESCRIPTION -Pass a long. If the value is 1, it tells curl to use the EPRT command when -doing active FTP downloads (which is enabled by -\fICURLOPT_FTPPORT(3)\fP). Using EPRT means that libcurl first attempts to use -EPRT before using PORT, but if you pass zero to this option, it avoids using -EPRT, only plain PORT. - -The EPRT command is a slightly newer addition to the FTP protocol than PORT -and is the preferred command to use since it enables IPv6 to be used. Very old -FTP servers might not support it, which is why libcurl has a fallback -mechanism. Sometimes that fallback is not enough and then this option might -come handy. - -If the server is an IPv6 host, this option has no effect as EPRT is necessary -then. -.SH DEFAULT -.SH PROTOCOLS -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); - - /* contact us back, aka "active" FTP */ - curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); - - /* FTP the way the neanderthals did it */ - curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.5 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_FTP_USE_EPSV (3), -.BR CURLOPT_FTPPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.md b/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.md new file mode 100644 index 000000000..644f51aa9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_USE_EPRT.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_USE_EPRT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTPPORT (3) + - CURLOPT_FTP_USE_EPSV (3) +--- + +# NAME + +CURLOPT_FTP_USE_EPRT - use EPRT for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPRT, long enabled); +~~~ + +# DESCRIPTION + +Pass a long. If the value is 1, it tells curl to use the EPRT command when +doing active FTP downloads (which is enabled by +CURLOPT_FTPPORT(3)). Using EPRT means that libcurl first attempts to use +EPRT before using PORT, but if you pass zero to this option, it avoids using +EPRT, only plain PORT. + +The EPRT command is a slightly newer addition to the FTP protocol than PORT +and is the preferred command to use since it enables IPv6 to be used. Old FTP +servers might not support it, which is why libcurl has a fallback mechanism. +Sometimes that fallback is not enough and then this option might come handy. + +If the server is an IPv6 host, this option has no effect as EPRT is necessary +then. + +# DEFAULT + +# PROTOCOLS + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); + + /* contact us back, aka "active" FTP */ + curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); + + /* FTP the way the neanderthals did it */ + curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.5 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.3 b/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.3 deleted file mode 100644 index af5d4ace9..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_USE_EPSV 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_USE_EPSV \- use EPSV for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPSV, long epsv); -.fi -.SH DESCRIPTION -Pass \fIepsv\fP as a long. If the value is 1, it tells curl to use the EPSV -command when doing passive FTP downloads (which it does by default). Using -EPSV means that libcurl first attempts to use the EPSV command before using -PASV. If you pass zero to this option, it does not use EPSV, only plain PASV. - -The EPSV command is a slightly newer addition to the FTP protocol than PASV -and is the preferred command to use since it enables IPv6 to be used. Very old -FTP servers might not support it, which is why libcurl has a fallback -mechanism. Sometimes that fallback is not enough and then this option might -come handy. - -If the server is an IPv6 host, this option has no effect. -.SH DEFAULT -1 -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/old-server/file.txt"); - - /* let's shut off this modern feature */ - curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with FTP -.SH RETURN VALUE -Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FTP_USE_EPRT (3), -.BR CURLOPT_FTPPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.md b/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.md new file mode 100644 index 000000000..985ca8ba3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_USE_EPSV.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_USE_EPSV +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTPPORT (3) + - CURLOPT_FTP_USE_EPRT (3) +--- + +# NAME + +CURLOPT_FTP_USE_EPSV - use EPSV for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_EPSV, long epsv); +~~~ + +# DESCRIPTION + +Pass *epsv* as a long. If the value is 1, it tells curl to use the EPSV +command when doing passive FTP downloads (which it does by default). Using +EPSV means that libcurl first attempts to use the EPSV command before using +PASV. If you pass zero to this option, it does not use EPSV, only plain PASV. + +The EPSV command is a slightly newer addition to the FTP protocol than PASV +and is the preferred command to use since it enables IPv6 to be used. Old FTP +servers might not support it, which is why libcurl has a fallback mechanism. +Sometimes that fallback is not enough and then this option might come handy. + +If the server is an IPv6 host, this option has no effect. + +# DEFAULT + +1 + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/old-server/file.txt"); + + /* let's shut off this modern feature */ + curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with FTP + +# RETURN VALUE + +Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.3 b/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.3 deleted file mode 100644 index c4538bda8..000000000 --- a/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_FTP_USE_PRET 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_FTP_USE_PRET \- use PRET for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_PRET, long enable); -.fi -.SH DESCRIPTION -Pass a long. If the value is 1, it tells curl to send a PRET command before -PASV (and EPSV). Certain FTP servers, mainly drftpd, require this non-standard -command for directory listings as well as up and downloads in PASV mode. Has -no effect when using the active FTP transfers mode. -.SH DEFAULT -0 -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/old-server/file.txt"); - - /* a drftpd server, do it! */ - curl_easy_setopt(curl, CURLOPT_FTP_USE_PRET, 1L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FTP_USE_EPRT (3), -.BR CURLOPT_FTP_USE_EPSV (3) diff --git a/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.md b/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.md new file mode 100644 index 000000000..f81ca4cf0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_FTP_USE_PRET.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_FTP_USE_PRET +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_USE_EPRT (3) + - CURLOPT_FTP_USE_EPSV (3) +--- + +# NAME + +CURLOPT_FTP_USE_PRET - use PRET for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_PRET, long enable); +~~~ + +# DESCRIPTION + +Pass a long. If the value is 1, it tells curl to send a PRET command before +PASV (and EPSV). Certain FTP servers, mainly drftpd, require this non-standard +command for directory listings as well as up and downloads in PASV mode. Has +no effect when using the active FTP transfers mode. + +# DEFAULT + +0 + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/old-server/file.txt"); + + /* a drftpd server, do it! */ + curl_easy_setopt(curl, CURLOPT_FTP_USE_PRET, 1L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.3 b/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.3 deleted file mode 100644 index 2a711b8fa..000000000 --- a/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_GSSAPI_DELEGATION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_GSSAPI_DELEGATION \- allowed GSS-API delegation -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_GSSAPI_DELEGATION, long level); -.fi -.SH DESCRIPTION -Set the long parameter \fIlevel\fP to \fBCURLGSSAPI_DELEGATION_FLAG\fP to -allow unconditional GSSAPI credential delegation. The delegation is disabled -by default since 7.21.7. Set the parameter to -\fBCURLGSSAPI_DELEGATION_POLICY_FLAG\fP to delegate only if the OK-AS-DELEGATE -flag is set in the service ticket in case this feature is supported by the -GSS-API implementation and the definition of \fIGSS_C_DELEG_POLICY_FLAG\fP was -available at compile-time. -.SH DEFAULT -CURLGSSAPI_DELEGATION_NONE -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* delegate if okayed by policy */ - curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION, - (long)CURLGSSAPI_DELEGATION_POLICY_FLAG); - ret = curl_easy_perform(curl); - } -} -.fi - -.SH AVAILABILITY -Added in 7.22.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PROXYAUTH (3) diff --git a/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.md b/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.md new file mode 100644 index 000000000..01c1d5062 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_GSSAPI_DELEGATION.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_GSSAPI_DELEGATION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PROXYAUTH (3) +--- + +# NAME + +CURLOPT_GSSAPI_DELEGATION - allowed GSS-API delegation + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_GSSAPI_DELEGATION, long level); +~~~ + +# DESCRIPTION + +Set the long parameter *level* to **CURLGSSAPI_DELEGATION_FLAG** to allow +unconditional GSSAPI credential delegation. The delegation is disabled by +default since 7.21.7. Set the parameter to +**CURLGSSAPI_DELEGATION_POLICY_FLAG** to delegate only if the OK-AS-DELEGATE +flag is set in the service ticket in case this feature is supported by the +GSS-API implementation and the definition of *GSS_C_DELEG_POLICY_FLAG* was +available at compile-time. + +# DEFAULT + +CURLGSSAPI_DELEGATION_NONE + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* delegate if okayed by policy */ + curl_easy_setopt(curl, CURLOPT_GSSAPI_DELEGATION, + (long)CURLGSSAPI_DELEGATION_POLICY_FLAG); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.22.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 b/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 deleted file mode 100644 index 5e3865f12..000000000 --- a/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS 3 "1 Feb 2018" libcurl libcurl -.SH NAME -CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS \- head start for IPv6 for happy eyeballs -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, - long timeout); -.fi -.SH DESCRIPTION -Happy eyeballs is an algorithm that attempts to connect to both IPv4 and IPv6 -addresses for dual-stack hosts, preferring IPv6 first for \fItimeout\fP -milliseconds. If the IPv6 address cannot be connected to within that time then -a connection attempt is made to the IPv4 address in parallel. The first -connection to be established is the one that is used. - -The range of suggested useful values for \fItimeout\fP is limited. Happy -Eyeballs RFC 6555 says "It is RECOMMENDED that connection attempts be paced -150-250 ms apart to balance human factors against network load." libcurl -currently defaults to 200 ms. Firefox and Chrome currently default to 300 ms. -.SH DEFAULT -CURL_HET_DEFAULT (currently defined as 200L) -.SH PROTOCOLS -All except FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 300L); - - curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.59.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH SEE ALSO -.BR CURLOPT_CONNECTTIMEOUT_MS "(3), " -.BR CURLOPT_TIMEOUT "(3), " CURLOPT_LOW_SPEED_LIMIT "(3), " diff --git a/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.md new file mode 100644 index 000000000..23299c736 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT_MS (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS - head start for IPv6 for happy eyeballs + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, + long timeout); +~~~ + +# DESCRIPTION + +Happy eyeballs is an algorithm that attempts to connect to both IPv4 and IPv6 +addresses for dual-stack hosts, preferring IPv6 first for *timeout* +milliseconds. If the IPv6 address cannot be connected to within that time then +a connection attempt is made to the IPv4 address in parallel. The first +connection to be established is the one that is used. + +The range of suggested useful values for *timeout* is limited. Happy +Eyeballs RFC 6555 says "It is RECOMMENDED that connection attempts be paced +150-250 ms apart to balance human factors against network load." libcurl +currently defaults to 200 ms. Firefox and Chrome currently default to 300 ms. + +# DEFAULT + +CURL_HET_DEFAULT (currently defined as 200L) + +# PROTOCOLS + +All except FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 300L); + + curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.59.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.3 b/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.3 deleted file mode 100644 index 5c3b079d8..000000000 --- a/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HAPROXYPROTOCOL 3 "5 Feb 2018" libcurl libcurl -.SH NAME -CURLOPT_HAPROXYPROTOCOL \- send HAProxy PROXY protocol v1 header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXYPROTOCOL, - long haproxy_protocol); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to send an HAProxy PROXY -protocol v1 header at beginning of the connection. The default action is not to -send this header. - -This option is primarily useful when sending test requests to a service that -expects this header. - -Most applications do not need this option. -.SH DEFAULT -0, do not send any HAProxy PROXY protocol header -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP. Added in 7.60.0. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. -.SH SEE ALSO -.BR CURLOPT_PROXY "(3), " diff --git a/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.md b/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.md new file mode 100644 index 000000000..51eb2656c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HAPROXYPROTOCOL.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HAPROXYPROTOCOL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) +--- + +# NAME + +CURLOPT_HAPROXYPROTOCOL - send HAProxy PROXY protocol v1 header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXYPROTOCOL, + long haproxy_protocol); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to send an HAProxy PROXY +protocol v1 header at beginning of the connection. The default action is not to +send this header. + +This option is primarily useful when sending test requests to a service that +expects this header. + +Most applications do not need this option. + +# DEFAULT + +0, do not send any HAProxy PROXY protocol header + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HAPROXYPROTOCOL, 1L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP. Added in 7.60.0. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.3 b/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.3 deleted file mode 100644 index a2c9b2ff4..000000000 --- a/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HAPROXY_CLIENT_IP 3 "8 May 2023" libcurl libcurl -.SH NAME -CURLOPT_HAPROXY_CLIENT_IP \- set HAProxy PROXY protocol client IP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXY_CLIENT_IP, - char *client_ip); -.fi -.SH DESCRIPTION -When this parameter is set to a valid IPv4 or IPv6 numerical address, the -library sends this address as client address in the HAProxy PROXY protocol v1 -header at beginning of the connection. - -This option is an alternative to \fICURLOPT_HAPROXYPROTOCOL(3)\fP as that one -cannot use a specified address. -.SH DEFAULT -NULL, no HAProxy header is sent -.SH PROTOCOLS -HTTP, HAProxy PROTOCOL -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HAPROXY_CLIENT_IP, "1.1.1.1"); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP. Added in 8.2.0. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. -.SH SEE ALSO -.BR CURLOPT_PROXY "(3), " -.BR CURLOPT_HAPROXYPROTOCOL "(3), " diff --git a/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.md b/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.md new file mode 100644 index 000000000..ac0da3a1c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HAPROXY_CLIENT_IP.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HAPROXY_CLIENT_IP +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HAPROXYPROTOCOL (3) + - CURLOPT_PROXY (3) +--- + +# NAME + +CURLOPT_HAPROXY_CLIENT_IP - set HAProxy PROXY protocol client IP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXY_CLIENT_IP, + char *client_ip); +~~~ + +# DESCRIPTION + +When this parameter is set to a valid IPv4 or IPv6 numerical address, the +library sends this address as client address in the HAProxy PROXY protocol v1 +header at beginning of the connection. + +This option is an alternative to CURLOPT_HAPROXYPROTOCOL(3) as that one +cannot use a specified address. + +# DEFAULT + +NULL, no HAProxy header is sent + +# PROTOCOLS + +HTTP, HAProxy PROTOCOL + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HAPROXY_CLIENT_IP, "1.1.1.1"); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP. Added in 8.2.0. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HEADER.3 b/docs/libcurl/opts/CURLOPT_HEADER.3 deleted file mode 100644 index 193cdf1a5..000000000 --- a/docs/libcurl/opts/CURLOPT_HEADER.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HEADER 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HEADER \- pass headers to the data stream -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff); -.fi -.SH DESCRIPTION -Pass the long value \fIonoff\fP set to 1 to ask libcurl to include the headers -in the write callback (\fICURLOPT_WRITEFUNCTION(3)\fP). This option is -relevant for protocols that actually have headers or other meta-data (like -HTTP and FTP). - -When asking to get the headers passed to the same callback as the body, it is -not possible to accurately separate them again without detailed knowledge -about the protocol in use. - -Further: the \fICURLOPT_WRITEFUNCTION(3)\fP callback is limited to only ever -get a maximum of \fICURL_MAX_WRITE_SIZE\fP bytes passed to it (16KB), while a -header can be longer and the \fICURLOPT_HEADERFUNCTION(3)\fP supports getting -called with headers up to \fICURL_MAX_HTTP_HEADER\fP bytes big (100KB). - -It is often better to use \fICURLOPT_HEADERFUNCTION(3)\fP to get the header -data separately. - -While named confusingly similar, \fICURLOPT_HTTPHEADER(3)\fP is used to set -custom HTTP headers! -.SH DEFAULT -0 -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Provided in all libcurl versions. -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HEADERFUNCTION (3), -.BR CURLOPT_HTTPHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_HEADER.md b/docs/libcurl/opts/CURLOPT_HEADER.md new file mode 100644 index 000000000..d5e272ac5 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HEADER.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HEADER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERFUNCTION (3) + - CURLOPT_HTTPHEADER (3) +--- + +# NAME + +CURLOPT_HEADER - pass headers to the data stream + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff); +~~~ + +# DESCRIPTION + +Pass the long value *onoff* set to 1 to ask libcurl to include the headers +in the write callback (CURLOPT_WRITEFUNCTION(3)). This option is +relevant for protocols that actually have headers or other meta-data (like +HTTP and FTP). + +When asking to get the headers passed to the same callback as the body, it is +not possible to accurately separate them again without detailed knowledge +about the protocol in use. + +Further: the CURLOPT_WRITEFUNCTION(3) callback is limited to only ever +get a maximum of *CURL_MAX_WRITE_SIZE* bytes passed to it (16KB), while a +header can be longer and the CURLOPT_HEADERFUNCTION(3) supports getting +called with headers up to *CURL_MAX_HTTP_HEADER* bytes big (100KB). + +It is often better to use CURLOPT_HEADERFUNCTION(3) to get the header +data separately. + +While named confusingly similar, CURLOPT_HTTPHEADER(3) is used to set +custom HTTP headers! + +# DEFAULT + +0 + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Provided in all libcurl versions. + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_HEADERDATA.3 b/docs/libcurl/opts/CURLOPT_HEADERDATA.3 deleted file mode 100644 index 20e696e49..000000000 --- a/docs/libcurl/opts/CURLOPT_HEADERDATA.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HEADERDATA 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HEADERDATA \- pointer to pass to header callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP to be used to write the header part of the received data -to. - -If \fICURLOPT_WRITEFUNCTION(3)\fP or \fICURLOPT_HEADERFUNCTION(3)\fP is used, -\fIpointer\fP is passed in to the respective callback. - -If neither of those options are set, \fIpointer\fP must be a valid FILE * and -it is used by a plain fwrite() to write headers to. - -If you are using libcurl as a win32 DLL, you \fBMUST\fP use a -\fICURLOPT_WRITEFUNCTION(3)\fP or \fICURLOPT_HEADERFUNCTION(3)\fP if you set -this option or you might experience crashes. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct my_info { - int shoesize; - char *secret; -}; - -static size_t header_callback(char *buffer, size_t size, - size_t nitems, void *userdata) -{ - struct my_info *i = userdata; - printf("shoe size: %d\\n", i->shoesize); - /* now this callback can access the my_info struct */ - - return nitems * size; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct my_info my = { 10, "the cookies are in the cupboard" }; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); - - /* pass in custom data to the callback */ - curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR curl_easy_header (3), -.BR CURLOPT_HEADERFUNCTION (3), -.BR CURLOPT_WRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HEADERDATA.md b/docs/libcurl/opts/CURLOPT_HEADERDATA.md new file mode 100644 index 000000000..7f056361f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HEADERDATA.md @@ -0,0 +1,89 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HEADERDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERFUNCTION (3) + - CURLOPT_WRITEFUNCTION (3) + - curl_easy_header (3) +--- + +# NAME + +CURLOPT_HEADERDATA - pointer to pass to header callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* to be used to write the header part of the received data +to. + +If CURLOPT_WRITEFUNCTION(3) or CURLOPT_HEADERFUNCTION(3) is used, +*pointer* is passed in to the respective callback. + +If neither of those options are set, *pointer* must be a valid FILE * and +it is used by a plain fwrite() to write headers to. + +If you are using libcurl as a win32 DLL, you **MUST** use a +CURLOPT_WRITEFUNCTION(3) or CURLOPT_HEADERFUNCTION(3) if you set +this option or you might experience crashes. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct my_info { + int shoesize; + char *secret; +}; + +static size_t header_callback(char *buffer, size_t size, + size_t nitems, void *userdata) +{ + struct my_info *i = userdata; + printf("shoe size: %d\n", i->shoesize); + /* now this callback can access the my_info struct */ + + return nitems * size; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct my_info my = { 10, "the cookies are in the cupboard" }; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); + + /* pass in custom data to the callback */ + curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.3 b/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.3 deleted file mode 100644 index 03051b193..000000000 --- a/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.3 +++ /dev/null @@ -1,132 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HEADERFUNCTION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HEADERFUNCTION \- callback that receives header data -.SH SYNOPSIS -.nf -#include - -size_t header_callback(char *buffer, - size_t size, - size_t nitems, - void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERFUNCTION, - header_callback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets invoked by libcurl as soon as it has received -header data. The header callback is called once for each header and only -complete header lines are passed on to the callback. Parsing headers is easy -to do using this callback. \fIbuffer\fP points to the delivered data, and the -size of that data is \fInitems\fP; \fIsize\fP is always 1. The provide header -line is not null-terminated! - -The pointer named \fIuserdata\fP is the one you set with the -\fICURLOPT_HEADERDATA(3)\fP option. - -Your callback should return the number of bytes actually taken care of. If -that amount differs from the amount passed to your callback function, it -signals an error condition to the library. This causes the transfer to get -aborted and the libcurl function used returns \fICURLE_WRITE_ERROR\fP. - -You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0) - -A complete HTTP header that is passed to this function can be up to -\fICURL_MAX_HTTP_HEADER\fP (100K) bytes and includes the final line terminator. - -If this option is not set, or if it is set to NULL, but -\fICURLOPT_HEADERDATA(3)\fP is set to anything but NULL, the function used to -accept response data is used instead. That is the function specified with -\fICURLOPT_WRITEFUNCTION(3)\fP, or if it is not specified or NULL - the -default, stream-writing function. - -It's important to note that the callback is invoked for the headers of all -responses received after initiating a request and not just the final -response. This includes all responses which occur during authentication -negotiation. If you need to operate on only the headers from the final -response, you need to collect headers in the callback yourself and use HTTP -status lines, for example, to delimit response boundaries. - -For an HTTP transfer, the status line and the blank line preceding the response -body are both included as headers and passed to this function. - -When a server sends a chunked encoded transfer, it may contain a trailer. That -trailer is identical to an HTTP header and if such a trailer is received it is -passed to the application using this callback as well. There are several ways -to detect it being a trailer and not an ordinary header: 1) it comes after the -response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: -header among the regular response-headers mention what header(s) to expect in -the trailer. - -For non-HTTP protocols like FTP, POP3, IMAP and SMTP this function gets called -with the server responses to the commands that libcurl sends. - -A more convenient way to get HTTP headers might be to use -\fIcurl_easy_header(3)\fP. -.SH LIMITATIONS -libcurl does not unfold HTTP "folded headers" (deprecated since RFC 7230). A -folded header is a header that continues on a subsequent line and starts with -a whitespace. Such folds are passed to the header callback as separate ones, -although strictly they are just continuations of the previous lines. -.SH DEFAULT -Nothing. -.SH PROTOCOLS -Used for all protocols with headers or meta-data concept: HTTP, FTP, POP3, -IMAP, SMTP and more. -.SH EXAMPLE -.nf -static size_t header_callback(char *buffer, size_t size, - size_t nitems, void *userdata) -{ - /* received header is nitems * size long in 'buffer' NOT ZERO TERMINATED */ - /* 'userdata' is set with CURLOPT_HEADERDATA */ - return nitems * size; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR curl_easy_header (3), -.BR CURLOPT_HEADERDATA (3), -.BR CURLOPT_WRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.md b/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.md new file mode 100644 index 000000000..eb14cdd6f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HEADERFUNCTION.md @@ -0,0 +1,132 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HEADERFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERDATA (3) + - CURLOPT_WRITEFUNCTION (3) + - curl_easy_header (3) +--- + +# NAME + +CURLOPT_HEADERFUNCTION - callback that receives header data + +# SYNOPSIS + +~~~c +#include + +size_t header_callback(char *buffer, + size_t size, + size_t nitems, + void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERFUNCTION, + header_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets invoked by libcurl as soon as it has received +header data. The header callback is called once for each header and only +complete header lines are passed on to the callback. Parsing headers is easy +to do using this callback. *buffer* points to the delivered data, and the +size of that data is *nitems*; *size* is always 1. The provide header +line is not null-terminated! + +The pointer named *userdata* is the one you set with the +CURLOPT_HEADERDATA(3) option. + +Your callback should return the number of bytes actually taken care of. If +that amount differs from the amount passed to your callback function, it +signals an error condition to the library. This causes the transfer to get +aborted and the libcurl function used returns *CURLE_WRITE_ERROR*. + +You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0) + +A complete HTTP header that is passed to this function can be up to +*CURL_MAX_HTTP_HEADER* (100K) bytes and includes the final line terminator. + +If this option is not set, or if it is set to NULL, but +CURLOPT_HEADERDATA(3) is set to anything but NULL, the function used to +accept response data is used instead. That is the function specified with +CURLOPT_WRITEFUNCTION(3), or if it is not specified or NULL - the +default, stream-writing function. + +It is important to note that the callback is invoked for the headers of all +responses received after initiating a request and not just the final +response. This includes all responses which occur during authentication +negotiation. If you need to operate on only the headers from the final +response, you need to collect headers in the callback yourself and use HTTP +status lines, for example, to delimit response boundaries. + +For an HTTP transfer, the status line and the blank line preceding the response +body are both included as headers and passed to this function. + +When a server sends a chunked encoded transfer, it may contain a trailer. That +trailer is identical to an HTTP header and if such a trailer is received it is +passed to the application using this callback as well. There are several ways +to detect it being a trailer and not an ordinary header: 1) it comes after the +response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: +header among the regular response-headers mention what header(s) to expect in +the trailer. + +For non-HTTP protocols like FTP, POP3, IMAP and SMTP this function gets called +with the server responses to the commands that libcurl sends. + +A more convenient way to get HTTP headers might be to use +curl_easy_header(3). + +# LIMITATIONS + +libcurl does not unfold HTTP "folded headers" (deprecated since RFC 7230). A +folded header is a header that continues on a subsequent line and starts with +a whitespace. Such folds are passed to the header callback as separate ones, +although strictly they are just continuations of the previous lines. + +# DEFAULT + +Nothing. + +# PROTOCOLS + +Used for all protocols with headers or meta-data concept: HTTP, FTP, POP3, +IMAP, SMTP and more. + +# EXAMPLE + +~~~c +static size_t header_callback(char *buffer, size_t size, + size_t nitems, void *userdata) +{ + /* received header is nitems * size long in 'buffer' NOT ZERO TERMINATED */ + /* 'userdata' is set with CURLOPT_HEADERDATA */ + return nitems * size; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_HEADEROPT.3 b/docs/libcurl/opts/CURLOPT_HEADEROPT.3 deleted file mode 100644 index 000f2035f..000000000 --- a/docs/libcurl/opts/CURLOPT_HEADEROPT.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HEADEROPT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HEADEROPT \- send HTTP headers to both proxy and host or separately -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long bitmask); -.fi -.SH DESCRIPTION -Pass a long that is a bitmask of options of how to deal with headers. The two -mutually exclusive options are: - -\fBCURLHEADER_UNIFIED\fP - the headers specified in -\fICURLOPT_HTTPHEADER(3)\fP are used in requests both to servers and -proxies. With this option enabled, \fICURLOPT_PROXYHEADER(3)\fP does not have -any effect. - -\fBCURLHEADER_SEPARATE\fP - makes \fICURLOPT_HTTPHEADER(3)\fP headers only get -sent to a server and not to a proxy. Proxy headers must be set with -\fICURLOPT_PROXYHEADER(3)\fP to get used. Note that if a non-CONNECT request -is sent to a proxy, libcurl sends both server headers and proxy headers. When -doing CONNECT, libcurl sends \fICURLOPT_PROXYHEADER(3)\fP headers only to the -proxy and then \fICURLOPT_HTTPHEADER(3)\fP headers only to the server. -.SH DEFAULT -CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then) -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - struct curl_slist *list; - list = curl_slist_append(NULL, "Shoesize: 10"); - list = curl_slist_append(list, "Accept:"); - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); - - /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell - libcurl to not send the custom headers to the proxy. Keep them - separate! */ - curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE); - ret = curl_easy_perform(curl); - curl_slist_free_all(list); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.37.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_PROXYHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_HEADEROPT.md b/docs/libcurl/opts/CURLOPT_HEADEROPT.md new file mode 100644 index 000000000..bb3bcf41c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HEADEROPT.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HEADEROPT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPHEADER (3) + - CURLOPT_PROXYHEADER (3) +--- + +# NAME + +CURLOPT_HEADEROPT - send HTTP headers to both proxy and host or separately + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADEROPT, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long that is a bitmask of options of how to deal with headers. The two +mutually exclusive options are: + +**CURLHEADER_UNIFIED** - the headers specified in +CURLOPT_HTTPHEADER(3) are used in requests both to servers and +proxies. With this option enabled, CURLOPT_PROXYHEADER(3) does not have +any effect. + +**CURLHEADER_SEPARATE** - makes CURLOPT_HTTPHEADER(3) headers only get +sent to a server and not to a proxy. Proxy headers must be set with +CURLOPT_PROXYHEADER(3) to get used. Note that if a non-CONNECT request +is sent to a proxy, libcurl sends both server headers and proxy headers. When +doing CONNECT, libcurl sends CURLOPT_PROXYHEADER(3) headers only to the +proxy and then CURLOPT_HTTPHEADER(3) headers only to the server. + +# DEFAULT + +CURLHEADER_SEPARATE (changed in 7.42.1, used CURLHEADER_UNIFIED before then) + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + struct curl_slist *list; + list = curl_slist_append(NULL, "Shoesize: 10"); + list = curl_slist_append(list, "Accept:"); + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); + + /* HTTPS over a proxy makes a separate CONNECT to the proxy, so tell + libcurl to not send the custom headers to the proxy. Keep them + separate! */ + curl_easy_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_SEPARATE); + ret = curl_easy_perform(curl); + curl_slist_free_all(list); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.37.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HSTS.3 b/docs/libcurl/opts/CURLOPT_HSTS.3 deleted file mode 100644 index 30d3f3753..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTS.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTS 3 "5 Feb 2019" libcurl libcurl -.SH NAME -CURLOPT_HSTS \- HSTS cache file name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS, char *filename); -.fi -.SH DESCRIPTION -Make the \fIfilename\fP point to a file name to load an existing HSTS cache -from, and to store the cache in when the easy handle is closed. Setting a file -name with this option also enables HSTS for this handle (the equivalent of -setting \fICURLHSTS_ENABLE\fP with \fICURLOPT_HSTS_CTRL(3)\fP). - -If the given file does not exist or contains no HSTS entries at startup, the -HSTS cache simply starts empty. Setting the file name to NULL or "" only -enables HSTS without reading from or writing to any file. - -If this option is set multiple times, libcurl loads cache entries from each -given file but only stores the last used name for later writing. -.SH "FILE FORMAT" -The HSTS cache is saved to and loaded from a text file with one entry per -physical line. Each line in the file has the following format: - -[host] [stamp] - -[host] is the domain name for the entry and the name is dot-prefixed if it is -an entry valid for all subdomains to the name as well or only for the exact -name. - -[stamp] is the time (in UTC) when the entry expires and it uses the format -\&"YYYYMMDD HH:MM:SS". - -Lines starting with "#" are treated as comments and are ignored. There is -currently no length or size limit. -.SH DEFAULT -NULL, no file name -.SH PROTOCOLS -HTTPS and HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ALTSVC (3), -.BR CURLOPT_HSTS_CTRL (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTS.md b/docs/libcurl/opts/CURLOPT_HSTS.md new file mode 100644 index 000000000..83379f270 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTS.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ALTSVC (3) + - CURLOPT_HSTS_CTRL (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_HSTS - HSTS cache file name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS, char *filename); +~~~ + +# DESCRIPTION + +Make the *filename* point to a filename to load an existing HSTS cache +from, and to store the cache in when the easy handle is closed. Setting a file +name with this option also enables HSTS for this handle (the equivalent of +setting *CURLHSTS_ENABLE* with CURLOPT_HSTS_CTRL(3)). + +If the given file does not exist or contains no HSTS entries at startup, the +HSTS cache simply starts empty. Setting the filename to NULL or "" only +enables HSTS without reading from or writing to any file. + +If this option is set multiple times, libcurl loads cache entries from each +given file but only stores the last used name for later writing. + +# FILE FORMAT + +The HSTS cache is saved to and loaded from a text file with one entry per +physical line. Each line in the file has the following format: + +[host] [stamp] + +[host] is the domain name for the entry and the name is dot-prefixed if it is +an entry valid for all subdomains to the name as well or only for the exact +name. + +[stamp] is the time (in UTC) when the entry expires and it uses the format +"YYYYMMDD HH:MM:SS". + +Lines starting with "#" are treated as comments and are ignored. There is +currently no length or size limit. + +# DEFAULT + +NULL, no file name + +# PROTOCOLS + +HTTPS and HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_HSTS, "/home/user/.hsts-cache"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HSTSREADDATA.3 b/docs/libcurl/opts/CURLOPT_HSTSREADDATA.3 deleted file mode 100644 index 3097fbda8..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTSREADDATA.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTSREADDATA 3 "14 Sep 2020" libcurl libcurl -.SH NAME -CURLOPT_HSTSREADDATA \- pointer passed to the HSTS read callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADDATA, void *pointer); -.fi -.SH DESCRIPTION -Data \fIpointer\fP to pass to the HSTS read function. If you use the -\fICURLOPT_HSTSREADFUNCTION(3)\fP option, this is the pointer you get as input -in the 3rd argument to the callback. - -This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to -do that. -.SH DEFAULT -NULL -.SH PROTOCOLS -This feature is only used for HTTP(S) transfer. -.SH EXAMPLE -.nf -struct MyData { - void *custom; -}; - -int main(void) -{ - CURL *curl = curl_easy_init(); - struct MyData this; - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); - - /* pass pointer that gets passed in to the - CURLOPT_HSTSREADFUNCTION callback */ - curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &this); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HSTS (3), -.BR CURLOPT_HSTSREADFUNCTION (3), -.BR CURLOPT_HSTSWRITEDATA (3), -.BR CURLOPT_HSTSWRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTSREADDATA.md b/docs/libcurl/opts/CURLOPT_HSTSREADDATA.md new file mode 100644 index 000000000..8fbb888d3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTSREADDATA.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTSREADDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HSTS (3) + - CURLOPT_HSTSREADFUNCTION (3) + - CURLOPT_HSTSWRITEDATA (3) + - CURLOPT_HSTSWRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_HSTSREADDATA - pointer passed to the HSTS read callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADDATA, void *pointer); +~~~ + +# DESCRIPTION + +Data *pointer* to pass to the HSTS read function. If you use the +CURLOPT_HSTSREADFUNCTION(3) option, this is the pointer you get as input +in the 3rd argument to the callback. + +This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3) to +do that. + +# DEFAULT + +NULL + +# PROTOCOLS + +This feature is only used for HTTP(S) transfer. + +# EXAMPLE + +~~~c +struct MyData { + void *custom; +}; + +int main(void) +{ + CURL *curl = curl_easy_init(); + struct MyData this; + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); + + /* pass pointer that gets passed in to the + CURLOPT_HSTSREADFUNCTION callback */ + curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &this); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.3 b/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.3 deleted file mode 100644 index 9fcd04645..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.3 +++ /dev/null @@ -1,108 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTSREADFUNCTION 3 "14 Sep 2020" libcurl libcurl -.SH NAME -CURLOPT_HSTSREADFUNCTION \- read callback for HSTS hosts -.SH SYNOPSIS -.nf -#include - -struct curl_hstsentry { - char *name; - size_t namelen; - unsigned int includeSubDomains:1; - char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */ -}; - -CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *sts, void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADFUNCTION, hstsread); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, as the prototype shows above. - -This callback function gets called by libcurl repeatedly when it populates the -in-memory HSTS cache. - -Set the \fIclientp\fP argument with the \fICURLOPT_HSTSREADDATA(3)\fP option -or it is NULL. - -When this callback is invoked, the \fIsts\fP pointer points to a populated -struct: Copy the host name to \fIname\fP (no longer than \fInamelen\fP -bytes). Make it null-terminated. Set \fIincludeSubDomains\fP to TRUE or -FALSE. Set \fIexpire\fP to a date stamp or a zero length string for *forever* -(wrong date stamp format might cause the name to not get accepted) - -The callback should return \fICURLSTS_OK\fP if it returns a name and is -prepared to be called again (for another host) or \fICURLSTS_DONE\fP if it has -no entry to return. It can also return \fICURLSTS_FAIL\fP to signal -error. Returning \fICURLSTS_FAIL\fP stops the transfer from being performed -and make \fICURLE_ABORTED_BY_CALLBACK\fP get returned. - -This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to -do that. -.SH DEFAULT -NULL - no callback. -.SH PROTOCOLS -This feature is only used for HTTP(S) transfer. -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static CURLSTScode hsts_cb(CURL *easy, struct curl_hstsentry *sts, - void *clientp) -{ - /* populate the struct as documented */ - return CURLSTS_OK; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct priv my_stuff; - CURLcode res; - - /* set HSTS read callback */ - curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hsts_cb); - - /* pass in suitable argument to the callback */ - curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &my_stuff); - - res = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HSTS (3), -.BR CURLOPT_HSTS_CTRL (3), -.BR CURLOPT_HSTSREADDATA (3), -.BR CURLOPT_HSTSWRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.md b/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.md new file mode 100644 index 000000000..cc221638c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTSREADFUNCTION.md @@ -0,0 +1,106 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTSREADFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HSTS (3) + - CURLOPT_HSTSREADDATA (3) + - CURLOPT_HSTSWRITEFUNCTION (3) + - CURLOPT_HSTS_CTRL (3) +--- + +# NAME + +CURLOPT_HSTSREADFUNCTION - read callback for HSTS hosts + +# SYNOPSIS + +~~~c +#include + +struct curl_hstsentry { + char *name; + size_t namelen; + unsigned int includeSubDomains:1; + char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */ +}; + +CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *sts, void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSREADFUNCTION, hstsread); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, as the prototype shows above. + +This callback function gets called by libcurl repeatedly when it populates the +in-memory HSTS cache. + +Set the *clientp* argument with the CURLOPT_HSTSREADDATA(3) option +or it is NULL. + +When this callback is invoked, the *sts* pointer points to a populated +struct: Copy the hostname to *name* (no longer than *namelen* +bytes). Make it null-terminated. Set *includeSubDomains* to TRUE or +FALSE. Set *expire* to a date stamp or a zero length string for *forever* +(wrong date stamp format might cause the name to not get accepted) + +The callback should return *CURLSTS_OK* if it returns a name and is +prepared to be called again (for another host) or *CURLSTS_DONE* if it has +no entry to return. It can also return *CURLSTS_FAIL* to signal +error. Returning *CURLSTS_FAIL* stops the transfer from being performed +and make *CURLE_ABORTED_BY_CALLBACK* get returned. + +This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3) to +do that. + +# DEFAULT + +NULL - no callback. + +# PROTOCOLS + +This feature is only used for HTTP(S) transfer. + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static CURLSTScode hsts_cb(CURL *easy, struct curl_hstsentry *sts, + void *clientp) +{ + /* populate the struct as documented */ + return CURLSTS_OK; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct priv my_stuff; + CURLcode res; + + /* set HSTS read callback */ + curl_easy_setopt(curl, CURLOPT_HSTSREADFUNCTION, hsts_cb); + + /* pass in suitable argument to the callback */ + curl_easy_setopt(curl, CURLOPT_HSTSREADDATA, &my_stuff); + + res = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.3 b/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.3 deleted file mode 100644 index 04b7d383e..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTSWRITEDATA 3 "14 Sep 2020" libcurl libcurl -.SH NAME -CURLOPT_HSTSWRITEDATA \- pointer passed to the HSTS write callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEDATA, void *pointer); -.fi -.SH DESCRIPTION -Data \fIpointer\fP to pass to the HSTS write function. If you use the -\fICURLOPT_HSTSWRITEFUNCTION(3)\fP option, this is the pointer you get as -input in the fourth argument to the callback. - -This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to -do that. -.SH DEFAULT -NULL -.SH PROTOCOLS -This feature is only used for HTTP(S) transfer. -.SH EXAMPLE -.nf -struct MyData { - void *custom; -}; - -int main(void) -{ - CURL *curl = curl_easy_init(); - struct MyData this; - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); - - /* pass pointer that gets passed in to the - CURLOPT_HSTSWRITEFUNCTION callback */ - curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &this); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HSTS (3), -.BR CURLOPT_HSTSREADDATA (3), -.BR CURLOPT_HSTSREADFUNCTION (3), -.BR CURLOPT_HSTSWRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.md b/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.md new file mode 100644 index 000000000..b4486d7a3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTSWRITEDATA.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTSWRITEDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HSTS (3) + - CURLOPT_HSTSREADDATA (3) + - CURLOPT_HSTSREADFUNCTION (3) + - CURLOPT_HSTSWRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_HSTSWRITEDATA - pointer passed to the HSTS write callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEDATA, void *pointer); +~~~ + +# DESCRIPTION + +Data *pointer* to pass to the HSTS write function. If you use the +CURLOPT_HSTSWRITEFUNCTION(3) option, this is the pointer you get as +input in the fourth argument to the callback. + +This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3) to +do that. + +# DEFAULT + +NULL + +# PROTOCOLS + +This feature is only used for HTTP(S) transfer. + +# EXAMPLE + +~~~c +struct MyData { + void *custom; +}; + +int main(void) +{ + CURL *curl = curl_easy_init(); + struct MyData this; + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); + + /* pass pointer that gets passed in to the + CURLOPT_HSTSWRITEFUNCTION callback */ + curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &this); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.3 b/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.3 deleted file mode 100644 index e5b3a950b..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTSWRITEFUNCTION 3 "14 Sep 2020" libcurl libcurl -.SH NAME -CURLOPT_HSTSWRITEFUNCTION \- write callback for HSTS hosts -.SH SYNOPSIS -.nf -#include - -struct curl_hstsentry { - char *name; - size_t namelen; - unsigned int includeSubDomains:1; - char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */ -}; - -struct curl_index { - size_t index; /* the provided entry's "index" or count */ - size_t total; /* total number of entries to save */ -}; - -CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts, - struct curl_index *count, void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, as the prototype shows above. - -This callback function gets called by libcurl repeatedly to allow the -application to store the in-memory HSTS cache when libcurl is about to discard -it. - -Set the \fIclientp\fP argument with the \fICURLOPT_HSTSWRITEDATA(3)\fP option -or it is NULL. -When the callback is invoked, the \fIsts\fP pointer points to a populated -struct: Read the host name to 'name' (it is \fInamelen\fP bytes long and null -terminated. The \fIincludeSubDomains\fP field is non-zero if the entry matches -subdomains. The \fIexpire\fP string is a date stamp null-terminated string -using the syntax YYYYMMDD HH:MM:SS. - -The callback should return \fICURLSTS_OK\fP if it succeeded and is prepared to -be called again (for another host) or \fICURLSTS_DONE\fP if there is nothing -more to do. It can also return \fICURLSTS_FAIL\fP to signal error. - -This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to -do that. -.SH DEFAULT -NULL - no callback. -.SH PROTOCOLS -This feature is only used for HTTP(S) transfer. -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static CURLSTScode hswr_cb(CURL *easy, struct curl_hstsentry *sts, - struct curl_index *count, void *clientp) -{ - /* save the passed in HSTS data somewhere */ - return CURLSTS_OK; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct priv my_stuff; - CURLcode res; - - /* set HSTS read callback */ - curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hswr_cb); - - /* pass in suitable argument to the callback */ - curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &my_stuff); - - res = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HSTS (3), -.BR CURLOPT_HSTS_CTRL (3), -.BR CURLOPT_HSTSWRITEDATA (3), -.BR CURLOPT_HSTSWRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.md b/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.md new file mode 100644 index 000000000..ede35218c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTSWRITEFUNCTION.md @@ -0,0 +1,110 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTSWRITEFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HSTS (3) + - CURLOPT_HSTSWRITEDATA (3) + - CURLOPT_HSTSWRITEFUNCTION (3) + - CURLOPT_HSTS_CTRL (3) +--- + +# NAME + +CURLOPT_HSTSWRITEFUNCTION - write callback for HSTS hosts + +# SYNOPSIS + +~~~c +#include + +struct curl_hstsentry { + char *name; + size_t namelen; + unsigned int includeSubDomains:1; + char expire[18]; /* YYYYMMDD HH:MM:SS [null-terminated] */ +}; + +struct curl_index { + size_t index; /* the provided entry's "index" or count */ + size_t total; /* total number of entries to save */ +}; + +CURLSTScode hstswrite(CURL *easy, struct curl_hstsentry *sts, + struct curl_index *count, void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTSWRITEFUNCTION, hstswrite); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, as the prototype shows above. + +This callback function gets called by libcurl repeatedly to allow the +application to store the in-memory HSTS cache when libcurl is about to discard +it. + +Set the *clientp* argument with the CURLOPT_HSTSWRITEDATA(3) option +or it is NULL. +When the callback is invoked, the *sts* pointer points to a populated +struct: Read the hostname to 'name' (it is *namelen* bytes long and null +terminated. The *includeSubDomains* field is non-zero if the entry matches +subdomains. The *expire* string is a date stamp null-terminated string +using the syntax YYYYMMDD HH:MM:SS. + +The callback should return *CURLSTS_OK* if it succeeded and is prepared to +be called again (for another host) or *CURLSTS_DONE* if there is nothing +more to do. It can also return *CURLSTS_FAIL* to signal error. + +This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3) to +do that. + +# DEFAULT + +NULL - no callback. + +# PROTOCOLS + +This feature is only used for HTTP(S) transfer. + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static CURLSTScode hswr_cb(CURL *easy, struct curl_hstsentry *sts, + struct curl_index *count, void *clientp) +{ + /* save the passed in HSTS data somewhere */ + return CURLSTS_OK; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct priv my_stuff; + CURLcode res; + + /* set HSTS read callback */ + curl_easy_setopt(curl, CURLOPT_HSTSWRITEFUNCTION, hswr_cb); + + /* pass in suitable argument to the callback */ + curl_easy_setopt(curl, CURLOPT_HSTSWRITEDATA, &my_stuff); + + res = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_HSTS_CTRL.3 b/docs/libcurl/opts/CURLOPT_HSTS_CTRL.3 deleted file mode 100644 index 2747ccdd7..000000000 --- a/docs/libcurl/opts/CURLOPT_HSTS_CTRL.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HSTS_CTRL 3 "4 Sep 2020" libcurl libcurl -.SH NAME -CURLOPT_HSTS_CTRL \- control HSTS behavior -.SH SYNOPSIS -.nf -#include - -#define CURLHSTS_ENABLE (1<<0) -#define CURLHSTS_READONLYFILE (1<<1) - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS_CTRL, long bitmask); -.fi -.SH DESCRIPTION -HSTS (HTTP Strict Transport Security) means that an HTTPS server can instruct -the client to not contact it again over clear-text HTTP for a certain period -into the future. libcurl then automatically redirects HTTP attempts to such -hosts to instead use HTTPS. This is done by libcurl retaining this knowledge -in an in-memory cache. - -Populate the long \fIbitmask\fP with the correct set of features to instruct -libcurl how to handle HSTS for the transfers using this handle. -.SH BITS -.IP "CURLHSTS_ENABLE" -Enable the in-memory HSTS cache for this handle. -.IP "CURLHSTS_READONLYFILE" -Make the HSTS file (if specified) read-only - makes libcurl not save the cache -to the file when closing the handle. -.SH DEFAULT -0. HSTS is disabled by default. -.SH PROTOCOLS -HTTPS and HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.74.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ALTSVC (3), -.BR CURLOPT_CONNECT_TO (3), -.BR CURLOPT_HSTS (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_HSTS_CTRL.md b/docs/libcurl/opts/CURLOPT_HSTS_CTRL.md new file mode 100644 index 000000000..d60e58f0f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HSTS_CTRL.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HSTS_CTRL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ALTSVC (3) + - CURLOPT_CONNECT_TO (3) + - CURLOPT_HSTS (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_HSTS_CTRL - control HSTS behavior + +# SYNOPSIS + +~~~c +#include + +#define CURLHSTS_ENABLE (1<<0) +#define CURLHSTS_READONLYFILE (1<<1) + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HSTS_CTRL, long bitmask); +~~~ + +# DESCRIPTION + +HSTS (HTTP Strict Transport Security) means that an HTTPS server can instruct +the client to not contact it again over clear-text HTTP for a certain period +into the future. libcurl then automatically redirects HTTP attempts to such +hosts to instead use HTTPS. This is done by libcurl retaining this knowledge +in an in-memory cache. + +Populate the long *bitmask* with the correct set of features to instruct +libcurl how to handle HSTS for the transfers using this handle. + +# BITS + +## CURLHSTS_ENABLE + +Enable the in-memory HSTS cache for this handle. + +## CURLHSTS_READONLYFILE + +Make the HSTS file (if specified) read-only - makes libcurl not save the cache +to the file when closing the handle. + +# DEFAULT + +0. HSTS is disabled by default. + +# PROTOCOLS + +HTTPS and HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, (long)CURLHSTS_ENABLE); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.74.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.3 b/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.3 deleted file mode 100644 index af8f26bae..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTP09_ALLOWED 3 "17 Dec 2018" libcurl libcurl -.SH NAME -CURLOPT_HTTP09_ALLOWED \- allow HTTP/0.9 response -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP09_ALLOWED, long allowed); -.fi -.SH DESCRIPTION -Pass the long argument \fIallowed\fP set to 1L to allow HTTP/0.9 responses. - -An HTTP/0.9 response is a server response entirely without headers and only a -body. You can connect to lots of random TCP services and still get a response -that curl might consider to be HTTP/0.9! -.SH DEFAULT -curl allowed HTTP/0.9 responses by default before 7.66.0 - -Since 7.66.0, libcurl requires this option set to 1L to allow HTTP/0.9 -responses. -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HTTP09_ALLOWED, 1L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Option added in 7.64.0, present along with HTTP. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.md b/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.md new file mode 100644 index 000000000..d3594926f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTP09_ALLOWED.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTP09_ALLOWED +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_SSLVERSION (3) +--- + +# NAME + +CURLOPT_HTTP09_ALLOWED - allow HTTP/0.9 response + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP09_ALLOWED, long allowed); +~~~ + +# DESCRIPTION + +Pass the long argument *allowed* set to 1L to allow HTTP/0.9 responses. + +An HTTP/0.9 response is a server response entirely without headers and only a +body. You can connect to lots of random TCP services and still get a response +that curl might consider to be HTTP/0.9! + +# DEFAULT + +curl allowed HTTP/0.9 responses by default before 7.66.0 + +Since 7.66.0, libcurl requires this option set to 1L to allow HTTP/0.9 +responses. + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HTTP09_ALLOWED, 1L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Option added in 7.64.0, present along with HTTP. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.3 b/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.3 deleted file mode 100644 index 05a0e3ac3..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTP200ALIASES 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTP200ALIASES \- alternative matches for HTTP 200 OK -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP200ALIASES, - struct curl_slist *aliases); -.SH DESCRIPTION -Pass a pointer to a linked list of \fIaliases\fP to be treated as valid HTTP -200 responses. Some servers respond with a custom header response line. For -example, SHOUTcast servers respond with "ICY 200 OK". Also some old Icecast -1.3.x servers respond like that for certain user agent headers or in absence -of such. By including this string in your list of aliases, the response gets -treated as a valid HTTP header line such as "HTTP/1.0 200 OK". - -The linked list should be a fully valid list of struct curl_slist structs, and -be properly filled in. Use \fIcurl_slist_append(3)\fP to create the list and -\fIcurl_slist_free_all(3)\fP to clean up an entire list. - -The alias itself is not parsed for any version strings. The protocol is -assumed to match HTTP 1.0 when an alias match. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct curl_slist *list; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - list = curl_slist_append(NULL, "ICY 200 OK"); - list = curl_slist_append(list, "WEIRDO 99 FINE"); - - curl_easy_setopt(curl, CURLOPT_HTTP200ALIASES, list); - curl_easy_perform(curl); - curl_slist_free_all(list); /* free the list again */ - } -} -.fi -.SH AVAILABILITY -Added in 7.10.3 -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP09_ALLOWED (3), -.BR CURLOPT_HTTP_VERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.md b/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.md new file mode 100644 index 000000000..b48faf603 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTP200ALIASES.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTP200ALIASES +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP09_ALLOWED (3) + - CURLOPT_HTTP_VERSION (3) +--- + +# NAME + +CURLOPT_HTTP200ALIASES - alternative matches for HTTP 200 OK + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP200ALIASES, + struct curl_slist *aliases); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of *aliases* to be treated as valid HTTP 200 +responses. Some servers respond with a custom header response line. For +example, SHOUTcast servers respond with "ICY 200 OK". Also some old Icecast +1.3.x servers respond like that for certain user agent headers or in absence +of such. By including this string in your list of aliases, the response gets +treated as a valid HTTP header line such as "HTTP/1.0 200 OK". + +The linked list should be a fully valid list of struct curl_slist structs, and +be properly filled in. Use curl_slist_append(3) to create the list and +curl_slist_free_all(3) to clean up an entire list. + +The alias itself is not parsed for any version strings. The protocol is +assumed to match HTTP 1.0 when an alias match. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct curl_slist *list; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + list = curl_slist_append(NULL, "ICY 200 OK"); + list = curl_slist_append(list, "WEIRDO 99 FINE"); + + curl_easy_setopt(curl, CURLOPT_HTTP200ALIASES, list); + curl_easy_perform(curl); + curl_slist_free_all(list); /* free the list again */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.3 + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTPAUTH.3 b/docs/libcurl/opts/CURLOPT_HTTPAUTH.3 deleted file mode 100644 index 661f52942..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTPAUTH.3 +++ /dev/null @@ -1,143 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTPAUTH 3 "2 Aug 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTPAUTH \- HTTP server authentication methods to try -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPAUTH, long bitmask); -.SH DESCRIPTION -Pass a long as parameter, which is set to a bitmask, to tell libcurl which -authentication method(s) you want it to use speaking to the remote server. - -The available bits are listed below. If more than one bit is set, libcurl -first queries the host to see which authentication methods it supports and -then picks the best one you allow it to use. For some methods, this induces an -extra network round-trip. Set the actual name and password with the -\fICURLOPT_USERPWD(3)\fP option or with the \fICURLOPT_USERNAME(3)\fP and the -\fICURLOPT_PASSWORD(3)\fP options. - -For authentication with a proxy, see \fICURLOPT_PROXYAUTH(3)\fP. - -.IP CURLAUTH_BASIC -HTTP Basic authentication. This is the default choice, and the only method -that is in wide-spread use and supported virtually everywhere. This sends -the user name and password over the network in plain text, easily captured by -others. -.IP CURLAUTH_DIGEST -HTTP Digest authentication. Digest authentication is defined in RFC 2617 and -is a more secure way to do authentication over public networks than the -regular old-fashioned Basic method. -.IP CURLAUTH_DIGEST_IE -HTTP Digest authentication with an IE flavor. Digest authentication is -defined in RFC 2617 and is a more secure way to do authentication over public -networks than the regular old-fashioned Basic method. The IE flavor is simply -that libcurl uses a special "quirk" that IE is known to have used before -version 7 and that some servers require the client to use. -.IP CURLAUTH_BEARER -HTTP Bearer token authentication, used primarily in OAuth 2.0 protocol. - -You can set the Bearer token to use with \fICURLOPT_XOAUTH2_BEARER(3)\fP. -.IP CURLAUTH_NEGOTIATE -HTTP Negotiate (SPNEGO) authentication. Negotiate authentication is defined -in RFC 4559 and is the most secure way to perform authentication over HTTP. - -You need to build libcurl with a suitable GSS-API library or SSPI on Windows -for this to work. -.IP CURLAUTH_NTLM -HTTP NTLM authentication. A proprietary protocol invented and used by -Microsoft. It uses a challenge-response and hash concept similar to Digest, to -prevent the password from being eavesdropped. - -You need to build libcurl with either OpenSSL or GnuTLS support for this -option to work, or build libcurl on Windows with SSPI support. -.IP CURLAUTH_NTLM_WB -NTLM delegating to winbind helper. Authentication is performed by a separate -binary application that is executed when needed. The name of the application -is specified at compile time but is typically \fB/usr/bin/ntlm_auth\fP. - -Note that libcurl forks when necessary to run the winbind application and kill -it when complete, calling \fBwaitpid()\fP to await its exit when done. On -POSIX operating systems, killing the process causes a SIGCHLD signal to be -raised (regardless of whether \fICURLOPT_NOSIGNAL(3)\fP is set), which must be -handled intelligently by the application. In particular, the application must -not unconditionally call wait() in its SIGCHLD signal handler to avoid being -subject to a race condition. This behavior is subject to change in future -versions of libcurl. -.IP CURLAUTH_ANY -This is a convenience macro that sets all bits and thus makes libcurl pick any -it finds suitable. libcurl automatically selects the one it finds most secure. -.IP CURLAUTH_ANYSAFE -This is a convenience macro that sets all bits except Basic and thus makes -libcurl pick any it finds suitable. libcurl automatically selects the one it -finds most secure. -.IP CURLAUTH_ONLY -This is a meta symbol. OR this value together with a single specific auth -value to force libcurl to probe for unrestricted auth and if not, only that -single auth algorithm is acceptable. -.IP CURLAUTH_AWS_SIGV4 -provides AWS V4 signature authentication on HTTPS header -see \fICURLOPT_AWS_SIGV4(3)\fP. -.SH DEFAULT -CURLAUTH_BASIC -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* allow whatever auth the server speaks */ - curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); - curl_easy_setopt(curl, CURLOPT_USERPWD, "james:bond"); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Option Added in 7.10.6. - -CURLAUTH_DIGEST_IE was added in 7.19.3 - -CURLAUTH_ONLY was added in 7.21.3 - -CURLAUTH_NTLM_WB was added in 7.22.0 - -CURLAUTH_BEARER was added in 7.61.0 - -CURLAUTH_AWS_SIGV4 was added in 7.74.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_NOT_BUILT_IN if the bitmask specified no supported authentication -methods. -.SH "SEE ALSO" -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_PROXYAUTH (3), -.BR CURLOPT_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTPAUTH.md b/docs/libcurl/opts/CURLOPT_HTTPAUTH.md new file mode 100644 index 000000000..ca92f5eb0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTPAUTH.md @@ -0,0 +1,163 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTPAUTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PASSWORD (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_HTTPAUTH - HTTP server authentication methods to try + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPAUTH, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long as parameter, which is set to a bitmask, to tell libcurl which +authentication method(s) you want it to use speaking to the remote server. + +The available bits are listed below. If more than one bit is set, libcurl +first queries the host to see which authentication methods it supports and +then picks the best one you allow it to use. For some methods, this induces an +extra network round-trip. Set the actual name and password with the +CURLOPT_USERPWD(3) option or with the CURLOPT_USERNAME(3) and the +CURLOPT_PASSWORD(3) options. + +For authentication with a proxy, see CURLOPT_PROXYAUTH(3). + +## CURLAUTH_BASIC + +HTTP Basic authentication. This is the default choice, and the only method +that is in wide-spread use and supported virtually everywhere. This sends +the user name and password over the network in plain text, easily captured by +others. + +## CURLAUTH_DIGEST + +HTTP Digest authentication. Digest authentication is defined in RFC 2617 and +is a more secure way to do authentication over public networks than the +regular old-fashioned Basic method. + +## CURLAUTH_DIGEST_IE + +HTTP Digest authentication with an IE flavor. Digest authentication is defined +in RFC 2617 and is a more secure way to do authentication over public networks +than the regular old-fashioned Basic method. The IE flavor is simply that +libcurl uses a special "quirk" that IE is known to have used before version 7 +and that some servers require the client to use. + +## CURLAUTH_BEARER + +HTTP Bearer token authentication, used primarily in OAuth 2.0 protocol. + +You can set the Bearer token to use with CURLOPT_XOAUTH2_BEARER(3). + +## CURLAUTH_NEGOTIATE + +HTTP Negotiate (SPNEGO) authentication. Negotiate authentication is defined +in RFC 4559 and is the most secure way to perform authentication over HTTP. + +You need to build libcurl with a suitable GSS-API library or SSPI on Windows +for this to work. + +## CURLAUTH_NTLM + +HTTP NTLM authentication. A proprietary protocol invented and used by +Microsoft. It uses a challenge-response and hash concept similar to Digest, to +prevent the password from being eavesdropped. + +You need to build libcurl with either OpenSSL or GnuTLS support for this +option to work, or build libcurl on Windows with SSPI support. + +## CURLAUTH_NTLM_WB + +NTLM delegating to winbind helper. Authentication is performed by a separate +binary application that is executed when needed. The name of the application +is specified at compile time but is typically **/usr/bin/ntlm_auth**. + +Note that libcurl forks when necessary to run the winbind application and kill +it when complete, calling **waitpid()** to await its exit when done. On POSIX +operating systems, killing the process causes a SIGCHLD signal to be raised +(regardless of whether CURLOPT_NOSIGNAL(3) is set), which must be handled +intelligently by the application. In particular, the application must not +unconditionally call wait() in its SIGCHLD signal handler to avoid being +subject to a race condition. This behavior is subject to change in future +versions of libcurl. + +## CURLAUTH_ANY + +This is a convenience macro that sets all bits and thus makes libcurl pick any +it finds suitable. libcurl automatically selects the one it finds most secure. + +## CURLAUTH_ANYSAFE + +This is a convenience macro that sets all bits except Basic and thus makes +libcurl pick any it finds suitable. libcurl automatically selects the one it +finds most secure. + +## CURLAUTH_ONLY + +This is a meta symbol. OR this value together with a single specific auth +value to force libcurl to probe for unrestricted auth and if not, only that +single auth algorithm is acceptable. + +## CURLAUTH_AWS_SIGV4 + +provides AWS V4 signature authentication on HTTPS header +see CURLOPT_AWS_SIGV4(3). + +# DEFAULT + +CURLAUTH_BASIC + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* allow whatever auth the server speaks */ + curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); + curl_easy_setopt(curl, CURLOPT_USERPWD, "james:bond"); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Option Added in 7.10.6. + +CURLAUTH_DIGEST_IE was added in 7.19.3 + +CURLAUTH_ONLY was added in 7.21.3 + +CURLAUTH_NTLM_WB was added in 7.22.0 + +CURLAUTH_BEARER was added in 7.61.0 + +CURLAUTH_AWS_SIGV4 was added in 7.74.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_NOT_BUILT_IN if the bitmask specified no supported authentication +methods. diff --git a/docs/libcurl/opts/CURLOPT_HTTPGET.3 b/docs/libcurl/opts/CURLOPT_HTTPGET.3 deleted file mode 100644 index 9a3af4d7c..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTPGET.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTPGET 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTPGET \- ask for an HTTP GET request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPGET, long useget); -.fi -.SH DESCRIPTION -Pass a long. If \fIuseget\fP is 1, this forces the HTTP request to get back to -using GET. Usable if a POST, HEAD, PUT, etc has been used previously using the -same curl \fIhandle\fP. - -When setting \fICURLOPT_HTTPGET(3)\fP to 1, libcurl automatically sets -\fICURLOPT_NOBODY(3)\fP to 0 and \fICURLOPT_UPLOAD(3)\fP to 0. - -Setting this option to zero has no effect. Applications need to explicitly -select which HTTP request method to use, they cannot deselect a method. To -reset a handle to default method, consider \fIcurl_easy_reset(3)\fP. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* use a GET to fetch this */ - curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_easy_reset (3), -.BR CURLOPT_NOBODY (3), -.BR CURLOPT_POST (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTPGET.md b/docs/libcurl/opts/CURLOPT_HTTPGET.md new file mode 100644 index 000000000..d8b024d8e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTPGET.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTPGET +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NOBODY (3) + - CURLOPT_POST (3) + - CURLOPT_UPLOAD (3) + - curl_easy_reset (3) +--- + +# NAME + +CURLOPT_HTTPGET - ask for an HTTP GET request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPGET, long useget); +~~~ + +# DESCRIPTION + +Pass a long. If *useget* is 1, this forces the HTTP request to get back to +using GET. Usable if a POST, HEAD, PUT, etc has been used previously using the +same curl *handle*. + +When setting CURLOPT_HTTPGET(3) to 1, libcurl automatically sets +CURLOPT_NOBODY(3) to 0 and CURLOPT_UPLOAD(3) to 0. + +Setting this option to zero has no effect. Applications need to explicitly +select which HTTP request method to use, they cannot deselect a method. To +reset a handle to default method, consider curl_easy_reset(3). + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* use a GET to fetch this */ + curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTPHEADER.3 b/docs/libcurl/opts/CURLOPT_HTTPHEADER.3 deleted file mode 100644 index a750b9810..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTPHEADER.3 +++ /dev/null @@ -1,170 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTPHEADER 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTPHEADER \- set of HTTP headers -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPHEADER, - struct curl_slist *headers); -.fi -.SH DESCRIPTION -Pass a pointer to a linked list of HTTP headers to pass to the server and/or -proxy in your HTTP request. The same list can be used for both host and proxy -requests! - -When used within an IMAP or SMTP request to upload a MIME mail, the given -header list establishes the document-level MIME headers to prepend to the -uploaded document described by \fICURLOPT_MIMEPOST(3)\fP. This does not affect -raw mail uploads. - -The linked list should be a fully valid list of \fBstruct curl_slist\fP -structs properly filled in. Use \fIcurl_slist_append(3)\fP to create the list -and \fIcurl_slist_free_all(3)\fP to clean up an entire list. If you add a -header that is otherwise generated and used by libcurl internally, your added -header is used instead. If you add a header with no content as in 'Accept:' -(no data on the right side of the colon), the internally used header is -disabled/removed. With this option you can add new headers, replace internal -headers and remove internal headers. To add a header with no content (nothing -to the right side of the colon), use the form 'name;' (note the ending -semicolon). - -The headers included in the linked list \fBmust not\fP be CRLF-terminated, -because libcurl adds CRLF after each header item itself. Failure to comply -with this might result in strange behavior. libcurl passes on the verbatim -strings you give it, without any filter or other safe guards. That includes -white space and control characters. - -The first line in an HTTP request (containing the method, usually a GET or -POST) is not a header and cannot be replaced using this option. Only the lines -following the request-line are headers. Adding this method line in this list -of headers only causes your request to send an invalid header. Use -\fICURLOPT_CUSTOMREQUEST(3)\fP to change the method. - -When this option is passed to \fIcurl_easy_setopt(3)\fP, libcurl does not copy -the entire list so you \fBmust\fP keep it around until you no longer use this -\fIhandle\fP for a transfer before you call \fIcurl_slist_free_all(3)\fP on -the list. - -Pass a NULL to this option to reset back to no custom headers. - -The most commonly replaced HTTP headers have "shortcuts" in the options -\fICURLOPT_COOKIE(3)\fP, \fICURLOPT_USERAGENT(3)\fP and -\fICURLOPT_REFERER(3)\fP. We recommend using those. - -There is an alternative option that sets or replaces headers only for requests -that are sent with CONNECT to a proxy: \fICURLOPT_PROXYHEADER(3)\fP. Use -\fICURLOPT_HEADEROPT(3)\fP to control the behavior. -.SH SPECIFIC HTTP HEADERS -Setting some specific headers causes libcurl to act differently. -.IP "Host:" -The specified host name is used for cookie matching if the cookie engine is -also enabled for this transfer. If the request is done over HTTP/2 or HTTP/3, -the custom host name is instead used in the ":authority" header field and -Host: is not sent at all over the wire. -.IP "Transfer-Encoding: chunked" -Tells libcurl the upload is to be done using this chunked encoding instead of -providing the Content-Length: field in the request. -.SH SPECIFIC MIME HEADERS -When used to build a MIME e-mail for IMAP or SMTP, the following -document-level headers can be set to override libcurl-generated values: -.IP "Mime-Version:" -Tells the parser at the receiving site how to interpret the MIME framing. -It defaults to "1.0" and should normally not be altered. -.IP "Content-Type:" -Indicates the document's global structure type. By default, libcurl sets it -to "multipart/mixed", describing a document made of independent parts. When a -MIME mail is only composed of alternative representations of the same data -(i.e.: HTML and plain text), this header must be set to "multipart/alternative". -In all cases the value must be of the form "multipart/*" to respect the -document structure and may not include the "boundary=" parameter. - -Other specific headers that do not have a libcurl default value but are -strongly desired by mail delivery and user agents should also be included. -These are "From:", "To:", "Date:" and "Subject:" among others and their -presence and value is generally checked by anti-spam utilities. -.SH SECURITY CONCERNS -By default, this option makes libcurl send the given headers in all HTTP -requests done by this handle. You should therefore use this option with -caution if you for example connect to the remote site using a proxy and a -CONNECT request, you should to consider if that proxy is supposed to also get -the headers. They may be private or otherwise sensitive to leak. - -Use \fICURLOPT_HEADEROPT(3)\fP to make the headers only get sent to where you -intend them to get sent. - -Custom headers are sent in all requests done by the easy handle, which implies -that if you tell libcurl to follow redirects -(\fICURLOPT_FOLLOWLOCATION(3)\fP), the same set of custom headers is sent in -the subsequent request. Redirects can of course go to other hosts and thus -those servers get all the contents of your custom headers too. - -Starting in 7.58.0, libcurl specifically prevents "Authorization:" headers -from being sent to other hosts than the first used one, unless specifically -permitted with the \fICURLOPT_UNRESTRICTED_AUTH(3)\fP option. - -Starting in 7.64.0, libcurl specifically prevents "Cookie:" headers from being -sent to other hosts than the first used one, unless specifically permitted -with the \fICURLOPT_UNRESTRICTED_AUTH(3)\fP option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP, IMAP and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - - struct curl_slist *list = NULL; - - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - list = curl_slist_append(list, "Shoesize: 10"); - list = curl_slist_append(list, "Accept:"); - - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); - - curl_easy_perform(curl); - - curl_slist_free_all(list); /* free the list */ - } -} -.fi - -.SH AVAILABILITY -As long as HTTP is enabled. Use in MIME mail added in 7.56.0. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_mime_init (3), -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_HEADER (3), -.BR CURLOPT_HEADEROPT (3), -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_PROXYHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTPHEADER.md b/docs/libcurl/opts/CURLOPT_HTTPHEADER.md new file mode 100644 index 000000000..0ccda775e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTPHEADER.md @@ -0,0 +1,181 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTPHEADER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CUSTOMREQUEST (3) + - CURLOPT_HEADER (3) + - CURLOPT_HEADEROPT (3) + - CURLOPT_MIMEPOST (3) + - CURLOPT_PROXYHEADER (3) + - curl_mime_init (3) +--- + +# NAME + +CURLOPT_HTTPHEADER - set of HTTP headers + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPHEADER, + struct curl_slist *headers); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of HTTP headers to pass to the server and/or +proxy in your HTTP request. The same list can be used for both host and proxy +requests! + +When used within an IMAP or SMTP request to upload a MIME mail, the given +header list establishes the document-level MIME headers to prepend to the +uploaded document described by CURLOPT_MIMEPOST(3). This does not affect +raw mail uploads. + +The linked list should be a fully valid list of **struct curl_slist** +structs properly filled in. Use curl_slist_append(3) to create the list +and curl_slist_free_all(3) to clean up an entire list. If you add a +header that is otherwise generated and used by libcurl internally, your added +header is used instead. If you add a header with no content as in 'Accept:' +(no data on the right side of the colon), the internally used header is +disabled/removed. With this option you can add new headers, replace internal +headers and remove internal headers. To add a header with no content (nothing +to the right side of the colon), use the form 'name;' (note the ending +semicolon). + +The headers included in the linked list **must not** be CRLF-terminated, +because libcurl adds CRLF after each header item itself. Failure to comply +with this might result in strange behavior. libcurl passes on the verbatim +strings you give it, without any filter or other safe guards. That includes +white space and control characters. + +The first line in an HTTP request (containing the method, usually a GET or +POST) is not a header and cannot be replaced using this option. Only the lines +following the request-line are headers. Adding this method line in this list +of headers only causes your request to send an invalid header. Use +CURLOPT_CUSTOMREQUEST(3) to change the method. + +When this option is passed to curl_easy_setopt(3), libcurl does not copy +the entire list so you **must** keep it around until you no longer use this +*handle* for a transfer before you call curl_slist_free_all(3) on +the list. + +Pass a NULL to this option to reset back to no custom headers. + +The most commonly replaced HTTP headers have "shortcuts" in the options +CURLOPT_COOKIE(3), CURLOPT_USERAGENT(3) and +CURLOPT_REFERER(3). We recommend using those. + +There is an alternative option that sets or replaces headers only for requests +that are sent with CONNECT to a proxy: CURLOPT_PROXYHEADER(3). Use +CURLOPT_HEADEROPT(3) to control the behavior. + +# SPECIFIC HTTP HEADERS + +Setting some specific headers causes libcurl to act differently. + +## Host: + +The specified hostname is used for cookie matching if the cookie engine is +also enabled for this transfer. If the request is done over HTTP/2 or HTTP/3, +the custom hostname is instead used in the ":authority" header field and +Host: is not sent at all over the wire. + +## Transfer-Encoding: chunked + +Tells libcurl the upload is to be done using this chunked encoding instead of +providing the Content-Length: field in the request. + +# SPECIFIC MIME HEADERS + +When used to build a MIME email for IMAP or SMTP, the following document-level +headers can be set to override libcurl-generated values: + +## Mime-Version: + +Tells the parser at the receiving site how to interpret the MIME framing. +It defaults to "1.0" and should normally not be altered. + +## Content-Type: + +Indicates the document's global structure type. By default, libcurl sets it +to "multipart/mixed", describing a document made of independent parts. When a +MIME mail is only composed of alternative representations of the same data +(i.e.: HTML and plain text), this header must be set to "multipart/alternative". +In all cases the value must be of the form "multipart/*" to respect the +document structure and may not include the "boundary=" parameter. + +Other specific headers that do not have a libcurl default value but are +strongly desired by mail delivery and user agents should also be included. +These are "From:", "To:", "Date:" and "Subject:" among others and their +presence and value is generally checked by anti-spam utilities. + +# SECURITY CONCERNS + +By default, this option makes libcurl send the given headers in all HTTP +requests done by this handle. You should therefore use this option with +caution if you for example connect to the remote site using a proxy and a +CONNECT request, you should to consider if that proxy is supposed to also get +the headers. They may be private or otherwise sensitive to leak. + +Use CURLOPT_HEADEROPT(3) to make the headers only get sent to where you +intend them to get sent. + +Custom headers are sent in all requests done by the easy handle, which implies +that if you tell libcurl to follow redirects +(CURLOPT_FOLLOWLOCATION(3)), the same set of custom headers is sent in +the subsequent request. Redirects can of course go to other hosts and thus +those servers get all the contents of your custom headers too. + +Starting in 7.58.0, libcurl specifically prevents "Authorization:" headers +from being sent to other hosts than the first used one, unless specifically +permitted with the CURLOPT_UNRESTRICTED_AUTH(3) option. + +Starting in 7.64.0, libcurl specifically prevents "Cookie:" headers from being +sent to other hosts than the first used one, unless specifically permitted +with the CURLOPT_UNRESTRICTED_AUTH(3) option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP, IMAP and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + + struct curl_slist *list = NULL; + + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + list = curl_slist_append(list, "Shoesize: 10"); + list = curl_slist_append(list, "Accept:"); + + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); + + curl_easy_perform(curl); + + curl_slist_free_all(list); /* free the list */ + } +} +~~~ + +# AVAILABILITY + +As long as HTTP is enabled. Use in MIME mail added in 7.56.0. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTPPOST.3 b/docs/libcurl/opts/CURLOPT_HTTPPOST.3 deleted file mode 100644 index f86db4ee7..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTPPOST.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTPPOST 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTPPOST \- multipart formpost content -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPOST, - struct curl_httppost *formpost); -.SH DESCRIPTION -\fBThis option is deprecated.\fP Use \fICURLOPT_MIMEPOST(3)\fP instead. - -Tells libcurl you want a \fBmultipart/formdata\fP HTTP POST to be made and you -instruct what data to pass on to the server in the \fIformpost\fP argument. -Pass a pointer to a linked list of \fIcurl_httppost\fP structs as parameter. -The easiest way to create such a list, is to use \fIcurl_formadd(3)\fP as -documented. The data in this list must remain intact as long as the curl -transfer is alive and is using it. - -Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. -You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP. - -When setting \fICURLOPT_HTTPPOST(3)\fP, libcurl automatically sets -\fICURLOPT_NOBODY(3)\fP to 0. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - struct curl_httppost *formpost; - struct curl_httppost *lastptr; - - /* Fill in the file upload field. This makes libcurl load data from - the given file name when curl_easy_perform() is called. */ - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "sendfile", - CURLFORM_FILE, "postit2.c", - CURLFORM_END); - - /* Fill in the filename field */ - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "filename", - CURLFORM_COPYCONTENTS, "postit2.c", - CURLFORM_END); - - /* Fill in the submit field too, even if this is rarely needed */ - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "submit", - CURLFORM_COPYCONTENTS, "send", - CURLFORM_END); - - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - } - curl_formfree(formpost); -} -.fi -.SH AVAILABILITY -As long as HTTP is enabled. Deprecated in 7.56.0. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_formadd (3), -.BR curl_formfree (3), -.BR curl_mime_init (3), -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_POST (3), -.BR CURLOPT_POSTFIELDS (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTPPOST.md b/docs/libcurl/opts/CURLOPT_HTTPPOST.md new file mode 100644 index 000000000..6fdfc1707 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTPPOST.md @@ -0,0 +1,100 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTPPOST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MIMEPOST (3) + - CURLOPT_POST (3) + - CURLOPT_POSTFIELDS (3) + - curl_formadd (3) + - curl_formfree (3) + - curl_mime_init (3) +--- + +# NAME + +CURLOPT_HTTPPOST - multipart formpost content + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPOST, + struct curl_httppost *formpost); +~~~ + +# DESCRIPTION + +**This option is deprecated.** Use CURLOPT_MIMEPOST(3) instead. + +Tells libcurl you want a **multipart/formdata** HTTP POST to be made and you +instruct what data to pass on to the server in the *formpost* argument. +Pass a pointer to a linked list of *curl_httppost* structs as parameter. +The easiest way to create such a list, is to use curl_formadd(3) as +documented. The data in this list must remain intact as long as the curl +transfer is alive and is using it. + +Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. +You can disable this header with CURLOPT_HTTPHEADER(3). + +When setting CURLOPT_HTTPPOST(3), libcurl automatically sets +CURLOPT_NOBODY(3) to 0. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + struct curl_httppost *formpost; + struct curl_httppost *lastptr; + + /* Fill in the file upload field. This makes libcurl load data from + the given file name when curl_easy_perform() is called. */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile", + CURLFORM_FILE, "postit2.c", + CURLFORM_END); + + /* Fill in the filename field */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "filename", + CURLFORM_COPYCONTENTS, "postit2.c", + CURLFORM_END); + + /* Fill in the submit field too, even if this is rarely needed */ + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "submit", + CURLFORM_COPYCONTENTS, "send", + CURLFORM_END); + + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + curl_easy_perform(curl); + curl_easy_cleanup(curl); + } + curl_formfree(formpost); +} +~~~ + +# AVAILABILITY + +As long as HTTP is enabled. Deprecated in 7.56.0. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.3 b/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.3 deleted file mode 100644 index 542eefe6c..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTPPROXYTUNNEL 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTPPROXYTUNNEL \- tunnel through HTTP proxy -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPROXYTUNNEL, long tunnel); -.fi -.SH DESCRIPTION -Set the \fBtunnel\fP parameter to 1L to make libcurl tunnel all operations -through the HTTP proxy (set with \fICURLOPT_PROXY(3)\fP). There is a big -difference between using a proxy and to tunnel through it. - -Tunneling means that an HTTP CONNECT request is sent to the proxy, asking it -to connect to a remote host on a specific port number and then the traffic is -just passed through the proxy. Proxies tend to white-list specific port numbers -it allows CONNECT requests to and often only port 80 and 443 are allowed. - -To suppress proxy CONNECT response headers from user callbacks use -\fICURLOPT_SUPPRESS_CONNECT_HEADERS(3)\fP. - -HTTP proxies can generally only speak HTTP (for obvious reasons), which makes -libcurl convert non-HTTP requests to HTTP when using an HTTP proxy without -this tunnel option set. For example, asking for an FTP URL and specifying an -HTTP proxy makes libcurl send an FTP URL in an HTTP GET request to the -proxy. By instead tunneling through the proxy, you avoid that conversion (that -rarely works through the proxy anyway). -.SH DEFAULT -0 -.SH PROTOCOLS -All network protocols -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80"); - curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYTYPE (3), -.BR CURLOPT_PROXYPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.md b/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.md new file mode 100644 index 000000000..bd67640b4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTPPROXYTUNNEL.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTPPROXYTUNNEL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYPORT (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_HTTPPROXYTUNNEL - tunnel through HTTP proxy + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPROXYTUNNEL, long tunnel); +~~~ + +# DESCRIPTION + +Set the **tunnel** parameter to 1L to make libcurl tunnel all operations +through the HTTP proxy (set with CURLOPT_PROXY(3)). There is a big +difference between using a proxy and to tunnel through it. + +Tunneling means that an HTTP CONNECT request is sent to the proxy, asking it +to connect to a remote host on a specific port number and then the traffic is +just passed through the proxy. Proxies tend to white-list specific port numbers +it allows CONNECT requests to and often only port 80 and 443 are allowed. + +To suppress proxy CONNECT response headers from user callbacks use +CURLOPT_SUPPRESS_CONNECT_HEADERS(3). + +HTTP proxies can generally only speak HTTP (for obvious reasons), which makes +libcurl convert non-HTTP requests to HTTP when using an HTTP proxy without +this tunnel option set. For example, asking for an FTP URL and specifying an +HTTP proxy makes libcurl send an FTP URL in an HTTP GET request to the +proxy. By instead tunneling through the proxy, you avoid that conversion (that +rarely works through the proxy anyway). + +# DEFAULT + +0 + +# PROTOCOLS + +All network protocols + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:80"); + curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.3 b/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.3 deleted file mode 100644 index 7d6dabee3..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTP_CONTENT_DECODING 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTP_CONTENT_DECODING \- HTTP content decoding control -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_CONTENT_DECODING, - long enabled); -.SH DESCRIPTION -Pass a long to tell libcurl how to act on content decoding. If set to zero, -content decoding is disabled. If set to 1 it is enabled. Libcurl has no -default content decoding but requires you to use -\fICURLOPT_ACCEPT_ENCODING(3)\fP for that. -.SH DEFAULT -1 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 0L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ACCEPT_ENCODING (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.md b/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.md new file mode 100644 index 000000000..b48c0f9fb --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTP_CONTENT_DECODING.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTP_CONTENT_DECODING +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ACCEPT_ENCODING (3) + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_HTTP_CONTENT_DECODING - HTTP content decoding control + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_CONTENT_DECODING, + long enabled); +~~~ + +# DESCRIPTION + +Pass a long to tell libcurl how to act on content decoding. If set to zero, +content decoding is disabled. If set to 1 it is enabled. Libcurl has no +default content decoding but requires you to use +CURLOPT_ACCEPT_ENCODING(3) for that. + +# DEFAULT + +1 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 0L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.3 b/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.3 deleted file mode 100644 index a00fb1a1d..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.3 +++ /dev/null @@ -1,62 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTP_TRANSFER_DECODING 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTP_TRANSFER_DECODING \- HTTP transfer decoding control -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_TRANSFER_DECODING, - long enabled); -.SH DESCRIPTION -Pass a long to tell libcurl how to act on transfer decoding. If set to zero, -transfer decoding is disabled, if set to 1 it is enabled (default). libcurl -does chunked transfer decoding by default unless this option is set to zero. -.SH DEFAULT -1 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, 0L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.2 Does not work with the hyper backend (it always has transfer -decoding enabled). -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_CONTENT_DECODING (3), -.BR CURLOPT_ACCEPT_ENCODING (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.md b/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.md new file mode 100644 index 000000000..ba83acaae --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTP_TRANSFER_DECODING.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTP_TRANSFER_DECODING +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ACCEPT_ENCODING (3) + - CURLOPT_HTTP_CONTENT_DECODING (3) +--- + +# NAME + +CURLOPT_HTTP_TRANSFER_DECODING - HTTP transfer decoding control + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_TRANSFER_DECODING, + long enabled); +~~~ + +# DESCRIPTION + +Pass a long to tell libcurl how to act on transfer decoding. If set to zero, +transfer decoding is disabled, if set to 1 it is enabled (default). libcurl +does chunked transfer decoding by default unless this option is set to zero. + +# DEFAULT + +1 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, 0L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.2 Does not work with the hyper backend (it always has transfer +decoding enabled). + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_HTTP_VERSION.3 b/docs/libcurl/opts/CURLOPT_HTTP_VERSION.3 deleted file mode 100644 index 87b133b88..000000000 --- a/docs/libcurl/opts/CURLOPT_HTTP_VERSION.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_HTTP_VERSION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_HTTP_VERSION \- HTTP protocol version to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_VERSION, long version); -.fi -.SH DESCRIPTION -Pass \fIversion\fP a long, set to one of the values described below. They ask -libcurl to use the specific HTTP versions. - -Note that the HTTP version is just a request. libcurl still prioritizes to -reuse existing connections so it might then reuse a connection using a HTTP -version you have not asked for. - -.IP CURL_HTTP_VERSION_NONE -We do not care about what version the library uses. libcurl uses whatever it -thinks fit. -.IP CURL_HTTP_VERSION_1_0 -Enforce HTTP 1.0 requests. -.IP CURL_HTTP_VERSION_1_1 -Enforce HTTP 1.1 requests. -.IP CURL_HTTP_VERSION_2_0 -Attempt HTTP 2 requests. libcurl falls back to HTTP 1.1 if HTTP 2 cannot be -negotiated with the server. (Added in 7.33.0) - -When libcurl uses HTTP/2 over HTTPS, it does not itself insist on TLS 1.2 or -higher even though that is required by the specification. A user can add this -version requirement with \fICURLOPT_SSLVERSION(3)\fP. - -The alias \fICURL_HTTP_VERSION_2\fP was added in 7.43.0 to better reflect the -actual protocol name. -.IP CURL_HTTP_VERSION_2TLS -Attempt HTTP 2 over TLS (HTTPS) only. libcurl falls back to HTTP 1.1 if HTTP 2 -cannot be negotiated with the HTTPS server. For clear text HTTP servers, -libcurl uses 1.1. (Added in 7.47.0) -.IP CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE -Issue non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires -prior knowledge that the server supports HTTP/2 straight away. HTTPS requests -still do HTTP/2 the standard way with negotiated protocol version in the TLS -handshake. (Added in 7.49.0) -.IP CURL_HTTP_VERSION_3 -(Added in 7.66.0) This option makes libcurl attempt to use HTTP/3 to the host -given in the URL, with fallback to earlier HTTP versions if needed. -.IP CURL_HTTP_VERSION_3ONLY -(Added in 7.88.0) Setting this makes libcurl attempt to use HTTP/3 directly to -server given in the URL and does not downgrade to earlier HTTP version if the -server does not support HTTP/3. -.SH DEFAULT -Since curl 7.62.0: CURL_HTTP_VERSION_2TLS - -Before that: CURL_HTTP_VERSION_1_1 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, - (long)CURL_HTTP_VERSION_2TLS); - ret = curl_easy_perform(curl); - if(ret == CURLE_HTTP_RETURNED_ERROR) { - /* an HTTP response error problem */ - } - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ALTSVC (3), -.BR CURLOPT_HTTP09_ALLOWED (3), -.BR CURLOPT_HTTP200ALIASES (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_HTTP_VERSION.md b/docs/libcurl/opts/CURLOPT_HTTP_VERSION.md new file mode 100644 index 000000000..69dc48c61 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_HTTP_VERSION.md @@ -0,0 +1,119 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_HTTP_VERSION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ALTSVC (3) + - CURLOPT_HTTP09_ALLOWED (3) + - CURLOPT_HTTP200ALIASES (3) + - CURLOPT_SSLVERSION (3) +--- + +# NAME + +CURLOPT_HTTP_VERSION - HTTP protocol version to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTP_VERSION, long version); +~~~ + +# DESCRIPTION + +Pass *version* a long, set to one of the values described below. They ask +libcurl to use the specific HTTP versions. + +Note that the HTTP version is just a request. libcurl still prioritizes to +reuse existing connections so it might then reuse a connection using an HTTP +version you have not asked for. + +## CURL_HTTP_VERSION_NONE + +We do not care about what version the library uses. libcurl uses whatever it +thinks fit. + +## CURL_HTTP_VERSION_1_0 + +Enforce HTTP 1.0 requests. + +## CURL_HTTP_VERSION_1_1 + +Enforce HTTP 1.1 requests. + +## CURL_HTTP_VERSION_2_0 + +Attempt HTTP 2 requests. libcurl falls back to HTTP 1.1 if HTTP 2 cannot be +negotiated with the server. (Added in 7.33.0) + +When libcurl uses HTTP/2 over HTTPS, it does not itself insist on TLS 1.2 or +higher even though that is required by the specification. A user can add this +version requirement with CURLOPT_SSLVERSION(3). + +The alias *CURL_HTTP_VERSION_2* was added in 7.43.0 to better reflect the +actual protocol name. + +## CURL_HTTP_VERSION_2TLS + +Attempt HTTP 2 over TLS (HTTPS) only. libcurl falls back to HTTP 1.1 if HTTP 2 +cannot be negotiated with the HTTPS server. For clear text HTTP servers, +libcurl uses 1.1. (Added in 7.47.0) + +## CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE + +Issue non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires +prior knowledge that the server supports HTTP/2 straight away. HTTPS requests +still do HTTP/2 the standard way with negotiated protocol version in the TLS +handshake. (Added in 7.49.0) + +## CURL_HTTP_VERSION_3 + +(Added in 7.66.0) This option makes libcurl attempt to use HTTP/3 to the host +given in the URL, with fallback to earlier HTTP versions if needed. + +## CURL_HTTP_VERSION_3ONLY + +(Added in 7.88.0) Setting this makes libcurl attempt to use HTTP/3 directly to +server given in the URL and does not downgrade to earlier HTTP version if the +server does not support HTTP/3. + +# DEFAULT + +Since curl 7.62.0: CURL_HTTP_VERSION_2TLS + +Before that: CURL_HTTP_VERSION_1_1 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, + (long)CURL_HTTP_VERSION_2TLS); + ret = curl_easy_perform(curl); + if(ret == CURLE_HTTP_RETURNED_ERROR) { + /* an HTTP response error problem */ + } + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.3 b/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.3 deleted file mode 100644 index 2512b665f..000000000 --- a/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_IGNORE_CONTENT_LENGTH 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_IGNORE_CONTENT_LENGTH \- ignore content length -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IGNORE_CONTENT_LENGTH, - long ignore); -.SH DESCRIPTION -If \fIignore\fP is set to 1L, ignore the Content-Length header in the HTTP -response and ignore asking for or relying on it for FTP transfers. - -This is useful for doing HTTP transfers with ancient web servers which report -incorrect content length for files over 2 gigabytes. If this option is used, -curl cannot accurately report progress, and it instead stops the download when -the server ends the connection. - -It is also useful with FTP when for example the file is growing while the -transfer is in progress which otherwise unconditionally causes libcurl to -report error. - -Only use this option if strictly necessary. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* we know the server is silly, ignore content-length */ - curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.14.1. Support for FTP added in 7.46.0. This option is not working -for HTTP when libcurl is built to use the hyper backend. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_MAXFILESIZE_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.md b/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.md new file mode 100644 index 000000000..d12b49120 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_IGNORE_CONTENT_LENGTH.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_IGNORE_CONTENT_LENGTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_MAXFILESIZE_LARGE (3) +--- + +# NAME + +CURLOPT_IGNORE_CONTENT_LENGTH - ignore content length + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IGNORE_CONTENT_LENGTH, + long ignore); +~~~ + +# DESCRIPTION + +If *ignore* is set to 1L, ignore the Content-Length header in the HTTP +response and ignore asking for or relying on it for FTP transfers. + +This is useful for doing HTTP transfers with ancient web servers which report +incorrect content length for files over 2 gigabytes. If this option is used, +curl cannot accurately report progress, and it instead stops the download when +the server ends the connection. + +It is also useful with FTP when for example the file is growing while the +transfer is in progress which otherwise unconditionally causes libcurl to +report error. + +Only use this option if strictly necessary. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* we know the server is silly, ignore content-length */ + curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.14.1. Support for FTP added in 7.46.0. This option is not working +for HTTP when libcurl is built to use the hyper backend. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_INFILESIZE.3 b/docs/libcurl/opts/CURLOPT_INFILESIZE.3 deleted file mode 100644 index a26e46302..000000000 --- a/docs/libcurl/opts/CURLOPT_INFILESIZE.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_INFILESIZE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_INFILESIZE \- size of the input file to send off -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE, long filesize); -.fi -.SH DESCRIPTION -When uploading a file to a remote site, \fIfilesize\fP should be used to tell -libcurl what the expected size of the input file is. This value must be passed -as a long. See also \fICURLOPT_INFILESIZE_LARGE(3)\fP for sending files larger -than 2GB. - -For uploading using SCP, this option or \fICURLOPT_INFILESIZE_LARGE(3)\fP is -mandatory. - -To unset this value again, set it to -1. - -Using \fICURLOPT_UPLOAD(3)\fP to a HTTP/1.1 server and this value set to -1, -makes libcurl do a chunked transfer-encoded upload. - -When sending emails using SMTP, this command can be used to specify the -optional SIZE parameter for the MAIL FROM command. - -This option does not limit how much data libcurl actually sends, as that is -controlled entirely by what the read callback returns, but telling one value -and sending a different amount may lead to errors. -.SH DEFAULT -Unset -.SH PROTOCOLS -Many -.SH EXAMPLE -.nf - -#define FILE_SIZE 12345L - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - long uploadsize = FILE_SIZE; - - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/destination.tar.gz"); - - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - - curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -SMTP support added in 7.23.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_CONTENT_LENGTH_UPLOAD_T (3), -.BR CURLOPT_INFILESIZE_LARGE (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_INFILESIZE.md b/docs/libcurl/opts/CURLOPT_INFILESIZE.md new file mode 100644 index 000000000..eab597ff4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_INFILESIZE.md @@ -0,0 +1,85 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_INFILESIZE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CONTENT_LENGTH_UPLOAD_T (3) + - CURLOPT_INFILESIZE_LARGE (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_INFILESIZE - size of the input file to send off + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE, long filesize); +~~~ + +# DESCRIPTION + +When uploading a file to a remote site, *filesize* should be used to tell +libcurl what the expected size of the input file is. This value must be passed +as a long. See also CURLOPT_INFILESIZE_LARGE(3) for sending files larger +than 2GB. + +For uploading using SCP, this option or CURLOPT_INFILESIZE_LARGE(3) is +mandatory. + +To unset this value again, set it to -1. + +Using CURLOPT_UPLOAD(3) to an HTTP/1.1 server and this value set to -1, makes +libcurl do a chunked transfer-encoded upload. + +When sending emails using SMTP, this command can be used to specify the +optional SIZE parameter for the MAIL FROM command. + +This option does not limit how much data libcurl actually sends, as that is +controlled entirely by what the read callback returns, but telling one value +and sending a different amount may lead to errors. + +# DEFAULT + +Unset + +# PROTOCOLS + +Many + +# EXAMPLE + +~~~c + +#define FILE_SIZE 12345L + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + long uploadsize = FILE_SIZE; + + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/destination.tar.gz"); + + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + + curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +SMTP support added in 7.23.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.3 b/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.3 deleted file mode 100644 index 5cac91089..000000000 --- a/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_INFILESIZE_LARGE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_INFILESIZE_LARGE \- size of the input file to send off -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE_LARGE, - curl_off_t filesize); -.SH DESCRIPTION -When uploading a file to a remote site, \fIfilesize\fP should be used to tell -libcurl what the expected size of the input file is. This value must be passed -as a \fBcurl_off_t\fP. - -For uploading using SCP, this option or \fICURLOPT_INFILESIZE(3)\fP is -mandatory. - -To unset this value again, set it to -1. - -When sending emails using SMTP, this command can be used to specify the -optional SIZE parameter for the MAIL FROM command. - -This option does not limit how much data libcurl actually sends, as that is -controlled entirely by what the read callback returns, but telling one value -and sending a different amount may lead to errors. -.SH DEFAULT -Unset -.SH PROTOCOLS -Many -.SH EXAMPLE -.nf -#define FILE_SIZE 123456 - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_off_t uploadsize = FILE_SIZE; - - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/destination.tar.gz"); - - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -SMTP support added in 7.23.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_CONTENT_LENGTH_UPLOAD_T (3), -.BR CURLOPT_INFILESIZE (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.md b/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.md new file mode 100644 index 000000000..5f8a3386f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_INFILESIZE_LARGE.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_INFILESIZE_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CONTENT_LENGTH_UPLOAD_T (3) + - CURLOPT_INFILESIZE (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_INFILESIZE_LARGE - size of the input file to send off + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE_LARGE, + curl_off_t filesize); +~~~ + +# DESCRIPTION + +When uploading a file to a remote site, *filesize* should be used to tell +libcurl what the expected size of the input file is. This value must be passed +as a **curl_off_t**. + +For uploading using SCP, this option or CURLOPT_INFILESIZE(3) is +mandatory. + +To unset this value again, set it to -1. + +When sending emails using SMTP, this command can be used to specify the +optional SIZE parameter for the MAIL FROM command. + +This option does not limit how much data libcurl actually sends, as that is +controlled entirely by what the read callback returns, but telling one value +and sending a different amount may lead to errors. + +# DEFAULT + +Unset + +# PROTOCOLS + +Many + +# EXAMPLE + +~~~c +#define FILE_SIZE 123456 + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_off_t uploadsize = FILE_SIZE; + + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/destination.tar.gz"); + + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +SMTP support added in 7.23.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_INTERFACE.3 b/docs/libcurl/opts/CURLOPT_INTERFACE.3 deleted file mode 100644 index 676f8ba7c..000000000 --- a/docs/libcurl/opts/CURLOPT_INTERFACE.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_INTERFACE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_INTERFACE \- source interface for outgoing traffic -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface); -.fi -.SH DESCRIPTION -Pass a char * as parameter. This sets the \fIinterface\fP name to use as -outgoing network interface. The name can be an interface name, an IP address, -or a host name. - -If the parameter starts with "if!" then it is treated only as an interface -name. If the parameter starts with \&"host!" it is treated as either an IP -address or a hostname. - -If "if!" is specified but the parameter does not match an existing interface, -\fICURLE_INTERFACE_FAILED\fP is returned from the libcurl function used to -perform the transfer. - -libcurl does not support using network interface names for this option on -Windows. - -We strongly advise against specifying the interface with a hostname, as it -causes libcurl to do a blocking name resolve call to retrieve the IP -address. That name resolve operation does \fBnot\fP use DNS-over-HTTPS even if -\fICURLOPT_DOH_URL(3)\fP is set. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, use whatever the TCP stack finds suitable -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -The "if!" and "host!" syntax was added in 7.24.0. -.SH RETURN VALUE -Returns CURLE_OK on success or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SOCKOPTFUNCTION (3), -.BR CURLOPT_TCP_NODELAY (3) diff --git a/docs/libcurl/opts/CURLOPT_INTERFACE.md b/docs/libcurl/opts/CURLOPT_INTERFACE.md new file mode 100644 index 000000000..24927fdf8 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_INTERFACE.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_INTERFACE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SOCKOPTFUNCTION (3) + - CURLOPT_TCP_NODELAY (3) +--- + +# NAME + +CURLOPT_INTERFACE - source interface for outgoing traffic + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter. This sets the *interface* name to use as +outgoing network interface. The name can be an interface name, an IP address, +or a hostname. + +If the parameter starts with "if!" then it is treated only as an interface +name. If the parameter starts with &"host!" it is treated as either an IP +address or a hostname. + +If "if!" is specified but the parameter does not match an existing interface, +*CURLE_INTERFACE_FAILED* is returned from the libcurl function used to +perform the transfer. + +libcurl does not support using network interface names for this option on +Windows. + +We strongly advise against specifying the interface with a hostname, as it +causes libcurl to do a blocking name resolve call to retrieve the IP +address. That name resolve operation does **not** use DNS-over-HTTPS even if +CURLOPT_DOH_URL(3) is set. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, use whatever the TCP stack finds suitable + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +The "if!" and "host!" syntax was added in 7.24.0. + +# RETURN VALUE + +Returns CURLE_OK on success or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.3 b/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.3 deleted file mode 100644 index adc54f694..000000000 --- a/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_INTERLEAVEDATA 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_INTERLEAVEDATA \- pointer passed to RTSP interleave callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEDATA, void *pointer); -.fi -.SH DESCRIPTION -This is the userdata \fIpointer\fP that is passed to -\fICURLOPT_INTERLEAVEFUNCTION(3)\fP when interleaved RTP data is received. If -the interleave function callback is not set, this pointer is not used -anywhere. -.SH DEFAULT -NULL -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -struct local { - void *custom; -}; -static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp) -{ - struct local *l = userp; - printf("my pointer: %p\\n", l->custom); - /* take care of the packet in 'ptr', then return... */ - return size * nmemb; -} - -int main(void) -{ - struct local rtp_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); - curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_INTERLEAVEFUNCTION (3), -.BR CURLOPT_RTSP_REQUEST (3) diff --git a/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.md b/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.md new file mode 100644 index 000000000..64311f83c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_INTERLEAVEDATA.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_INTERLEAVEDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INTERLEAVEFUNCTION (3) + - CURLOPT_RTSP_REQUEST (3) +--- + +# NAME + +CURLOPT_INTERLEAVEDATA - pointer passed to RTSP interleave callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEDATA, void *pointer); +~~~ + +# DESCRIPTION + +This is the userdata *pointer* that is passed to +CURLOPT_INTERLEAVEFUNCTION(3) when interleaved RTP data is received. If +the interleave function callback is not set, this pointer is not used +anywhere. + +# DEFAULT + +NULL + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +struct local { + void *custom; +}; +static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct local *l = userp; + printf("my pointer: %p\n", l->custom); + /* take care of the packet in 'ptr', then return... */ + return size * nmemb; +} + +int main(void) +{ + struct local rtp_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); + curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.3 b/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.3 deleted file mode 100644 index b2fa947dd..000000000 --- a/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_INTERLEAVEFUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_INTERLEAVEFUNCTION \- callback for RTSP interleaved data -.SH SYNOPSIS -.nf -#include - -size_t interleave_callback(void *ptr, size_t size, size_t nmemb, - void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEFUNCTION, - interleave_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl as soon as it has received -interleaved RTP data. This function gets called for each $ block and therefore -contains exactly one upper-layer protocol unit (e.g. one RTP packet). Curl -writes the interleaved header as well as the included data for each call. The -first byte is always an ASCII dollar sign. The dollar sign is followed by a -one byte channel identifier and then a 2 byte integer length in network byte -order. See RFC 2326 Section 10.12 for more information on how RTP interleaving -behaves. If unset or set to NULL, curl uses the default write function. - -Interleaved RTP poses some challenges for the client application. Since the -stream data is sharing the RTSP control connection, it is critical to service -the RTP in a timely fashion. If the RTP data is not handled quickly, -subsequent response processing may become unreasonably delayed and the -connection may close. The application may use \fICURL_RTSPREQ_RECEIVE\fP to -service RTP data when no requests are desired. If the application makes a -request, (e.g. \fICURL_RTSPREQ_PAUSE\fP) then the response handler processes -any pending RTP data before marking the request as finished. - -The \fICURLOPT_INTERLEAVEDATA(3)\fP is passed in the \fIuserdata\fP argument in -the callback. - -Your callback should return the number of bytes actually taken care of. If -that amount differs from the amount passed to your callback function, it -signals an error condition to the library. This causes the transfer to abort -and the libcurl function used returns \fICURLE_WRITE_ERROR\fP. - -You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0) -.SH DEFAULT -NULL, the interleave data is then passed to the regular write function: -\fICURLOPT_WRITEFUNCTION(3)\fP. -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -struct local { - void *custom; -}; - -static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp) -{ - struct local *l = userp; - printf("our ptr: %p\\n", l->custom); - /* take care of the packet in 'ptr', then return... */ - return size * nmemb; -} - -int main(void) -{ - struct local rtp_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); - curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_INTERLEAVEDATA (3), -.BR CURLOPT_RTSP_REQUEST (3) diff --git a/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.md b/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.md new file mode 100644 index 000000000..5f8e999df --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_INTERLEAVEFUNCTION.md @@ -0,0 +1,102 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_INTERLEAVEFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INTERLEAVEDATA (3) + - CURLOPT_RTSP_REQUEST (3) +--- + +# NAME + +CURLOPT_INTERLEAVEFUNCTION - callback for RTSP interleaved data + +# SYNOPSIS + +~~~c +#include + +size_t interleave_callback(void *ptr, size_t size, size_t nmemb, + void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERLEAVEFUNCTION, + interleave_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl as soon as it has received +interleaved RTP data. This function gets called for each $ block and therefore +contains exactly one upper-layer protocol unit (e.g. one RTP packet). Curl +writes the interleaved header as well as the included data for each call. The +first byte is always an ASCII dollar sign. The dollar sign is followed by a +one byte channel identifier and then a 2 byte integer length in network byte +order. See RFC 2326 Section 10.12 for more information on how RTP interleaving +behaves. If unset or set to NULL, curl uses the default write function. + +Interleaved RTP poses some challenges for the client application. Since the +stream data is sharing the RTSP control connection, it is critical to service +the RTP in a timely fashion. If the RTP data is not handled quickly, +subsequent response processing may become unreasonably delayed and the +connection may close. The application may use *CURL_RTSPREQ_RECEIVE* to +service RTP data when no requests are desired. If the application makes a +request, (e.g. *CURL_RTSPREQ_PAUSE*) then the response handler processes +any pending RTP data before marking the request as finished. + +The CURLOPT_INTERLEAVEDATA(3) is passed in the *userdata* argument in +the callback. + +Your callback should return the number of bytes actually taken care of. If +that amount differs from the amount passed to your callback function, it +signals an error condition to the library. This causes the transfer to abort +and the libcurl function used returns *CURLE_WRITE_ERROR*. + +You can also abort the transfer by returning CURL_WRITEFUNC_ERROR. (7.87.0) + +# DEFAULT + +NULL, the interleave data is then passed to the regular write function: +CURLOPT_WRITEFUNCTION(3). + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +struct local { + void *custom; +}; + +static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct local *l = userp; + printf("our ptr: %p\n", l->custom); + /* take care of the packet in 'ptr', then return... */ + return size * nmemb; +} + +int main(void) +{ + struct local rtp_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); + curl_easy_setopt(curl, CURLOPT_INTERLEAVEDATA, &rtp_data); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_IOCTLDATA.3 b/docs/libcurl/opts/CURLOPT_IOCTLDATA.3 deleted file mode 100644 index 93742c75e..000000000 --- a/docs/libcurl/opts/CURLOPT_IOCTLDATA.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_IOCTLDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_IOCTLDATA \- pointer passed to I/O callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass the \fIpointer\fP that is untouched by libcurl and passed as the 3rd -argument in the ioctl callback set with \fICURLOPT_IOCTLFUNCTION(3)\fP. -.SH DEFAULT -By default, the value of this parameter is NULL. -.SH PROTOCOLS -Used with HTTP -.SH EXAMPLE -.nf -#include /* for lseek */ - -struct data { - int fd; /* our file descriptor */ -}; - -static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) -{ - struct data *io = (struct data *)clientp; - if(cmd == CURLIOCMD_RESTARTREAD) { - lseek(io->fd, 0, SEEK_SET); - return CURLIOE_OK; - } - return CURLIOE_UNKNOWNCMD; -} -int main(void) -{ - struct data ioctl_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); - curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.3. Deprecated since 7.18.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_IOCTLFUNCTION (3), -.BR CURLOPT_SEEKFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_IOCTLDATA.md b/docs/libcurl/opts/CURLOPT_IOCTLDATA.md new file mode 100644 index 000000000..2490fbc7f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_IOCTLDATA.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_IOCTLDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_IOCTLFUNCTION (3) + - CURLOPT_SEEKFUNCTION (3) +--- + +# NAME + +CURLOPT_IOCTLDATA - pointer passed to I/O callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass the *pointer* that is untouched by libcurl and passed as the 3rd +argument in the ioctl callback set with CURLOPT_IOCTLFUNCTION(3). + +# DEFAULT + +By default, the value of this parameter is NULL. + +# PROTOCOLS + +Used with HTTP + +# EXAMPLE + +~~~c +#include /* for lseek */ + +struct data { + int fd; /* our file descriptor */ +}; + +static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) +{ + struct data *io = (struct data *)clientp; + if(cmd == CURLIOCMD_RESTARTREAD) { + lseek(io->fd, 0, SEEK_SET); + return CURLIOE_OK; + } + return CURLIOE_UNKNOWNCMD; +} +int main(void) +{ + struct data ioctl_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); + curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data); + } +} +~~~ + +# AVAILABILITY + +Added in 7.12.3. Deprecated since 7.18.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.3 b/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.3 deleted file mode 100644 index 981051472..000000000 --- a/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_IOCTLFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_IOCTLFUNCTION \- callback for I/O operations -.SH SYNOPSIS -.nf -#include - -typedef enum { - CURLIOE_OK, /* I/O operation successful */ - CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ - CURLIOE_FAILRESTART, /* failed to restart the read */ - CURLIOE_LAST /* never use */ -} curlioerr; - -typedef enum { - CURLIOCMD_NOP, /* no operation */ - CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ - CURLIOCMD_LAST /* never use */ -} curliocmd; - -curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl when something special -I/O-related needs to be done that the library cannot do by itself. For now, -rewinding the read data stream is the only action it can request. The -rewinding of the read data stream may be necessary when doing an HTTP PUT or -POST with a multi-pass authentication method. - -The callback MUST return \fICURLIOE_UNKNOWNCMD\fP if the input \fIcmd\fP is -not \fICURLIOCMD_RESTARTREAD\fP. - -The \fIclientp\fP argument to the callback is set with the -\fICURLOPT_IOCTLDATA(3)\fP option. - -This option is deprecated! Do not use it. Use \fICURLOPT_SEEKFUNCTION(3)\fP -instead to provide seeking! If \fICURLOPT_SEEKFUNCTION(3)\fP is set, this -parameter is ignored when seeking. -.SH DEFAULT -By default, this parameter is set to NULL. Not used. -.SH PROTOCOLS -Used with HTTP -.SH EXAMPLE -.nf -#include /* for lseek */ - -struct data { - int fd; /* our file descriptor */ -}; - -static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) -{ - struct data *io = (struct data *)clientp; - if(cmd == CURLIOCMD_RESTARTREAD) { - lseek(io->fd, 0, SEEK_SET); - return CURLIOE_OK; - } - return CURLIOE_UNKNOWNCMD; -} -int main(void) -{ - struct data ioctl_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); - curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data); - } -} -.fi -.SH AVAILABILITY -Added in 7.12.3. Deprecated since 7.18.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_IOCTLDATA (3), -.BR CURLOPT_SEEKFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.md b/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.md new file mode 100644 index 000000000..8804ae578 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_IOCTLFUNCTION.md @@ -0,0 +1,103 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_IOCTLFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_IOCTLDATA (3) + - CURLOPT_SEEKFUNCTION (3) +--- + +# NAME + +CURLOPT_IOCTLFUNCTION - callback for I/O operations + +# SYNOPSIS + +~~~c +#include + +typedef enum { + CURLIOE_OK, /* I/O operation successful */ + CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ + CURLIOE_FAILRESTART, /* failed to restart the read */ + CURLIOE_LAST /* never use */ +} curlioerr; + +typedef enum { + CURLIOCMD_NOP, /* no operation */ + CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ + CURLIOCMD_LAST /* never use */ +} curliocmd; + +curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl when something special +I/O-related needs to be done that the library cannot do by itself. For now, +rewinding the read data stream is the only action it can request. The +rewinding of the read data stream may be necessary when doing an HTTP PUT or +POST with a multi-pass authentication method. + +The callback MUST return *CURLIOE_UNKNOWNCMD* if the input *cmd* is +not *CURLIOCMD_RESTARTREAD*. + +The *clientp* argument to the callback is set with the +CURLOPT_IOCTLDATA(3) option. + +**This option is deprecated**. Do not use it. Use CURLOPT_SEEKFUNCTION(3) +instead to provide seeking! If CURLOPT_SEEKFUNCTION(3) is set, this +parameter is ignored when seeking. + +# DEFAULT + +By default, this parameter is set to NULL. Not used. + +# PROTOCOLS + +Used with HTTP + +# EXAMPLE + +~~~c +#include /* for lseek */ + +struct data { + int fd; /* our file descriptor */ +}; + +static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) +{ + struct data *io = (struct data *)clientp; + if(cmd == CURLIOCMD_RESTARTREAD) { + lseek(io->fd, 0, SEEK_SET); + return CURLIOE_OK; + } + return CURLIOE_UNKNOWNCMD; +} +int main(void) +{ + struct data ioctl_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); + curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data); + } +} +~~~ + +# AVAILABILITY + +Added in 7.12.3. Deprecated since 7.18.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_IPRESOLVE.3 b/docs/libcurl/opts/CURLOPT_IPRESOLVE.3 deleted file mode 100644 index 499aed513..000000000 --- a/docs/libcurl/opts/CURLOPT_IPRESOLVE.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_IPRESOLVE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_IPRESOLVE \- IP protocol version to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IPRESOLVE, long resolve); -.fi -.SH DESCRIPTION -Allows an application to select what kind of IP addresses to use when -establishing a connection or choosing one from the connection pool. This is -interesting when using host names that resolve to more than one IP family. - -If the URL provided for a transfer contains a numerical IP version as a host -name, this option does not override or prohibit libcurl from using that IP -version. - -Available values for this option are: -.IP CURL_IPRESOLVE_WHATEVER -Default, can use addresses of all IP versions that your system allows. -.IP CURL_IPRESOLVE_V4 -Uses only IPv4 addresses. -.IP CURL_IPRESOLVE_V6 -Uses only IPv6 addresses. -.SH DEFAULT -CURL_IPRESOLVE_WHATEVER -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - /* of all addresses example.com resolves to, only IPv6 ones are used */ - curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_RESOLVE (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_IPRESOLVE.md b/docs/libcurl/opts/CURLOPT_IPRESOLVE.md new file mode 100644 index 000000000..7d06405ec --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_IPRESOLVE.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_IPRESOLVE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_RESOLVE (3) + - CURLOPT_SSLVERSION (3) +--- + +# NAME + +CURLOPT_IPRESOLVE - IP protocol version to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IPRESOLVE, long resolve); +~~~ + +# DESCRIPTION + +Allows an application to select what kind of IP addresses to use when +establishing a connection or choosing one from the connection pool. This is +interesting when using host names that resolve to more than one IP family. + +If the URL provided for a transfer contains a numerical IP version as a host +name, this option does not override or prohibit libcurl from using that IP +version. + +Available values for this option are: + +## CURL_IPRESOLVE_WHATEVER + +Default, can use addresses of all IP versions that your system allows. + +## CURL_IPRESOLVE_V4 + +Uses only IPv4 addresses. + +## CURL_IPRESOLVE_V6 + +Uses only IPv6 addresses. + +# DEFAULT + +CURL_IPRESOLVE_WHATEVER + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + /* of all addresses example.com resolves to, only IPv6 ones are used */ + curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_ISSUERCERT.3 b/docs/libcurl/opts/CURLOPT_ISSUERCERT.3 deleted file mode 100644 index a0c2f5f79..000000000 --- a/docs/libcurl/opts/CURLOPT_ISSUERCERT.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ISSUERCERT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_ISSUERCERT \- issuer SSL certificate filename -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ISSUERCERT, char *file); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a \fIfile\fP holding a CA -certificate in PEM format. If the option is set, an additional check against -the peer certificate is performed to verify the issuer is indeed the one -associated with the certificate provided by the option. This additional check -is useful in multi-level PKI where one needs to enforce that the peer -certificate is from a specific branch of the tree. - -This option makes sense only when used in combination with the -\fICURLOPT_SSL_VERIFYPEER(3)\fP option. Otherwise, the result of the check is -not considered as failure. - -A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, -which is returned if the setup of the SSL/TLS session has failed due to a -mismatch with the issuer of peer certificate (\fICURLOPT_SSL_VERIFYPEER(3)\fP -has to be set too for the check to fail). (Added in 7.19.0) - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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_ISSUERCERT, "/etc/certs/cacert.pem"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CRLFILE (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_ISSUERCERT.md b/docs/libcurl/opts/CURLOPT_ISSUERCERT.md new file mode 100644 index 000000000..9b35d5d79 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ISSUERCERT.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ISSUERCERT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CRLFILE (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_ISSUERCERT - issuer SSL certificate filename + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ISSUERCERT, char *file); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a *file* holding a CA +certificate in PEM format. If the option is set, an additional check against +the peer certificate is performed to verify the issuer is indeed the one +associated with the certificate provided by the option. This additional check +is useful in multi-level PKI where one needs to enforce that the peer +certificate is from a specific branch of the tree. + +This option makes sense only when used in combination with the +CURLOPT_SSL_VERIFYPEER(3) option. Otherwise, the result of the check is +not considered as failure. + +A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, +which is returned if the setup of the SSL/TLS session has failed due to a +mismatch with the issuer of peer certificate (CURLOPT_SSL_VERIFYPEER(3) +has to be set too for the check to fail). (Added in 7.19.0) + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based 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_ISSUERCERT, "/etc/certs/cacert.pem"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.3 b/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.3 deleted file mode 100644 index 858987e9b..000000000 --- a/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_ISSUERCERT_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_ISSUERCERT_BLOB \- issuer SSL certificate from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ISSUERCERT_BLOB, - struct curl_blob *stblob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure, which contains information (pointer -and size) about a memory block with binary data of a CA certificate in PEM -format. If the option is set, an additional check against the peer certificate -is performed to verify the issuer is indeed the one associated with the -certificate provided by the option. This additional check is useful in -multi-level PKI where one needs to enforce that the peer certificate is from a -specific branch of the tree. - -This option should be used in combination with the -\fICURLOPT_SSL_VERIFYPEER(3)\fP option. Otherwise, the result of the check is -not considered as failure. - -A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, -which is returned if the setup of the SSL/TLS session has failed due to a -mismatch with the issuer of peer certificate (\fICURLOPT_SSL_VERIFYPEER(3)\fP -has to be set too for the check to fail). - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -This option is an alternative to \fICURLOPT_ISSUERCERT(3)\fP which instead -expects a file name as input. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf - -extern char *certificateData; -extern size_t filesize; - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - blob.data = certificateData; - blob.len = filesize; - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_ISSUERCERT_BLOB, &blob); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_ISSUERCERT (3), -.BR CURLOPT_CRLFILE (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.md new file mode 100644 index 000000000..4832f4125 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_ISSUERCERT_BLOB.md @@ -0,0 +1,92 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_ISSUERCERT_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CRLFILE (3) + - CURLOPT_ISSUERCERT (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_ISSUERCERT_BLOB - issuer SSL certificate from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ISSUERCERT_BLOB, + struct curl_blob *stblob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure, which contains information (pointer +and size) about a memory block with binary data of a CA certificate in PEM +format. If the option is set, an additional check against the peer certificate +is performed to verify the issuer is indeed the one associated with the +certificate provided by the option. This additional check is useful in +multi-level PKI where one needs to enforce that the peer certificate is from a +specific branch of the tree. + +This option should be used in combination with the +CURLOPT_SSL_VERIFYPEER(3) option. Otherwise, the result of the check is +not considered as failure. + +A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, +which is returned if the setup of the SSL/TLS session has failed due to a +mismatch with the issuer of peer certificate (CURLOPT_SSL_VERIFYPEER(3) +has to be set too for the check to fail). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +This option is an alternative to CURLOPT_ISSUERCERT(3) which instead +expects a filename as input. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based protocols + +# EXAMPLE + +~~~c + +extern char *certificateData; +extern size_t filesize; + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + blob.data = certificateData; + blob.len = filesize; + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_ISSUERCERT_BLOB, &blob); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.3 b/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.3 deleted file mode 100644 index 466436095..000000000 --- a/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_KEEP_SENDING_ON_ERROR 3 "22 Sep 2016" libcurl libcurl -.SH NAME -CURLOPT_KEEP_SENDING_ON_ERROR \- keep sending on early HTTP response >= 300 -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEEP_SENDING_ON_ERROR, - long keep_sending); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells the library to keep sending the request body -if the HTTP code returned is equal to or larger than 300. The default action -would be to stop sending and close the stream or connection. - -This option is suitable for manual NTLM authentication, i.e. if an application -does not use \fICURLOPT_HTTPAUTH(3)\fP, but instead sets "Authorization: NTLM ..." -headers manually using \fICURLOPT_HTTPHEADER(3)\fP. - -Most applications do not need this option. -.SH DEFAULT -0, stop sending on error -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "sending data"); - curl_easy_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP. Added in 7.51.0. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_RESPONSE_CODE (3), -.BR CURLOPT_FAILONERROR (3), -.BR CURLOPT_HTTPHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.md b/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.md new file mode 100644 index 000000000..090a8fc2d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_KEEP_SENDING_ON_ERROR.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_KEEP_SENDING_ON_ERROR +Section: 3 +Source: libcurl +See-also: + - CURLINFO_RESPONSE_CODE (3) + - CURLOPT_FAILONERROR (3) + - CURLOPT_HTTPHEADER (3) +--- + +# NAME + +CURLOPT_KEEP_SENDING_ON_ERROR - keep sending on early HTTP response >= 300 + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEEP_SENDING_ON_ERROR, + long keep_sending); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells the library to keep sending the request body +if the HTTP code returned is equal to or larger than 300. The default action +would be to stop sending and close the stream or connection. + +This option is suitable for manual NTLM authentication, i.e. if an application +does not use CURLOPT_HTTPAUTH(3), but instead sets "Authorization: NTLM ..." +headers manually using CURLOPT_HTTPHEADER(3). + +Most applications do not need this option. + +# DEFAULT + +0, stop sending on error + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "sending data"); + curl_easy_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP. Added in 7.51.0. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_KEYPASSWD.3 b/docs/libcurl/opts/CURLOPT_KEYPASSWD.3 deleted file mode 100644 index 119f26cd1..000000000 --- a/docs/libcurl/opts/CURLOPT_KEYPASSWD.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_KEYPASSWD 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_KEYPASSWD \- passphrase to private key -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEYPASSWD, char *pwd); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It is used as the -password required to use the \fICURLOPT_SSLKEY(3)\fP or -\fICURLOPT_SSH_PRIVATE_KEYFILE(3)\fP private key. You never need a pass -phrase to load a certificate but you need one to load your private key. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option was known as CURLOPT_SSLKEYPASSWD up to 7.16.4 and -CURLOPT_SSLCERTPASSWD up to 7.9.2. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_PRIVATE_KEYFILE (3), -.BR CURLOPT_SSLKEY (3) diff --git a/docs/libcurl/opts/CURLOPT_KEYPASSWD.md b/docs/libcurl/opts/CURLOPT_KEYPASSWD.md new file mode 100644 index 000000000..7407f0939 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_KEYPASSWD.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_KEYPASSWD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_PRIVATE_KEYFILE (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_KEYPASSWD - passphrase to private key + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KEYPASSWD, char *pwd); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It is used as the +password required to use the CURLOPT_SSLKEY(3) or +CURLOPT_SSH_PRIVATE_KEYFILE(3) private key. You never need a pass phrase to +load a certificate but you need one to load your private key. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "superman"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option was known as CURLOPT_SSLKEYPASSWD up to 7.16.4 and +CURLOPT_SSLCERTPASSWD up to 7.9.2. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_KRBLEVEL.3 b/docs/libcurl/opts/CURLOPT_KRBLEVEL.3 deleted file mode 100644 index 7be711e1d..000000000 --- a/docs/libcurl/opts/CURLOPT_KRBLEVEL.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_KRBLEVEL 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_KRBLEVEL \- FTP kerberos security level -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KRBLEVEL, char *level); -.fi -.SH DESCRIPTION -Pass a char * as parameter. Set the kerberos security level for FTP; this also -enables kerberos awareness. This is a string that should match one of the -following: \&'clear', \&'safe', \&'confidential' or \&'private'. If the string -is set but does not match one of these, 'private' is used. Set the string to -NULL to disable kerberos support for FTP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_KRBLEVEL, "private"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option was known as CURLOPT_KRB4LEVEL up to 7.16.3 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_KRBLEVEL (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_KRBLEVEL.md b/docs/libcurl/opts/CURLOPT_KRBLEVEL.md new file mode 100644 index 000000000..cb8e27689 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_KRBLEVEL.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_KRBLEVEL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_KRBLEVEL (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_KRBLEVEL - FTP kerberos security level + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_KRBLEVEL, char *level); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter. Set the kerberos security level for FTP; +this also enables kerberos awareness. This is a string that should match one +of the following: &'clear', &'safe', &'confidential' or &'private'. If the +string is set but does not match one of these, 'private' is used. Set the +string to NULL to disable kerberos support for FTP. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_KRBLEVEL, "private"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option was known as CURLOPT_KRB4LEVEL up to 7.16.3 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_LOCALPORT.3 b/docs/libcurl/opts/CURLOPT_LOCALPORT.3 deleted file mode 100644 index e5bddf1c1..000000000 --- a/docs/libcurl/opts/CURLOPT_LOCALPORT.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_LOCALPORT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_LOCALPORT \- local port number to use for socket -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port); -.fi -.SH DESCRIPTION -Pass a long. This sets the local port number of the socket used for the -connection. This can be used in combination with \fICURLOPT_INTERFACE(3)\fP -and you are recommended to use \fICURLOPT_LOCALPORTRANGE(3)\fP as well when -this option is set. Valid port numbers are 1 - 65535. -.SH DEFAULT -0, disabled - use whatever the system thinks is fine -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); - /* and try 20 more ports following that */ - curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.2 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLINFO_LOCAL_PORT (3), -.BR CURLOPT_INTERFACE (3), -.BR CURLOPT_LOCALPORTRANGE (3) diff --git a/docs/libcurl/opts/CURLOPT_LOCALPORT.md b/docs/libcurl/opts/CURLOPT_LOCALPORT.md new file mode 100644 index 000000000..25a21c15e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_LOCALPORT.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_LOCALPORT +Section: 3 +Source: libcurl +See-also: + - CURLINFO_LOCAL_PORT (3) + - CURLOPT_INTERFACE (3) + - CURLOPT_LOCALPORTRANGE (3) +--- + +# NAME + +CURLOPT_LOCALPORT - local port number to use for socket + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port); +~~~ + +# DESCRIPTION + +Pass a long. This sets the local port number of the socket used for the +connection. This can be used in combination with CURLOPT_INTERFACE(3) +and you are recommended to use CURLOPT_LOCALPORTRANGE(3) as well when +this option is set. Valid port numbers are 1 - 65535. + +# DEFAULT + +0, disabled - use whatever the system thinks is fine + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); + /* and try 20 more ports following that */ + curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.2 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.3 b/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.3 deleted file mode 100644 index 71934e323..000000000 --- a/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_LOCALPORTRANGE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_LOCALPORTRANGE \- number of additional local ports to try -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE, - long range); -.fi -.SH DESCRIPTION -Pass a long. The \fIrange\fP argument is the number of attempts libcurl makes -to find a working local port number. It starts with the given -\fICURLOPT_LOCALPORT(3)\fP and adds one to the number for each retry. Setting -this option to 1 or below makes libcurl only do one try for the exact port -number. Port numbers by nature are scarce resources that are busy at times so -setting this value to something too low might cause unnecessary connection -setup failures. -.SH DEFAULT -1 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); - /* and try 20 more ports following that */ - curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.2 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_INTERFACE (3), -.BR CURLOPT_LOCALPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.md b/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.md new file mode 100644 index 000000000..520020790 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_LOCALPORTRANGE.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_LOCALPORTRANGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INTERFACE (3) + - CURLOPT_LOCALPORT (3) +--- + +# NAME + +CURLOPT_LOCALPORTRANGE - number of additional local ports to try + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORTRANGE, + long range); +~~~ + +# DESCRIPTION + +Pass a long. The *range* argument is the number of attempts libcurl makes +to find a working local port number. It starts with the given +CURLOPT_LOCALPORT(3) and adds one to the number for each retry. Setting +this option to 1 or below makes libcurl only do one try for the exact port +number. Port numbers by nature are scarce resources that are busy at times so +setting this value to something too low might cause unnecessary connection +setup failures. + +# DEFAULT + +1 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L); + /* and try 20 more ports following that */ + curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.2 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.3 deleted file mode 100644 index 5410bbdce..000000000 --- a/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_LOGIN_OPTIONS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_LOGIN_OPTIONS \- login options -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOGIN_OPTIONS, char *options); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -\fIoptions\fP string to use for the transfer. - -For more information about the login options please see RFC 2384, RFC 5092 and -the IETF draft \fBdraft-earhart-url-smtp-00.txt\fP. - -\fICURLOPT_LOGIN_OPTIONS(3)\fP can be used to set protocol specific login -options, such as the preferred authentication mechanism via "AUTH=NTLM" or -"AUTH=*", and should be used in conjunction with the \fICURLOPT_USERNAME(3)\fP -option. - -Since 8.2.0, IMAP supports the login option "AUTH=+LOGIN". With this option, -curl uses the plain (not SASL) LOGIN IMAP command even if the server -advertises SASL authentication. Care should be taken in using this option, as -it sends your password in plain text. This does not work if the IMAP server -disables the plain LOGIN (e.g. to prevent password snooping). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -Only IMAP, LDAP, POP3 and SMTP support login options. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=*"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.34.0. Support for OpenLDAP added in 7.82.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.md b/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.md new file mode 100644 index 000000000..a57b44690 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_LOGIN_OPTIONS.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_LOGIN_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PASSWORD (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_LOGIN_OPTIONS - login options + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOGIN_OPTIONS, char *options); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the +null-terminated *options* string to use for the transfer. + +For more information about the login options please see RFC 2384, RFC 5092 and +the IETF draft **draft-earhart-url-smtp-00.txt**. + +CURLOPT_LOGIN_OPTIONS(3) can be used to set protocol specific login options, +such as the preferred authentication mechanism via "AUTH=NTLM" or "AUTH=*", +and should be used in conjunction with the CURLOPT_USERNAME(3) option. + +Since 8.2.0, IMAP supports the login option "AUTH=+LOGIN". With this option, +curl uses the plain (not SASL) LOGIN IMAP command even if the server +advertises SASL authentication. Care should be taken in using this option, as +it sends your password in plain text. This does not work if the IMAP server +disables the plain LOGIN (e.g. to prevent password snooping). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +Only IMAP, LDAP, POP3 and SMTP support login options. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=*"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.34.0. Support for OpenLDAP added in 7.82.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.3 b/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.3 deleted file mode 100644 index d491e655b..000000000 --- a/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_LOW_SPEED_LIMIT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_LOW_SPEED_LIMIT \- low speed limit in bytes per second -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOW_SPEED_LIMIT, - long speedlimit); -.fi -.SH DESCRIPTION -Pass a long as parameter. It contains the average transfer speed in bytes per -second that the transfer should be below during -\fICURLOPT_LOW_SPEED_TIME(3)\fP seconds for libcurl to consider it to be too -slow and abort. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - /* abort if slower than 30 bytes/sec during 60 seconds */ - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L); - res = curl_easy_perform(curl); - if(CURLE_OPERATION_TIMEDOUT == res) { - printf("Timeout!\\n"); - } - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_LOW_SPEED_TIME (3), -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_MAX_SEND_SPEED_LARGE (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.md b/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.md new file mode 100644 index 000000000..99df9faed --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_LOW_SPEED_LIMIT.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_LOW_SPEED_LIMIT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_TIME (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) + - CURLOPT_MAX_SEND_SPEED_LARGE (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_LOW_SPEED_LIMIT - low speed limit in bytes per second + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOW_SPEED_LIMIT, + long speedlimit); +~~~ + +# DESCRIPTION + +Pass a long as parameter. It contains the average transfer speed in bytes per +second that the transfer should be below during +CURLOPT_LOW_SPEED_TIME(3) seconds for libcurl to consider it to be too +slow and abort. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + /* abort if slower than 30 bytes/sec during 60 seconds */ + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L); + res = curl_easy_perform(curl); + if(CURLE_OPERATION_TIMEDOUT == res) { + printf("Timeout!\n"); + } + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.3 b/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.3 deleted file mode 100644 index 507ac4528..000000000 --- a/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_LOW_SPEED_TIME 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_LOW_SPEED_TIME \- low speed limit time period -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOW_SPEED_TIME, - long speedtime); -.fi -.SH DESCRIPTION -Pass a long as parameter. It contains the time in number seconds that the -transfer speed should be below the \fICURLOPT_LOW_SPEED_LIMIT(3)\fP for the -library to consider it too slow and abort. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - /* abort if slower than 30 bytes/sec during 60 seconds */ - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L); - res = curl_easy_perform(curl); - if(CURLE_OPERATION_TIMEDOUT == res) { - printf("Timeout!\\n"); - } - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.md b/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.md new file mode 100644 index 000000000..a3a9ef1ff --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_LOW_SPEED_TIME.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_LOW_SPEED_TIME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_LOW_SPEED_TIME - low speed limit time period + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOW_SPEED_TIME, + long speedtime); +~~~ + +# DESCRIPTION + +Pass a long as parameter. It contains the time in number seconds that the +transfer speed should be below the CURLOPT_LOW_SPEED_LIMIT(3) for the +library to consider it too slow and abort. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + /* abort if slower than 30 bytes/sec during 60 seconds */ + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L); + res = curl_easy_perform(curl); + if(CURLE_OPERATION_TIMEDOUT == res) { + printf("Timeout!\n"); + } + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_MAIL_AUTH.3 b/docs/libcurl/opts/CURLOPT_MAIL_AUTH.3 deleted file mode 100644 index 340d801d8..000000000 --- a/docs/libcurl/opts/CURLOPT_MAIL_AUTH.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAIL_AUTH 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAIL_AUTH \- SMTP authentication address -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_AUTH, char *auth); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. This is used to -specify the authentication address (identity) of a submitted message that is -being relayed to another server. - -This optional parameter allows co-operating agents in a trusted environment to -communicate the authentication of individual messages and should only be used -by the application program, using libcurl, if the application is itself a mail -server acting in such an environment. If the application is operating as such -and the AUTH address is not known or is invalid, then an empty string should -be used for this parameter. - -Unlike \fICURLOPT_MAIL_FROM(3)\fP and \fICURLOPT_MAIL_RCPT(3)\fP, the address -should not be specified within a pair of angled brackets (<>). However, if an -empty string is used then a pair of brackets are sent by libcurl as required -by RFC 2554. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, ""); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.25.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_FROM (3), -.BR CURLOPT_MAIL_RCPT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAIL_AUTH.md b/docs/libcurl/opts/CURLOPT_MAIL_AUTH.md new file mode 100644 index 000000000..a5dbc7d79 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAIL_AUTH.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAIL_AUTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_FROM (3) + - CURLOPT_MAIL_RCPT (3) +--- + +# NAME + +CURLOPT_MAIL_AUTH - SMTP authentication address + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_AUTH, char *auth); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. This is used to +specify the authentication address (identity) of a submitted message that is +being relayed to another server. + +This optional parameter allows co-operating agents in a trusted environment to +communicate the authentication of individual messages and should only be used +by the application program, using libcurl, if the application is itself a mail +server acting in such an environment. If the application is operating as such +and the AUTH address is not known or is invalid, then an empty string should +be used for this parameter. + +Unlike CURLOPT_MAIL_FROM(3) and CURLOPT_MAIL_RCPT(3), the address +should not be specified within a pair of angled brackets (<>). However, if an +empty string is used then a pair of brackets are sent by libcurl as required +by RFC 2554. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, ""); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.25.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_MAIL_FROM.3 b/docs/libcurl/opts/CURLOPT_MAIL_FROM.3 deleted file mode 100644 index b76455c61..000000000 --- a/docs/libcurl/opts/CURLOPT_MAIL_FROM.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAIL_FROM 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAIL_FROM \- SMTP sender address -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_FROM, char *from); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. This should be used -to specify the sender's email address when sending SMTP mail with libcurl. - -An originator email address should be specified with angled brackets (<>) -around it, which if not specified are added automatically. - -If this parameter is not specified then an empty address is sent to the SMTP -server which might cause the email to be rejected. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "president@example.com"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_AUTH (3), -.BR CURLOPT_MAIL_RCPT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAIL_FROM.md b/docs/libcurl/opts/CURLOPT_MAIL_FROM.md new file mode 100644 index 000000000..c4984b056 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAIL_FROM.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAIL_FROM +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_AUTH (3) + - CURLOPT_MAIL_RCPT (3) +--- + +# NAME + +CURLOPT_MAIL_FROM - SMTP sender address + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_FROM, char *from); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. This should be used +to specify the sender's email address when sending SMTP mail with libcurl. + +An originator email address should be specified with angled brackets (<>) +around it, which if not specified are added automatically. + +If this parameter is not specified then an empty address is sent to the SMTP +server which might cause the email to be rejected. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "president@example.com"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_MAIL_RCPT.3 b/docs/libcurl/opts/CURLOPT_MAIL_RCPT.3 deleted file mode 100644 index 5a47e3d9a..000000000 --- a/docs/libcurl/opts/CURLOPT_MAIL_RCPT.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAIL_RCPT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAIL_RCPT \- list of SMTP mail recipients -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT, - struct curl_slist *rcpts); -.SH DESCRIPTION -Pass a pointer to a linked list of recipients to pass to the server in your -SMTP mail request. The linked list should be a fully valid list of -\fBstruct curl_slist\fP structs properly filled in. Use -\fIcurl_slist_append(3)\fP to create the list and \fIcurl_slist_free_all(3)\fP -to clean up an entire list. - -When performing a mail transfer, each recipient should be specified within a -pair of angled brackets (<>), however, should you not use an angled bracket as -the first character libcurl assumes you provided a single email address and -encloses that address within brackets for you. - -When performing an address verification (\fBVRFY\fP command), each recipient -should be specified as the user name or user name and domain (as per Section -3.5 of RFC 5321). - -When performing a mailing list expand (\fBEXPN\fP command), each recipient -should be specified using the mailing list name, such as "Friends" or -"London-Office". -.SH DEFAULT -NULL -.SH PROTOCOLS -SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_slist *list; - list = curl_slist_append(NULL, "root@localhost"); - list = curl_slist_append(list, "person@example.com"); - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list); - res = curl_easy_perform(curl); - curl_slist_free_all(list); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0. The \fBVRFY\fP and \fBEXPN\fP logic was added in 7.34.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_AUTH (3), -.BR CURLOPT_MAIL_FROM (3) diff --git a/docs/libcurl/opts/CURLOPT_MAIL_RCPT.md b/docs/libcurl/opts/CURLOPT_MAIL_RCPT.md new file mode 100644 index 000000000..ce57074f0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAIL_RCPT.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAIL_RCPT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_AUTH (3) + - CURLOPT_MAIL_FROM (3) +--- + +# NAME + +CURLOPT_MAIL_RCPT - list of SMTP mail recipients + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT, + struct curl_slist *rcpts); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of recipients to pass to the server in your +SMTP mail request. The linked list should be a fully valid list of +**struct curl_slist** structs properly filled in. Use +curl_slist_append(3) to create the list and curl_slist_free_all(3) +to clean up an entire list. + +When performing a mail transfer, each recipient should be specified within a +pair of angled brackets (<>), however, should you not use an angled bracket as +the first character libcurl assumes you provided a single email address and +encloses that address within brackets for you. + +When performing an address verification (**VRFY** command), each recipient +should be specified as the user name or user name and domain (as per Section +3.5 of RFC 5321). + +When performing a mailing list expand (**EXPN** command), each recipient +should be specified using the mailing list name, such as "Friends" or +"London-Office". + +# DEFAULT + +NULL + +# PROTOCOLS + +SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_slist *list; + list = curl_slist_append(NULL, "root@localhost"); + list = curl_slist_append(list, "person@example.com"); + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list); + res = curl_easy_perform(curl); + curl_slist_free_all(list); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0. The **VRFY** and **EXPN** logic was added in 7.34.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.3 b/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.3 deleted file mode 100644 index bef151485..000000000 --- a/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAIL_RCPT_ALLOWFAILS 3 "16 Jan 2020" libcurl libcurl -.SH NAME -CURLOPT_MAIL_RCPT_ALLOWFAILS \- allow RCPT TO command to fail for some recipients -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT_ALLOWFAILS, - long allow); -.SH DESCRIPTION -If \fIallow\fP is set to 1L, allow RCPT TO command to fail for some recipients. - -When sending data to multiple recipients, by default curl aborts the SMTP -conversation if either one of the recipients causes the RCPT TO command to -return an error. - -The default behavior can be changed by setting \fIallow\fP to 1L which makes -libcurl ignore errors for individual recipients and proceed with the remaining -accepted recipients. - -If all recipients trigger RCPT TO failures and this flag is specified, curl -aborts the SMTP conversation and returns the error received from to the last -RCPT TO command. -.SH DEFAULT -0 -.SH PROTOCOLS -SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct curl_slist *list; - CURLcode res; - - /* Adding one valid and one invalid email address */ - list = curl_slist_append(NULL, "person@example.com"); - list = curl_slist_append(list, "invalidemailaddress"); - - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L); - - res = curl_easy_perform(curl); - curl_slist_free_all(list); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -This option was called CURLOPT_MAIL_RCPT_ALLLOWFAILS before 8.2.0 - -Added in 7.69.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_FROM (3), -.BR CURLOPT_MAIL_RCPT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.md b/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.md new file mode 100644 index 000000000..cf595e26b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAIL_RCPT_ALLOWFAILS.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAIL_RCPT_ALLOWFAILS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_FROM (3) + - CURLOPT_MAIL_RCPT (3) +--- + +# NAME + +CURLOPT_MAIL_RCPT_ALLOWFAILS - allow RCPT TO command to fail for some recipients + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT_ALLOWFAILS, + long allow); +~~~ + +# DESCRIPTION + +If *allow* is set to 1L, allow RCPT TO command to fail for some recipients. + +When sending data to multiple recipients, by default curl aborts the SMTP +conversation if either one of the recipients causes the RCPT TO command to +return an error. + +The default behavior can be changed by setting *allow* to 1L which makes +libcurl ignore errors for individual recipients and proceed with the remaining +accepted recipients. + +If all recipients trigger RCPT TO failures and this flag is specified, curl +aborts the SMTP conversation and returns the error received from to the last +RCPT TO command. + +# DEFAULT + +0 + +# PROTOCOLS + +SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct curl_slist *list; + CURLcode res; + + /* Adding one valid and one invalid email address */ + list = curl_slist_append(NULL, "person@example.com"); + list = curl_slist_append(list, "invalidemailaddress"); + + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_MAIL_RCPT_ALLOWFAILS, 1L); + + res = curl_easy_perform(curl); + curl_slist_free_all(list); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +This option was called CURLOPT_MAIL_RCPT_ALLLOWFAILS before 8.2.0 + +Added in 7.69.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.3 b/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.3 deleted file mode 100644 index 652792857..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXAGE_CONN 3 "18 Apr 2019" libcurl libcurl -.SH NAME -CURLOPT_MAXAGE_CONN \- max idle time allowed for reusing a connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long age); -.fi -.SH DESCRIPTION -Pass a long as parameter containing \fIage\fP - the maximum time in seconds -allowed for an existing connection to have been idle to be considered for -reuse for this request. - -The "connection cache" holds previously used connections. When a new request -is to be done, libcurl considers any connection that matches for reuse. The -\fICURLOPT_MAXAGE_CONN(3)\fP limit prevents libcurl from trying too old -connections for reuse, since old connections have a higher risk of not working -and thus trying them is a performance loss and sometimes service loss due to -the difficulties to figure out the situation. If a connection is found in the -cache that is older than this set \fIage\fP, it is closed instead. -.SH DEFAULT -Default maximum age is set to 118 seconds. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* only allow 30 seconds idle time */ - curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.65.0 -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_FORBID_REUSE (3), -.BR CURLOPT_FRESH_CONNECT (3), -.BR CURLOPT_MAXLIFETIME_CONN (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.md b/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.md new file mode 100644 index 000000000..3d0a9cb2a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXAGE_CONN.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXAGE_CONN +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FORBID_REUSE (3) + - CURLOPT_FRESH_CONNECT (3) + - CURLOPT_MAXLIFETIME_CONN (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_MAXAGE_CONN - max idle time allowed for reusing a connection + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXAGE_CONN, long age); +~~~ + +# DESCRIPTION + +Pass a long as parameter containing *age* - the maximum time in seconds +allowed for an existing connection to have been idle to be considered for +reuse for this request. + +The "connection cache" holds previously used connections. When a new request +is to be done, libcurl considers any connection that matches for reuse. The +CURLOPT_MAXAGE_CONN(3) limit prevents libcurl from trying too old +connections for reuse, since old connections have a higher risk of not working +and thus trying them is a performance loss and sometimes service loss due to +the difficulties to figure out the situation. If a connection is found in the +cache that is older than this set *age*, it is closed instead. + +# DEFAULT + +Default maximum age is set to 118 seconds. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* only allow 30 seconds idle time */ + curl_easy_setopt(curl, CURLOPT_MAXAGE_CONN, 30L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.65.0 + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_MAXCONNECTS.3 b/docs/libcurl/opts/CURLOPT_MAXCONNECTS.3 deleted file mode 100644 index bb1c40398..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXCONNECTS.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXCONNECTS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAXCONNECTS \- maximum connection cache size -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount); -.fi -.SH DESCRIPTION -Pass a long. The set \fIamount\fP is the maximum number of simultaneously open -persistent connections that libcurl may cache in the pool associated with this -handle. The default is 5, and there is not much point in changing this value -unless you are perfectly aware of how this works. This concerns connections -using any of the protocols that support persistent connections. - -When reaching the maximum limit, curl closes the oldest one in the cache to -prevent increasing the number of open connections. - -If you already have performed transfers with this curl handle, setting a -smaller \fICURLOPT_MAXCONNECTS(3)\fP than before may cause open connections to -get closed unnecessarily. - -If you add this easy handle to a multi handle, this setting is not -acknowledged, and you must instead use \fIcurl_multi_setopt(3)\fP and the -\fICURLMOPT_MAXCONNECTS(3)\fP option. -.SH DEFAULT -5 -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* limit the connection cache for this handle to no more than 3 */ - curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3), -.BR CURLMOPT_MAX_TOTAL_CONNECTIONS (3), -.BR CURLMOPT_MAXCONNECTS (3), -.BR CURLOPT_MAXREDIRS (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXCONNECTS.md b/docs/libcurl/opts/CURLOPT_MAXCONNECTS.md new file mode 100644 index 000000000..807df4da1 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXCONNECTS.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXCONNECTS +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_MAXCONNECTS (3) + - CURLMOPT_MAX_HOST_CONNECTIONS (3) + - CURLMOPT_MAX_TOTAL_CONNECTIONS (3) + - CURLOPT_MAXREDIRS (3) +--- + +# NAME + +CURLOPT_MAXCONNECTS - maximum connection cache size + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXCONNECTS, long amount); +~~~ + +# DESCRIPTION + +Pass a long. The set *amount* is the maximum number of simultaneously open +persistent connections that libcurl may cache in the pool associated with this +handle. The default is 5, and there is not much point in changing this value +unless you are perfectly aware of how this works. This concerns connections +using any of the protocols that support persistent connections. + +When reaching the maximum limit, curl closes the oldest one in the cache to +prevent increasing the number of open connections. + +If you already have performed transfers with this curl handle, setting a +smaller CURLOPT_MAXCONNECTS(3) than before may cause open connections to +get closed unnecessarily. + +If you add this easy handle to a multi handle, this setting is not +acknowledged, and you must instead use curl_multi_setopt(3) and the +CURLMOPT_MAXCONNECTS(3) option. + +# DEFAULT + +5 + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* limit the connection cache for this handle to no more than 3 */ + curl_easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_MAXFILESIZE.3 b/docs/libcurl/opts/CURLOPT_MAXFILESIZE.3 deleted file mode 100644 index ed970b29e..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXFILESIZE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXFILESIZE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAXFILESIZE \- maximum file size allowed to download -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE, long size); -.fi -.SH DESCRIPTION -Pass a long as parameter. This specifies the maximum accepted \fIsize\fP (in -bytes) of a file to download. If the file requested is found larger than this -value, the transfer is aborted and \fICURLE_FILESIZE_EXCEEDED\fP is returned. - -The file size is not always known prior to the download start, and for such -transfers this option has no effect - even if the file transfer eventually -ends up being larger than this given limit. - -If you want a limit above 2GB, use \fICURLOPT_MAXFILESIZE_LARGE(3)\fP. - -Since 8.4.0, this option also stops ongoing transfers if they reach this -threshold. -.SH DEFAULT -None -.SH PROTOCOLS -FTP, HTTP and MQTT -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* refuse to download if larger than 1000 bytes! */ - curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_MAXFILESIZE_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXFILESIZE.md b/docs/libcurl/opts/CURLOPT_MAXFILESIZE.md new file mode 100644 index 000000000..a90c94b7d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXFILESIZE.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXFILESIZE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAXFILESIZE_LARGE (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) +--- + +# NAME + +CURLOPT_MAXFILESIZE - maximum file size allowed to download + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE, long size); +~~~ + +# DESCRIPTION + +Pass a long as parameter. This specifies the maximum accepted *size* (in +bytes) of a file to download. If the file requested is found larger than this +value, the transfer is aborted and *CURLE_FILESIZE_EXCEEDED* is returned. + +The file size is not always known prior to the download start, and for such +transfers this option has no effect - even if the file transfer eventually +ends up being larger than this given limit. + +If you want a limit above 2GB, use CURLOPT_MAXFILESIZE_LARGE(3). + +Since 8.4.0, this option also stops ongoing transfers if they reach this +threshold. + +# DEFAULT + +None + +# PROTOCOLS + +FTP, HTTP and MQTT + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* refuse to download if larger than 1000 bytes! */ + curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.3 b/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.3 deleted file mode 100644 index 209701c4e..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXFILESIZE_LARGE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAXFILESIZE_LARGE \- maximum file size allowed to download -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE_LARGE, - curl_off_t size); -.SH DESCRIPTION -Pass a curl_off_t as parameter. This specifies the maximum accepted \fIsize\fP -(in bytes) of a file to download. If the file requested is found larger than -this value, the transfer is aborted and \fICURLE_FILESIZE_EXCEEDED\fP is -returned. - -The file size is not always known prior to the download start, and for such -transfers this option has no effect - even if the file transfer eventually -ends up being larger than this given limit. - -Since 8.4.0, this option also stops ongoing transfers if they reach this -threshold. -.SH DEFAULT -None -.SH PROTOCOLS -FTP, HTTP and MQTT -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_off_t ridiculous = (curl_off_t)1 << 48; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* refuse to download if larger than ridiculous */ - curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.11.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_MAXFILESIZE (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.md b/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.md new file mode 100644 index 000000000..041282f41 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXFILESIZE_LARGE.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXFILESIZE_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAXFILESIZE (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) +--- + +# NAME + +CURLOPT_MAXFILESIZE_LARGE - maximum file size allowed to download + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE_LARGE, + curl_off_t size); +~~~ + +# DESCRIPTION + +Pass a curl_off_t as parameter. This specifies the maximum accepted *size* +(in bytes) of a file to download. If the file requested is found larger than +this value, the transfer is aborted and *CURLE_FILESIZE_EXCEEDED* is +returned. + +The file size is not always known prior to the download start, and for such +transfers this option has no effect - even if the file transfer eventually +ends up being larger than this given limit. + +Since 8.4.0, this option also stops ongoing transfers if they reach this +threshold. + +# DEFAULT + +None + +# PROTOCOLS + +FTP, HTTP and MQTT + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_off_t ridiculous = (curl_off_t)1 << 48; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* refuse to download if larger than ridiculous */ + curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.11.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.3 b/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.3 deleted file mode 100644 index c3ec8aab9..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXLIFETIME_CONN 3 "10 Nov 2021" libcurl libcurl -.SH NAME -CURLOPT_MAXLIFETIME_CONN \- max lifetime (since creation) allowed for reusing a connection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXLIFETIME_CONN, - long maxlifetime); -.fi -.SH DESCRIPTION -Pass a long as parameter containing \fImaxlifetime\fP - the maximum time in -seconds, since the creation of the connection, that you allow an existing -connection to have to be considered for reuse for this request. - -libcurl features a connection cache that holds previously used connections. -When a new request is to be done, libcurl considers any connection that -matches for reuse. The \fICURLOPT_MAXLIFETIME_CONN(3)\fP limit prevents -libcurl from trying too old connections for reuse. This can be used for -client-side load balancing. If a connection is found in the cache that is -older than this set \fImaxlifetime\fP, it is instead marked for closure. - -If set to 0, this behavior is disabled: all connections are eligible for reuse. -.SH DEFAULT -Default \fImaxlifetime\fP is 0 seconds (i.e., disabled). -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* only allow each connection to be reused for 30 seconds */ - curl_easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 30L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.80.0 -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_FORBID_REUSE (3), -.BR CURLOPT_FRESH_CONNECT (3), -.BR CURLOPT_MAXAGE_CONN (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.md b/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.md new file mode 100644 index 000000000..f731ad999 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXLIFETIME_CONN +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FORBID_REUSE (3) + - CURLOPT_FRESH_CONNECT (3) + - CURLOPT_MAXAGE_CONN (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_MAXLIFETIME_CONN - max lifetime (since creation) allowed for reusing a connection + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXLIFETIME_CONN, + long maxlifetime); +~~~ + +# DESCRIPTION + +Pass a long as parameter containing *maxlifetime* - the maximum time in +seconds, since the creation of the connection, that you allow an existing +connection to have to be considered for reuse for this request. + +libcurl features a connection cache that holds previously used connections. +When a new request is to be done, libcurl considers any connection that +matches for reuse. The CURLOPT_MAXLIFETIME_CONN(3) limit prevents +libcurl from trying too old connections for reuse. This can be used for +client-side load balancing. If a connection is found in the cache that is +older than this set *maxlifetime*, it is instead marked for closure. + +If set to 0, this behavior is disabled: all connections are eligible for reuse. + +# DEFAULT + +Default *maxlifetime* is 0 seconds (i.e., disabled). + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* only allow each connection to be reused for 30 seconds */ + curl_easy_setopt(curl, CURLOPT_MAXLIFETIME_CONN, 30L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.80.0 + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_MAXREDIRS.3 b/docs/libcurl/opts/CURLOPT_MAXREDIRS.3 deleted file mode 100644 index 763425a07..000000000 --- a/docs/libcurl/opts/CURLOPT_MAXREDIRS.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAXREDIRS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAXREDIRS \- maximum number of redirects allowed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXREDIRS, long amount); -.fi -.SH DESCRIPTION -Pass a long. The set number is the redirection limit \fIamount\fP. If that -many redirections have been followed, the next redirect triggers the error -(\fICURLE_TOO_MANY_REDIRECTS\fP). This option only makes sense if the -\fICURLOPT_FOLLOWLOCATION(3)\fP is used at the same time. - -Setting the limit to 0 makes libcurl refuse any redirect. - -Set it to -1 for an infinite number of redirects. This allows your application -to get stuck in never-ending redirect loops. -.SH DEFAULT -30 (since 8.3.0), it was previously unlimited. -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - - /* enable redirect following */ - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - - /* allow three redirects */ - curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLOPT_FOLLOWLOCATION (3) diff --git a/docs/libcurl/opts/CURLOPT_MAXREDIRS.md b/docs/libcurl/opts/CURLOPT_MAXREDIRS.md new file mode 100644 index 000000000..5ace67e42 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAXREDIRS.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAXREDIRS +Section: 3 +Source: libcurl +See-also: + - CURLINFO_REDIRECT_COUNT (3) + - CURLINFO_REDIRECT_URL (3) + - CURLOPT_FOLLOWLOCATION (3) +--- + +# NAME + +CURLOPT_MAXREDIRS - maximum number of redirects allowed + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXREDIRS, long amount); +~~~ + +# DESCRIPTION + +Pass a long. The set number is the redirection limit *amount*. If that +many redirections have been followed, the next redirect triggers the error +(*CURLE_TOO_MANY_REDIRECTS*). This option only makes sense if the +CURLOPT_FOLLOWLOCATION(3) is used at the same time. + +Setting the limit to 0 makes libcurl refuse any redirect. + +Set it to -1 for an infinite number of redirects. This allows your application +to get stuck in never-ending redirect loops. + +# DEFAULT + +30 (since 8.3.0), it was previously unlimited. + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + + /* enable redirect following */ + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + /* allow three redirects */ + curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.3 b/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.3 deleted file mode 100644 index 9f0a5ac92..000000000 --- a/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAX_RECV_SPEED_LARGE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAX_RECV_SPEED_LARGE \- rate limit data download speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAX_RECV_SPEED_LARGE, - curl_off_t maxspeed); -.SH DESCRIPTION -Pass a curl_off_t as parameter. If a download exceeds this \fImaxspeed\fP -(counted in bytes per second) the transfer pauses to keep the average speed -less than or equal to the parameter value. Defaults to unlimited speed. - -This is not an exact science. libcurl attempts to keep the average speed below -the given threshold over a period time. - -If you set \fImaxspeed\fP to a value lower than \fICURLOPT_BUFFERSIZE(3)\fP, -libcurl might download faster than the set limit initially. - -This option does not affect transfer speeds done with FILE:// URLs. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -All but file:// -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* cap the download speed to 31415 bytes/sec */ - curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)31415); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.5 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_MAX_SEND_SPEED_LARGE (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.md b/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.md new file mode 100644 index 000000000..646f301e4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAX_RECV_SPEED_LARGE.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAX_RECV_SPEED_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_MAX_SEND_SPEED_LARGE (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_MAX_RECV_SPEED_LARGE - rate limit data download speed + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAX_RECV_SPEED_LARGE, + curl_off_t maxspeed); +~~~ + +# DESCRIPTION + +Pass a curl_off_t as parameter. If a download exceeds this *maxspeed* +(counted in bytes per second) the transfer pauses to keep the average speed +less than or equal to the parameter value. Defaults to unlimited speed. + +This is not an exact science. libcurl attempts to keep the average speed below +the given threshold over a period time. + +If you set *maxspeed* to a value lower than CURLOPT_BUFFERSIZE(3), +libcurl might download faster than the set limit initially. + +This option does not affect transfer speeds done with FILE:// URLs. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +All but file:// + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* cap the download speed to 31415 bytes/sec */ + curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)31415); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.5 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.3 b/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.3 deleted file mode 100644 index 364baed31..000000000 --- a/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MAX_SEND_SPEED_LARGE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_MAX_SEND_SPEED_LARGE \- rate limit data upload speed -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAX_SEND_SPEED_LARGE, - curl_off_t maxspeed); -.SH DESCRIPTION -Pass a curl_off_t as parameter with the \fImaxspeed\fP. If an upload exceeds -this speed (counted in bytes per second) the transfer pauses to keep the -average speed less than or equal to the parameter value. Defaults to unlimited -speed. - -This is not an exact science. libcurl attempts to keep the average speed below -the given threshold over a period time. - -If you set \fImaxspeed\fP to a value lower than -\fICURLOPT_UPLOAD_BUFFERSIZE(3)\fP, libcurl might "shoot over" the limit on -its first send and still send off a full buffer. - -This option does not affect transfer speeds done with FILE:// URLs. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -All except file:// -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* cap the upload speed to 1000 bytes/sec */ - curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)1000); - /* (set some upload options as well!) */ - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.15.5 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.md b/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.md new file mode 100644 index 000000000..8b709ccb7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MAX_SEND_SPEED_LARGE.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MAX_SEND_SPEED_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) +--- + +# NAME + +CURLOPT_MAX_SEND_SPEED_LARGE - rate limit data upload speed + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAX_SEND_SPEED_LARGE, + curl_off_t maxspeed); +~~~ + +# DESCRIPTION + +Pass a curl_off_t as parameter with the *maxspeed*. If an upload exceeds +this speed (counted in bytes per second) the transfer pauses to keep the +average speed less than or equal to the parameter value. Defaults to unlimited +speed. + +This is not an exact science. libcurl attempts to keep the average speed below +the given threshold over a period time. + +If you set *maxspeed* to a value lower than +CURLOPT_UPLOAD_BUFFERSIZE(3), libcurl might "shoot over" the limit on +its first send and still send off a full buffer. + +This option does not affect transfer speeds done with FILE:// URLs. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +All except file:// + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* cap the upload speed to 1000 bytes/sec */ + curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)1000); + /* (set some upload options as well!) */ + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.15.5 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_MIMEPOST.3 b/docs/libcurl/opts/CURLOPT_MIMEPOST.3 deleted file mode 100644 index 02a5a0a7f..000000000 --- a/docs/libcurl/opts/CURLOPT_MIMEPOST.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MIMEPOST 3 "22 Aug 2017" libcurl libcurl -.SH NAME -CURLOPT_MIMEPOST \- send data from mime structure -.SH SYNOPSIS -.nf -#include - -curl_mime *mime; - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime); -.SH DESCRIPTION -Pass a mime handle previously obtained from \fIcurl_mime_init(3)\fP. - -This setting is supported by the HTTP protocol to post forms and by the -SMTP and IMAP protocols to provide the email data to send/upload. - -This option is the preferred way of posting an HTTP form, replacing and -extending the \fICURLOPT_HTTPPOST(3)\fP option. - -When setting \fICURLOPT_MIMEPOST(3)\fP to NULL, libcurl resets the request -type for HTTP to the default to disable the POST. Typically that would mean it -is reset to GET. Instead you should set a desired request method explicitly. -.SH PROTOCOLS -HTTP, SMTP, IMAP. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_mime *multipart = curl_mime_init(curl); - if(multipart) { - curl_mimepart *part = curl_mime_addpart(multipart); - curl_mime_name(part, "name"); - curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); - part = curl_mime_addpart(multipart); - curl_mime_name(part, "project"); - curl_mime_data(part, "curl", CURL_ZERO_TERMINATED); - part = curl_mime_addpart(multipart); - curl_mime_name(part, "logotype-image"); - curl_mime_filedata(part, "curl.png"); - - /* Set the form info */ - curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart); - - curl_easy_perform(curl); /* post away! */ - curl_mime_free(multipart); /* free the post data */ - } - } -} -.fi -.SH AVAILABILITY -Added in 7.56.0 -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR curl_mime_init (3), -.BR CURLOPT_HTTPPOST (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_PUT (3) diff --git a/docs/libcurl/opts/CURLOPT_MIMEPOST.md b/docs/libcurl/opts/CURLOPT_MIMEPOST.md new file mode 100644 index 000000000..588b7e803 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MIMEPOST.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MIMEPOST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPOST (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_PUT (3) + - curl_mime_init (3) +--- + +# NAME + +CURLOPT_MIMEPOST - send data from mime structure + +# SYNOPSIS + +~~~c +#include + +curl_mime *mime; + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime); +~~~ + +# DESCRIPTION + +Pass a mime handle previously obtained from curl_mime_init(3). + +This setting is supported by the HTTP protocol to post forms and by the +SMTP and IMAP protocols to provide the email data to send/upload. + +This option is the preferred way of posting an HTTP form, replacing and +extending the CURLOPT_HTTPPOST(3) option. + +When setting CURLOPT_MIMEPOST(3) to NULL, libcurl resets the request +type for HTTP to the default to disable the POST. Typically that would mean it +is reset to GET. Instead you should set a desired request method explicitly. + +# PROTOCOLS + +HTTP, SMTP, IMAP. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_mime *multipart = curl_mime_init(curl); + if(multipart) { + curl_mimepart *part = curl_mime_addpart(multipart); + curl_mime_name(part, "name"); + curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); + part = curl_mime_addpart(multipart); + curl_mime_name(part, "project"); + curl_mime_data(part, "curl", CURL_ZERO_TERMINATED); + part = curl_mime_addpart(multipart); + curl_mime_name(part, "logotype-image"); + curl_mime_filedata(part, "curl.png"); + + /* Set the form info */ + curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart); + + curl_easy_perform(curl); /* post away! */ + curl_mime_free(multipart); /* free the post data */ + } + } +} +~~~ + +# AVAILABILITY + +Added in 7.56.0 + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.3 deleted file mode 100644 index 3f7282351..000000000 --- a/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.3 +++ /dev/null @@ -1,97 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_MIME_OPTIONS 3 "2 Oct 2021" libcurl libcurl -.SH NAME -CURLOPT_MIME_OPTIONS \- set MIME option flags -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options); -.fi -.SH DESCRIPTION -Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a -Boolean flag used while encoding a MIME tree or multipart form data. - -Available bits are: -.IP CURLMIMEOPT_FORMESCAPE -Tells libcurl to escape multipart form field and file names using the -backslash-escaping algorithm rather than percent-encoding (HTTP only). - -Backslash-escaping consists in preceding backslashes and double quotes with -a backslash. Percent encoding maps all occurrences of double quote, -carriage return and line feed to %22, %0D and %0A respectively. - -Before version 7.81.0, percent-encoding was never applied. - -HTTP browsers used to do backslash-escaping in the past but have over time -transitioned to use percent-encoding. This option allows one to address -server-side applications that have not yet have been converted. - -As an example, consider field or file name \fIstrange\\name"kind\fP. -When the containing multipart form is sent, this is normally transmitted as -\fIstrange\\name%22kind\fP. When this option is set, it is sent as -\fIstrange\\\\name\\"kind\fP. -.SH DEFAULT -0, meaning disabled. -.SH PROTOCOLS -HTTP, IMAP, SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - curl_mime *form = NULL; - - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE); - - form = curl_mime_init(curl); - if(form) { - curl_mimepart *part = curl_mime_addpart(form); - - if(part) { - curl_mime_filedata(part, "strange\\\\file\\\\name"); - curl_mime_name(part, "strange\\"field\\"name"); - curl_easy_setopt(curl, CURLOPT_MIMEPOST, form); - - /* Perform the request */ - curl_easy_perform(curl); - } - } - - curl_easy_cleanup(curl); - curl_mime_free(form); - } -} -.fi -.SH AVAILABILITY -Option added in 7.81.0. -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_HTTPPOST (3), -.BR CURLOPT_MIMEPOST (3) diff --git a/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.md b/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.md new file mode 100644 index 000000000..a8da7d7ab --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_MIME_OPTIONS.md @@ -0,0 +1,97 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_MIME_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPOST (3) + - CURLOPT_MIMEPOST (3) +--- + +# NAME + +CURLOPT_MIME_OPTIONS - set MIME option flags + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIME_OPTIONS, long options); +~~~ + +# DESCRIPTION + +Pass a long that holds a bitmask of CURLMIMEOPT_* defines. Each bit is a +Boolean flag used while encoding a MIME tree or multipart form data. + +Available bits are: + +## CURLMIMEOPT_FORMESCAPE + +Tells libcurl to escape multipart form field and file names using the +backslash-escaping algorithm rather than percent-encoding (HTTP only). + +Backslash-escaping consists in preceding backslashes and double quotes with +a backslash. Percent encoding maps all occurrences of double quote, +carriage return and line feed to %22, %0D and %0A respectively. + +Before version 7.81.0, percent-encoding was never applied. + +HTTP browsers used to do backslash-escaping in the past but have over time +transitioned to use percent-encoding. This option allows one to address +server-side applications that have not yet have been converted. + +As an example, consider field or filename *strangename"kind*. When the +containing multipart form is sent, this is normally transmitted as +*strangename%22kind*. When this option is set, it is sent as +*strangename"kind*. + +# DEFAULT + +0, meaning disabled. + +# PROTOCOLS + +HTTP, IMAP, SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + curl_mime *form = NULL; + + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE); + + form = curl_mime_init(curl); + if(form) { + curl_mimepart *part = curl_mime_addpart(form); + + if(part) { + curl_mime_filedata(part, "strange\\file\\name"); + curl_mime_name(part, "strange\"field\"name"); + curl_easy_setopt(curl, CURLOPT_MIMEPOST, form); + + /* Perform the request */ + curl_easy_perform(curl); + } + } + + curl_easy_cleanup(curl); + curl_mime_free(form); + } +} +~~~ + +# AVAILABILITY + +Option added in 7.81.0. + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_NETRC.3 b/docs/libcurl/opts/CURLOPT_NETRC.3 deleted file mode 100644 index 3f04fccf7..000000000 --- a/docs/libcurl/opts/CURLOPT_NETRC.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NETRC 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NETRC \- enable use of .netrc -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level); -.fi -.SH DESCRIPTION -This parameter controls the preference \fIlevel\fP of libcurl between using -user names and passwords from your \fI~/.netrc\fP file, relative to user names -and passwords in the URL supplied with \fICURLOPT_URL(3)\fP. - -On Windows, libcurl uses the file as \fI%HOME%/_netrc\fP. If \fI%HOME%\fP is -not set on Windows, libcurl falls back to \fI%USERPROFILE%\fP. - -You can also tell libcurl a different file name to use with -\fICURLOPT_NETRC_FILE(3)\fP. - -libcurl uses a user name (and supplied or prompted password) supplied with -\fICURLOPT_USERPWD(3)\fP or \fICURLOPT_USERNAME(3)\fP in preference to any of -the options controlled by this parameter. - -Only machine name, user name and password are taken into account (init macros -and similar things are not supported). - -libcurl does not verify that the file has the correct properties set (as the -standard Unix ftp client does). It should only be readable by user. - -\fIlevel\fP is a long that should be set to one of the values described below. -.IP "CURL_NETRC_IGNORED (0)" -libcurl ignores the \fI.netrc\fP file. This is the default. -.IP "CURL_NETRC_OPTIONAL (1)" -The use of the \fI.netrc\fP file is optional, and information in the URL is to -be preferred. The file is scanned for the host and user name (to find the -password only) or for the host only, to find the first user name and password -after that \fImachine\fP, which ever information is not specified. -.IP "CURL_NETRC_REQUIRED (2)" -The use of the \fI.netrc\fP file is required, and any credential information -present in the URL is ignored. The file is scanned for the host and user name -(to find the password only) or for the host only, to find the first user name -and password after that \fImachine\fP, which ever information is not -specified. -.SH FILE FORMAT -The \fB.netrc\fP file format is simple: you specify lines with a machine name -and follow the login and password that are associated with that machine. - -Each field is provided as a sequence of letters that ends with a space or -newline. Starting in 7.84.0, libcurl also supports quoted strings. They start -and end with double quotes and support the escaped special letters \\\", \\n, -\\r, and \\t. Quoted strings are the only way a space character can be used in -a user name or password. - -.IP "machine " -Provides credentials for a host called \fBname\fP. libcurl searches the .netrc -file for a machine token that matches the host name specified in the URL. Once -a match is made, the subsequent tokens are processed, stopping when the end of -file is reached or another "machine" is encountered. -.IP default -This is the same as "machine" name except that default matches any name. There -can be only one default token, and it must be after all machine tokens. To -provide a default anonymous login for hosts that are not otherwise matched, -add a line similar to this in the end: - - default login anonymous password user@domain -.IP "login " -The user name string for the remote machine. -.IP "password " -Supply a password. If this token is present, curl supplies the specified -string if the remote server requires a password as part of the login process. -Note that if this token is present in the .netrc file you really should make -sure the file is not readable by anyone besides the user. -.IP "macdef " -Define a macro. This feature is not supported by libcurl. In order for the -rest of the .netrc to still work fine, libcurl properly skips every definition -done with "macdef" that it finds. -.SH DEFAULT -CURL_NETRC_IGNORED -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); - curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_USERPWD (3), -.BR CURLOPT_USERNAME (3), -.BR CURLOPT_NETRC_FILE (3) diff --git a/docs/libcurl/opts/CURLOPT_NETRC.md b/docs/libcurl/opts/CURLOPT_NETRC.md new file mode 100644 index 000000000..89a55b4d9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NETRC.md @@ -0,0 +1,141 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NETRC +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NETRC_FILE (3) + - CURLOPT_USERNAME (3) + - CURLOPT_USERPWD (3) +--- + +# NAME + +CURLOPT_NETRC - enable use of .netrc + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level); +~~~ + +# DESCRIPTION + +This parameter controls the preference *level* of libcurl between using +user names and passwords from your *~/.netrc* file, relative to user names +and passwords in the URL supplied with CURLOPT_URL(3). + +On Windows, libcurl uses the file as *%HOME%/_netrc*. If *%HOME%* is +not set on Windows, libcurl falls back to *%USERPROFILE%*. + +You can also tell libcurl a different filename to use with +CURLOPT_NETRC_FILE(3). + +libcurl uses a user name (and supplied or prompted password) supplied with +CURLOPT_USERPWD(3) or CURLOPT_USERNAME(3) in preference to any of +the options controlled by this parameter. + +Only machine name, user name and password are taken into account (init macros +and similar things are not supported). + +libcurl does not verify that the file has the correct properties set (as the +standard Unix ftp client does). It should only be readable by user. + +*level* is a long that should be set to one of the values described below. + +## CURL_NETRC_IGNORED (0) + +libcurl ignores the *.netrc* file. This is the default. + +## CURL_NETRC_OPTIONAL (1) + +The use of the *.netrc* file is optional, and information in the URL is to +be preferred. The file is scanned for the host and user name (to find the +password only) or for the host only, to find the first user name and password +after that *machine*, which ever information is not specified. + +## CURL_NETRC_REQUIRED (2) + +The use of the *.netrc* file is required, and any credential information +present in the URL is ignored. The file is scanned for the host and user name +(to find the password only) or for the host only, to find the first user name +and password after that *machine*, which ever information is not +specified. + +# FILE FORMAT + +The **.netrc** file format is simple: you specify lines with a machine name +and follow the login and password that are associated with that machine. + +Each field is provided as a sequence of letters that ends with a space or +newline. Starting in 7.84.0, libcurl also supports quoted strings. They start +and end with double quotes and support the escaped special letters ", n, +r, and t. Quoted strings are the only way a space character can be used in +a user name or password. + +## machine + +Provides credentials for a host called **name**. libcurl searches the .netrc +file for a machine token that matches the hostname specified in the URL. Once +a match is made, the subsequent tokens are processed, stopping when the end of +file is reached or another "machine" is encountered. + +## default + +This is the same as "machine" name except that default matches any name. There +can be only one default token, and it must be after all machine tokens. To +provide a default anonymous login for hosts that are not otherwise matched, +add a line similar to this in the end: + + default login anonymous password user@domain + +## login + +The user name string for the remote machine. + +## password + +Supply a password. If this token is present, curl supplies the specified +string if the remote server requires a password as part of the login process. +Note that if this token is present in the .netrc file you really should make +sure the file is not readable by anyone besides the user. + +## macdef + +Define a macro. This feature is not supported by libcurl. In order for the +rest of the .netrc to still work fine, libcurl properly skips every definition +done with "macdef" that it finds. + +# DEFAULT + +CURL_NETRC_IGNORED + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); + curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_NETRC_FILE.3 b/docs/libcurl/opts/CURLOPT_NETRC_FILE.3 deleted file mode 100644 index ff0bb5050..000000000 --- a/docs/libcurl/opts/CURLOPT_NETRC_FILE.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NETRC_FILE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NETRC_FILE \- file name to read .netrc info from -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC_FILE, char *file); -.fi -.SH DESCRIPTION -Pass a char * as parameter, pointing to a null-terminated string containing -the full path name to the \fIfile\fP you want libcurl to use as .netrc -file. If this option is omitted, and \fICURLOPT_NETRC(3)\fP is set, libcurl -checks for a .netrc file in the current user's home directory. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); - curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); - curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/tmp/magic-netrc"); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.9 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_NETRC (3), -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_NETRC_FILE.md b/docs/libcurl/opts/CURLOPT_NETRC_FILE.md new file mode 100644 index 000000000..62fe7a521 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NETRC_FILE.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NETRC_FILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NETRC (3) + - CURLOPT_PASSWORD (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_NETRC_FILE - filename to read .netrc info from + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC_FILE, char *file); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, pointing to a null-terminated string +containing the full path name to the *file* you want libcurl to use as .netrc +file. If this option is omitted, and CURLOPT_NETRC(3) is set, libcurl checks +for a .netrc file in the current user's home directory. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); + curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); + curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/tmp/magic-netrc"); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.9 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.3 b/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.3 deleted file mode 100644 index 97282225a..000000000 --- a/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NEW_DIRECTORY_PERMS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NEW_DIRECTORY_PERMS \- permissions for remotely created directories -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_DIRECTORY_PERMS, - long mode); -.SH DESCRIPTION -Pass a long as a parameter, containing the value of the permissions that is -set on newly created directories on the remote server. The default value is -\fI0755\fP, but any valid value can be used. The only protocols that can use -this are \fIsftp://\fP, \fIscp://\fP, and \fIfile://\fP. -.SH DEFAULT -0755 -.SH PROTOCOLS -SFTP, SCP and FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, - "sftp://upload.example.com/newdir/file.zip"); - curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); - curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FTP_CREATE_MISSING_DIRS (3), -.BR CURLOPT_NEW_FILE_PERMS (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.md b/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.md new file mode 100644 index 000000000..bb302d42b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NEW_DIRECTORY_PERMS.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NEW_DIRECTORY_PERMS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FTP_CREATE_MISSING_DIRS (3) + - CURLOPT_NEW_FILE_PERMS (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_NEW_DIRECTORY_PERMS - permissions for remotely created directories + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_DIRECTORY_PERMS, + long mode); +~~~ + +# DESCRIPTION + +Pass a long as a parameter, containing the value of the permissions that is +set on newly created directories on the remote server. The default value is +*0755*, but any valid value can be used. The only protocols that can use +this are *sftp://*, *scp://*, and *file://*. + +# DEFAULT + +0755 + +# PROTOCOLS + +SFTP, SCP and FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, + "sftp://upload.example.com/newdir/file.zip"); + curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L); + curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.3 b/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.3 deleted file mode 100644 index b81041d16..000000000 --- a/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.3 +++ /dev/null @@ -1,62 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NEW_FILE_PERMS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NEW_FILE_PERMS \- permissions for remotely created files -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_FILE_PERMS, - long mode); -.SH DESCRIPTION -Pass a long as a parameter, containing the value of the permissions that are -set on newly created files on the remote server. The default value is -\fI0644\fP, but any valid value can be used. The only protocols that can use -this are \fIsftp://\fP, \fIscp://\fP, and \fIfile://\fP. -.SH DEFAULT -0644 -.SH PROTOCOLS -SFTP, SCP and FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_NEW_FILE_PERMS, 0664L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_NEW_DIRECTORY_PERMS (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.md b/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.md new file mode 100644 index 000000000..dd12c0bbd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NEW_FILE_PERMS.md @@ -0,0 +1,60 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NEW_FILE_PERMS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NEW_DIRECTORY_PERMS (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_NEW_FILE_PERMS - permissions for remotely created files + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_FILE_PERMS, + long mode); +~~~ + +# DESCRIPTION + +Pass a long as a parameter, containing the value of the permissions that are +set on newly created files on the remote server. The default value is *0644*. +The only protocols that can use this are *sftp://*, *scp://*, and *file://*. + +# DEFAULT + +0644 + +# PROTOCOLS + +SFTP, SCP and FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_NEW_FILE_PERMS, 0664L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_NOBODY.3 b/docs/libcurl/opts/CURLOPT_NOBODY.3 deleted file mode 100644 index a21a825a3..000000000 --- a/docs/libcurl/opts/CURLOPT_NOBODY.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NOBODY 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NOBODY \- do the download request without getting the body -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt); -.fi -.SH DESCRIPTION -A long parameter set to 1 tells libcurl to not include the body-part in the -output when doing what would otherwise be a download. For HTTP(S), this makes -libcurl do a HEAD request. For most other protocols it means just not asking -to transfer the body data. - -For HTTP operations when \fICURLOPT_NOBODY(3)\fP has been set, disabling this -option (with 0) makes it a GET again - only if the method is still set to be -HEAD. The proper way to get back to a GET request is to set -\fICURLOPT_HTTPGET(3)\fP and for other methods, use the POST or UPLOAD -options. - -Enabling \fICURLOPT_NOBODY(3)\fP means asking for a download without a body. - -If you do a transfer with HTTP that involves a method other than HEAD, you get -a body (unless the resource and server sends a zero byte body for the specific -URL you request). -.SH DEFAULT -0, the body is transferred -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* get us the resource without a body - use HEAD! */ - curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_HTTPGET (3), -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_REQUEST_TARGET (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_NOBODY.md b/docs/libcurl/opts/CURLOPT_NOBODY.md new file mode 100644 index 000000000..9d63154c9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NOBODY.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NOBODY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPGET (3) + - CURLOPT_MIMEPOST (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_REQUEST_TARGET (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_NOBODY - do the download request without getting the body + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt); +~~~ + +# DESCRIPTION + +A long parameter set to 1 tells libcurl to not include the body-part in the +output when doing what would otherwise be a download. For HTTP(S), this makes +libcurl do a HEAD request. For most other protocols it means just not asking +to transfer the body data. + +For HTTP operations when CURLOPT_NOBODY(3) has been set, disabling this +option (with 0) makes it a GET again - only if the method is still set to be +HEAD. The proper way to get back to a GET request is to set +CURLOPT_HTTPGET(3) and for other methods, use the POST or UPLOAD +options. + +Enabling CURLOPT_NOBODY(3) means asking for a download without a body. + +If you do a transfer with HTTP that involves a method other than HEAD, you get +a body (unless the resource and server sends a zero byte body for the specific +URL you request). + +# DEFAULT + +0, the body is transferred + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* get us the resource without a body - use HEAD! */ + curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_NOPROGRESS.3 b/docs/libcurl/opts/CURLOPT_NOPROGRESS.3 deleted file mode 100644 index fd4e07f32..000000000 --- a/docs/libcurl/opts/CURLOPT_NOPROGRESS.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NOPROGRESS 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NOPROGRESS \- switch off the progress meter -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROGRESS, long onoff); -.fi -.SH DESCRIPTION -If \fIonoff\fP is to 1, it tells the library to shut off the progress meter -completely for requests done with this \fIhandle\fP. It also prevents the -\fICURLOPT_XFERINFOFUNCTION(3)\fP or \fICURLOPT_PROGRESSFUNCTION(3)\fP from -getting called. -.SH DEFAULT -1, meaning it normally runs without a progress meter. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* enable progress meter */ - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_PROGRESSFUNCTION (3), -.BR CURLOPT_VERBOSE (3), -.BR CURLOPT_XFERINFOFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_NOPROGRESS.md b/docs/libcurl/opts/CURLOPT_NOPROGRESS.md new file mode 100644 index 000000000..e2845a96f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NOPROGRESS.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NOPROGRESS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_PROGRESSFUNCTION (3) + - CURLOPT_VERBOSE (3) + - CURLOPT_XFERINFOFUNCTION (3) +--- + +# NAME + +CURLOPT_NOPROGRESS - switch off the progress meter + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROGRESS, long onoff); +~~~ + +# DESCRIPTION + +If *onoff* is to 1, it tells the library to shut off the progress meter +completely for requests done with this *handle*. It also prevents the +CURLOPT_XFERINFOFUNCTION(3) or CURLOPT_PROGRESSFUNCTION(3) from +getting called. + +# DEFAULT + +1, meaning it normally runs without a progress meter. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* enable progress meter */ + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_NOPROXY.3 b/docs/libcurl/opts/CURLOPT_NOPROXY.3 deleted file mode 100644 index 1a5b07570..000000000 --- a/docs/libcurl/opts/CURLOPT_NOPROXY.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NOPROXY 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NOPROXY \- disable proxy use for specific hosts -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROXY, char *noproxy); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string. The string consists of a comma -separated list of host names that do not require a proxy to get reached, even -if one is specified. The only wildcard available is a single * character, -which matches all hosts, and effectively disables the proxy. Each name in this -list is matched as either a domain which contains the hostname, or the -hostname itself. For example, "ample.com" would match ample.com, ample.com:80, -and www.ample.com, but not www.example.com or ample.com.org. - -Setting the \fInoproxy\fP string to "" (an empty string) explicitly enables -the proxy for all host names, even if there is an environment variable set for -it. - -Enter IPv6 numerical addresses in the list of host names without enclosing -brackets: - - "example.com,::1,localhost" - -Since 7.86.0, IP addresses specified to this option can be provided using CIDR -notation: an appended slash and number specifies the number of "network bits" -out of the address to use in the comparison. For example "192.168.0.0/16" -would match all addresses starting with "192.168". - -The application does not have to keep the string around after setting this -option. -.SH "Environment variables" -If there is an environment variable called \fBno_proxy\fP (or \fBNO_PROXY\fP), -it is used if the \fICURLOPT_NOPROXY(3)\fP option is not set. It works exactly -the same way. -.SH DEFAULT -NULL -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* accept various URLs */ - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* use this proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); - /* ... but make sure this host name is not proxied */ - curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYAUTH (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_NOPROXY.md b/docs/libcurl/opts/CURLOPT_NOPROXY.md new file mode 100644 index 000000000..91292e22e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NOPROXY.md @@ -0,0 +1,91 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NOPROXY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_NOPROXY - disable proxy use for specific hosts + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOPROXY, char *noproxy); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string. The string consists of a comma +separated list of host names that do not require a proxy to get reached, even +if one is specified. The only wildcard available is a single * character, +which matches all hosts, and effectively disables the proxy. Each name in this +list is matched as either a domain which contains the hostname, or the +hostname itself. For example, "ample.com" would match ample.com, ample.com:80, +and www.ample.com, but not www.example.com or ample.com.org. + +Setting the *noproxy* string to "" (an empty string) explicitly enables +the proxy for all host names, even if there is an environment variable set for +it. + +Enter IPv6 numerical addresses in the list of host names without enclosing +brackets: + + "example.com,::1,localhost" + +Since 7.86.0, IP addresses specified to this option can be provided using CIDR +notation: an appended slash and number specifies the number of "network bits" +out of the address to use in the comparison. For example "192.168.0.0/16" +would match all addresses starting with "192.168". + +The application does not have to keep the string around after setting this +option. + +# Environment variables + +If there is an environment variable called **no_proxy** (or **NO_PROXY**), +it is used if the CURLOPT_NOPROXY(3) option is not set. It works exactly +the same way. + +# DEFAULT + +NULL + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* accept various URLs */ + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* use this proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); + /* ... but make sure this host name is not proxied */ + curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_NOSIGNAL.3 b/docs/libcurl/opts/CURLOPT_NOSIGNAL.3 deleted file mode 100644 index 290f44e42..000000000 --- a/docs/libcurl/opts/CURLOPT_NOSIGNAL.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_NOSIGNAL 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_NOSIGNAL \- skip all signal handling -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOSIGNAL, long onoff); -.fi -.SH DESCRIPTION -If \fIonoff\fP is 1, libcurl uses no functions that install signal handlers or -any functions that cause signals to be sent to the process. This option is -here to allow multi-threaded unix applications to still set/use all timeout -options etc, without risking getting signals. - -If this option is set and libcurl has been built with the standard name -resolver, timeouts cannot occur while the name resolve takes place. Consider -building libcurl with the c-ares or threaded resolver backends to enable -asynchronous DNS lookups, to enable timeouts for name resolves without the use -of signals. - -Setting \fICURLOPT_NOSIGNAL(3)\fP to 1 makes libcurl NOT ask the system to -ignore SIGPIPE signals, which otherwise are sent by the system when trying to -send data to a socket which is closed in the other end. libcurl makes an -effort to never cause such SIGPIPE signals to trigger, but some operating -systems have no way to avoid them and even on those that have there are some -corner cases when they may still happen, contrary to our desire. In addition, -using \fICURLAUTH_NTLM_WB\fP authentication could cause a SIGCHLD signal to be -raised. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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_NOSIGNAL, 1L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH SEE ALSO -.BR CURLOPT_TIMEOUT "(3), " diff --git a/docs/libcurl/opts/CURLOPT_NOSIGNAL.md b/docs/libcurl/opts/CURLOPT_NOSIGNAL.md new file mode 100644 index 000000000..50ae65cca --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_NOSIGNAL.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_NOSIGNAL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_NOSIGNAL - skip all signal handling + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOSIGNAL, long onoff); +~~~ + +# DESCRIPTION + +If *onoff* is 1, libcurl uses no functions that install signal handlers or +any functions that cause signals to be sent to the process. This option is +here to allow multi-threaded unix applications to still set/use all timeout +options etc, without risking getting signals. + +If this option is set and libcurl has been built with the standard name +resolver, timeouts cannot occur while the name resolve takes place. Consider +building libcurl with the c-ares or threaded resolver backends to enable +asynchronous DNS lookups, to enable timeouts for name resolves without the use +of signals. + +Setting CURLOPT_NOSIGNAL(3) to 1 makes libcurl NOT ask the system to +ignore SIGPIPE signals, which otherwise are sent by the system when trying to +send data to a socket which is closed in the other end. libcurl makes an +effort to never cause such SIGPIPE signals to trigger, but some operating +systems have no way to avoid them and even on those that have there are some +corner cases when they may still happen, contrary to our desire. In addition, +using *CURLAUTH_NTLM_WB* authentication could cause a SIGCHLD signal to be +raised. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# 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_NOSIGNAL, 1L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.3 b/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.3 deleted file mode 100644 index e4c227a89..000000000 --- a/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_OPENSOCKETDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_OPENSOCKETDATA \- pointer passed to open socket callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_OPENSOCKETDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the first -argument in the open socket callback set with -\fICURLOPT_OPENSOCKETFUNCTION(3)\fP. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -/* make libcurl use the already established socket 'sockfd' */ - -static curl_socket_t opensocket(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *address) -{ - curl_socket_t sockfd; - sockfd = *(curl_socket_t *)clientp; - /* the actual externally set socket is passed in via the OPENSOCKETDATA - option */ - return sockfd; -} - -static int sockopt_callback(void *clientp, curl_socket_t curlfd, - curlsocktype purpose) -{ - /* This return code was added in libcurl 7.21.5 */ - return CURL_SOCKOPT_ALREADY_CONNECTED; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - extern int sockfd; /* the already connected one */ - - /* libcurl thinks that you connect to the host - * and port that you specify in the URL option. */ - curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); - /* call this function to get a socket */ - curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); - curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); - - /* call this function to set options for the socket */ - curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.17.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CLOSESOCKETFUNCTION (3), -.BR CURLOPT_OPENSOCKETFUNCTION (3), -.BR CURLOPT_SOCKOPTFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.md b/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.md new file mode 100644 index 000000000..f3e7ef855 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_OPENSOCKETDATA.md @@ -0,0 +1,92 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_OPENSOCKETDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CLOSESOCKETFUNCTION (3) + - CURLOPT_OPENSOCKETFUNCTION (3) + - CURLOPT_SOCKOPTFUNCTION (3) +--- + +# NAME + +CURLOPT_OPENSOCKETDATA - pointer passed to open socket callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_OPENSOCKETDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the first +argument in the open socket callback set with +CURLOPT_OPENSOCKETFUNCTION(3). + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +/* make libcurl use the already established socket 'sockfd' */ + +static curl_socket_t opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address) +{ + curl_socket_t sockfd; + sockfd = *(curl_socket_t *)clientp; + /* the actual externally set socket is passed in via the OPENSOCKETDATA + option */ + return sockfd; +} + +static int sockopt_callback(void *clientp, curl_socket_t curlfd, + curlsocktype purpose) +{ + /* This return code was added in libcurl 7.21.5 */ + return CURL_SOCKOPT_ALREADY_CONNECTED; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + extern int sockfd; /* the already connected one */ + + /* libcurl thinks that you connect to the host + * and port that you specify in the URL option. */ + curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); + /* call this function to get a socket */ + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); + curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); + + /* call this function to set options for the socket */ + curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.17.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.3 b/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.3 deleted file mode 100644 index f2f8628b4..000000000 --- a/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.3 +++ /dev/null @@ -1,134 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_OPENSOCKETFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_OPENSOCKETFUNCTION \- callback for opening socket -.SH SYNOPSIS -.nf -#include - -typedef enum { - CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ -} curlsocktype; - -struct curl_sockaddr { - int family; - int socktype; - int protocol; - unsigned int addrlen; - struct sockaddr addr; -}; - -curl_socket_t opensocket_callback(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *address); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_OPENSOCKETFUNCTION, opensocket_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl instead of the \fIsocket(2)\fP -call. The callback's \fIpurpose\fP argument identifies the exact purpose for -this particular socket. \fICURLSOCKTYPE_IPCXN\fP is for IP based connections -and is the only purpose currently used in libcurl. Future versions of libcurl -may support more purposes. - -The \fIclientp\fP pointer contains whatever user-defined value set using the -\fICURLOPT_OPENSOCKETDATA(3)\fP function. - -The callback gets the resolved peer address as the \fIaddress\fP argument and -is allowed to modify the address or refuse to connect completely. The callback -function should return the newly created socket or \fICURL_SOCKET_BAD\fP in -case no connection could be established or another error was detected. Any -additional \fIsetsockopt(2)\fP calls can of course be done on the socket at -the user's discretion. A \fICURL_SOCKET_BAD\fP return value from the callback -function signals an unrecoverable error to libcurl and it returns -\fICURLE_COULDNT_CONNECT\fP from the function that triggered this callback. -This return code can be used for IP address block listing. - -If you want to pass in a socket with an already established connection, pass -the socket back with this callback and then use -\fICURLOPT_SOCKOPTFUNCTION(3)\fP to signal that it already is connected. -.SH DEFAULT -The default behavior is the equivalent of this: -.nf - return socket(addr->family, addr->socktype, addr->protocol); -.fi -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -/* make libcurl use the already established socket 'sockfd' */ - -static curl_socket_t opensocket(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *address) -{ - curl_socket_t sockfd; - sockfd = *(curl_socket_t *)clientp; - /* the actual externally set socket is passed in via the OPENSOCKETDATA - option */ - return sockfd; -} - -static int sockopt_callback(void *clientp, curl_socket_t curlfd, - curlsocktype purpose) -{ - /* This return code was added in libcurl 7.21.5 */ - return CURL_SOCKOPT_ALREADY_CONNECTED; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - extern int sockfd; /* the already connected one */ - /* libcurl thinks that you connect to the host - * and port that you specify in the URL option. */ - curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); - /* call this function to get a socket */ - curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); - curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); - - /* call this function to set options for the socket */ - curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.17.1. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CLOSESOCKETFUNCTION (3), -.BR CURLOPT_OPENSOCKETFUNCTION (3), -.BR CURLOPT_SOCKOPTFUNCTION (3) - diff --git a/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.md b/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.md new file mode 100644 index 000000000..125ccff68 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_OPENSOCKETFUNCTION.md @@ -0,0 +1,132 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_OPENSOCKETFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CLOSESOCKETFUNCTION (3) + - CURLOPT_OPENSOCKETFUNCTION (3) + - CURLOPT_SOCKOPTFUNCTION (3) +--- + +# NAME + +CURLOPT_OPENSOCKETFUNCTION - callback for opening socket + +# SYNOPSIS + +~~~c +#include + +typedef enum { + CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ +} curlsocktype; + +struct curl_sockaddr { + int family; + int socktype; + int protocol; + unsigned int addrlen; + struct sockaddr addr; +}; + +curl_socket_t opensocket_callback(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_OPENSOCKETFUNCTION, opensocket_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl instead of the *socket(2)* +call. The callback's *purpose* argument identifies the exact purpose for +this particular socket. *CURLSOCKTYPE_IPCXN* is for IP based connections +and is the only purpose currently used in libcurl. Future versions of libcurl +may support more purposes. + +The *clientp* pointer contains whatever user-defined value set using the +CURLOPT_OPENSOCKETDATA(3) function. + +The callback gets the resolved peer address as the *address* argument and +is allowed to modify the address or refuse to connect completely. The callback +function should return the newly created socket or *CURL_SOCKET_BAD* in +case no connection could be established or another error was detected. Any +additional *setsockopt(2)* calls can of course be done on the socket at +the user's discretion. A *CURL_SOCKET_BAD* return value from the callback +function signals an unrecoverable error to libcurl and it returns +*CURLE_COULDNT_CONNECT* from the function that triggered this callback. +This return code can be used for IP address block listing. + +If you want to pass in a socket with an already established connection, pass +the socket back with this callback and then use +CURLOPT_SOCKOPTFUNCTION(3) to signal that it already is connected. + +# DEFAULT + +The default behavior is the equivalent of this: +~~~c + return socket(addr->family, addr->socktype, addr->protocol); +~~~ + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +/* make libcurl use the already established socket 'sockfd' */ + +static curl_socket_t opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address) +{ + curl_socket_t sockfd; + sockfd = *(curl_socket_t *)clientp; + /* the actual externally set socket is passed in via the OPENSOCKETDATA + option */ + return sockfd; +} + +static int sockopt_callback(void *clientp, curl_socket_t curlfd, + curlsocktype purpose) +{ + /* This return code was added in libcurl 7.21.5 */ + return CURL_SOCKOPT_ALREADY_CONNECTED; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + extern int sockfd; /* the already connected one */ + /* libcurl thinks that you connect to the host + * and port that you specify in the URL option. */ + curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); + /* call this function to get a socket */ + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); + curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); + + /* call this function to set options for the socket */ + curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.17.1. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PASSWORD.3 b/docs/libcurl/opts/CURLOPT_PASSWORD.3 deleted file mode 100644 index 73d8627c0..000000000 --- a/docs/libcurl/opts/CURLOPT_PASSWORD.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PASSWORD 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PASSWORD \- password to use in authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PASSWORD, char *pwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -password to use for the transfer. - -The \fICURLOPT_PASSWORD(3)\fP option should be used in conjunction with the -\fICURLOPT_USERNAME(3)\fP option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - curl_easy_setopt(curl, CURLOPT_PASSWORD, "qwerty"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PROXYAUTH (3), -.BR CURLOPT_USERNAME (3), -.BR CURLOPT_USERPWD (3) diff --git a/docs/libcurl/opts/CURLOPT_PASSWORD.md b/docs/libcurl/opts/CURLOPT_PASSWORD.md new file mode 100644 index 000000000..9849802d1 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PASSWORD.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PASSWORD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_USERNAME (3) + - CURLOPT_USERPWD (3) +--- + +# NAME + +CURLOPT_PASSWORD - password to use in authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PASSWORD, char *pwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the +null-terminated password to use for the transfer. + +The CURLOPT_PASSWORD(3) option should be used in conjunction with the +CURLOPT_USERNAME(3) option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + curl_easy_setopt(curl, CURLOPT_PASSWORD, "qwerty"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PATH_AS_IS.3 b/docs/libcurl/opts/CURLOPT_PATH_AS_IS.3 deleted file mode 100644 index 5bfa0ccdc..000000000 --- a/docs/libcurl/opts/CURLOPT_PATH_AS_IS.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PATH_AS_IS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PATH_AS_IS \- do not handle dot dot sequences -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PATH_AS_IS, long leaveit); -.fi -.SH DESCRIPTION -Set the long \fIleaveit\fP to 1, to explicitly tell libcurl to not alter the -given path before passing it on to the server. - -This instructs libcurl to NOT squash sequences of "/../" or "/./" that may -exist in the URL's path part and that is supposed to be removed according to -RFC 3986 section 5.2.4. - -Some server implementations are known to (erroneously) require the dot dot -sequences to remain in the path and some clients want to pass these on in -order to try out server implementations. - -By default libcurl normalizes such sequences before using the path. - -The corresponding flag for the \fIcurl_url_set(3)\fP function is called -\fBCURLU_PATH_AS_IS\fP. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, - "https://example.com/../../etc/password"); - - curl_easy_setopt(curl, CURLOPT_PATH_AS_IS, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.42.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_url_set (3), -.BR CURLOPT_STDERR (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_URL (3) - - diff --git a/docs/libcurl/opts/CURLOPT_PATH_AS_IS.md b/docs/libcurl/opts/CURLOPT_PATH_AS_IS.md new file mode 100644 index 000000000..499469172 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PATH_AS_IS.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PATH_AS_IS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_STDERR (3) + - CURLOPT_URL (3) + - curl_url_set (3) +--- + +# NAME + +CURLOPT_PATH_AS_IS - do not handle dot dot sequences + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PATH_AS_IS, long leaveit); +~~~ + +# DESCRIPTION + +Set the long *leaveit* to 1, to explicitly tell libcurl to not alter the +given path before passing it on to the server. + +This instructs libcurl to NOT squash sequences of "/../" or "/./" that may +exist in the URL's path part and that is supposed to be removed according to +RFC 3986 section 5.2.4. + +Some server implementations are known to (erroneously) require the dot dot +sequences to remain in the path and some clients want to pass these on in +order to try out server implementations. + +By default libcurl normalizes such sequences before using the path. + +The corresponding flag for the curl_url_set(3) function is called +**CURLU_PATH_AS_IS**. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, + "https://example.com/../../etc/password"); + + curl_easy_setopt(curl, CURLOPT_PATH_AS_IS, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.42.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.3 b/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.3 deleted file mode 100644 index 9a72fa85f..000000000 --- a/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.3 +++ /dev/null @@ -1,140 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PINNEDPUBLICKEY 3 "27 Aug 2014" libcurl libcurl -.SH NAME -CURLOPT_PINNEDPUBLICKEY \- pinned public key -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PINNEDPUBLICKEY, - char *pinnedpubkey); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string can be the -file name of your pinned public key. The file format expected is "PEM" or "DER". -The string can also be any number of base64 encoded sha256 hashes preceded by -"sha256//" and separated by ";" - -When negotiating a TLS or SSL connection, the server sends a certificate -indicating its identity. A public key is extracted from this certificate and -if it does not exactly match the public key provided to this option, curl -aborts the connection before sending or receiving any data. - -This option is independent of option \fICURLOPT_SSL_VERIFYPEER(3)\fP. If you -turn off that option then the peer is still verified by public key. - -On mismatch, \fICURLE_SSL_PINNEDPUBKEYNOTMATCH\fP is returned. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "/etc/publickey.der"); - /* OR - curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, - "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3" - "tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEg" - "oChTociMee9wno="); - */ - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH PUBLIC KEY EXTRACTION -If you do not have the server's public key file you can extract it from the -server's certificate. -.nf -# retrieve the server's certificate if you do not already have it -# -# be sure to examine the certificate to see if it is what you expected -# -# Windows-specific: -# - Use NUL instead of /dev/null. -# - OpenSSL may wait for input instead of disconnecting. Hit enter. -# - If you do not have sed, then just copy the certificate into a file: -# Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----. -# -openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem - -# extract public key in pem format from certificate -openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem - -# convert public key from pem to der -openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem -out www.example.com.pubkey.der - -# sha256 hash and base64 encode der to string for use -openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64 -.fi -The public key in PEM format contains a header, base64 data and a -footer: -.nf ------BEGIN PUBLIC KEY----- -[BASE 64 DATA] ------END PUBLIC KEY----- -.fi -.SH AVAILABILITY -PEM/DER support: - - 7.39.0: OpenSSL, GnuTLS - - 7.43.0: wolfSSL - - 7.47.0: mbedTLS - - 7.54.1: Secure Transport on macOS 10.7+/iOS 10+ - - 7.58.1: Schannel - -sha256 support: - - 7.44.0: OpenSSL, GnuTLS and wolfSSL - - 7.47.0: mbedTLS - - 7.54.1: Secure Transport on macOS 10.7+/iOS 10+ - - 7.58.1: Schannel - -Other SSL backends not supported. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.md b/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.md new file mode 100644 index 000000000..922e2a6d6 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PINNEDPUBLICKEY.md @@ -0,0 +1,143 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PINNEDPUBLICKEY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAPATH (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PINNEDPUBLICKEY - pinned public key + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PINNEDPUBLICKEY, + char *pinnedpubkey); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string can be the +filename of your pinned public key. The file format expected is "PEM" or +"DER". The string can also be any number of base64 encoded sha256 hashes +preceded by "sha256//" and separated by ";" + +When negotiating a TLS or SSL connection, the server sends a certificate +indicating its identity. A public key is extracted from this certificate and +if it does not exactly match the public key provided to this option, curl +aborts the connection before sending or receiving any data. + +This option is independent of option CURLOPT_SSL_VERIFYPEER(3). If you turn +off that option then the peer is still verified by public key. + +On mismatch, *CURLE_SSL_PINNEDPUBKEYNOTMATCH* is returned. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, "/etc/publickey.der"); + /* OR + curl_easy_setopt(curl, CURLOPT_PINNEDPUBLICKEY, + "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3" + "tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEg" + "oChTociMee9wno="); + */ + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# PUBLIC KEY EXTRACTION + +If you do not have the server's public key file you can extract it from the +server's certificate. +~~~ +# retrieve the server's certificate if you do not already have it +# +# be sure to examine the certificate to see if it is what you expected +# +# Windows-specific: +# - Use NUL instead of /dev/null. +# - OpenSSL may wait for input instead of disconnecting. Hit enter. +# - If you do not have sed, then just copy the certificate into a file: +# Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----. +# +openssl s_client -servername www.example.com -connect www.example.com:443 \ + < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem + +# extract public key in pem format from certificate +openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem + +# convert public key from pem to der +openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem \ + -out www.example.com.pubkey.der + +# sha256 hash and base64 encode der to string for use +openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64 +~~~ + +The public key in PEM format contains a header, base64 data and a +footer: +~~~ +-----BEGIN PUBLIC KEY----- +[BASE 64 DATA] +-----END PUBLIC KEY----- +~~~ + +# AVAILABILITY + +## PEM/DER support + +7.39.0: OpenSSL, GnuTLS + +7.43.0: wolfSSL + +7.47.0: mbedTLS + +7.54.1: Secure Transport on macOS 10.7+/iOS 10+ + +7.58.1: Schannel + +## sha256 support + +7.44.0: OpenSSL, GnuTLS and wolfSSL + +7.47.0: mbedTLS + +7.54.1: Secure Transport on macOS 10.7+/iOS 10+ + +7.58.1: Schannel + +Other SSL backends not supported. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PIPEWAIT.3 b/docs/libcurl/opts/CURLOPT_PIPEWAIT.3 deleted file mode 100644 index 645f788f9..000000000 --- a/docs/libcurl/opts/CURLOPT_PIPEWAIT.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PIPEWAIT 3 "12 May 2015" libcurl libcurl -.SH NAME -CURLOPT_PIPEWAIT \- wait for multiplexing -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PIPEWAIT, long wait); -.fi -.SH DESCRIPTION -Set \fIwait\fP to 1L to tell libcurl to prefer to wait for a connection to -confirm or deny that it can do multiplexing before continuing. - -When about to perform a new transfer that allows multiplexing, libcurl checks -for existing connections to use. If no such connection exists it immediately -continues and creates a fresh new connection to use. - -By setting this option to 1 - and having \fICURLMOPT_PIPELINING(3)\fP enabled -for the multi handle this transfer is associated with - libcurl instead waits -for the connection to reveal if it is possible to multiplex on before it -continues. This enables libcurl to much better keep the number of connections -to a minimum when using multiplexing protocols. - -With this option set, libcurl prefers to wait and reuse an existing connection -for multiplexing rather than the opposite: prefer to open a new connection -rather than waiting. - -The waiting time is as long as it takes for the connection to get up and for -libcurl to get the necessary response back that informs it about its protocol -and support level. -.SH DEFAULT -0 (off) -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1L); - - /* now add this easy handle to the multi handle */ - } -} -.fi -.SH AVAILABILITY -Added in 7.43.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_MAX_HOST_CONNECTIONS (3), -.BR CURLMOPT_PIPELINING (3), -.BR CURLOPT_FORBID_REUSE (3), -.BR CURLOPT_FRESH_CONNECT (3) diff --git a/docs/libcurl/opts/CURLOPT_PIPEWAIT.md b/docs/libcurl/opts/CURLOPT_PIPEWAIT.md new file mode 100644 index 000000000..1be844dd0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PIPEWAIT.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PIPEWAIT +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_MAX_HOST_CONNECTIONS (3) + - CURLMOPT_PIPELINING (3) + - CURLOPT_FORBID_REUSE (3) + - CURLOPT_FRESH_CONNECT (3) +--- + +# NAME + +CURLOPT_PIPEWAIT - wait for multiplexing + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PIPEWAIT, long wait); +~~~ + +# DESCRIPTION + +Set *wait* to 1L to tell libcurl to prefer to wait for a connection to +confirm or deny that it can do multiplexing before continuing. + +When about to perform a new transfer that allows multiplexing, libcurl checks +for existing connections to use. If no such connection exists it immediately +continues and creates a fresh new connection to use. + +By setting this option to 1 - and having CURLMOPT_PIPELINING(3) enabled +for the multi handle this transfer is associated with - libcurl instead waits +for the connection to reveal if it is possible to multiplex on before it +continues. This enables libcurl to much better keep the number of connections +to a minimum when using multiplexing protocols. + +With this option set, libcurl prefers to wait and reuse an existing connection +for multiplexing rather than the opposite: prefer to open a new connection +rather than waiting. + +The waiting time is as long as it takes for the connection to get up and for +libcurl to get the necessary response back that informs it about its protocol +and support level. + +# DEFAULT + +0 (off) + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1L); + + /* now add this easy handle to the multi handle */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.43.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PORT.3 b/docs/libcurl/opts/CURLOPT_PORT.3 deleted file mode 100644 index 4b6667ba8..000000000 --- a/docs/libcurl/opts/CURLOPT_PORT.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PORT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PORT \- remote port number to connect to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PORT, long number); -.fi -.SH DESCRIPTION -We discourage using this option since its scope is not obvious and hard to -predict. Set the preferred port number in the URL instead. - -This option sets \fInumber\fP to be the remote port number to connect to, -instead of the one specified in the URL or the default port for the used -protocol. - -Usually, you just let the URL decide which port to use but this allows the -application to override that. - -While this option accepts a 'long', a port number is an unsigned 16 bit number -and therefore using a port number lower than zero or over 65535 causes a -\fBCURLE_BAD_FUNCTION_ARGUMENT\fP error. -.SH DEFAULT -By default this is 0 which makes it not used. This also makes port number zero -impossible to set with this API. -.SH PROTOCOLS -Used for all protocols that speak to a port number. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PORT, 8080L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLINFO_PRIMARY_PORT (3), -.BR CURLOPT_STDERR (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_PORT.md b/docs/libcurl/opts/CURLOPT_PORT.md new file mode 100644 index 000000000..42dc80133 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PORT.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PORT +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PRIMARY_PORT (3) + - CURLOPT_STDERR (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_PORT - remote port number to connect to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PORT, long number); +~~~ + +# DESCRIPTION + +We discourage using this option since its scope is not obvious and hard to +predict. Set the preferred port number in the URL instead. + +This option sets *number* to be the remote port number to connect to, +instead of the one specified in the URL or the default port for the used +protocol. + +Usually, you just let the URL decide which port to use but this allows the +application to override that. + +While this option accepts a 'long', a port number is an unsigned 16 bit number +and therefore using a port number lower than zero or over 65535 causes a +**CURLE_BAD_FUNCTION_ARGUMENT** error. + +# DEFAULT + +By default this is 0 which makes it not used. This also makes port number zero +impossible to set with this API. + +# PROTOCOLS + +Used for all protocols that speak to a port number. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PORT, 8080L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_POST.3 b/docs/libcurl/opts/CURLOPT_POST.3 deleted file mode 100644 index 182b59cb8..000000000 --- a/docs/libcurl/opts/CURLOPT_POST.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POST 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POST \- make an HTTP POST -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POST, long post); -.fi -.SH DESCRIPTION -A parameter set to 1 tells libcurl to do a regular HTTP post. This also makes -libcurl use a "Content-Type: application/x-www-form-urlencoded" header. This -is the most commonly used POST method. - -Use one of \fICURLOPT_POSTFIELDS(3)\fP or \fICURLOPT_COPYPOSTFIELDS(3)\fP -options to specify what data to post and \fICURLOPT_POSTFIELDSIZE(3)\fP or -\fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP to set the data size. - -Optionally, you can provide data to POST using the -\fICURLOPT_READFUNCTION(3)\fP and \fICURLOPT_READDATA(3)\fP options but then -you must make sure to not set \fICURLOPT_POSTFIELDS(3)\fP to anything but -NULL. When providing data with a callback, you must transmit it using chunked -transfer-encoding or you must set the size of the data with the -\fICURLOPT_POSTFIELDSIZE(3)\fP or \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP -options. To enable chunked encoding, you simply pass in the appropriate -Transfer-Encoding header, see the post-callback.c example. - -You can override the default POST Content-Type: header by setting your own -with \fICURLOPT_HTTPHEADER(3)\fP. - -Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. -You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP as usual. - -If you use POST to an HTTP 1.1 server, you can send data without knowing the -size before starting the POST if you use chunked encoding. You enable this by -adding a header like "Transfer-Encoding: chunked" with -\fICURLOPT_HTTPHEADER(3)\fP. With HTTP 1.0 or without chunked transfer, you -must specify the size in the request. (Since 7.66.0, libcurl automatically -uses chunked encoding for POSTs if the size is unknown.) - -When setting \fICURLOPT_POST(3)\fP to 1, libcurl automatically sets -\fICURLOPT_NOBODY(3)\fP and \fICURLOPT_HTTPGET(3)\fP to 0. - -If you issue a POST request and then want to make a HEAD or GET using the same -reused handle, you must explicitly set the new request type using -\fICURLOPT_NOBODY(3)\fP or \fICURLOPT_HTTPGET(3)\fP or similar. - -When setting \fICURLOPT_POST(3)\fP to 0, libcurl resets the request type to -the default to disable the POST. Typically that would mean it's reset to GET. -Instead you should set a new request type explicitly as described above. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_POST, 1L); - - /* set up the read callback with CURLOPT_READFUNCTION */ - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPPOST (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_PUT (3) diff --git a/docs/libcurl/opts/CURLOPT_POST.md b/docs/libcurl/opts/CURLOPT_POST.md new file mode 100644 index 000000000..96fcd42de --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POST.md @@ -0,0 +1,102 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPOST (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_PUT (3) +--- + +# NAME + +CURLOPT_POST - make an HTTP POST + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POST, long post); +~~~ + +# DESCRIPTION + +A parameter set to 1 tells libcurl to do a regular HTTP post. This also makes +libcurl use a "Content-Type: application/x-www-form-urlencoded" header. This +is the most commonly used POST method. + +Use one of CURLOPT_POSTFIELDS(3) or CURLOPT_COPYPOSTFIELDS(3) +options to specify what data to post and CURLOPT_POSTFIELDSIZE(3) or +CURLOPT_POSTFIELDSIZE_LARGE(3) to set the data size. + +Optionally, you can provide data to POST using the +CURLOPT_READFUNCTION(3) and CURLOPT_READDATA(3) options but then +you must make sure to not set CURLOPT_POSTFIELDS(3) to anything but +NULL. When providing data with a callback, you must transmit it using chunked +transfer-encoding or you must set the size of the data with the +CURLOPT_POSTFIELDSIZE(3) or CURLOPT_POSTFIELDSIZE_LARGE(3) +options. To enable chunked encoding, you simply pass in the appropriate +Transfer-Encoding header, see the post-callback.c example. + +You can override the default POST Content-Type: header by setting your own +with CURLOPT_HTTPHEADER(3). + +Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. +You can disable this header with CURLOPT_HTTPHEADER(3) as usual. + +If you use POST to an HTTP 1.1 server, you can send data without knowing the +size before starting the POST if you use chunked encoding. You enable this by +adding a header like "Transfer-Encoding: chunked" with +CURLOPT_HTTPHEADER(3). With HTTP 1.0 or without chunked transfer, you +must specify the size in the request. (Since 7.66.0, libcurl automatically +uses chunked encoding for POSTs if the size is unknown.) + +When setting CURLOPT_POST(3) to 1, libcurl automatically sets +CURLOPT_NOBODY(3) and CURLOPT_HTTPGET(3) to 0. + +If you issue a POST request and then want to make a HEAD or GET using the same +reused handle, you must explicitly set the new request type using +CURLOPT_NOBODY(3) or CURLOPT_HTTPGET(3) or similar. + +When setting CURLOPT_POST(3) to 0, libcurl resets the request type to the +default to disable the POST. Typically that means gets reset to GET. Instead +you should set a new request type explicitly as described above. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_POST, 1L); + + /* set up the read callback with CURLOPT_READFUNCTION */ + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDS.3 b/docs/libcurl/opts/CURLOPT_POSTFIELDS.3 deleted file mode 100644 index c42cd65fb..000000000 --- a/docs/libcurl/opts/CURLOPT_POSTFIELDS.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POSTFIELDS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POSTFIELDS \- data to POST to server -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDS, char *postdata); -.fi -.SH DESCRIPTION -Pass a char * as parameter, pointing to the data buffer to use in an HTTP POST -operation. The data must be formatted and encoded the way you want the server -to receive it. libcurl does not convert or encode it in any way. For example, -the web server may assume that this data is URL encoded. - -The data pointed to is NOT copied by the library: as a consequence, it must be -preserved by the calling application until the associated transfer finishes. -This behavior can be changed (so libcurl does copy the data) by instead using -the \fICURLOPT_COPYPOSTFIELDS(3)\fP option. - -This POST is a normal \fBapplication/x-www-form-urlencoded\fP kind (and -libcurl sets that Content-Type by default when this option is used), which is -commonly used by HTML forms. Change Content-Type with -\fICURLOPT_HTTPHEADER(3)\fP. - -You can use \fIcurl_easy_escape(3)\fP to URL encode your data, if -necessary. It returns a pointer to an encoded string that can be passed as -\fIpostdata\fP. - -Using \fICURLOPT_POSTFIELDS(3)\fP implies setting \fICURLOPT_POST(3)\fP to 1. - -If \fICURLOPT_POSTFIELDS(3)\fP is explicitly set to NULL then libcurl gets the -POST data from the read callback. If you want to send a zero-byte POST set -\fICURLOPT_POSTFIELDS(3)\fP to an empty string, or set \fICURLOPT_POST(3)\fP -to 1 and \fICURLOPT_POSTFIELDSIZE(3)\fP to 0. - -libcurl assumes this option points to a null-terminated string unless you also -set \fICURLOPT_POSTFIELDSIZE(3)\fP to specify the length of the provided data, -which then is strictly required if you want to send off null bytes included in -the data. - -Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header, -and libcurl adds that header automatically if the POST is either known to be -larger than 1MB or if the expected size is unknown. You can disable this -header with \fICURLOPT_HTTPHEADER(3)\fP as usual. - -To make \fBmultipart/formdata\fP posts, check out the -\fICURLOPT_MIMEPOST(3)\fP option combined with \fIcurl_mime_init(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -/* send an application/x-www-form-urlencoded POST */ -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - const char *data = "data to send"; - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* size of the POST data if strlen() is not good enough */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L); - - /* pass in a pointer to the data - libcurl does not copy */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); - - curl_easy_perform(curl); - } - - /* send an application/json POST */ - curl = curl_easy_init(); - if(curl) { - const char *json = "{\"name\": \"daniel\"}"; - struct curl_slist *slist1 = NULL; - slist1 = curl_slist_append(slist1, "Content-Type: application/json"); - slist1 = curl_slist_append(slist1, "Accept: application/json"); - - /* set custom headers */ - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* pass in a pointer to the data - libcurl does not copy */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_COPYPOSTFIELDS (3), -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_POSTFIELDSIZE (3), -.BR CURLOPT_READFUNCTION (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDS.md b/docs/libcurl/opts/CURLOPT_POSTFIELDS.md new file mode 100644 index 000000000..409e4100a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POSTFIELDS.md @@ -0,0 +1,124 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POSTFIELDS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COPYPOSTFIELDS (3) + - CURLOPT_MIMEPOST (3) + - CURLOPT_POSTFIELDSIZE (3) + - CURLOPT_READFUNCTION (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_POSTFIELDS - data to POST to server + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDS, char *postdata); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, pointing to the data buffer to use in an +HTTP POST operation. The data must be formatted and encoded the way you want +the server to receive it. libcurl does not convert or encode it in any +way. For example, the web server may assume that this data is URL encoded. + +The data pointed to is NOT copied by the library: as a consequence, it must be +preserved by the calling application until the associated transfer finishes. +This behavior can be changed (so libcurl does copy the data) by instead using +the CURLOPT_COPYPOSTFIELDS(3) option. + +This POST is a normal **application/x-www-form-urlencoded** kind (and +libcurl sets that Content-Type by default when this option is used), which is +commonly used by HTML forms. Change Content-Type with +CURLOPT_HTTPHEADER(3). + +You can use curl_easy_escape(3) to URL encode your data, if +necessary. It returns a pointer to an encoded string that can be passed as +*postdata*. + +Using CURLOPT_POSTFIELDS(3) implies setting CURLOPT_POST(3) to 1. + +If CURLOPT_POSTFIELDS(3) is explicitly set to NULL then libcurl gets the +POST data from the read callback. If you want to send a zero-byte POST set +CURLOPT_POSTFIELDS(3) to an empty string, or set CURLOPT_POST(3) +to 1 and CURLOPT_POSTFIELDSIZE(3) to 0. + +libcurl assumes this option points to a null-terminated string unless you also +set CURLOPT_POSTFIELDSIZE(3) to specify the length of the provided data, +which then is strictly required if you want to send off null bytes included in +the data. + +Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header, +and libcurl adds that header automatically if the POST is either known to be +larger than 1MB or if the expected size is unknown. You can disable this +header with CURLOPT_HTTPHEADER(3) as usual. + +To make **multipart/formdata** posts, check out the +CURLOPT_MIMEPOST(3) option combined with curl_mime_init(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +/* send an application/x-www-form-urlencoded POST */ +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + const char *data = "data to send"; + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* size of the POST data if strlen() is not good enough */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L); + + /* pass in a pointer to the data - libcurl does not copy */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); + + curl_easy_perform(curl); + } + + /* send an application/json POST */ + curl = curl_easy_init(); + if(curl) { + const char *json = "{\"name\": \"daniel\"}"; + struct curl_slist *slist1 = NULL; + slist1 = curl_slist_append(slist1, "Content-Type: application/json"); + slist1 = curl_slist_append(slist1, "Accept: application/json"); + + /* set custom headers */ + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* pass in a pointer to the data - libcurl does not copy */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.3 b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.3 deleted file mode 100644 index 75ec05291..000000000 --- a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POSTFIELDSIZE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POSTFIELDSIZE \- size of POST data pointed to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE, long size); -.fi -.SH DESCRIPTION -If you want to post static data to the server without having libcurl do a -strlen() to measure the data size, this option must be used. When this option -is used you can post fully binary data, which otherwise is likely to fail. If -this size is set to -1, libcurl uses strlen() to get the size or relies on the -\fICURLOPT_READFUNCTION(3)\fP (if used) to signal the end of data. - -If you post more than 2GB, use \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP. -.SH DEFAULT --1 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -#include /* for strlen */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - const char *data = "data to send"; - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* size of the POST data */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data)); - - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_POSTFIELDSIZE_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.md b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.md new file mode 100644 index 000000000..d086809cb --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POSTFIELDSIZE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_POSTFIELDS (3) + - CURLOPT_POSTFIELDSIZE_LARGE (3) +--- + +# NAME + +CURLOPT_POSTFIELDSIZE - size of POST data pointed to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE, long size); +~~~ + +# DESCRIPTION + +If you want to post static data to the server without having libcurl do a +strlen() to measure the data size, this option must be used. When this option +is used you can post fully binary data, which otherwise is likely to fail. If +this size is set to -1, libcurl uses strlen() to get the size or relies on the +CURLOPT_READFUNCTION(3) (if used) to signal the end of data. + +If you post more than 2GB, use CURLOPT_POSTFIELDSIZE_LARGE(3). + +# DEFAULT + +-1 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +#include /* for strlen */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + const char *data = "data to send"; + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* size of the POST data */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data)); + + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.3 b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.3 deleted file mode 100644 index c09feea9a..000000000 --- a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POSTFIELDSIZE_LARGE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POSTFIELDSIZE_LARGE \- size of POST data pointed to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE_LARGE, - curl_off_t size); -.SH DESCRIPTION -If you want to post static data to the server without having libcurl do a -strlen() to measure the data size, this option must be used. When this option -is used you can post fully binary data, which otherwise is likely to fail. If -this size is set to -1, libcurl uses strlen() to get the size or relies on the -\fICURLOPT_READFUNCTION(3)\fP (if used) to signal the end of data. -.SH DEFAULT --1 -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -extern char *large_chunk; /* pointer to somewhere */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - const char *data = large_chunk; - curl_off_t length_of_data; /* set somehow */ - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* size of the POST data */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data); - - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_COPYPOSTFIELDS (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_POSTFIELDSIZE (3) diff --git a/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.md b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.md new file mode 100644 index 000000000..36fc0ff95 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POSTFIELDSIZE_LARGE.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POSTFIELDSIZE_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COPYPOSTFIELDS (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_POSTFIELDSIZE (3) +--- + +# NAME + +CURLOPT_POSTFIELDSIZE_LARGE - size of POST data pointed to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE_LARGE, + curl_off_t size); +~~~ + +# DESCRIPTION + +If you want to post static data to the server without having libcurl do a +strlen() to measure the data size, this option must be used. When this option +is used you can post fully binary data, which otherwise is likely to fail. If +this size is set to -1, libcurl uses strlen() to get the size or relies on the +CURLOPT_READFUNCTION(3) (if used) to signal the end of data. + +# DEFAULT + +-1 + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +extern char *large_chunk; /* pointer to somewhere */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + const char *data = large_chunk; + curl_off_t length_of_data; /* set somehow */ + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* size of the POST data */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data); + + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_POSTQUOTE.3 b/docs/libcurl/opts/CURLOPT_POSTQUOTE.3 deleted file mode 100644 index 33c46c7a5..000000000 --- a/docs/libcurl/opts/CURLOPT_POSTQUOTE.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POSTQUOTE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POSTQUOTE \- (S)FTP commands to run after the transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTQUOTE, - struct curl_slist *cmds); -.fi -.SH DESCRIPTION -Pass a pointer to a linked list of FTP or SFTP commands to pass to the server -after your FTP transfer request. The commands are only issues if no error -occur. The linked list should be a fully valid list of struct curl_slist -structs properly filled in as described for \fICURLOPT_QUOTE(3)\fP. - -Disable this operation again by setting a NULL to this option. -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and FTP -.SH EXAMPLE -.nf -int main(void) -{ - struct curl_slist *cmdlist = NULL; - cmdlist = curl_slist_append(cmdlist, "RNFR source-name"); - cmdlist = curl_slist_append(cmdlist, "RNTO new-name"); - - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - - /* pass in the FTP commands to run after the transfer */ - curl_easy_setopt(curl, CURLOPT_POSTQUOTE, cmdlist); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If support for the protocols are built-in. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PREQUOTE (3), -.BR CURLOPT_QUOTE (3) diff --git a/docs/libcurl/opts/CURLOPT_POSTQUOTE.md b/docs/libcurl/opts/CURLOPT_POSTQUOTE.md new file mode 100644 index 000000000..300a1f2c5 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POSTQUOTE.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POSTQUOTE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PREQUOTE (3) + - CURLOPT_QUOTE (3) +--- + +# NAME + +CURLOPT_POSTQUOTE - (S)FTP commands to run after the transfer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTQUOTE, + struct curl_slist *cmds); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of FTP or SFTP commands to pass to the server +after your FTP transfer request. The commands are only issues if no error +occur. The linked list should be a fully valid list of struct curl_slist +structs properly filled in as described for CURLOPT_QUOTE(3). + +Disable this operation again by setting a NULL to this option. + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and FTP + +# EXAMPLE + +~~~c +int main(void) +{ + struct curl_slist *cmdlist = NULL; + cmdlist = curl_slist_append(cmdlist, "RNFR source-name"); + cmdlist = curl_slist_append(cmdlist, "RNTO new-name"); + + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + + /* pass in the FTP commands to run after the transfer */ + curl_easy_setopt(curl, CURLOPT_POSTQUOTE, cmdlist); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If support for the protocols are built-in. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_POSTREDIR.3 b/docs/libcurl/opts/CURLOPT_POSTREDIR.3 deleted file mode 100644 index da7d826d7..000000000 --- a/docs/libcurl/opts/CURLOPT_POSTREDIR.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_POSTREDIR 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_POSTREDIR \- how to act on an HTTP POST redirect -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTREDIR, - long bitmask); -.SH DESCRIPTION -Pass a bitmask to control how libcurl acts on redirects after POSTs that get a -301, 302 or 303 response back. A parameter with bit 0 set (value -\fBCURL_REDIR_POST_301\fP) tells the library to respect RFC 7231 (section -6.4.2 to 6.4.4) and not convert POST requests into GET requests when following -a 301 redirection. Setting bit 1 (value \fBCURL_REDIR_POST_302\fP) makes -libcurl maintain the request method after a 302 redirect whilst setting bit 2 -(value \fBCURL_REDIR_POST_303\fP) makes libcurl maintain the request method -after a 303 redirect. The value \fBCURL_REDIR_POST_ALL\fP is a convenience -define that sets all three bits. - -The non-RFC behavior is ubiquitous in web browsers, so the library does the -conversion by default to maintain consistency. However, a server may require a -POST to remain a POST after such a redirection. This option is meaningful only -when setting \fICURLOPT_FOLLOWLOCATION(3)\fP. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP(S) -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* a silly POST example */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true"); - - /* example.com is redirected, so we tell libcurl to send POST on 301, - 302 and 303 HTTP response codes */ - curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.17.1. This option was known as CURLOPT_POST301 up to 7.19.0 as it -only supported the 301 then. CURL_REDIR_POST_303 was added in 7.26.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_EFFECTIVE_METHOD (3), -.BR CURLINFO_REDIRECT_COUNT (3), -.BR CURLOPT_FOLLOWLOCATION (3), -.BR CURLOPT_MAXREDIRS (3), -.BR CURLOPT_POSTFIELDS (3) diff --git a/docs/libcurl/opts/CURLOPT_POSTREDIR.md b/docs/libcurl/opts/CURLOPT_POSTREDIR.md new file mode 100644 index 000000000..0ca04a98c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_POSTREDIR.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_POSTREDIR +Section: 3 +Source: libcurl +See-also: + - CURLINFO_EFFECTIVE_METHOD (3) + - CURLINFO_REDIRECT_COUNT (3) + - CURLOPT_FOLLOWLOCATION (3) + - CURLOPT_MAXREDIRS (3) + - CURLOPT_POSTFIELDS (3) +--- + +# NAME + +CURLOPT_POSTREDIR - how to act on an HTTP POST redirect + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTREDIR, + long bitmask); +~~~ + +# DESCRIPTION + +Pass a bitmask to control how libcurl acts on redirects after POSTs that get a +301, 302 or 303 response back. A parameter with bit 0 set (value +**CURL_REDIR_POST_301**) tells the library to respect RFC 7231 (section +6.4.2 to 6.4.4) and not convert POST requests into GET requests when following +a 301 redirection. Setting bit 1 (value **CURL_REDIR_POST_302**) makes +libcurl maintain the request method after a 302 redirect whilst setting bit 2 +(value **CURL_REDIR_POST_303**) makes libcurl maintain the request method +after a 303 redirect. The value **CURL_REDIR_POST_ALL** is a convenience +define that sets all three bits. + +The non-RFC behavior is ubiquitous in web browsers, so the library does the +conversion by default to maintain consistency. However, a server may require a +POST to remain a POST after such a redirection. This option is meaningful only +when setting CURLOPT_FOLLOWLOCATION(3). + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP(S) + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* a silly POST example */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "data=true"); + + /* example.com is redirected, so we tell libcurl to send POST on 301, + 302 and 303 HTTP response codes */ + curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.17.1. This option was known as CURLOPT_POST301 up to 7.19.0 as it +only supported the 301 then. CURL_REDIR_POST_303 was added in 7.26.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PREQUOTE.3 b/docs/libcurl/opts/CURLOPT_PREQUOTE.3 deleted file mode 100644 index fd5ba0467..000000000 --- a/docs/libcurl/opts/CURLOPT_PREQUOTE.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PREQUOTE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PREQUOTE \- commands to run before an FTP transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREQUOTE, - struct curl_slist *cmds); -.fi -.SH DESCRIPTION -Pass a pointer to a linked list of FTP commands to pass to the server after -the transfer type is set. The linked list should be a fully valid list of -struct curl_slist structs properly filled in as described for -\fICURLOPT_QUOTE(3)\fP. Disable this operation again by setting a NULL to this -option. - -These commands are not performed when a directory listing is performed, only -for file transfers. - -While \fICURLOPT_QUOTE(3)\fP and \fICURLOPT_POSTQUOTE(3)\fP work for SFTP, -this option does not. -.SH DEFAULT -NULL -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - struct curl_slist *cmdlist = NULL; - cmdlist = curl_slist_append(cmdlist, "SYST"); - - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - - /* pass in the FTP commands to run */ - curl_easy_setopt(curl, CURLOPT_PREQUOTE, cmdlist); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with the protocol support -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_POSTQUOTE (3), -.BR CURLOPT_QUOTE (3) diff --git a/docs/libcurl/opts/CURLOPT_PREQUOTE.md b/docs/libcurl/opts/CURLOPT_PREQUOTE.md new file mode 100644 index 000000000..e5192039d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PREQUOTE.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PREQUOTE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_POSTQUOTE (3) + - CURLOPT_QUOTE (3) +--- + +# NAME + +CURLOPT_PREQUOTE - commands to run before an FTP transfer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREQUOTE, + struct curl_slist *cmds); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of FTP commands to pass to the server after +the transfer type is set. The linked list should be a fully valid list of +struct curl_slist structs properly filled in as described for +CURLOPT_QUOTE(3). Disable this operation again by setting a NULL to this +option. + +These commands are not performed when a directory listing is performed, only +for file transfers. + +While CURLOPT_QUOTE(3) and CURLOPT_POSTQUOTE(3) work for SFTP, +this option does not. + +# DEFAULT + +NULL + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + struct curl_slist *cmdlist = NULL; + cmdlist = curl_slist_append(cmdlist, "SYST"); + + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + + /* pass in the FTP commands to run */ + curl_easy_setopt(curl, CURLOPT_PREQUOTE, cmdlist); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with the protocol support + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PREREQDATA.3 b/docs/libcurl/opts/CURLOPT_PREREQDATA.3 deleted file mode 100644 index 2d9c4e12c..000000000 --- a/docs/libcurl/opts/CURLOPT_PREREQDATA.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Max Dymond, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PREREQDATA 3 "2 Aug 2021" libcurl libcurl -.SH NAME -CURLOPT_PREREQDATA \- pointer passed to the pre-request callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the first -argument in the pre-request callback set with \fICURLOPT_PREREQFUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int prereq_callback(void *clientp, - char *conn_primary_ip, - char *conn_local_ip, - int conn_primary_port, - int conn_local_port) -{ - printf("Connection made to %s:%d\\n", conn_primary_ip, conn_primary_port); - return CURL_PREREQFUNC_OK; -} - -int main(void) -{ - struct priv prereq_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback); - curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.80.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_PRIMARY_IP (3), -.BR CURLINFO_PRIMARY_PORT (3), -.BR CURLOPT_PREREQFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_PREREQDATA.md b/docs/libcurl/opts/CURLOPT_PREREQDATA.md new file mode 100644 index 000000000..14ba8e302 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PREREQDATA.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PREREQDATA +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PRIMARY_IP (3) + - CURLINFO_PRIMARY_PORT (3) + - CURLOPT_PREREQFUNCTION (3) +--- + +# NAME + +CURLOPT_PREREQDATA - pointer passed to the pre-request callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the first +argument in the pre-request callback set with CURLOPT_PREREQFUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int prereq_callback(void *clientp, + char *conn_primary_ip, + char *conn_local_ip, + int conn_primary_port, + int conn_local_port) +{ + printf("Connection made to %s:%d\n", conn_primary_ip, conn_primary_port); + return CURL_PREREQFUNC_OK; +} + +int main(void) +{ + struct priv prereq_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback); + curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.80.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.3 b/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.3 deleted file mode 100644 index a2e3dd38f..000000000 --- a/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Max Dymond, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PREREQFUNCTION 3 "2 Aug 2021" libcurl libcurl -.SH NAME -CURLOPT_PREREQFUNCTION \- user callback called when a connection has been -established, but before a request has been made. -.SH SYNOPSIS -.nf -#include - -/* These are the return codes for the pre-request callback. */ -#define CURL_PREREQFUNC_OK 0 -#define CURL_PREREQFUNC_ABORT 1 /* fail the entire transfer */ - -int prereq_callback(void *clientp, - char *conn_primary_ip, - char *conn_local_ip, - int conn_primary_port, - int conn_local_port); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQFUNCTION, prereq_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This function gets called by libcurl after a connection has been established -or a connection has been reused (including any SSL handshaking), but before any -request is actually made on the connection. For example, for HTTP, this -callback is called once a connection has been established to the server, but -before a GET/HEAD/POST/etc request has been sent. - -This function may be called multiple times if redirections are enabled and are -being followed (see \fICURLOPT_FOLLOWLOCATION(3)\fP). - -The callback function must return \fICURL_PREREQFUNC_OK\fP on success, or -\fICURL_PREREQFUNC_ABORT\fP to cause the transfer to fail. - -This function is passed the following arguments: -.IP conn_primary_ip -A null-terminated pointer to a C string containing the primary IP of the -remote server established with this connection. For FTP, this is the IP for -the control connection. IPv6 addresses are represented without surrounding -brackets. -.IP conn_local_ip -A null-terminated pointer to a C string containing the originating IP for this -connection. IPv6 addresses are represented without surrounding brackets. -.IP conn_primary_port -The primary port number on the remote server established with this connection. -For FTP, this is the port for the control connection. This can be a TCP or a -UDP port number depending on the protocol. -.IP conn_local_port -The originating port number for this connection. This can be a TCP or a UDP -port number depending on the protocol. -.IP clientp -The pointer you set with \fICURLOPT_PREREQDATA(3)\fP. -.SH DEFAULT -By default, this is NULL and unused. -.SH PROTOCOLS -ALL -.SH EXAMPLE -.nf -struct priv { - void *custom; -}; - -static int prereq_callback(void *clientp, - char *conn_primary_ip, - char *conn_local_ip, - int conn_primary_port, - int conn_local_port) -{ - printf("Connection made to %s:%d\\n", conn_primary_ip, conn_primary_port); - return CURL_PREREQFUNC_OK; -} - -int main(void) -{ - struct priv prereq_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback); - curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.80.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_PRIMARY_IP (3), -.BR CURLINFO_PRIMARY_PORT (3), -.BR CURLOPT_PREREQDATA (3) diff --git a/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.md b/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.md new file mode 100644 index 000000000..c81408494 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PREREQFUNCTION.md @@ -0,0 +1,125 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PREREQFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PRIMARY_IP (3) + - CURLINFO_PRIMARY_PORT (3) + - CURLOPT_PREREQDATA (3) +--- + +# NAME + +CURLOPT_PREREQFUNCTION - user callback called when a connection has been +established, but before a request has been made. + +# SYNOPSIS + +~~~c +#include + +/* These are the return codes for the pre-request callback. */ +#define CURL_PREREQFUNC_OK 0 +#define CURL_PREREQFUNC_ABORT 1 /* fail the entire transfer */ + +int prereq_callback(void *clientp, + char *conn_primary_ip, + char *conn_local_ip, + int conn_primary_port, + int conn_local_port); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQFUNCTION, prereq_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This function gets called by libcurl after a connection has been established +or a connection has been reused (including any SSL handshaking), but before any +request is actually made on the connection. For example, for HTTP, this +callback is called once a connection has been established to the server, but +before a GET/HEAD/POST/etc request has been sent. + +This function may be called multiple times if redirections are enabled and are +being followed (see CURLOPT_FOLLOWLOCATION(3)). + +The callback function must return *CURL_PREREQFUNC_OK* on success, or +*CURL_PREREQFUNC_ABORT* to cause the transfer to fail. + +This function is passed the following arguments: + +## conn_primary_ip + +A null-terminated pointer to a C string containing the primary IP of the +remote server established with this connection. For FTP, this is the IP for +the control connection. IPv6 addresses are represented without surrounding +brackets. + +## conn_local_ip + +A null-terminated pointer to a C string containing the originating IP for this +connection. IPv6 addresses are represented without surrounding brackets. + +## conn_primary_port + +The primary port number on the remote server established with this connection. +For FTP, this is the port for the control connection. This can be a TCP or a +UDP port number depending on the protocol. + +## conn_local_port + +The originating port number for this connection. This can be a TCP or a UDP +port number depending on the protocol. + +## clientp + +The pointer you set with CURLOPT_PREREQDATA(3). + +# DEFAULT + +By default, this is NULL and unused. + +# PROTOCOLS + +ALL + +# EXAMPLE + +~~~c +struct priv { + void *custom; +}; + +static int prereq_callback(void *clientp, + char *conn_primary_ip, + char *conn_local_ip, + int conn_primary_port, + int conn_local_port) +{ + printf("Connection made to %s:%d\n", conn_primary_ip, conn_primary_port); + return CURL_PREREQFUNC_OK; +} + +int main(void) +{ + struct priv prereq_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback); + curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.80.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PRE_PROXY.3 b/docs/libcurl/opts/CURLOPT_PRE_PROXY.3 deleted file mode 100644 index 044d60c0c..000000000 --- a/docs/libcurl/opts/CURLOPT_PRE_PROXY.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PRE_PROXY 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PRE_PROXY \- pre-proxy host to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRE_PROXY, char *preproxy); -.fi -.SH DESCRIPTION -Set the \fIpreproxy\fP to use for the upcoming request. The parameter -should be a char * to a null-terminated string holding the host name or dotted -numerical IP address. A numerical IPv6 address must be written within -[brackets]. - -To specify port number in this string, append :[port] to the end of the host -name. The proxy's port number may optionally be specified with the separate -option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl defaults to using -port 1080 for proxies. - -A pre proxy is a SOCKS proxy that curl connects to before it connects to the -HTTP(S) proxy specified in the \fICURLOPT_PROXY(3)\fP option. The pre proxy -can only be a SOCKS proxy. - -The pre proxy string should be prefixed with [scheme]:// to specify which kind -of socks is used. Use socks4://, socks4a://, socks5:// or socks5h:// (the last -one to enable socks5 and asking the proxy to do the resolving, also known as -\fICURLPROXY_SOCKS5_HOSTNAME\fP type) to request the specific SOCKS version to -be used. Otherwise SOCKS4 is used as default. - -Setting the pre proxy string to "" (an empty string) explicitly disables the -use of a pre proxy. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -Default is NULL, meaning no pre proxy is used. - -When you set a host name to use, do not assume that there is any particular -single port number used widely for proxies. Specify it! -.SH PROTOCOLS -All except file://. Note that some protocols do not work well over proxy. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_HTTPPROXYTUNNEL (3) diff --git a/docs/libcurl/opts/CURLOPT_PRE_PROXY.md b/docs/libcurl/opts/CURLOPT_PRE_PROXY.md new file mode 100644 index 000000000..1afe831e3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PRE_PROXY.md @@ -0,0 +1,84 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PRE_PROXY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_PROXY (3) +--- + +# NAME + +CURLOPT_PRE_PROXY - pre-proxy host to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRE_PROXY, char *preproxy); +~~~ + +# DESCRIPTION + +Set the *preproxy* to use for the upcoming request. The parameter should be a +char * to a null-terminated string holding the hostname or dotted numerical IP +address. A numerical IPv6 address must be written within [brackets]. + +To specify port number in this string, append :[port] to the end of the host +name. The proxy's port number may optionally be specified with the separate +option CURLOPT_PROXYPORT(3). If not specified, libcurl defaults to using +port 1080 for proxies. + +A pre proxy is a SOCKS proxy that curl connects to before it connects to the +HTTP(S) proxy specified in the CURLOPT_PROXY(3) option. The pre proxy +can only be a SOCKS proxy. + +The pre proxy string should be prefixed with [scheme]:// to specify which kind +of socks is used. Use socks4://, socks4a://, socks5:// or socks5h:// (the last +one to enable socks5 and asking the proxy to do the resolving, also known as +*CURLPROXY_SOCKS5_HOSTNAME* type) to request the specific SOCKS version to +be used. Otherwise SOCKS4 is used as default. + +Setting the pre proxy string to "" (an empty string) explicitly disables the +use of a pre proxy. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +Default is NULL, meaning no pre proxy is used. + +When you set a hostname to use, do not assume that there is any particular +single port number used widely for proxies. Specify it! + +# PROTOCOLS + +All except file://. Note that some protocols do not work well over proxy. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_PRE_PROXY, "socks4://socks-proxy:1080"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PRIVATE.3 b/docs/libcurl/opts/CURLOPT_PRIVATE.3 deleted file mode 100644 index 273ba1df6..000000000 --- a/docs/libcurl/opts/CURLOPT_PRIVATE.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PRIVATE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PRIVATE \- store a private pointer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRIVATE, void *pointer); -.fi -.SH DESCRIPTION -Pass a void * as parameter, pointing to data that should be associated with -this curl handle. The pointer can subsequently be retrieved using -\fIcurl_easy_getinfo(3)\fP with the \fICURLINFO_PRIVATE(3)\fP option. libcurl -itself never does anything with this data. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct private { - void *custom; -}; - -int main(void) -{ - CURL *curl = curl_easy_init(); - struct private secrets; - if(curl) { - struct private *extracted; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* store a pointer to our private struct */ - curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets); - - curl_easy_perform(curl); - - /* we can extract the private pointer again too */ - curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.3 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_PRIVATE (3), -.BR CURLOPT_STDERR (3), -.BR CURLOPT_VERBOSE (3) diff --git a/docs/libcurl/opts/CURLOPT_PRIVATE.md b/docs/libcurl/opts/CURLOPT_PRIVATE.md new file mode 100644 index 000000000..571a681b9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PRIVATE.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PRIVATE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PRIVATE (3) + - CURLOPT_STDERR (3) + - CURLOPT_VERBOSE (3) +--- + +# NAME + +CURLOPT_PRIVATE - store a private pointer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PRIVATE, void *pointer); +~~~ + +# DESCRIPTION + +Pass a void * as parameter, pointing to data that should be associated with +this curl handle. The pointer can subsequently be retrieved using +curl_easy_getinfo(3) with the CURLINFO_PRIVATE(3) option. libcurl itself +never does anything with this data. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct private { + void *custom; +}; + +int main(void) +{ + CURL *curl = curl_easy_init(); + struct private secrets; + if(curl) { + struct private *extracted; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* store a pointer to our private struct */ + curl_easy_setopt(curl, CURLOPT_PRIVATE, &secrets); + + curl_easy_perform(curl); + + /* we can extract the private pointer again too */ + curl_easy_getinfo(curl, CURLINFO_PRIVATE, &extracted); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.3 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROGRESSDATA.3 b/docs/libcurl/opts/CURLOPT_PROGRESSDATA.3 deleted file mode 100644 index 8d1fef100..000000000 --- a/docs/libcurl/opts/CURLOPT_PROGRESSDATA.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROGRESSDATA 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROGRESSDATA \- pointer passed to the progress callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the first -argument in the progress callback set with \fICURLOPT_PROGRESSFUNCTION(3)\fP. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct progress { - char *private; - size_t size; -}; - -static size_t progress_callback(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow) -{ - struct progress *memory = clientp; - printf("private: %p\\n", memory->private); - - /* use the values */ - - return 0; /* all is good */ -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct progress data; - - /* pass struct to callback */ - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PROGRESSFUNCTION (3), -.BR CURLOPT_XFERINFOFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_PROGRESSDATA.md b/docs/libcurl/opts/CURLOPT_PROGRESSDATA.md new file mode 100644 index 000000000..276bee827 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROGRESSDATA.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROGRESSDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROGRESSFUNCTION (3) + - CURLOPT_XFERINFOFUNCTION (3) +--- + +# NAME + +CURLOPT_PROGRESSDATA - pointer passed to the progress callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the first +argument in the progress callback set with CURLOPT_PROGRESSFUNCTION(3). + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct progress { + char *private; + size_t size; +}; + +static size_t progress_callback(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow) +{ + struct progress *memory = clientp; + printf("private: %p\n", memory->private); + + /* use the values */ + + return 0; /* all is good */ +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct progress data; + + /* pass struct to callback */ + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 b/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 deleted file mode 100644 index 5682900d5..000000000 --- a/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 +++ /dev/null @@ -1,127 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROGRESSFUNCTION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROGRESSFUNCTION \- progress meter callback -.SH SYNOPSIS -.nf -#include - -int progress_callback(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION, - progress_callback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This option is deprecated and we encourage users to use the -newer \fICURLOPT_XFERINFOFUNCTION(3)\fP instead, if you can. - -This function gets called by libcurl instead of its internal equivalent with a -frequent interval. While data is being transferred it is invoked frequently, -and during slow periods like when nothing is being transferred it can slow -down to about one call per second. - -\fIclientp\fP is the pointer set with \fICURLOPT_PROGRESSDATA(3)\fP, it is not -used by libcurl but is only passed along from the application to the callback. - -The callback gets told how much data libcurl is about to transfer and has -transferred, in number of bytes. \fIdltotal\fP is the total number of bytes -libcurl expects to download in this transfer. \fIdlnow\fP is the number of -bytes downloaded so far. \fIultotal\fP is the total number of bytes libcurl -expects to upload in this transfer. \fIulnow\fP is the number of bytes -uploaded so far. - -Unknown/unused argument values passed to the callback are be set to zero (like -if you only download data, the upload size remains 0). Many times the callback -is called one or more times first, before it knows the data sizes so a program -must be made to handle that. - -If your callback function returns CURL_PROGRESSFUNC_CONTINUE it causes libcurl -to continue executing the default progress function. - -Returning any other non-zero value from this callback makes libcurl abort the -transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP. - -If you transfer data with the multi interface, this function is not called -during periods of idleness unless you call the appropriate libcurl function -that performs transfers. - -\fICURLOPT_NOPROGRESS(3)\fP must be set to 0 to make this function actually -get called. -.SH DEFAULT -By default, libcurl has an internal progress meter. That is rarely wanted by -users. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct progress { - char *private; - size_t size; -}; - -static size_t progress_callback(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow) -{ - struct progress *memory = clientp; - printf("private: %p\\n", memory->private); - - /* use the values */ - - return 0; /* all is good */ -} - -int main(void) -{ - struct progress data; - - CURL *curl = curl_easy_init(); - if(curl) { - /* pass struct to callback */ - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Deprecated since 7.32.0. -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_VERBOSE (3), -.BR CURLOPT_NOPROGRESS (3), -.BR CURLOPT_XFERINFOFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.md b/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.md new file mode 100644 index 000000000..19d84c889 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.md @@ -0,0 +1,125 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROGRESSFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NOPROGRESS (3) + - CURLOPT_VERBOSE (3) + - CURLOPT_XFERINFOFUNCTION (3) +--- + +# NAME + +CURLOPT_PROGRESSFUNCTION - progress meter callback + +# SYNOPSIS + +~~~c +#include + +int progress_callback(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION, + progress_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This option is deprecated and we encourage users to use the +newer CURLOPT_XFERINFOFUNCTION(3) instead, if you can. + +This function gets called by libcurl instead of its internal equivalent with a +frequent interval. While data is being transferred it is invoked frequently, +and during slow periods like when nothing is being transferred it can slow +down to about one call per second. + +*clientp* is the pointer set with CURLOPT_PROGRESSDATA(3), it is not +used by libcurl but is only passed along from the application to the callback. + +The callback gets told how much data libcurl is about to transfer and has +transferred, in number of bytes. *dltotal* is the total number of bytes +libcurl expects to download in this transfer. *dlnow* is the number of +bytes downloaded so far. *ultotal* is the total number of bytes libcurl +expects to upload in this transfer. *ulnow* is the number of bytes +uploaded so far. + +Unknown/unused argument values passed to the callback are be set to zero (like +if you only download data, the upload size remains 0). Many times the callback +is called one or more times first, before it knows the data sizes so a program +must be made to handle that. + +If your callback function returns CURL_PROGRESSFUNC_CONTINUE it causes libcurl +to continue executing the default progress function. + +Returning any other non-zero value from this callback makes libcurl abort the +transfer and return *CURLE_ABORTED_BY_CALLBACK*. + +If you transfer data with the multi interface, this function is not called +during periods of idleness unless you call the appropriate libcurl function +that performs transfers. + +CURLOPT_NOPROGRESS(3) must be set to 0 to make this function actually +get called. + +# DEFAULT + +By default, libcurl has an internal progress meter. That is rarely wanted by +users. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct progress { + char *private; + size_t size; +}; + +static size_t progress_callback(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow) +{ + struct progress *memory = clientp; + printf("private: %p\n", memory->private); + + /* use the values */ + + return 0; /* all is good */ +} + +int main(void) +{ + struct progress data; + + CURL *curl = curl_easy_init(); + if(curl) { + /* pass struct to callback */ + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Deprecated since 7.32.0. + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_PROTOCOLS.3 b/docs/libcurl/opts/CURLOPT_PROTOCOLS.3 deleted file mode 100644 index 29538d660..000000000 --- a/docs/libcurl/opts/CURLOPT_PROTOCOLS.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROTOCOLS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROTOCOLS \- allowed protocols -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS, long bitmask); -.fi -.SH DESCRIPTION -This option is deprecated. We strongly recommend using -\fICURLOPT_PROTOCOLS_STR(3)\fP instead because this option cannot control all -available protocols! - -Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask -limits what protocols libcurl may use in the transfer. This allows you to have -a libcurl built to support a wide range of protocols but still limit specific -transfers to only be allowed to use a subset of them. By default libcurl -accepts all protocols it supports (\fICURLPROTO_ALL\fP). See also -\fICURLOPT_REDIR_PROTOCOLS(3)\fP. - -These are the available protocol defines: -.nf -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 -.fi -.SH DEFAULT -All protocols built-in. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(int argc, char **argv) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* pass in the URL from an external source */ - curl_easy_setopt(curl, CURLOPT_URL, argv[1]); - - /* only allow HTTP, TFTP and SFTP */ - curl_easy_setopt(curl, CURLOPT_PROTOCOLS, - CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4. Deprecated since 7.85.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DEFAULT_PROTOCOL (3), -.BR CURLOPT_REDIR_PROTOCOLS (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_PROTOCOLS.md b/docs/libcurl/opts/CURLOPT_PROTOCOLS.md new file mode 100644 index 000000000..a4d1a5a7c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROTOCOLS.md @@ -0,0 +1,104 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROTOCOLS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEFAULT_PROTOCOL (3) + - CURLOPT_REDIR_PROTOCOLS (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_PROTOCOLS - allowed protocols + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS, long bitmask); +~~~ + +# DESCRIPTION + +This option is deprecated. We strongly recommend using +CURLOPT_PROTOCOLS_STR(3) instead because this option cannot control all +available protocols! + +Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask +limits what protocols libcurl may use in the transfer. This allows you to have +a libcurl built to support a wide range of protocols but still limit specific +transfers to only be allowed to use a subset of them. By default libcurl +accepts all protocols it supports (*CURLPROTO_ALL*). See also +CURLOPT_REDIR_PROTOCOLS(3). + +These are the available protocol defines: +~~~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 +~~~ + +# DEFAULT + +All protocols built-in. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(int argc, char **argv) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* pass in the URL from an external source */ + curl_easy_setopt(curl, CURLOPT_URL, argv[1]); + + /* only allow HTTP, TFTP and SFTP */ + curl_easy_setopt(curl, CURLOPT_PROTOCOLS, + CURLPROTO_HTTP | CURLPROTO_TFTP | CURLPROTO_SFTP); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4. Deprecated since 7.85.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.3 b/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.3 deleted file mode 100644 index 8af32244d..000000000 --- a/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROTOCOLS_STR 3 "11 Jun 2022" libcurl libcurl -.SH NAME -CURLOPT_PROTOCOLS_STR \- allowed protocols -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS_STR, char *spec); -.fi -.SH DESCRIPTION -Pass a pointer to a string that holds a comma-separated list of case -insensitive protocol names (URL schemes) to allow in the transfer. This -option allows applications to use libcurl built to support a wide range of -protocols but still limit specific transfers to only be allowed to use a -subset of them. By default, libcurl accepts all protocols it was built with -support for. See also \fICURLOPT_REDIR_PROTOCOLS_STR(3)\fP. - -If trying to set a non-existing protocol or if no matching protocol at all is -set, it returns error. - -These are the available protocols: - -DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, -MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP, -SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS - -You can set "ALL" as a short-cut to enable all protocols. Note that by setting -all, you may enable protocols that were not supported the day you write this -but are introduced in a future libcurl version. - -\fIcurl_version_info(3)\fP can be used to get a list of all supported -protocols in the current libcurl. \fICURLINFO_SCHEME(3)\fP is the recommended -way to figure out the protocol used in a previous transfer. -.SH DEFAULT -All protocols built-in -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(int argc, char **argv) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* pass in the URL from an external source */ - curl_easy_setopt(curl, CURLOPT_URL, argv[1]); - - /* only allow HTTP, TFTP and SFTP */ - curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.85.0 -.SH RETURN VALUE -Returns CURLE_UNKNOWN_OPTION if the option is not implemented, -CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled, -CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK. -.SH "SEE ALSO" -.BR curl_version_info (3), -.BR CURLINFO_SCHEME (3), -.BR CURLOPT_DEFAULT_PROTOCOL (3), -.BR CURLOPT_REDIR_PROTOCOLS_STR (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.md b/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.md new file mode 100644 index 000000000..9da056d23 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROTOCOLS_STR.md @@ -0,0 +1,88 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROTOCOLS_STR +Section: 3 +Source: libcurl +See-also: + - CURLINFO_SCHEME (3) + - CURLOPT_DEFAULT_PROTOCOL (3) + - CURLOPT_REDIR_PROTOCOLS_STR (3) + - CURLOPT_URL (3) + - curl_version_info (3) +--- + +# NAME + +CURLOPT_PROTOCOLS_STR - allowed protocols + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROTOCOLS_STR, char *spec); +~~~ + +# DESCRIPTION + +Pass a pointer to a string that holds a comma-separated list of case +insensitive protocol names (URL schemes) to allow in the transfer. This +option allows applications to use libcurl built to support a wide range of +protocols but still limit specific transfers to only be allowed to use a +subset of them. By default, libcurl accepts all protocols it was built with +support for. See also CURLOPT_REDIR_PROTOCOLS_STR(3). + +If trying to set a non-existing protocol or if no matching protocol at all is +set, it returns error. + +These are the available protocols: + +DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, +MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS + +You can set "ALL" as a short-cut to enable all protocols. Note that by setting +all, you may enable protocols that were not supported the day you write this +but are introduced in a future libcurl version. + +curl_version_info(3) can be used to get a list of all supported +protocols in the current libcurl. CURLINFO_SCHEME(3) is the recommended +way to figure out the protocol used in a previous transfer. + +# DEFAULT + +All protocols built-in + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(int argc, char **argv) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* pass in the URL from an external source */ + curl_easy_setopt(curl, CURLOPT_URL, argv[1]); + + /* only allow HTTP, TFTP and SFTP */ + curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,tftp,sftp"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.85.0 + +# RETURN VALUE + +Returns CURLE_UNKNOWN_OPTION if the option is not implemented, +CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled, +CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_PROXY.3 b/docs/libcurl/opts/CURLOPT_PROXY.3 deleted file mode 100644 index a3a36152a..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY.3 +++ /dev/null @@ -1,137 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXY \- proxy to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy); -.fi -.SH DESCRIPTION -Set the \fIproxy\fP to use for transfers with this easy handle. The parameter -should be a char * to a null-terminated string holding the host name or dotted -numerical IP address. A numerical IPv6 address must be written within -[brackets]. - -To specify port number in this string, append :[port] to the end of the host -name. The proxy's port number may optionally (but discouraged) be specified -with the separate option \fICURLOPT_PROXYPORT(3)\fP. If not specified, libcurl -defaults to using port 1080 for proxies. - -The proxy string may be prefixed with [scheme]:// to specify which kind of -proxy is used. - -.RS -.IP http:// -HTTP Proxy. Default when no scheme or proxy type is specified. -.IP https:// -HTTPS Proxy. (Added in 7.52.0 for OpenSSL and GnuTLS Since 7.87.0, it -also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport and -wolfSSL.) - -This uses HTTP/1 by default. Setting \fICURLOPT_PROXYTYPE(3)\fP to -\fBCURLPROXY_HTTPS2\fP allows libcurl to negotiate using HTTP/2 with proxy. -.IP socks4:// -SOCKS4 Proxy. -.IP socks4a:// -SOCKS4a Proxy. Proxy resolves URL hostname. -.IP socks5:// -SOCKS5 Proxy. -.IP socks5h:// -SOCKS5 Proxy. Proxy resolves URL hostname. -.RE - -Without a scheme prefix, \fICURLOPT_PROXYTYPE(3)\fP can be used to specify -which kind of proxy the string identifies. - -When you tell the library to use an HTTP proxy, libcurl transparently converts -operations to HTTP even if you specify an FTP URL etc. This may have an impact -on what other features of the library you can use, such as -\fICURLOPT_QUOTE(3)\fP and similar FTP specifics that do not work unless you -tunnel through the HTTP proxy. Such tunneling is activated with -\fICURLOPT_HTTPPROXYTUNNEL(3)\fP. - -Setting the proxy string to "" (an empty string) explicitly disables the use -of a proxy, even if there is an environment variable set for it. - -A proxy host string can also include protocol scheme (http://) and embedded -user + password. - -Unix domain sockets are supported for socks proxies since 7.84.0. Set -localhost for the host part. e.g. socks5h://localhost/path/to/socket.sock - -The application does not have to keep the string around after setting this -option. - -When a proxy is used, the active FTP mode as set with \fICUROPT_FTPPORT(3)\fP, -cannot be used. -.SH "Environment variables" -libcurl respects the proxy environment variables named \fBhttp_proxy\fP, -\fBftp_proxy\fP, \fBsftp_proxy\fP etc. If set, libcurl uses the specified -proxy for that URL scheme. So for a "FTP://" URL, the \fBftp_proxy\fP is -considered. \fBall_proxy\fP is used if no protocol specific proxy was set. - -If \fBno_proxy\fP (or \fBNO_PROXY\fP) is set, it is the exact equivalent of -setting the \fICURLOPT_NOPROXY(3)\fP option. - -The \fICURLOPT_PROXY(3)\fP and \fICURLOPT_NOPROXY(3)\fP options override -environment variables. -.SH DEFAULT -Default is NULL, meaning no proxy is used. - -When you set a host name to use, do not assume that there is any particular -single port number used widely for proxies. Specify it! -.SH PROTOCOLS -All except file://. Note that some protocols do not work well over proxy. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Since 7.14.1 the proxy environment variable names can include the protocol -scheme. - -Since 7.21.7 the proxy string supports the socks protocols as "schemes". - -Since 7.50.2, unsupported schemes in proxy strings cause libcurl to return -error. -.SH RETURN VALUE -Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_HTTPPROXYTUNNEL (3), -.BR CURLOPT_PRE_PROXY (3), -.BR CURLOPT_PROXYPORT (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY.md b/docs/libcurl/opts/CURLOPT_PROXY.md new file mode 100644 index 000000000..89c22df9b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY.md @@ -0,0 +1,146 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_PRE_PROXY (3) + - CURLOPT_PROXYPORT (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_PROXY - proxy to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY, char *proxy); +~~~ + +# DESCRIPTION + +Set the *proxy* to use for transfers with this easy handle. The parameter +should be a char * to a null-terminated string holding the hostname or dotted +numerical IP address. A numerical IPv6 address must be written within +[brackets]. + +To specify port number in this string, append :[port] to the end of the host +name. The proxy's port number may optionally (but discouraged) be specified +with the separate option CURLOPT_PROXYPORT(3). If not specified, libcurl +defaults to using port 1080 for proxies. + +The proxy string may be prefixed with [scheme]:// to specify which kind of +proxy is used. + +## http:// + +HTTP Proxy. Default when no scheme or proxy type is specified. + +## https:// + +HTTPS Proxy. (Added in 7.52.0 for OpenSSL and GnuTLS Since 7.87.0, it +also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport and +wolfSSL.) + +This uses HTTP/1 by default. Setting CURLOPT_PROXYTYPE(3) to +**CURLPROXY_HTTPS2** allows libcurl to negotiate using HTTP/2 with proxy. + +## socks4:// + +SOCKS4 Proxy. + +## socks4a:// + +SOCKS4a Proxy. Proxy resolves URL hostname. + +## socks5:// + +SOCKS5 Proxy. + +## socks5h:// + +SOCKS5 Proxy. Proxy resolves URL hostname. + +Without a scheme prefix, CURLOPT_PROXYTYPE(3) can be used to specify +which kind of proxy the string identifies. + +When you tell the library to use an HTTP proxy, libcurl transparently converts +operations to HTTP even if you specify an FTP URL etc. This may have an impact +on what other features of the library you can use, such as +CURLOPT_QUOTE(3) and similar FTP specifics that do not work unless you +tunnel through the HTTP proxy. Such tunneling is activated with +CURLOPT_HTTPPROXYTUNNEL(3). + +Setting the proxy string to "" (an empty string) explicitly disables the use +of a proxy, even if there is an environment variable set for it. + +A proxy host string can also include protocol scheme (http://) and embedded +user + password. + +Unix domain sockets are supported for socks proxies since 7.84.0. Set +localhost for the host part. e.g. socks5h://localhost/path/to/socket.sock + +The application does not have to keep the string around after setting this +option. + +When a proxy is used, the active FTP mode as set with *CUROPT_FTPPORT(3)*, +cannot be used. + +# Environment variables + +libcurl respects the proxy environment variables named **http_proxy**, +**ftp_proxy**, **sftp_proxy** etc. If set, libcurl uses the specified proxy +for that URL scheme. For an "FTP://" URL, the **ftp_proxy** is +considered. **all_proxy** is used if no protocol specific proxy was set. + +If **no_proxy** (or **NO_PROXY**) is set, it is the exact equivalent of +setting the CURLOPT_NOPROXY(3) option. + +The CURLOPT_PROXY(3) and CURLOPT_NOPROXY(3) options override environment +variables. + +# DEFAULT + +Default is NULL, meaning no proxy is used. + +When you set a hostname to use, do not assume that there is any particular +single port number used widely for proxies. Specify it! + +# PROTOCOLS + +All except file://. Note that some protocols do not work well over proxy. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Since 7.14.1 the proxy environment variable names can include the protocol +scheme. + +Since 7.21.7 the proxy string supports the socks protocols as "schemes". + +Since 7.50.2, unsupported schemes in proxy strings cause libcurl to return +error. + +# RETURN VALUE + +Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXYAUTH.3 b/docs/libcurl/opts/CURLOPT_PROXYAUTH.3 deleted file mode 100644 index db48dd1fb..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYAUTH.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYAUTH 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYAUTH \- HTTP proxy authentication methods -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYAUTH, long bitmask); -.fi -.SH DESCRIPTION -Pass a long as parameter, which is set to a bitmask, to tell libcurl which -HTTP authentication method(s) you want it to use for your proxy -authentication. If more than one bit is set, libcurl first queries the site to -see what authentication methods it supports and then it picks the best one you -allow it to use. For some methods, this induces an extra network round-trip. -Set the actual name and password with the \fICURLOPT_PROXYUSERPWD(3)\fP -option. - -The bitmask can be constructed by the bits listed and described in the -\fICURLOPT_HTTPAUTH(3)\fP man page. -.SH DEFAULT -CURLAUTH_BASIC -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* use this proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080"); - /* allow whatever auth the proxy speaks */ - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); - /* set the proxy credentials */ - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007"); - ret = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.7 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_NOT_BUILT_IN if the bitmask specified no supported authentication -methods. -.SH "SEE ALSO" -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYPORT (3), -.BR CURLOPT_PROXYTYPE (3), -.BR CURLOPT_PROXYUSERPWD (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYAUTH.md b/docs/libcurl/opts/CURLOPT_PROXYAUTH.md new file mode 100644 index 000000000..8e6dc093b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYAUTH.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYAUTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PROXY (3) + - CURLOPT_PROXYPORT (3) + - CURLOPT_PROXYTYPE (3) + - CURLOPT_PROXYUSERPWD (3) +--- + +# NAME + +CURLOPT_PROXYAUTH - HTTP proxy authentication methods + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYAUTH, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long as parameter, which is set to a bitmask, to tell libcurl which +HTTP authentication method(s) you want it to use for your proxy +authentication. If more than one bit is set, libcurl first queries the site to +see what authentication methods it supports and then it picks the best one you +allow it to use. For some methods, this induces an extra network round-trip. +Set the actual name and password with the CURLOPT_PROXYUSERPWD(3) +option. + +The bitmask can be constructed by the bits listed and described in the +CURLOPT_HTTPAUTH(3) man page. + +# DEFAULT + +CURLAUTH_BASIC + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* use this proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080"); + /* allow whatever auth the proxy speaks */ + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + /* set the proxy credentials */ + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007"); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.7 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_NOT_BUILT_IN if the bitmask specified no supported authentication +methods. diff --git a/docs/libcurl/opts/CURLOPT_PROXYHEADER.3 b/docs/libcurl/opts/CURLOPT_PROXYHEADER.3 deleted file mode 100644 index 1bc17e9e8..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYHEADER.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYHEADER 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYHEADER \- set of HTTP headers to pass to proxy -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYHEADER, - struct curl_slist *headers); -.SH DESCRIPTION -Pass a pointer to a linked list of HTTP headers to pass in your HTTP request -sent to a proxy. The rules for this list is identical to the -\fICURLOPT_HTTPHEADER(3)\fP option's. - -The headers set with this option is only ever used in requests sent to a proxy -- when there is also a request sent to a host. - -The first line in a request (containing the method, usually a GET or POST) is -NOT a header and cannot be replaced using this option. Only the lines -following the request-line are headers. Adding this method line in this list -of headers causes your request to send an invalid header. - -Pass a NULL to this to reset back to no custom headers. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - - struct curl_slist *list; - - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80"); - - list = curl_slist_append(NULL, "Shoesize: 10"); - list = curl_slist_append(list, "Accept:"); - - curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list); - - curl_easy_perform(curl); - - curl_slist_free_all(list); /* free the list again */ - } -} -.fi -.SH AVAILABILITY -Added in 7.37.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HEADEROPT (3), -.BR CURLOPT_HTTPHEADER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYHEADER.md b/docs/libcurl/opts/CURLOPT_PROXYHEADER.md new file mode 100644 index 000000000..e44afdd18 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYHEADER.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYHEADER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADEROPT (3) + - CURLOPT_HTTPHEADER (3) +--- + +# NAME + +CURLOPT_PROXYHEADER - set of HTTP headers to pass to proxy + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYHEADER, + struct curl_slist *headers); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of HTTP headers to pass in your HTTP request +sent to a proxy. The rules for this list is identical to the +CURLOPT_HTTPHEADER(3) option's. + +The headers set with this option is only ever used in requests sent to a proxy +- when there is also a request sent to a host. + +The first line in a request (containing the method, usually a GET or POST) is +NOT a header and cannot be replaced using this option. Only the lines +following the request-line are headers. Adding this method line in this list +of headers causes your request to send an invalid header. + +Pass a NULL to this to reset back to no custom headers. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + + struct curl_slist *list; + + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com:80"); + + list = curl_slist_append(NULL, "Shoesize: 10"); + list = curl_slist_append(list, "Accept:"); + + curl_easy_setopt(curl, CURLOPT_PROXYHEADER, list); + + curl_easy_perform(curl); + + curl_slist_free_all(list); /* free the list again */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.37.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.3 b/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.3 deleted file mode 100644 index 921caf329..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYPASSWORD 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYPASSWORD \- password to use with proxy authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYPASSWORD, char *pwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -password to use for authentication with the proxy. - -The \fICURLOPT_PROXYPASSWORD(3)\fP option should be used in conjunction with -the \fICURLOPT_PROXYUSERNAME(3)\fP option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); - curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith"); - curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_PROXYAUTH (3), -.BR CURLOPT_PROXYUSERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.md b/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.md new file mode 100644 index 000000000..22520ea11 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYPASSWORD.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYPASSWORD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PASSWORD (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_PROXYUSERNAME (3) +--- + +# NAME + +CURLOPT_PROXYPASSWORD - password to use with proxy authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYPASSWORD, char *pwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the null-terminated +password to use for authentication with the proxy. + +The CURLOPT_PROXYPASSWORD(3) option should be used in conjunction with +the CURLOPT_PROXYUSERNAME(3) option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); + curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith"); + curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXYPORT.3 b/docs/libcurl/opts/CURLOPT_PROXYPORT.3 deleted file mode 100644 index 04a20a7bb..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYPORT.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYPORT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYPORT \- port number the proxy listens on -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYPORT, long port); -.fi -.SH DESCRIPTION -We discourage use of this option. - -Pass a long with this option to set the proxy port to connect to unless it is -specified in the proxy string \fICURLOPT_PROXY(3)\fP or uses 443 for https -proxies and 1080 for all others as default. - -While this accepts a 'long', the port number is 16 bit so it cannot be larger -than 65535. -.SH DEFAULT -0, not specified which makes it use the default port -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "localhost"); - curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLINFO_PRIMARY_PORT (3), -.BR CURLOPT_PORT (3), -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYPORT.md b/docs/libcurl/opts/CURLOPT_PROXYPORT.md new file mode 100644 index 000000000..0cda8bb8f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYPORT.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYPORT +Section: 3 +Source: libcurl +See-also: + - CURLINFO_PRIMARY_PORT (3) + - CURLOPT_PORT (3) + - CURLOPT_PROXY (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_PROXYPORT - port number the proxy listens on + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYPORT, long port); +~~~ + +# DESCRIPTION + +We discourage use of this option. + +Pass a long with this option to set the proxy port to connect to unless it is +specified in the proxy string CURLOPT_PROXY(3) or uses 443 for https +proxies and 1080 for all others as default. + +While this accepts a 'long', the port number is 16 bit so it cannot be larger +than 65535. + +# DEFAULT + +0, not specified which makes it use the default port + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PROXY, "localhost"); + curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_PROXYTYPE.3 b/docs/libcurl/opts/CURLOPT_PROXYTYPE.3 deleted file mode 100644 index 91f3b5a9a..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYTYPE.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYTYPE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYTYPE \- proxy protocol type -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYTYPE, long type); -.fi -.SH DESCRIPTION -Pass one of the values below to set the type of the proxy. - -.RS -.IP CURLPROXY_HTTP -HTTP Proxy. Default. -.IP CURLPROXY_HTTPS -HTTPS Proxy using HTTP/1. (Added in 7.52.0 for OpenSSL and GnuTLS. Since -7.87.0, it also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport -and wolfSSL.) -.IP CURLPROXY_HTTPS2 -HTTPS Proxy and attempt to speak HTTP/2 over it. (Added in 8.1.0) -.IP CURLPROXY_HTTP_1_0 -HTTP 1.0 Proxy. This is similar to CURLPROXY_HTTP except it uses HTTP/1.0 for -any CONNECT tunneling. It does not change the HTTP version of the actual HTTP -requests, controlled by \fICURLOPT_HTTP_VERSION(3)\fP. -.IP CURLPROXY_SOCKS4 -SOCKS4 Proxy. -.IP CURLPROXY_SOCKS4A -SOCKS4a Proxy. Proxy resolves URL hostname. -.IP CURLPROXY_SOCKS5 -SOCKS5 Proxy. -.IP CURLPROXY_SOCKS5_HOSTNAME -SOCKS5 Proxy. Proxy resolves URL hostname. -.RE - -Often it is more convenient to specify the proxy type with the scheme part of -the \fICURLOPT_PROXY(3)\fP string. -.SH DEFAULT -CURLPROXY_HTTP -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "local.example.com:1080"); - /* set the proxy type */ - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); - ret = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYTYPE.md b/docs/libcurl/opts/CURLOPT_PROXYTYPE.md new file mode 100644 index 000000000..4f06fe550 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYTYPE.md @@ -0,0 +1,99 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYTYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYPORT (3) +--- + +# NAME + +CURLOPT_PROXYTYPE - proxy protocol type + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYTYPE, long type); +~~~ + +# DESCRIPTION + +Pass one of the values below to set the type of the proxy. + +## CURLPROXY_HTTP + +HTTP Proxy. Default. + +## CURLPROXY_HTTPS + +HTTPS Proxy using HTTP/1. (Added in 7.52.0 for OpenSSL and GnuTLS. Since +7.87.0, it also works for BearSSL, mbedTLS, rustls, Schannel, Secure Transport +and wolfSSL.) + +## CURLPROXY_HTTPS2 + +HTTPS Proxy and attempt to speak HTTP/2 over it. (Added in 8.1.0) + +## CURLPROXY_HTTP_1_0 + +HTTP 1.0 Proxy. This is similar to CURLPROXY_HTTP except it uses HTTP/1.0 for +any CONNECT tunneling. It does not change the HTTP version of the actual HTTP +requests, controlled by CURLOPT_HTTP_VERSION(3). + +## CURLPROXY_SOCKS4 + +SOCKS4 Proxy. + +## CURLPROXY_SOCKS4A + +SOCKS4a Proxy. Proxy resolves URL hostname. + +## CURLPROXY_SOCKS5 + +SOCKS5 Proxy. + +## CURLPROXY_SOCKS5_HOSTNAME + +SOCKS5 Proxy. Proxy resolves URL hostname. + +Often it is more convenient to specify the proxy type with the scheme part of +the CURLOPT_PROXY(3) string. + +# DEFAULT + +CURLPROXY_HTTP + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PROXY, "local.example.com:1080"); + /* set the proxy type */ + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + ret = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.3 b/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.3 deleted file mode 100644 index 7a0e54ee2..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYUSERNAME 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYUSERNAME \- user name to use for proxy authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYUSERNAME, - char *username); -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -user name to use for the transfer. - -\fICURLOPT_PROXYUSERNAME(3)\fP sets the user name to be used in protocol -authentication with the proxy. - -To specify the proxy password use the \fICURLOPT_PROXYPASSWORD(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); - curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith"); - curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXYPASSWORD (3), -.BR CURLOPT_USERNAME (3), -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PROXYAUTH (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.md b/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.md new file mode 100644 index 000000000..f0d1dfc4d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYUSERNAME.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYUSERNAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_PROXYPASSWORD (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_PROXYUSERNAME - user name to use for proxy authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYUSERNAME, + char *username); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the +null-terminated user name to use for the transfer. + +CURLOPT_PROXYUSERNAME(3) sets the user name to be used in protocol +authentication with the proxy. + +To specify the proxy password use the CURLOPT_PROXYPASSWORD(3). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); + curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "mrsmith"); + curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD, "qwerty"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.3 b/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.3 deleted file mode 100644 index e6bdcf956..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXYUSERPWD 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXYUSERPWD \- user name and password to use for proxy authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYUSERPWD, char *userpwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be [user name]:[password] to use for -the connection to the HTTP proxy. Both the name and the password are URL -decoded before used, so to include for example a colon in the user name you -should encode it as %3A. (This is different to how \fICURLOPT_USERPWD(3)\fP is -used - beware.) - -Use \fICURLOPT_PROXYAUTH(3)\fP to specify the authentication method. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -This is NULL by default. -.SH PROTOCOLS -Used with all protocols that can use a proxy -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "clark%20kent:superman"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYPASSWORD (3), -.BR CURLOPT_PROXYTYPE (3), -.BR CURLOPT_PROXYUSERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.md b/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.md new file mode 100644 index 000000000..196d587e2 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXYUSERPWD.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXYUSERPWD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYPASSWORD (3) + - CURLOPT_PROXYTYPE (3) + - CURLOPT_PROXYUSERNAME (3) +--- + +# NAME + +CURLOPT_PROXYUSERPWD - user name and password to use for proxy authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYUSERPWD, char *userpwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be [user name]:[password] to +use for the connection to the HTTP proxy. Both the name and the password are +URL decoded before used, so to include for example a colon in the user name +you should encode it as %3A. (This is different to how CURLOPT_USERPWD(3) is +used - beware.) + +Use CURLOPT_PROXYAUTH(3) to specify the authentication method. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +This is NULL by default. + +# PROTOCOLS + +Used with all protocols that can use a proxy + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:8080"); + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "clark%20kent:superman"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK if proxies are supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.3 b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.3 deleted file mode 100644 index 4b64353e6..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_CAINFO 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_CAINFO \- path to proxy Certificate Authority (CA) bundle -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAINFO, char *path); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a char * to a null-terminated string naming a file holding one or more -certificates to verify the HTTPS proxy with. - -If \fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP is zero and you avoid verifying the -server's certificate, \fICURLOPT_PROXY_CAINFO(3)\fP need not even indicate an -accessible file. - -This option is by default set to the system path where libcurl's CA -certificate bundle is assumed to be stored, as established at build time. - -(iOS and macOS only) If curl is built against Secure Transport, then this -option is supported for backward compatibility with other SSL engines, but it -should not be set. If the option is not set, then curl uses the certificates -in the system and user Keychain to verify the peer, which is the preferred -method of verifying the peer's certificate chain. - -The application does not have to keep the string around after setting this -option. - -The default value for this can be figured out with \fICURLINFO_CAINFO(3)\fP. -.SH DEFAULT -Built-in system specific -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); - curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO, "/etc/certs/cabundle.pem"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -For TLS backends that do not support certificate files, the -\fICURLOPT_PROXY_CAINFO(3)\fP option is ignored. Refer to -https://curl.se/docs/ssl-compared.html -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAINFO_BLOB (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_PROXY_CAINFO_BLOB (3), -.BR CURLOPT_PROXY_CAPATH (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md new file mode 100644 index 000000000..473083f35 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md @@ -0,0 +1,93 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_CAINFO +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAINFO_BLOB (3) + - CURLOPT_CAPATH (3) + - CURLOPT_PROXY_CAINFO_BLOB (3) + - CURLOPT_PROXY_CAPATH (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_CAINFO - path to proxy Certificate Authority (CA) bundle + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAINFO, char *path); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a char pointer to a null-terminated string naming a file holding one or +more certificates to verify the HTTPS proxy with. + +If CURLOPT_PROXY_SSL_VERIFYPEER(3) is zero and you avoid verifying the +server's certificate, CURLOPT_PROXY_CAINFO(3) need not even indicate an +accessible file. + +This option is by default set to the system path where libcurl's CA +certificate bundle is assumed to be stored, as established at build time. + +(iOS and macOS only) If curl is built against Secure Transport, then this +option is supported for backward compatibility with other SSL engines, but it +should not be set. If the option is not set, then curl uses the certificates +in the system and user Keychain to verify the peer, which is the preferred +method of verifying the peer's certificate chain. + +The application does not have to keep the string around after setting this +option. + +The default value for this can be figured out with CURLINFO_CAINFO(3). + +# DEFAULT + +Built-in system specific + +# PROTOCOLS + +Used with HTTPS proxy + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* using an HTTPS proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO, "/etc/certs/cabundle.pem"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +For TLS backends that do not support certificate files, the +CURLOPT_PROXY_CAINFO(3) option is ignored. Refer to +https://curl.se/docs/ssl-compared.html + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.3 b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.3 deleted file mode 100644 index 80c03f354..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_CAINFO_BLOB 3 "31 March 2021" libcurl libcurl -.SH NAME -CURLOPT_PROXY_CAINFO_BLOB \- proxy Certificate Authority (CA) bundle in PEM format -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAINFO_BLOB, - struct curl_blob *stblob); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a pointer to a curl_blob structure, which contains information (pointer -and size) about a memory block with binary data of PEM encoded content holding -one or more certificates to verify the HTTPS proxy with. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -If \fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP is zero and you avoid verifying the -server's certificate, \fICURLOPT_PROXY_CAINFO_BLOB(3)\fP is not needed. - -This option overrides \fICURLOPT_PROXY_CAINFO(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf -#include /* for strlen */ - -extern char *strpem; /* strpem must point to a PEM string */ -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); - blob.data = strpem; - blob.len = strlen(strpem); - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO_BLOB, &blob); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.77.0. - -This option is supported by the rustls (since 7.82.0), OpenSSL, Secure -Transport and Schannel backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_CAINFO_BLOB (3), -.BR CURLOPT_CAPATH (3), -.BR CURLOPT_PROXY_CAINFO (3), -.BR CURLOPT_PROXY_CAPATH (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md new file mode 100644 index 000000000..bbf30cba3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md @@ -0,0 +1,92 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_CAINFO_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_CAINFO_BLOB (3) + - CURLOPT_CAPATH (3) + - CURLOPT_PROXY_CAINFO (3) + - CURLOPT_PROXY_CAPATH (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_CAINFO_BLOB - proxy Certificate Authority (CA) bundle in PEM format + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAINFO_BLOB, + struct curl_blob *stblob); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a pointer to a curl_blob structure, which contains information (pointer +and size) about a memory block with binary data of PEM encoded content holding +one or more certificates to verify the HTTPS proxy with. + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +If CURLOPT_PROXY_SSL_VERIFYPEER(3) is zero and you avoid verifying the +server's certificate, CURLOPT_PROXY_CAINFO_BLOB(3) is not needed. + +This option overrides CURLOPT_PROXY_CAINFO(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +Used with HTTPS proxy + +# EXAMPLE + +~~~c +#include /* for strlen */ + +extern char *strpem; /* strpem must point to a PEM string */ +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* using an HTTPS proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + blob.data = strpem; + blob.len = strlen(strpem); + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO_BLOB, &blob); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.77.0. + +This option is supported by the rustls (since 7.82.0), OpenSSL, Secure +Transport and Schannel backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.3 b/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.3 deleted file mode 100644 index fd55b0918..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_CAPATH 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_CAPATH \- directory holding HTTPS proxy CA certificates -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAPATH, char *capath); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a directory holding multiple -CA certificates to verify the HTTPS proxy with. If libcurl is built against -OpenSSL, the certificate directory must be prepared using the OpenSSL -\fBc_rehash\fP utility. This makes sense only when -\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP is enabled (which it is by default). - -The application does not have to keep the string around after setting this -option. - -The default value for this can be figured out with \fICURLINFO_CAPATH(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -Everything used over an HTTPS proxy -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); - curl_easy_setopt(curl, CURLOPT_PROXY_CAPATH, "/etc/cert-dir"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -This option is supported by the OpenSSL, GnuTLS, and mbedTLS (since 7.56.0) -backends. -.SH RETURN VALUE -CURLE_OK if supported; or an error such as: - -CURLE_NOT_BUILT_IN - Not supported by the SSL backend - -CURLE_UNKNOWN_OPTION - -CURLE_OUT_OF_MEMORY -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_PROXY_CAINFO (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md b/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md new file mode 100644 index 000000000..2253c9f26 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_CAPATH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_PROXY_CAINFO (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_PROXY_CAPATH - directory holding HTTPS proxy CA certificates + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CAPATH, char *capath); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a directory holding +multiple CA certificates to verify the HTTPS proxy with. If libcurl is built +against OpenSSL, the certificate directory must be prepared using the OpenSSL +**c_rehash** utility. This makes sense only when +CURLOPT_PROXY_SSL_VERIFYPEER(3) is enabled (which it is by default). + +The application does not have to keep the string around after setting this +option. + +The default value for this can be figured out with CURLINFO_CAPATH(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +Everything used over an HTTPS proxy + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* using an HTTPS proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY_CAPATH, "/etc/cert-dir"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +This option is supported by the OpenSSL, GnuTLS, and mbedTLS (since 7.56.0) +backends. + +# RETURN VALUE + +CURLE_OK if supported; or an error such as: + +CURLE_NOT_BUILT_IN - Not supported by the SSL backend + +CURLE_UNKNOWN_OPTION + +CURLE_OUT_OF_MEMORY diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.3 b/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.3 deleted file mode 100644 index 80891666a..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_CRLFILE 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_CRLFILE \- HTTPS proxy Certificate Revocation List file -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CRLFILE, char *file); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a char * to a null-terminated string naming a \fIfile\fP with the -concatenation of CRL (in PEM format) to use in the certificate validation that -occurs during the SSL exchange. - -When curl is built to use GnuTLS, there is no way to influence the use of CRL -passed to help in the verification process. When libcurl is built with OpenSSL -support, X509_V_FLAG_CRL_CHECK and X509_V_FLAG_CRL_CHECK_ALL are both set, -requiring CRL check against all the elements of the certificate chain if a CRL -file is passed. - -This option makes sense only when used in combination with the -\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP option. - -A specific error code (\fICURLE_SSL_CRL_BADFILE\fP) is defined with the -option. It is returned when the SSL exchange fails because the CRL file cannot -be loaded. A failure in certificate verification due to a revocation -information found in the CRL does not trigger this specific error. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -Used with HTTPS proxy. -.SH EXAMPLE -.nf -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, "https://localhost:80"); - curl_easy_setopt(curl, CURLOPT_PROXY_CRLFILE, "/etc/certs/crl.pem"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.md b/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.md new file mode 100644 index 000000000..d12c29800 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_CRLFILE.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_CRLFILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_CRLFILE - HTTPS proxy Certificate Revocation List file + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_CRLFILE, char *file); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a char pointer to a null-terminated string naming a *file* with the +concatenation of CRL (in PEM format) to use in the certificate validation that +occurs during the SSL exchange. + +When curl is built to use GnuTLS, there is no way to influence the use of CRL +passed to help in the verification process. When libcurl is built with OpenSSL +support, X509_V_FLAG_CRL_CHECK and X509_V_FLAG_CRL_CHECK_ALL are both set, +requiring CRL check against all the elements of the certificate chain if a CRL +file is passed. + +This option makes sense only when used in combination with the +CURLOPT_PROXY_SSL_VERIFYPEER(3) option. + +A specific error code (*CURLE_SSL_CRL_BADFILE*) is defined with the option. It +is returned when the SSL exchange fails because the CRL file cannot be loaded. +A failure in certificate verification due to a revocation information found in +the CRL does not trigger this specific error. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +Used with HTTPS proxy. + +# 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, "https://localhost:80"); + curl_easy_setopt(curl, CURLOPT_PROXY_CRLFILE, "/etc/certs/crl.pem"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.3 b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.3 deleted file mode 100644 index 5ddbc712c..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_ISSUERCERT 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_PROXY_ISSUERCERT \- proxy issuer SSL certificate filename -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_ISSUERCERT, char *file); -.fi -.SH DESCRIPTION -Pass a char * to a null-terminated string naming a \fIfile\fP holding a CA -certificate in PEM format. If the option is set, an additional check against -the peer certificate is performed to verify the issuer of the the HTTPS proxy -is indeed the one associated with the certificate provided by the option. -This additional check is useful in multi-level PKI where one needs to enforce -that the peer certificate is from a specific branch of the tree. - -This option makes sense only when used in combination with the -\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP option. Otherwise, the result of the -check is not considered as failure. - -A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, -which is returned if the setup of the SSL/TLS session has failed due to a -mismatch with the issuer of peer certificate -(\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP has to be set too for the check to -fail). - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); - curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT, "/etc/certs/cacert.pem"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_ISSUERCERT (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md new file mode 100644 index 000000000..3b289d2d4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_ISSUERCERT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ISSUERCERT (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_ISSUERCERT - proxy issuer SSL certificate filename + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_ISSUERCERT, char *file); +~~~ + +# DESCRIPTION + +Pass a char pointer to a null-terminated string naming a *file* holding a CA +certificate in PEM format. If the option is set, an additional check against +the peer certificate is performed to verify the issuer of the HTTPS proxy is +indeed the one associated with the certificate provided by the option. This +additional check is useful in multi-level PKI where one needs to enforce that +the peer certificate is from a specific branch of the tree. + +This option makes sense only when used in combination with the +CURLOPT_PROXY_SSL_VERIFYPEER(3) option. Otherwise, the result of the +check is not considered as failure. + +A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, +which is returned if the setup of the SSL/TLS session has failed due to a +mismatch with the issuer of peer certificate +(CURLOPT_PROXY_SSL_VERIFYPEER(3) has to be set too for the check to +fail). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based protocols + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* using an HTTPS proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT, "/etc/certs/cacert.pem"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.3 b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.3 deleted file mode 100644 index 4f94d2eb0..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_ISSUERCERT_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_PROXY_ISSUERCERT_BLOB \- proxy issuer SSL certificate from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_ISSUERCERT_BLOB, - struct curl_blob *blob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob struct, which contains information (pointer and -size) about a memory block with binary data of a CA certificate in PEM -format. If the option is set, an additional check against the peer certificate -is performed to verify the issuer of the the HTTPS proxy is indeed the one -associated with the certificate provided by the option. This additional check -is useful in multi-level PKI where one needs to enforce that the peer -certificate is from a specific branch of the tree. - -This option should be used in combination with the -\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP option. Otherwise, the result of the -check is not considered as failure. - -A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, -which is returned if the setup of the SSL/TLS session has failed due to a -mismatch with the issuer of peer certificate -(\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP has to be set too for the check to -fail). - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -This option is an alternative to \fICURLOPT_PROXY_ISSUERCERT(3)\fP which -instead expects a file name as input. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf - -extern char *certificateData; /* point to the data */ -size_t filesize; /* size of the data */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); - blob.data = certificateData; - blob.len = filesize; - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT_BLOB, &blob); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL backends. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_ISSUERCERT_BLOB (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md new file mode 100644 index 000000000..ddd8cf5b4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md @@ -0,0 +1,95 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_ISSUERCERT_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ISSUERCERT_BLOB (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_ISSUERCERT_BLOB - proxy issuer SSL certificate from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_ISSUERCERT_BLOB, + struct curl_blob *blob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob struct, which contains information (pointer and +size) about a memory block with binary data of a CA certificate in PEM +format. If the option is set, an additional check against the peer certificate +is performed to verify the issuer of the HTTPS proxy is indeed the one +associated with the certificate provided by the option. This additional check +is useful in multi-level PKI where one needs to enforce that the peer +certificate is from a specific branch of the tree. + +This option should be used in combination with the +CURLOPT_PROXY_SSL_VERIFYPEER(3) option. Otherwise, the result of the +check is not considered as failure. + +A specific error code (CURLE_SSL_ISSUER_ERROR) is defined with the option, +which is returned if the setup of the SSL/TLS session has failed due to a +mismatch with the issuer of peer certificate +(CURLOPT_PROXY_SSL_VERIFYPEER(3) has to be set too for the check to fail). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +This option is an alternative to CURLOPT_PROXY_ISSUERCERT(3) which +instead expects a filename as input. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based protocols + +# EXAMPLE + +~~~c + +extern char *certificateData; /* point to the data */ +size_t filesize; /* size of the data */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* using an HTTPS proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + blob.data = certificateData; + blob.len = filesize; + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT_BLOB, &blob); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL backends. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.3 b/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.3 deleted file mode 100644 index 8d0ba91a0..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_KEYPASSWD 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_KEYPASSWD \- passphrase for the proxy private key -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_KEYPASSWD, char *pwd); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a pointer to a null-terminated string as parameter. It is used as the -password required to use the \fICURLOPT_PROXY_SSLKEY(3)\fP private key. You -never need a pass phrase to load a certificate but you need one to load your -private key. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "superman"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_KEYPASSWD (3), -.BR CURLOPT_PROXY_SSLKEY (3), -.BR CURLOPT_SSH_PRIVATE_KEYFILE (3), -.BR CURLOPT_SSLKEY (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md b/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md new file mode 100644 index 000000000..b29d95f07 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_KEYPASSWD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_KEYPASSWD (3) + - CURLOPT_PROXY_SSLKEY (3) + - CURLOPT_SSH_PRIVATE_KEYFILE (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_PROXY_KEYPASSWD - passphrase for the proxy private key + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_KEYPASSWD, char *pwd); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a pointer to a null-terminated string as parameter. It is used as the +password required to use the CURLOPT_PROXY_SSLKEY(3) private key. You +never need a pass phrase to load a certificate but you need one to load your +private key. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +Used with HTTPS proxy + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "superman"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.3 b/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.3 deleted file mode 100644 index 9a9ce119c..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_PINNEDPUBLICKEY 3 "24 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_PINNEDPUBLICKEY \- pinned public key for https proxy -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY, char *pinnedpubkey); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string can be the -file name of your pinned public key. The file format expected is "PEM" or "DER". -The string can also be any number of base64 encoded sha256 hashes preceded by -"sha256//" and separated by ";" - -When negotiating a TLS or SSL connection, the https proxy sends a certificate -indicating its identity. A public key is extracted from this certificate and -if it does not exactly match the public key provided to this option, libcurl -aborts the connection before sending or receiving any data. - -On mismatch, \fICURLE_SSL_PINNEDPUBKEYNOTMATCH\fP is returned. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); - curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY, - "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA" - "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74" - "Gxa2eg7fRbEgoChTociMee9wno="); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH PUBLIC KEY EXTRACTION -If you do not have the https proxy server's public key file you can extract it -from the https proxy server's certificate. -.nf -# retrieve the server's certificate if you do not already have it -# -# be sure to examine the certificate to see if it is what you expected -# -# Windows-specific: -# - Use NUL instead of /dev/null. -# - OpenSSL may wait for input instead of disconnecting. Hit enter. -# - If you do not have sed, then just copy the certificate into a file: -# Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----. -# -openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem - -# extract public key in pem format from certificate -openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem - -# convert public key from pem to der -openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem -out www.example.com.pubkey.der - -# sha256 hash and base64 encode der to string for use -openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64 -.fi -The public key in PEM format contains a header, base64 data and a -footer: -.nf ------BEGIN PUBLIC KEY----- -[BASE 64 DATA] ------END PUBLIC KEY----- -.fi -.SH AVAILABILITY -PEM/DER support: - - 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL - -sha256 support: - - 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL - -Other SSL backends not supported. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PINNEDPUBLICKEY (3), -.BR CURLOPT_PROXY_CAINFO (3), -.BR CURLOPT_PROXY_CAPATH (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3) - diff --git a/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md b/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md new file mode 100644 index 000000000..4db13652d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md @@ -0,0 +1,124 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_PINNEDPUBLICKEY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PINNEDPUBLICKEY (3) + - CURLOPT_PROXY_CAINFO (3) + - CURLOPT_PROXY_CAPATH (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_PINNEDPUBLICKEY - pinned public key for https proxy + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY, + char *pinnedpubkey); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string can be the +filename of your pinned public key. The file format expected is "PEM" or +"DER". The string can also be any number of base64 encoded sha256 hashes +preceded by "sha256//" and separated by ";" + +When negotiating a TLS or SSL connection, the https proxy sends a certificate +indicating its identity. A public key is extracted from this certificate and +if it does not exactly match the public key provided to this option, libcurl +aborts the connection before sending or receiving any data. + +On mismatch, *CURLE_SSL_PINNEDPUBKEYNOTMATCH* is returned. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); + curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY, + "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA" + "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74" + "Gxa2eg7fRbEgoChTociMee9wno="); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# PUBLIC KEY EXTRACTION + +If you do not have the https proxy server's public key file you can extract it +from the https proxy server's certificate. +~~~c +# retrieve the server's certificate if you do not already have it +# +# be sure to examine the certificate to see if it is what you expected +# +# Windows-specific: +# - Use NUL instead of /dev/null. +# - OpenSSL may wait for input instead of disconnecting. Hit enter. +# - If you do not have sed, then just copy the certificate into a file: +# Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----. +# +openssl s_client -servername www.example.com -connect www.example.com:443 \ + < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem + +# extract public key in pem format from certificate +openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem + +# convert public key from pem to der +openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem \ + -out www.example.com.pubkey.der + +# sha256 hash and base64 encode der to string for use +openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64 +~~~ +The public key in PEM format contains a header, base64 data and a +footer: +~~~c +-----BEGIN PUBLIC KEY----- +[BASE 64 DATA] +-----END PUBLIC KEY----- +~~~ + +# AVAILABILITY + +PEM/DER support: + + 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL + +sha256 support: + + 7.52.0: GnuTLS, OpenSSL, mbedTLS, wolfSSL + +Other SSL backends not supported. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.3 b/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.3 deleted file mode 100644 index 712836f60..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SERVICE_NAME 3 "17 Jun 2015" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SERVICE_NAME \- proxy authentication service name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SERVICE_NAME, - char *name); -.fi -.SH DESCRIPTION -Pass a char * as parameter to a string holding the \fIname\fP of the -service. The default service name is \fB"HTTP"\fP for HTTP based proxies and -\fB"rcmd"\fP for SOCKS5. This option allows you to change it. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -See above -.SH PROTOCOLS -All network protocols -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY_SERVICE_NAME, "custom"); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.43.0 for HTTP proxies, 7.49.0 for SOCKS5 proxies. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYTYPE (3), -.BR CURLOPT_SERVICE_NAME (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.md b/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.md new file mode 100644 index 000000000..73e5cb72a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SERVICE_NAME.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SERVICE_NAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYTYPE (3) + - CURLOPT_SERVICE_NAME (3) +--- + +# NAME + +CURLOPT_PROXY_SERVICE_NAME - proxy authentication service name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SERVICE_NAME, + char *name); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter to a string holding the *name* of the +service. The default service name is **"HTTP"** for HTTP based proxies and +**"rcmd"** for SOCKS5. This option allows you to change it. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +See above + +# PROTOCOLS + +All network protocols + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PROXY_SERVICE_NAME, "custom"); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.43.0 for HTTP proxies, 7.49.0 for SOCKS5 proxies. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.3 deleted file mode 100644 index 54e6f545b..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLCERT 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLCERT \- HTTPS proxy client certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERT, char *cert); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a pointer to a null-terminated string as parameter. The string should be -the file name of your client certificate used to connect to the HTTPS proxy. -The default format is "P12" on Secure Transport and "PEM" on other engines, -and can be changed with \fICURLOPT_PROXY_SSLCERTTYPE(3)\fP. - -With Secure Transport, this can also be the nickname of the certificate you -wish to authenticate with as it is named in the security database. If you want -to use a file from the current directory, please precede it with "./" prefix, -in order to avoid confusion with a nickname. - -When using a client certificate, you most likely also need to provide a -private key with \fICURLOPT_PROXY_SSLKEY(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLCERTTYPE (3), -.BR CURLOPT_PROXY_SSLKEY (3), -.BR CURLOPT_SSLCERT (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md new file mode 100644 index 000000000..debc7ea8e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md @@ -0,0 +1,79 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLCERT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLCERTTYPE (3) + - CURLOPT_PROXY_SSLKEY (3) + - CURLOPT_SSLCERT (3) +--- + +# NAME + +CURLOPT_PROXY_SSLCERT - HTTPS proxy client certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERT, char *cert); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a pointer to a null-terminated string as parameter. The string should be +the filename of your client certificate used to connect to the HTTPS proxy. +The default format is "P12" on Secure Transport and "PEM" on other engines, +and can be changed with CURLOPT_PROXY_SSLCERTTYPE(3). + +With Secure Transport, this can also be the nickname of the certificate you +wish to authenticate with as it is named in the security database. If you want +to use a file from the current directory, please precede it with "./" prefix, +in order to avoid confusion with a nickname. + +When using a client certificate, you most likely also need to provide a +private key with CURLOPT_PROXY_SSLKEY(3). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +Used with HTTPS proxy + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.3 deleted file mode 100644 index 380595c7e..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLCERTTYPE 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLCERTTYPE \- type of the proxy client SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERTTYPE, char *type); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the format of your client certificate used when connecting to an HTTPS proxy. - -Supported formats are "PEM" and "DER", except with Secure Transport or -Schannel. OpenSSL (versions 0.9.3 and later), Secure Transport (on iOS 5 or -later, or OS X 10.7 or later) and Schannel support "P12" for PKCS#12-encoded -files. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -"PEM" -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLCERT (3), -.BR CURLOPT_PROXY_SSLKEY (3), -.BR CURLOPT_SSLCERTTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md new file mode 100644 index 000000000..ce6c50887 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLCERTTYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLCERT (3) + - CURLOPT_PROXY_SSLKEY (3) + - CURLOPT_SSLCERTTYPE (3) +--- + +# NAME + +CURLOPT_PROXY_SSLCERTTYPE - type of the proxy client SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERTTYPE, char *type); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the format of your client certificate used when connecting to an HTTPS proxy. + +Supported formats are "PEM" and "DER", except with Secure Transport or +Schannel. OpenSSL (versions 0.9.3 and later), Secure Transport (on iOS 5 or +later, or OS X 10.7 or later) and Schannel support "P12" for PKCS#12-encoded +files. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +"PEM" + +# PROTOCOLS + +All + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.3 deleted file mode 100644 index a033193d1..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLCERT_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLCERT_BLOB \- SSL proxy client certificate from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERT_BLOB, - struct curl_blob *blob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure, which contains information (pointer -and size) about a memory block with binary data of the certificate used to -connect to the HTTPS proxy. The format must be "P12" on Secure Transport or -Schannel. The format must be "P12" or "PEM" on OpenSSL. The string "P12" or -"PEM" must be specified with \fICURLOPT_PROXY_SSLCERTTYPE(3)\fP. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -This option is an alternative to \fICURLOPT_PROXY_SSLCERT(3)\fP which instead -expects a file name as input. -.SH DEFAULT -NULL -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf - -extern char *certificateData; /* point to data */ -extern size_t filesize; /* size of the data */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - blob.data = certificateData; - blob.len = filesize; - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL, Secure Transport and -Schannel backends. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLCERT (3), -.BR CURLOPT_PROXY_SSLCERTTYPE (3), -.BR CURLOPT_PROXY_SSLKEY (3), -.BR CURLOPT_SSLCERT_BLOB (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md new file mode 100644 index 000000000..e880d38e0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md @@ -0,0 +1,85 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLCERT_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLCERT (3) + - CURLOPT_PROXY_SSLCERTTYPE (3) + - CURLOPT_PROXY_SSLKEY (3) + - CURLOPT_SSLCERT_BLOB (3) +--- + +# NAME + +CURLOPT_PROXY_SSLCERT_BLOB - SSL proxy client certificate from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLCERT_BLOB, + struct curl_blob *blob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure, which contains information (pointer +and size) about a memory block with binary data of the certificate used to +connect to the HTTPS proxy. The format must be "P12" on Secure Transport or +Schannel. The format must be "P12" or "PEM" on OpenSSL. The string "P12" or +"PEM" must be specified with CURLOPT_PROXY_SSLCERTTYPE(3). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +This option is an alternative to CURLOPT_PROXY_SSLCERT(3) which instead +expects a filename as input. + +# DEFAULT + +NULL + +# PROTOCOLS + +Used with HTTPS proxy + +# EXAMPLE + +~~~c + +extern char *certificateData; /* point to data */ +extern size_t filesize; /* size of the data */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + blob.data = certificateData; + blob.len = filesize; + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL, Secure Transport and +Schannel backends. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.3 deleted file mode 100644 index 82a5bf9c2..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLKEY 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLKEY \- private key file for HTTPS proxy client cert -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEY, char *keyfile); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the file name of your private key used for connecting to the HTTPS proxy. The -default format is "PEM" and can be changed with -\fICURLOPT_PROXY_SSLKEYTYPE(3)\fP. - -(Windows, iOS and Mac OS X) This option is ignored by Secure Transport and -Schannel SSL backends because they expect the private key to be already -present in the key chain or PKCS#12 file containing the certificate. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLCERT (3), -.BR CURLOPT_PROXY_SSLKEYTYPE (3), -.BR CURLOPT_SSLCERT (3), -.BR CURLOPT_SSLKEY (3), -.BR CURLOPT_SSLKEYTYPE (3) - diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md new file mode 100644 index 000000000..c8400db44 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLKEY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLCERT (3) + - CURLOPT_PROXY_SSLKEYTYPE (3) + - CURLOPT_SSLCERT (3) + - CURLOPT_SSLKEY (3) + - CURLOPT_SSLKEYTYPE (3) +--- + +# NAME + +CURLOPT_PROXY_SSLKEY - private key file for HTTPS proxy client cert + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEY, char *keyfile); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the filename of your private key used for connecting to the HTTPS proxy. The +default format is "PEM" and can be changed with +CURLOPT_PROXY_SSLKEYTYPE(3). + +(Windows, iOS and Mac OS X) This option is ignored by Secure Transport and +Schannel SSL backends because they expect the private key to be already +present in the key chain or PKCS#12 file containing the certificate. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.3 deleted file mode 100644 index dfa6ce6d4..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLKEYTYPE 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLKEYTYPE \- type of the proxy private key file -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEYTYPE, char *type); -.fi -.SH DESCRIPTION -This option is for connecting to an HTTPS proxy, not an HTTPS server. - -Pass a pointer to a null-terminated string as parameter. The string should be -the format of your private key. Supported formats are "PEM", "DER" and "ENG". - -The application does not have to keep the string around after setting this -option. -.SH PROTOCOLS -Used with HTTPS proxy -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEYTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLCERT (3), -.BR CURLOPT_PROXY_SSLKEY (3), -.BR CURLOPT_SSLKEYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md new file mode 100644 index 000000000..97960f437 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLKEYTYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLCERT (3) + - CURLOPT_PROXY_SSLKEY (3) + - CURLOPT_SSLKEYTYPE (3) +--- + +# NAME + +CURLOPT_PROXY_SSLKEYTYPE - type of the proxy private key file + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEYTYPE, char *type); +~~~ + +# DESCRIPTION + +This option is for connecting to an HTTPS proxy, not an HTTPS server. + +Pass a pointer to a null-terminated string as parameter. The string should be +the format of your private key. Supported formats are "PEM", "DER" and "ENG". + +The application does not have to keep the string around after setting this +option. + +# PROTOCOLS + +Used with HTTPS proxy + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEYTYPE, "PEM"); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.3 deleted file mode 100644 index 034e1fe0e..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLKEY_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLKEY_BLOB \- private key for proxy cert from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEY_BLOB, - struct curl_blob *blob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure that contains information (pointer and -size) about the private key for connecting to the HTTPS proxy. Compatible with -OpenSSL. The format (like "PEM") must be specified with -\fICURLOPT_PROXY_SSLKEYTYPE(3)\fP. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf - -extern char *certificateData; /* point to data */ -extern size_t filesize; /* size of data */ - -extern char *privateKeyData; /* point to data */ -extern size_t privateKeySize; /* size */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); - blob.data = certificateData; - blob.len = filesize; - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob); - curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM"); - - blob.data = privateKeyData; - blob.len = privateKeySize; - curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY_BLOB, &blob); - curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL backends. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLKEY (3), -.BR CURLOPT_SSLKEY_BLOB (3), -.BR CURLOPT_SSLKEYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md new file mode 100644 index 000000000..48bb2e88a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLKEY_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLKEY (3) + - CURLOPT_SSLKEYTYPE (3) + - CURLOPT_SSLKEY_BLOB (3) +--- + +# NAME + +CURLOPT_PROXY_SSLKEY_BLOB - private key for proxy cert from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLKEY_BLOB, + struct curl_blob *blob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure that contains information (pointer and +size) about the private key for connecting to the HTTPS proxy. Compatible with +OpenSSL. The format (like "PEM") must be specified with +CURLOPT_PROXY_SSLKEYTYPE(3). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c + +extern char *certificateData; /* point to data */ +extern size_t filesize; /* size of data */ + +extern char *privateKeyData; /* point to data */ +extern size_t privateKeySize; /* size */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + blob.data = certificateData; + blob.len = filesize; + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob); + curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM"); + + blob.data = privateKeyData; + blob.len = privateKeySize; + curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY_BLOB, &blob); + curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL backends. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.3 deleted file mode 100644 index 3c3fe0289..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.3 +++ /dev/null @@ -1,110 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSLVERSION 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSLVERSION \- preferred HTTPS proxy TLS version -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLVERSION, - long version); -.fi -.SH DESCRIPTION -Pass a long as parameter to control which version of SSL/TLS to attempt to use -when connecting to an HTTPS proxy. - -Use one of the available defines for this purpose. The available options are: -.RS -.IP CURL_SSLVERSION_DEFAULT -The default action. This attempts to figure out the remote SSL protocol -version. -.IP CURL_SSLVERSION_TLSv1 -TLSv1.x -.IP CURL_SSLVERSION_TLSv1_0 -TLSv1.0 -.IP CURL_SSLVERSION_TLSv1_1 -TLSv1.1 -.IP CURL_SSLVERSION_TLSv1_2 -TLSv1.2 -.IP CURL_SSLVERSION_TLSv1_3 -TLSv1.3 -.RE -The maximum TLS version can be set by using \fIone\fP of the -CURL_SSLVERSION_MAX_ macros below. It is also possible to OR \fIone\fP of the -CURL_SSLVERSION_ macros with \fIone\fP of the CURL_SSLVERSION_MAX_ macros. -The MAX macros are not supported for WolfSSL. -.RS -.IP CURL_SSLVERSION_MAX_DEFAULT -The flag defines the maximum supported TLS version as TLSv1.2, or the default -value from the SSL library. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_0 -The flag defines maximum supported TLS version as TLSv1.0. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_1 -The flag defines maximum supported TLS version as TLSv1.1. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_2 -The flag defines maximum supported TLS version as TLSv1.2. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_3 -The flag defines maximum supported TLS version as TLSv1.3. -(Added in 7.54.0) -.RE - -In versions of curl prior to 7.54 the CURL_SSLVERSION_TLS options were -documented to allow \fIonly\fP the specified TLS version, but behavior was -inconsistent depending on the TLS library. - -.SH DEFAULT -CURL_SSLVERSION_DEFAULT -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* ask libcurl to use TLS version 1.0 or later */ - curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_IPRESOLVE (3), -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.md new file mode 100644 index 000000000..6f159e87d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLVERSION.md @@ -0,0 +1,125 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSLVERSION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_IPRESOLVE (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_PROXY_SSLVERSION - preferred HTTPS proxy TLS version + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSLVERSION, + long version); +~~~ + +# DESCRIPTION + +Pass a long as parameter to control which version of SSL/TLS to attempt to use +when connecting to an HTTPS proxy. + +Use one of the available defines for this purpose. The available options are: + +## CURL_SSLVERSION_DEFAULT + +The default action. This attempts to figure out the remote SSL protocol +version. + +## CURL_SSLVERSION_TLSv1 + +TLSv1.x + +## CURL_SSLVERSION_TLSv1_0 + +TLSv1.0 + +## CURL_SSLVERSION_TLSv1_1 + +TLSv1.1 + +## CURL_SSLVERSION_TLSv1_2 + +TLSv1.2 + +## CURL_SSLVERSION_TLSv1_3 + +TLSv1.3 +The maximum TLS version can be set by using *one* of the +CURL_SSLVERSION_MAX_ macros below. It is also possible to OR *one* of the +CURL_SSLVERSION_ macros with *one* of the CURL_SSLVERSION_MAX_ macros. +The MAX macros are not supported for WolfSSL. + +## CURL_SSLVERSION_MAX_DEFAULT + +The flag defines the maximum supported TLS version as TLSv1.2, or the default +value from the SSL library. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_0 + +The flag defines maximum supported TLS version as TLSv1.0. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_1 + +The flag defines maximum supported TLS version as TLSv1.1. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_2 + +The flag defines maximum supported TLS version as TLSv1.2. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_3 + +The flag defines maximum supported TLS version as TLSv1.3. +(Added in 7.54.0) + +In versions of curl prior to 7.54 the CURL_SSLVERSION_TLS options were +documented to allow *only* the specified TLS version, but behavior was +inconsistent depending on the TLS library. + +# DEFAULT + +CURL_SSLVERSION_DEFAULT + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* ask libcurl to use TLS version 1.0 or later */ + curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.3 deleted file mode 100644 index 5677c655a..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSL_CIPHER_LIST 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSL_CIPHER_LIST \- ciphers to use for HTTPS proxy -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_CIPHER_LIST, - char *list); -.fi -.SH DESCRIPTION -Pass a char *, pointing to a null-terminated string holding the list of -ciphers to use for the connection to the HTTPS proxy. The list must be -syntactically correct, it consists of one or more cipher strings separated by -colons. Commas or spaces are also acceptable separators but colons are -normally used, \&!, \&- and \&+ can be used as operators. - -For OpenSSL and GnuTLS valid examples of cipher lists include \fBRC4-SHA\fP, -\fBSHA1+DES\fP, \fBTLSv1\fP and \fBDEFAULT\fP. The default list is normally -set when you compile OpenSSL. - -For WolfSSL, valid examples of cipher lists include \fBECDHE-RSA-RC4-SHA\fP, -\fBAES256-SHA:AES256-SHA256\fP, etc. - -For BearSSL, valid examples of cipher lists include -\fBECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256\fP, or when using IANA names -\fBTLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\fP, -etc. -With BearSSL you do not add/remove ciphers. If one uses this option then all -known ciphers are disabled and only those passed in are enabled. - -Find more details about cipher lists on this URL: - - https://curl.se/docs/ssl-ciphers.html - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, use internal default -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://localhost"); - curl_easy_setopt(curl, CURLOPT_PROXY_SSL_CIPHER_LIST, "TLSv1"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0, in 7.83.0 for BearSSL - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_PROXY_TLS13_CIPHERS (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_TLS13_CIPHERS (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md new file mode 100644 index 000000000..d7626c376 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md @@ -0,0 +1,91 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSL_CIPHER_LIST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_PROXY_TLS13_CIPHERS (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CIPHER_LIST (3) + - CURLOPT_TLS13_CIPHERS (3) +--- + +# NAME + +CURLOPT_PROXY_SSL_CIPHER_LIST - ciphers to use for HTTPS proxy + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_CIPHER_LIST, + char *list); +~~~ + +# DESCRIPTION + +Pass a char pointer, pointing to a null-terminated string holding the list of +ciphers to use for the connection to the HTTPS proxy. The list must be +syntactically correct, it consists of one or more cipher strings separated by +colons. Commas or spaces are also acceptable separators but colons are +normally used, &!, &- and &+ can be used as operators. + +For OpenSSL and GnuTLS valid examples of cipher lists include **RC4-SHA**, +**SHA1+DES**, **TLSv1** and **DEFAULT**. The default list is normally +set when you compile OpenSSL. + +For WolfSSL, valid examples of cipher lists include **ECDHE-RSA-RC4-SHA**, +**AES256-SHA:AES256-SHA256**, etc. + +For BearSSL, valid examples of cipher lists include +**ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256**, or when using IANA names +**TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256**, +etc. +With BearSSL you do not add/remove ciphers. If one uses this option then all +known ciphers are disabled and only those passed in are enabled. + +Find more details about cipher lists on this URL: + + https://curl.se/docs/ssl-ciphers.html + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, use internal default + +# PROTOCOLS + +All + +# 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, "https://localhost"); + curl_easy_setopt(curl, CURLOPT_PROXY_SSL_CIPHER_LIST, "TLSv1"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0, in 7.83.0 for BearSSL + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.3 deleted file mode 100644 index b64285afc..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.3 +++ /dev/null @@ -1,109 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSL_OPTIONS 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSL_OPTIONS \- HTTPS proxy SSL behavior options -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_OPTIONS, - long bitmask); -.fi -.SH DESCRIPTION -Pass a long with a bitmask to tell libcurl about specific SSL -behaviors. Available bits: -.IP CURLSSLOPT_ALLOW_BEAST -Tells libcurl to not attempt to use any workarounds for a security flaw in the -SSL3 and TLS1.0 protocols. If this option is not used or this bit is set to 0, -the SSL layer libcurl uses may use a work-around for this flaw although it -might cause interoperability problems with some (older) SSL implementations. -WARNING: avoiding this work-around lessens the security, and by setting this -option to 1 you ask for exactly that. This option is only supported for -Secure Transport and OpenSSL. -.IP CURLSSLOPT_NO_REVOKE -Tells libcurl to disable certificate revocation checks for those SSL backends -where such behavior is present. This option is only supported for Schannel -(the native Windows SSL library), with an exception in the case of Windows' -Untrusted Publishers block list which it seems cannot be bypassed. (Added in -7.44.0) -.IP CURLSSLOPT_NO_PARTIALCHAIN -Tells libcurl to not accept "partial" certificate chains, which it otherwise -does by default. This option is only supported for OpenSSL and fails the -certificate verification if the chain ends with an intermediate certificate -and not with a root cert. (Added in 7.68.0) -.IP CURLSSLOPT_REVOKE_BEST_EFFORT -Tells libcurl to ignore certificate revocation checks in case of missing or -offline distribution points for those SSL backends where such behavior is -present. This option is only supported for Schannel (the native Windows SSL -library). If combined with \fICURLSSLOPT_NO_REVOKE\fP, the latter takes -precedence. (Added in 7.70.0) -.IP CURLSSLOPT_NATIVE_CA -Tell libcurl to use the operating system's native CA store for certificate -verification. If you set this option and also set a CA certificate file or -directory then during verification those certificates are searched in addition -to the native CA store. - -Works with wolfSSL on Windows, Linux (Debian, Ubuntu, Gentoo, Fedora, RHEL), -macOS, Android and iOS (added in 8.3.0), with GnuTLS (added in 8.5.0) or on -Windows when built to use OpenSSL (Added in 7.71.0). -.IP CURLSSLOPT_AUTO_CLIENT_CERT -Tell libcurl to automatically locate and use a client certificate for -authentication, when requested by the server. This option is only supported -for Schannel (the native Windows SSL library). Prior to 7.77.0 this was the -default behavior in libcurl with Schannel. Since the server can request any -certificate that supports client authentication in the OS certificate store it -could be a privacy violation and unexpected. -(Added in 7.77.0) -.SH DEFAULT -0 -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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, "https://proxy"); - /* weaken TLS only for use with silly proxies */ - curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST | - CURLSSLOPT_NO_REVOKE); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_CIPHER_LIST (3), -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md new file mode 100644 index 000000000..30d6935a1 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md @@ -0,0 +1,119 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSL_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_PROXY_SSL_CIPHER_LIST (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CIPHER_LIST (3) +--- + +# NAME + +CURLOPT_PROXY_SSL_OPTIONS - HTTPS proxy SSL behavior options + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_OPTIONS, + long bitmask); +~~~ + +# DESCRIPTION + +Pass a long with a bitmask to tell libcurl about specific SSL +behaviors. Available bits: + +## CURLSSLOPT_ALLOW_BEAST + +Tells libcurl to not attempt to use any workarounds for a security flaw in the +SSL3 and TLS1.0 protocols. If this option is not used or this bit is set to 0, +the SSL layer libcurl uses may use a work-around for this flaw although it +might cause interoperability problems with some (older) SSL implementations. +WARNING: avoiding this work-around lessens the security, and by setting this +option to 1 you ask for exactly that. This option is only supported for Secure +Transport and OpenSSL. + +## CURLSSLOPT_NO_REVOKE + +Tells libcurl to disable certificate revocation checks for those SSL backends +where such behavior is present. This option is only supported for Schannel +(the native Windows SSL library), with an exception in the case of Windows' +Untrusted Publishers block list which it seems cannot be bypassed. (Added in +7.44.0) + +## CURLSSLOPT_NO_PARTIALCHAIN + +Tells libcurl to not accept "partial" certificate chains, which it otherwise +does by default. This option is only supported for OpenSSL and fails the +certificate verification if the chain ends with an intermediate certificate +and not with a root cert. (Added in 7.68.0) + +## CURLSSLOPT_REVOKE_BEST_EFFORT + +Tells libcurl to ignore certificate revocation checks in case of missing or +offline distribution points for those SSL backends where such behavior is +present. This option is only supported for Schannel (the native Windows SSL +library). If combined with *CURLSSLOPT_NO_REVOKE*, the latter takes +precedence. (Added in 7.70.0) + +## CURLSSLOPT_NATIVE_CA + +Tell libcurl to use the operating system's native CA store for certificate +verification. If you set this option and also set a CA certificate file or +directory then during verification those certificates are searched in addition +to the native CA store. + +Works with wolfSSL on Windows, Linux (Debian, Ubuntu, Gentoo, Fedora, RHEL), +macOS, Android and iOS (added in 8.3.0), with GnuTLS (added in 8.5.0) or on +Windows when built to use OpenSSL (Added in 7.71.0). + +## CURLSSLOPT_AUTO_CLIENT_CERT + +Tell libcurl to automatically locate and use a client certificate for +authentication, when requested by the server. This option is only supported +for Schannel (the native Windows SSL library). Prior to 7.77.0 this was the +default behavior in libcurl with Schannel. Since the server can request any +certificate that supports client authentication in the OS certificate store it +could be a privacy violation and unexpected. +(Added in 7.77.0) + +# DEFAULT + +0 + +# PROTOCOLS + +All TLS-based 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, "https://proxy"); + /* weaken TLS only for use with silly proxies */ + curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST | + CURLSSLOPT_NO_REVOKE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.3 deleted file mode 100644 index 42a96b6c2..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSL_VERIFYHOST 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSL_VERIFYHOST \- verify the proxy certificate's name against host -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_VERIFYHOST, - long verify); -.fi -.SH DESCRIPTION -Pass a long set to 2L as asking curl to \fIverify\fP in the HTTPS proxy's -certificate name fields against the proxy name. - -This option determines whether libcurl verifies that the proxy cert contains -the correct name for the name it is known as. - -When \fICURLOPT_PROXY_SSL_VERIFYHOST(3)\fP is 2, the proxy certificate must -indicate that the server is the proxy to which you meant to connect to, or the -connection fails. - -Curl considers the proxy the intended one when the Common Name field or a -Subject Alternate Name field in the certificate matches the host name in the -proxy string which you told curl to use. - -If \fIverify\fP value is set to 1: - -In 7.28.0 and earlier: treated as a debug option of some sorts, not supported -anymore due to frequently leading to programmer mistakes. - -From 7.28.1 to 7.65.3: setting it to 1 made \fIcurl_easy_setopt(3)\fP return -an error and leaving the flag untouched. - -From 7.66.0: treats 1 and 2 the same. - -When the \fIverify\fP value is 0L, the connection succeeds regardless of the -names used in the certificate. Use that ability with caution! - -See also \fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP to verify the digital signature -of the proxy certificate. -.SH DEFAULT -2 -.SH PROTOCOLS -All protocols when used over an HTTPS proxy. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* Set the default value: strict name check please */ - curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 2L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0. - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not. - -If 1 is set as argument, \fICURLE_BAD_FUNCTION_ARGUMENT\fP is returned. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_PROXY_CAINFO (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.md new file mode 100644 index 000000000..fdb8249ff --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYHOST.md @@ -0,0 +1,94 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSL_VERIFYHOST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_PROXY_CAINFO (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_SSL_VERIFYHOST - verify the proxy certificate's name against host + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_VERIFYHOST, + long verify); +~~~ + +# DESCRIPTION + +Pass a long set to 2L as asking curl to *verify* in the HTTPS proxy's +certificate name fields against the proxy name. + +This option determines whether libcurl verifies that the proxy cert contains +the correct name for the name it is known as. + +When CURLOPT_PROXY_SSL_VERIFYHOST(3) is 2, the proxy certificate must +indicate that the server is the proxy to which you meant to connect to, or the +connection fails. + +Curl considers the proxy the intended one when the Common Name field or a +Subject Alternate Name field in the certificate matches the hostname in the +proxy string which you told curl to use. + +If *verify* value is set to 1: + +In 7.28.0 and earlier: treated as a debug option of some sorts, not supported +anymore due to frequently leading to programmer mistakes. + +From 7.28.1 to 7.65.3: setting it to 1 made curl_easy_setopt(3) return +an error and leaving the flag untouched. + +From 7.66.0: treats 1 and 2 the same. + +When the *verify* value is 0L, the connection succeeds regardless of the +names used in the certificate. Use that ability with caution! + +See also CURLOPT_PROXY_SSL_VERIFYPEER(3) to verify the digital signature +of the proxy certificate. + +# DEFAULT + +2 + +# PROTOCOLS + +All protocols when used over an HTTPS proxy. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* Set the default value: strict name check please */ + curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 2L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0. + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not. + +If 1 is set as argument, *CURLE_BAD_FUNCTION_ARGUMENT* is returned. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.3 b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.3 deleted file mode 100644 index 866f07c9f..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.3 +++ /dev/null @@ -1,97 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_SSL_VERIFYPEER 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_SSL_VERIFYPEER \- verify the proxy's SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_VERIFYPEER, - long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1L to enable or 0L to disable. - -This option tells curl to verify the authenticity of the HTTPS proxy's -certificate. A value of 1 means curl verifies; 0 (zero) means it does not. - -This is the proxy version of \fICURLOPT_SSL_VERIFYPEER(3)\fP that is used for -ordinary HTTPS servers. - -When negotiating a TLS or SSL connection, the server sends a certificate -indicating its identity. Curl verifies whether the certificate is authentic, -i.e. that you can trust that the server is who the certificate says it is. -This trust is based on a chain of digital signatures, rooted in certification -authority (CA) certificates you supply. curl uses a default bundle of CA -certificates (the path for that is determined at build time) and you can -specify alternate certificates with the \fICURLOPT_PROXY_CAINFO(3)\fP option -or the \fICURLOPT_PROXY_CAPATH(3)\fP option. - -When \fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP is enabled, and the verification -fails to prove that the certificate is authentic, the connection fails. When -the option is zero, the peer certificate verification succeeds regardless. - -Authenticating the certificate is not enough to be sure about the server. You -typically also want to ensure that the server is the server you mean to be -talking to. Use \fICURLOPT_PROXY_SSL_VERIFYHOST(3)\fP for that. The check -that the host name in the certificate is valid for the host name you are -connecting to is done independently of the -\fICURLOPT_PROXY_SSL_VERIFYPEER(3)\fP option. - -WARNING: disabling verification of the certificate allows bad guys to -man-in-the-middle the communication without you knowing it. Disabling -verification makes the communication insecure. Just having encryption on a -transfer is not enough as you cannot be sure that you are communicating with -the correct end-point. -.SH DEFAULT -1 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* Set the default value: strict certificate check please */ - curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3), -.BR CURLOPT_SSL_VERIFYHOST (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.md new file mode 100644 index 000000000..f934ddeb7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_VERIFYPEER.md @@ -0,0 +1,94 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_SSL_VERIFYPEER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_PROXY_SSL_VERIFYPEER - verify the proxy's SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_SSL_VERIFYPEER, + long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1L to enable or 0L to disable. + +This option tells curl to verify the authenticity of the HTTPS proxy's +certificate. A value of 1 means curl verifies; 0 (zero) means it does not. + +This is the proxy version of CURLOPT_SSL_VERIFYPEER(3) that is used for +ordinary HTTPS servers. + +When negotiating a TLS or SSL connection, the server sends a certificate +indicating its identity. Curl verifies whether the certificate is authentic, +i.e. that you can trust that the server is who the certificate says it is. +This trust is based on a chain of digital signatures, rooted in certification +authority (CA) certificates you supply. curl uses a default bundle of CA +certificates (the path for that is determined at build time) and you can +specify alternate certificates with the CURLOPT_PROXY_CAINFO(3) option or +the CURLOPT_PROXY_CAPATH(3) option. + +When CURLOPT_PROXY_SSL_VERIFYPEER(3) is enabled, and the verification +fails to prove that the certificate is authentic, the connection fails. When +the option is zero, the peer certificate verification succeeds regardless. + +Authenticating the certificate is not enough to be sure about the server. You +typically also want to ensure that the server is the server you mean to be +talking to. Use CURLOPT_PROXY_SSL_VERIFYHOST(3) for that. The check that the +hostname in the certificate is valid for the hostname you are connecting to is +done independently of the CURLOPT_PROXY_SSL_VERIFYPEER(3) option. + +WARNING: disabling verification of the certificate allows bad guys to +man-in-the-middle the communication without you knowing it. Disabling +verification makes the communication insecure. Just having encryption on a +transfer is not enough as you cannot be sure that you are communicating with +the correct end-point. + +# DEFAULT + +1 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* Set the default value: strict certificate check please */ + curl_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.3 b/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.3 deleted file mode 100644 index d64d17ccc..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_TLS13_CIPHERS 3 "25 May 2018" libcurl libcurl -.SH NAME -CURLOPT_PROXY_TLS13_CIPHERS \- ciphers suites for proxy TLS 1.3 -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLS13_CIPHERS, - char *list); -.fi -.SH DESCRIPTION -Pass a char *, pointing to a null-terminated string holding the list of cipher -suites to use for the TLS 1.3 connection to a proxy. The list must be -syntactically correct, it consists of one or more cipher suite strings -separated by colons. - -Find more details about cipher lists on this URL: - - https://curl.se/docs/ssl-ciphers.html - -This option is currently used only when curl is built to use OpenSSL 1.1.1 or -later. If you are using a different SSL backend you can try setting TLS 1.3 -cipher suites by using the \fICURLOPT_PROXY_SSL_CIPHER_LIST(3)\fP option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, use internal default -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_TLS13_CIPHERS, - "TLS_CHACHA20_POLY1305_SHA256"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0. -Available when built with OpenSSL >= 1.1.1. -.SH RETURN VALUE -Returns CURLE_OK if supported, CURLE_NOT_BUILT_IN otherwise. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_CIPHER_LIST (3), -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_TLS13_CIPHERS (3) - diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md b/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md new file mode 100644 index 000000000..f3c5448f0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_TLS13_CIPHERS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_PROXY_SSL_CIPHER_LIST (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CIPHER_LIST (3) + - CURLOPT_TLS13_CIPHERS (3) +--- + +# NAME + +CURLOPT_PROXY_TLS13_CIPHERS - ciphers suites for proxy TLS 1.3 + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLS13_CIPHERS, + char *list); +~~~ + +# DESCRIPTION + +Pass a char pointer, pointing to a null-terminated string holding the list of +cipher suites to use for the TLS 1.3 connection to a proxy. The list must be +syntactically correct, it consists of one or more cipher suite strings +separated by colons. + +Find more details about cipher lists on this URL: + + https://curl.se/docs/ssl-ciphers.html + +This option is currently used only when curl is built to use OpenSSL 1.1.1 or +later. If you are using a different SSL backend you can try setting TLS 1.3 +cipher suites by using the CURLOPT_PROXY_SSL_CIPHER_LIST(3) option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, use internal default + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_TLS13_CIPHERS, + "TLS_CHACHA20_POLY1305_SHA256"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.61.0. +Available when built with OpenSSL >= 1.1.1. + +# RETURN VALUE + +Returns CURLE_OK if supported, CURLE_NOT_BUILT_IN otherwise. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.3 b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.3 deleted file mode 100644 index 327b92a81..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_TLSAUTH_PASSWORD 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_TLSAUTH_PASSWORD \- password to use for proxy TLS authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_PASSWORD, - char *pwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should point to the null-terminated password -to use for the TLS authentication method specified with the -\fICURLOPT_PROXY_TLSAUTH_TYPE(3)\fP option. Requires that the -\fICURLOPT_PROXY_TLSAUTH_USERNAME(3)\fP option also be set. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0, with the OpenSSL and GnuTLS backends only -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_TLSAUTH_TYPE (3), -.BR CURLOPT_PROXY_TLSAUTH_USERNAME (3), -.BR CURLOPT_TLSAUTH_TYPE (3), -.BR CURLOPT_TLSAUTH_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md new file mode 100644 index 000000000..778d1b79c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_TLSAUTH_PASSWORD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_TLSAUTH_TYPE (3) + - CURLOPT_PROXY_TLSAUTH_USERNAME (3) + - CURLOPT_TLSAUTH_TYPE (3) + - CURLOPT_TLSAUTH_USERNAME (3) +--- + +# NAME + +CURLOPT_PROXY_TLSAUTH_PASSWORD - password to use for proxy TLS authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_PASSWORD, + char *pwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should point to the null-terminated +password to use for the TLS authentication method specified with the +CURLOPT_PROXY_TLSAUTH_TYPE(3) option. Requires that the +CURLOPT_PROXY_TLSAUTH_USERNAME(3) option also be set. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0, with the OpenSSL and GnuTLS backends only + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.3 b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.3 deleted file mode 100644 index c4fe02c85..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_TLSAUTH_TYPE 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_TLSAUTH_TYPE \- HTTPS proxy TLS authentication methods -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_TYPE, - char *type); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the method of the TLS authentication used for the HTTPS connection. Supported -method is "SRP". - -.IP SRP -TLS-SRP authentication. Secure Remote Password authentication for TLS is -defined in RFC 5054 and provides mutual authentication if both sides have a -shared secret. To use TLS-SRP, you must also set the -\fICURLOPT_PROXY_TLSAUTH_USERNAME(3)\fP and -\fICURLOPT_PROXY_TLSAUTH_PASSWORD(3)\fP options. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0 - -You need to build libcurl with GnuTLS or OpenSSL with TLS-SRP support for this -to work. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_TLSAUTH_PASSWORD (3), -.BR CURLOPT_PROXY_TLSAUTH_USERNAME (3), -.BR CURLOPT_TLSAUTH_PASSWORD (3), -.BR CURLOPT_TLSAUTH_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md new file mode 100644 index 000000000..d4389188b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_TLSAUTH_TYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_TLSAUTH_PASSWORD (3) + - CURLOPT_PROXY_TLSAUTH_USERNAME (3) + - CURLOPT_TLSAUTH_PASSWORD (3) + - CURLOPT_TLSAUTH_USERNAME (3) +--- + +# NAME + +CURLOPT_PROXY_TLSAUTH_TYPE - HTTPS proxy TLS authentication methods + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_TYPE, + char *type); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the method of the TLS authentication used for the HTTPS connection. Supported +method is "SRP". + +## SRP + +TLS-SRP authentication. Secure Remote Password authentication for TLS is +defined in RFC 5054 and provides mutual authentication if both sides have a +shared secret. To use TLS-SRP, you must also set the +CURLOPT_PROXY_TLSAUTH_USERNAME(3) and +CURLOPT_PROXY_TLSAUTH_PASSWORD(3) options. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +All + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0 + +You need to build libcurl with GnuTLS or OpenSSL with TLS-SRP support for this +to work. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.3 b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.3 deleted file mode 100644 index e8362fa2f..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_TLSAUTH_USERNAME 3 "16 Nov 2016" libcurl libcurl -.SH NAME -CURLOPT_PROXY_TLSAUTH_USERNAME \- user name to use for proxy TLS authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_USERNAME, - char *user); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should point to the null-terminated username -to use for the HTTPS proxy TLS authentication method specified with the -\fICURLOPT_PROXY_TLSAUTH_TYPE(3)\fP option. Requires that the -\fICURLOPT_PROXY_TLSAUTH_PASSWORD(3)\fP option also be set. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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, "https://proxy"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.52.0, with the OpenSSL and GnuTLS backends only. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_TLSAUTH_PASSWORD (3), -.BR CURLOPT_PROXY_TLSAUTH_TYPE (3), -.BR CURLOPT_TLSAUTH_PASSWORD (3), -.BR CURLOPT_TLSAUTH_TYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md new file mode 100644 index 000000000..612ff4f92 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_TLSAUTH_USERNAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_TLSAUTH_PASSWORD (3) + - CURLOPT_PROXY_TLSAUTH_TYPE (3) + - CURLOPT_TLSAUTH_PASSWORD (3) + - CURLOPT_TLSAUTH_TYPE (3) +--- + +# NAME + +CURLOPT_PROXY_TLSAUTH_USERNAME - user name to use for proxy TLS authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TLSAUTH_USERNAME, + char *user); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should point to the null-terminated +username to use for the HTTPS proxy TLS authentication method specified with +the CURLOPT_PROXY_TLSAUTH_TYPE(3) option. Requires that the +CURLOPT_PROXY_TLSAUTH_PASSWORD(3) option also be set. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# 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, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.52.0, with the OpenSSL and GnuTLS backends only. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.3 b/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.3 deleted file mode 100644 index f948613a8..000000000 --- a/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PROXY_TRANSFER_MODE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PROXY_TRANSFER_MODE \- append FTP transfer mode to URL for proxy -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TRANSFER_MODE, - long enabled); -.fi -.SH DESCRIPTION -Pass a long. If the value is set to 1 (one), it tells libcurl to set the -transfer mode (binary or ASCII) for FTP transfers done via an HTTP proxy, by -appending ;type=a or ;type=i to the URL. Without this setting, or it being set -to 0 (zero, the default), \fICURLOPT_TRANSFERTEXT(3)\fP has no effect when -doing FTP via a proxy. Beware that not all proxies support this feature. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -FTP over proxy -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, - "ftp://example.com/old-server/file.txt"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:80"); - curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.18.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the -enabled value is not supported. -.SH "SEE ALSO" -.BR CURLOPT_CRLF (3), -.BR CURLOPT_TRANSFERTEXT (3), -.BR CURLOPT_HTTPPROXYTUNNEL (3), -.BR CURLOPT_PROXY (3) diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.md b/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.md new file mode 100644 index 000000000..c0fed8b21 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PROXY_TRANSFER_MODE.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PROXY_TRANSFER_MODE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CRLF (3) + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_PROXY (3) + - CURLOPT_TRANSFERTEXT (3) +--- + +# NAME + +CURLOPT_PROXY_TRANSFER_MODE - append FTP transfer mode to URL for proxy + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_TRANSFER_MODE, + long enabled); +~~~ + +# DESCRIPTION + +Pass a long. If the value is set to 1 (one), it tells libcurl to set the +transfer mode (binary or ASCII) for FTP transfers done via an HTTP proxy, by +appending ;type=a or ;type=i to the URL. Without this setting, or it being set +to 0 (zero, the default), CURLOPT_TRANSFERTEXT(3) has no effect when +doing FTP via a proxy. Beware that not all proxies support this feature. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +FTP over proxy + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, + "ftp://example.com/old-server/file.txt"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://localhost:80"); + curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.18.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the +enabled value is not supported. diff --git a/docs/libcurl/opts/CURLOPT_PUT.3 b/docs/libcurl/opts/CURLOPT_PUT.3 deleted file mode 100644 index fb4e4c9be..000000000 --- a/docs/libcurl/opts/CURLOPT_PUT.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_PUT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_PUT \- make an HTTP PUT request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PUT, long put); -.fi -.SH DESCRIPTION -A parameter set to 1 tells the library to use HTTP PUT to transfer data. The -data should be set with \fICURLOPT_READDATA(3)\fP and -\fICURLOPT_INFILESIZE(3)\fP. - -This option is \fBdeprecated\fP since version 7.12.1. Use -\fICURLOPT_UPLOAD(3)\fP! -.SH DEFAULT -0, disabled -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata) -{ - FILE *src = userdata; - /* copy as much data as possible into the 'ptr' buffer, but no more than - 'size' * 'nmemb' bytes! */ - size_t retcode = fread(ptr, size, nmemb, src); - - return retcode; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - FILE *src = fopen("local-file", "r"); - curl_off_t fsize; /* set this to the size of the input file */ - - /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); - - /* enable PUT */ - curl_easy_setopt(curl, CURLOPT_PUT, 1L); - - /* specify target */ - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); - - /* now specify which pointer to pass to our callback */ - curl_easy_setopt(curl, CURLOPT_READDATA, src); - - /* Set the size of the file to upload */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize); - - /* Now run off and do what you have been told! */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Deprecated since 7.12.1. Do not use. -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPGET (3), -.BR CURLOPT_MIMEPOST (3), -.BR CURLOPT_POSTFIELDS (3), -.BR CURLOPT_UPLOAD (3) diff --git a/docs/libcurl/opts/CURLOPT_PUT.md b/docs/libcurl/opts/CURLOPT_PUT.md new file mode 100644 index 000000000..117eaedd7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_PUT.md @@ -0,0 +1,89 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_PUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPGET (3) + - CURLOPT_MIMEPOST (3) + - CURLOPT_POSTFIELDS (3) + - CURLOPT_UPLOAD (3) +--- + +# NAME + +CURLOPT_PUT - make an HTTP PUT request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PUT, long put); +~~~ + +# DESCRIPTION + +A parameter set to 1 tells the library to use HTTP PUT to transfer data. The +data should be set with CURLOPT_READDATA(3) and +CURLOPT_INFILESIZE(3). + +This option is **deprecated** since version 7.12.1. Use CURLOPT_UPLOAD(3). + +# DEFAULT + +0, disabled + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + FILE *src = userdata; + /* copy as much data as possible into the 'ptr' buffer, but no more than + 'size' * 'nmemb' bytes */ + size_t retcode = fread(ptr, size, nmemb, src); + + return retcode; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + FILE *src = fopen("local-file", "r"); + curl_off_t fsize; /* set this to the size of the input file */ + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); + + /* enable PUT */ + curl_easy_setopt(curl, CURLOPT_PUT, 1L); + + /* specify target */ + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); + + /* now specify which pointer to pass to our callback */ + curl_easy_setopt(curl, CURLOPT_READDATA, src); + + /* Set the size of the file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize); + + /* Now run off and do what you have been told */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Deprecated since 7.12.1. Do not use. + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_QUICK_EXIT.3 b/docs/libcurl/opts/CURLOPT_QUICK_EXIT.3 deleted file mode 100644 index f34e771ac..000000000 --- a/docs/libcurl/opts/CURLOPT_QUICK_EXIT.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_QUICK_EXIT 3 "30 Sep 2022" libcurl libcurl -.SH NAME -CURLOPT_QUICK_EXIT \- allow to exit quickly -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUICK_EXIT, - long value); -.SH DESCRIPTION -Pass a long as a parameter, 1L meaning that when recovering from a timeout, -libcurl should skip lengthy cleanups that are intended to avoid all kinds of -leaks (threads etc.), as the caller program is about to call exit() anyway. -This allows for a swift termination after a DNS timeout for example, by -canceling and/or forgetting about a resolver thread, at the expense of a -possible (though short-lived) leak of associated resources. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.87.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FAILONERROR (3), -.BR CURLOPT_RESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_QUICK_EXIT.md b/docs/libcurl/opts/CURLOPT_QUICK_EXIT.md new file mode 100644 index 000000000..4159c02fb --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_QUICK_EXIT.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_QUICK_EXIT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_FAILONERROR (3) + - CURLOPT_RESOLVE (3) +--- + +# NAME + +CURLOPT_QUICK_EXIT - allow to exit quickly + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUICK_EXIT, + long value); +~~~ + +# DESCRIPTION + +Pass a long as a parameter, 1L meaning that when recovering from a timeout, +libcurl should skip lengthy cleanups that are intended to avoid all kinds of +leaks (threads etc.), as the caller program is about to call exit() anyway. +This allows for a swift termination after a DNS timeout for example, by +canceling and/or forgetting about a resolver thread, at the expense of a +possible (though short-lived) leak of associated resources. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_QUICK_EXIT, 1L); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.87.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_QUOTE.3 b/docs/libcurl/opts/CURLOPT_QUOTE.3 deleted file mode 100644 index 29e0154cd..000000000 --- a/docs/libcurl/opts/CURLOPT_QUOTE.3 +++ /dev/null @@ -1,133 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_QUOTE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_QUOTE \- (S)FTP commands to run before transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUOTE, - struct curl_slist *cmds); -.fi -.SH DESCRIPTION -Pass a pointer to a linked list of FTP or SFTP commands to pass to the server -prior to your request. This is done before any other commands are issued (even -before the CWD command for FTP). The linked list should be a fully valid list -of 'struct curl_slist' structs properly filled in with text strings. Use -\fIcurl_slist_append(3)\fP to append strings (commands) to the list, and clear -the entire list afterwards with \fIcurl_slist_free_all(3)\fP. - -Disable this operation again by setting a NULL to this option. - -When speaking to an FTP server, prefix the command with an asterisk (*) to -make libcurl continue even if the command fails as by default libcurl stops at -first failure. - -The set of valid FTP commands depends on the server (see RFC 959 for a list of -mandatory commands). - -libcurl does not inspect, parse or "understand" the commands passed to the -server using this option. If you change connection state, working directory or -similar using quote commands, libcurl does not know about it. - -The valid SFTP commands are: -.RS -.IP "atime date file" -The atime command sets the last access time of the file named by the file -operand. The can be all sorts of date strings, see the -\fIcurl_getdate(3)\fP man page for date expression details. (Added in 7.73.0) -.IP "chgrp group file" -The chgrp command sets the group ID of the file named by the file operand to -the group ID specified by the group operand. The group operand is a decimal -integer group ID. -.IP "chmod mode file" -The chmod command modifies the file mode bits of the specified file. The -mode operand is an octal integer mode number. -.IP "chown user file" -The chown command sets the owner of the file named by the file operand to the -user ID specified by the user operand. The user operand is a decimal -integer user ID. -.IP "ln source_file target_file" -The \fBln\fP and \fBsymlink\fP commands create a symbolic link at the -target_file location pointing to the source_file location. -.IP "mkdir directory_name" -The mkdir command creates the directory named by the directory_name operand. -.IP "mtime date file" -The mtime command sets the last modification time of the file named by the -file operand. The can be all sorts of date strings, see the -\fIcurl_getdate(3)\fP man page for date expression details. (Added in 7.73.0) -.IP "pwd" -The \fBpwd\fP command returns the absolute path of the current working -directory. -.IP "rename source target" -The rename command renames the file or directory named by the source -operand to the destination path named by the target operand. -.IP "rm file" -The rm command removes the file specified by the file operand. -.IP "rmdir directory" -The rmdir command removes the directory entry specified by the directory -operand, provided it is empty. -.IP "statvfs file" -The statvfs command returns statistics on the file system in which specified -file resides. (Added in 7.49.0) -.IP "symlink source_file target_file" -See ln. -.RE -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and FTP -.SH EXAMPLE -.nf -int main(void) -{ - struct curl_slist *cmdlist = NULL; - cmdlist = curl_slist_append(cmdlist, "RNFR source-name"); - cmdlist = curl_slist_append(cmdlist, "RNTO new-name"); - - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); - - /* pass in the FTP commands to run before the transfer */ - curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -SFTP support added in 7.16.3. *-prefix for SFTP added in 7.24.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_DIRLISTONLY (3), -.BR CURLOPT_POSTQUOTE (3), -.BR CURLOPT_PREQUOTE (3) diff --git a/docs/libcurl/opts/CURLOPT_QUOTE.md b/docs/libcurl/opts/CURLOPT_QUOTE.md new file mode 100644 index 000000000..f57b45eec --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_QUOTE.md @@ -0,0 +1,161 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_QUOTE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CUSTOMREQUEST (3) + - CURLOPT_DIRLISTONLY (3) + - CURLOPT_POSTQUOTE (3) + - CURLOPT_PREQUOTE (3) +--- + +# NAME + +CURLOPT_QUOTE - (S)FTP commands to run before transfer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUOTE, + struct curl_slist *cmds); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of FTP or SFTP commands to pass to the server +prior to your request. This is done before any other commands are issued (even +before the CWD command for FTP). The linked list should be a fully valid list +of 'struct curl_slist' structs properly filled in with text strings. Use +curl_slist_append(3) to append strings (commands) to the list, and clear +the entire list afterwards with curl_slist_free_all(3). + +Disable this operation again by setting a NULL to this option. + +When speaking to an FTP server, prefix the command with an asterisk (*) to +make libcurl continue even if the command fails as by default libcurl stops at +first failure. + +The set of valid FTP commands depends on the server (see RFC 959 for a list of +mandatory commands). + +libcurl does not inspect, parse or "understand" the commands passed to the +server using this option. If you change connection state, working directory or +similar using quote commands, libcurl does not know about it. + +The path arguments for FTP or SFTP can use single or double quotes to +distinguish a space from being the parameter separator or being a part of the +path. e.g. rename with sftp using a quote command like this: + + "rename 'test/_upload.txt' 'test/Hello World.txt'" + +# SFTP commands + +## atime date file + +The atime command sets the last access time of the file named by the file +operand. The can be all sorts of date strings, see the +curl_getdate(3) man page for date expression details. (Added in 7.73.0) + +## chgrp group file + +The chgrp command sets the group ID of the file named by the file operand to +the group ID specified by the group operand. The group operand is a decimal +integer group ID. + +## chmod mode file + +The chmod command modifies the file mode bits of the specified file. The +mode operand is an octal integer mode number. + +## chown user file + +The chown command sets the owner of the file named by the file operand to the +user ID specified by the user operand. The user operand is a decimal +integer user ID. + +## ln source_file target_file + +The **ln** and **symlink** commands create a symbolic link at the +target_file location pointing to the source_file location. + +## mkdir directory_name + +The mkdir command creates the directory named by the directory_name operand. + +## mtime date file + +The mtime command sets the last modification time of the file named by the +file operand. The can be all sorts of date strings, see the +curl_getdate(3) man page for date expression details. (Added in 7.73.0) + +## pwd + +The **pwd** command returns the absolute path of the current working +directory. + +## rename source target + +The rename command renames the file or directory named by the source +operand to the destination path named by the target operand. + +## rm file + +The rm command removes the file specified by the file operand. + +## rmdir directory + +The rmdir command removes the directory entry specified by the directory +operand, provided it is empty. + +## statvfs file + +The statvfs command returns statistics on the file system in which specified +file resides. (Added in 7.49.0) + +## symlink source_file target_file + +See ln. + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and FTP + +# EXAMPLE + +~~~c +int main(void) +{ + struct curl_slist *cmdlist = NULL; + cmdlist = curl_slist_append(cmdlist, "RNFR source-name"); + cmdlist = curl_slist_append(cmdlist, "RNTO new-name"); + + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); + + /* pass in the FTP commands to run before the transfer */ + curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +SFTP support added in 7.16.3. *-prefix for SFTP added in 7.24.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_RANDOM_FILE.3 b/docs/libcurl/opts/CURLOPT_RANDOM_FILE.3 deleted file mode 100644 index b226d15a0..000000000 --- a/docs/libcurl/opts/CURLOPT_RANDOM_FILE.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RANDOM_FILE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RANDOM_FILE \- file to read random data from -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANDOM_FILE, char *path); -.fi -.SH DESCRIPTION -Deprecated option. It serves no purpose anymore. - -Pass a char * to a null-terminated file name. The file might be used to read -from to seed the random engine for SSL and more. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, not used -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -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_RANDOM_FILE, "junk.txt"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built with TLS enabled. Only the OpenSSL backend uses this, and only with -OpenSSL versions before 1.1.0. - -This option was deprecated in 7.84.0. -.SH RETURN VALUE -Returns CURLE_OK on success or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_EGDSOCKET (3) diff --git a/docs/libcurl/opts/CURLOPT_RANDOM_FILE.md b/docs/libcurl/opts/CURLOPT_RANDOM_FILE.md new file mode 100644 index 000000000..7675461a2 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RANDOM_FILE.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RANDOM_FILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_EGDSOCKET (3) +--- + +# NAME + +CURLOPT_RANDOM_FILE - file to read random data from + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANDOM_FILE, char *path); +~~~ + +# DESCRIPTION + +Deprecated option. It serves no purpose anymore. + +Pass a char pointer to a null-terminated filename. The file might be used to +read from to seed the random engine for SSL and more. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, not used + +# PROTOCOLS + +All + +# 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_RANDOM_FILE, "junk.txt"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built with TLS enabled. Only the OpenSSL backend uses this, and only with +OpenSSL versions before 1.1.0. + +This option was deprecated in 7.84.0. + +# RETURN VALUE + +Returns CURLE_OK on success or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_RANGE.3 b/docs/libcurl/opts/CURLOPT_RANGE.3 deleted file mode 100644 index 90ad66696..000000000 --- a/docs/libcurl/opts/CURLOPT_RANGE.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RANGE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RANGE \- byte range to request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should contain the specified range you want -to retrieve. It should be in the format "X-Y", where either X or Y may be left -out and X and Y are byte indexes. - -HTTP transfers also support several intervals, separated with commas as in -\fI"X-Y,N-M"\fP. Using this kind of multiple intervals causes the HTTP server -to send the response document in pieces (using standard MIME separation -techniques). Unfortunately, the HTTP standard (RFC 7233 section 3.1) allows -servers to ignore range requests so even when you set \fICURLOPT_RANGE(3)\fP -for a request, you may end up getting the full response sent back. - -For RTSP, the formatting of a range should follow RFC 2326 Section 12.29. For -RTSP, byte ranges are \fBnot\fP permitted. Instead, ranges should be given in -\fBnpt\fP, \fButc\fP, or \fBsmpte\fP formats. - -For HTTP PUT uploads this option should not be used, since it may conflict with -other options. - -Pass a NULL to this option to disable the use of ranges. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP, FTP, FILE, RTSP and SFTP. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* get the first 200 bytes */ - curl_easy_setopt(curl, CURLOPT_RANGE, "0-199"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -FILE since 7.18.0, RTSP since 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK on success or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3), -.BR CURLOPT_MAXFILESIZE_LARGE (3), -.BR CURLOPT_RESUME_FROM (3) diff --git a/docs/libcurl/opts/CURLOPT_RANGE.md b/docs/libcurl/opts/CURLOPT_RANGE.md new file mode 100644 index 000000000..3f765bc61 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RANGE.md @@ -0,0 +1,84 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RANGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_MAXFILESIZE_LARGE (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) + - CURLOPT_RESUME_FROM (3) +--- + +# NAME + +CURLOPT_RANGE - byte range to request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RANGE, char *range); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should contain the specified range you +want to retrieve. It should be in the format "X-Y", where either X or Y may be +left out and X and Y are byte indexes. + +HTTP transfers also support several intervals, separated with commas as in +*"X-Y,N-M"*. Using this kind of multiple intervals causes the HTTP server +to send the response document in pieces (using standard MIME separation +techniques). Unfortunately, the HTTP standard (RFC 7233 section 3.1) allows +servers to ignore range requests so even when you set CURLOPT_RANGE(3) +for a request, you may end up getting the full response sent back. + +For RTSP, the formatting of a range should follow RFC 2326 Section 12.29. For +RTSP, byte ranges are **not** permitted. Instead, ranges should be given in +**npt**, **utc**, or **smpte** formats. + +For HTTP PUT uploads this option should not be used, since it may conflict with +other options. + +Pass a NULL to this option to disable the use of ranges. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP, FTP, FILE, RTSP and SFTP. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* get the first 200 bytes */ + curl_easy_setopt(curl, CURLOPT_RANGE, "0-199"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +FILE since 7.18.0, RTSP since 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK on success or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_READDATA.3 b/docs/libcurl/opts/CURLOPT_READDATA.3 deleted file mode 100644 index db0dcfc60..000000000 --- a/docs/libcurl/opts/CURLOPT_READDATA.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_READDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_READDATA \- pointer passed to the read callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READDATA, void *pointer); -.fi -.SH DESCRIPTION -Data \fIpointer\fP to pass to the file read function. If you use the -\fICURLOPT_READFUNCTION(3)\fP option, this is the pointer you get as input in -the fourth argument to the callback. - -If you do not specify a read callback but instead rely on the default internal -read function, this data must be a valid readable FILE * (cast to 'void *'). - -If you are using libcurl as a DLL on Windows, you must use the -\fICURLOPT_READFUNCTION(3)\fP callback if you set this option, otherwise you -might experience crashes. -.SH DEFAULT -By default, this is a FILE * to stdin. -.SH PROTOCOLS -This is used for all protocols when sending data. -.SH EXAMPLE -.nf -struct MyData { - void *custom; -}; - -int main(void) -{ - CURL *curl = curl_easy_init(); - struct MyData this; - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* pass pointer that gets passed in to the - CURLOPT_READFUNCTION callback */ - curl_easy_setopt(curl, CURLOPT_READDATA, &this); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -This option was once known by the older name CURLOPT_INFILE, the name -\fICURLOPT_READDATA(3)\fP was introduced in 7.9.7. -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_HEADERDATA (3), -.BR CURLOPT_READFUNCTION (3), -.BR CURLOPT_WRITEDATA (3), -.BR CURLOPT_WRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_READDATA.md b/docs/libcurl/opts/CURLOPT_READDATA.md new file mode 100644 index 000000000..d7aa4ff9a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_READDATA.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_READDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERDATA (3) + - CURLOPT_READFUNCTION (3) + - CURLOPT_WRITEDATA (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_READDATA - pointer passed to the read callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READDATA, void *pointer); +~~~ + +# DESCRIPTION + +Data *pointer* to pass to the file read function. If you use the +CURLOPT_READFUNCTION(3) option, this is the pointer you get as input in +the fourth argument to the callback. + +If you do not specify a read callback but instead rely on the default internal +read function, this data must be a valid readable FILE * (cast to 'void *'). + +If you are using libcurl as a DLL on Windows, you must use the +CURLOPT_READFUNCTION(3) callback if you set this option, otherwise you +might experience crashes. + +# DEFAULT + +By default, this is a FILE * to stdin. + +# PROTOCOLS + +This is used for all protocols when sending data. + +# EXAMPLE + +~~~c +struct MyData { + void *custom; +}; + +int main(void) +{ + CURL *curl = curl_easy_init(); + struct MyData this; + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* pass pointer that gets passed in to the + CURLOPT_READFUNCTION callback */ + curl_easy_setopt(curl, CURLOPT_READDATA, &this); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +This option was once known by the older name CURLOPT_INFILE, the name +CURLOPT_READDATA(3) was introduced in 7.9.7. + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_READFUNCTION.3 b/docs/libcurl/opts/CURLOPT_READFUNCTION.3 deleted file mode 100644 index de689fbdc..000000000 --- a/docs/libcurl/opts/CURLOPT_READFUNCTION.3 +++ /dev/null @@ -1,125 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_READFUNCTION 3 "25 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_READFUNCTION \- read callback for data uploads -.SH SYNOPSIS -.nf -#include - -size_t read_callback(char *buffer, size_t size, size_t nitems, void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READFUNCTION, read_callback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, as the prototype shows above. - -This callback function gets called by libcurl as soon as it needs to read data -in order to send it to the peer - like if you ask it to upload or post data to -the server. The data area pointed at by the pointer \fIbuffer\fP should be -filled up with at most \fIsize\fP multiplied with \fInitems\fP number of bytes -by your function. \fIsize\fP is always 1. - -Set the \fIuserdata\fP argument with the \fICURLOPT_READDATA(3)\fP option. - -Your function must return the actual number of bytes that it stored in the -data area pointed at by the pointer \fIbuffer\fP. Returning 0 signals -end-of-file to the library and causes it to stop the current transfer. - -If you stop the current transfer by returning 0 "pre-maturely" (i.e before the -server expected it, like when you have said you would upload N bytes and you -upload less than N bytes), you may experience that the server "hangs" waiting -for the rest of the data that is not sent. - -The read callback may return \fICURL_READFUNC_ABORT\fP to stop the current -operation immediately, resulting in a \fICURLE_ABORTED_BY_CALLBACK\fP error -code from the transfer. - -The callback can return \fICURL_READFUNC_PAUSE\fP to cause reading from this -connection to pause. See \fIcurl_easy_pause(3)\fP for further details. - -\fBBugs\fP: when doing TFTP uploads, you must return the exact amount of data -that the callback wants, or it is considered the final packet by the server -end and the transfer ends there. - -If you set this callback pointer to NULL, or do not set it at all, the default -internal read function is used. It is doing an fread() on the FILE * userdata -set with \fICURLOPT_READDATA(3)\fP. - -You can set the total size of the data you are sending by using -\fICURLOPT_INFILESIZE_LARGE(3)\fP or \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP, -depending on the type of transfer. For some transfer types it may be required -and it allows for better error checking. -.SH DEFAULT -The default internal read callback is fread(). -.SH PROTOCOLS -This is used for all protocols when doing uploads. -.SH EXAMPLE -.nf -size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userdata) -{ - FILE *readhere = (FILE *)userdata; - curl_off_t nread; - - /* copy as much data as possible into the 'ptr' buffer, but no more than - 'size' * 'nmemb' bytes! */ - size_t retcode = fread(ptr, size, nmemb, readhere); - - nread = (curl_off_t)retcode; - - fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T - " bytes from file\\n", nread); - return retcode; -} - -int main(int argc, char **argv) -{ - FILE *file = fopen(argv[1], "rb"); - CURLcode result; - - CURL *curl = curl_easy_init(); - if(curl) { - /* set callback to use */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); - - /* pass in suitable argument to callback */ - curl_easy_setopt(curl, CURLOPT_READDATA, (void *)file); - - result = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -CURL_READFUNC_PAUSE return code was added in 7.18.0 and CURL_READFUNC_ABORT -was added in 7.12.1. -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_POST (3), -.BR CURLOPT_READDATA (3), -.BR CURLOPT_SEEKFUNCTION (3), -.BR CURLOPT_UPLOAD (3), -.BR CURLOPT_UPLOAD_BUFFERSIZE (3), -.BR CURLOPT_WRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_READFUNCTION.md b/docs/libcurl/opts/CURLOPT_READFUNCTION.md new file mode 100644 index 000000000..978440d13 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_READFUNCTION.md @@ -0,0 +1,123 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_READFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_POST (3) + - CURLOPT_READDATA (3) + - CURLOPT_SEEKFUNCTION (3) + - CURLOPT_UPLOAD (3) + - CURLOPT_UPLOAD_BUFFERSIZE (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_READFUNCTION - read callback for data uploads + +# SYNOPSIS + +~~~c +#include + +size_t read_callback(char *buffer, size_t size, size_t nitems, void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_READFUNCTION, read_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, as the prototype shows above. + +This callback function gets called by libcurl as soon as it needs to read data +in order to send it to the peer - like if you ask it to upload or post data to +the server. The data area pointed at by the pointer *buffer* should be +filled up with at most *size* multiplied with *nitems* number of bytes +by your function. *size* is always 1. + +Set the *userdata* argument with the CURLOPT_READDATA(3) option. + +Your function must return the actual number of bytes that it stored in the +data area pointed at by the pointer *buffer*. Returning 0 signals +end-of-file to the library and causes it to stop the current transfer. + +If you stop the current transfer by returning 0 "pre-maturely" (i.e before the +server expected it, like when you have said you would upload N bytes and you +upload less than N bytes), you may experience that the server "hangs" waiting +for the rest of the data that is not sent. + +The read callback may return *CURL_READFUNC_ABORT* to stop the current +operation immediately, resulting in a *CURLE_ABORTED_BY_CALLBACK* error +code from the transfer. + +The callback can return *CURL_READFUNC_PAUSE* to cause reading from this +connection to pause. See curl_easy_pause(3) for further details. + +**Bugs**: when doing TFTP uploads, you must return the exact amount of data +that the callback wants, or it is considered the final packet by the server +end and the transfer ends there. + +If you set this callback pointer to NULL, or do not set it at all, the default +internal read function is used. It is doing an fread() on the FILE * userdata +set with CURLOPT_READDATA(3). + +You can set the total size of the data you are sending by using +CURLOPT_INFILESIZE_LARGE(3) or CURLOPT_POSTFIELDSIZE_LARGE(3), +depending on the type of transfer. For some transfer types it may be required +and it allows for better error checking. + +# DEFAULT + +The default internal read callback is fread(). + +# PROTOCOLS + +This is used for all protocols when doing uploads. + +# EXAMPLE + +~~~c +size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + FILE *readhere = (FILE *)userdata; + curl_off_t nread; + + /* copy as much data as possible into the 'ptr' buffer, but no more than + 'size' * 'nmemb' bytes! */ + size_t retcode = fread(ptr, size, nmemb, readhere); + + nread = (curl_off_t)retcode; + + fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T + " bytes from file\n", nread); + return retcode; +} + +int main(int argc, char **argv) +{ + FILE *file = fopen(argv[1], "rb"); + CURLcode result; + + CURL *curl = curl_easy_init(); + if(curl) { + /* set callback to use */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pass in suitable argument to callback */ + curl_easy_setopt(curl, CURLOPT_READDATA, (void *)file); + + result = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +CURL_READFUNC_PAUSE return code was added in 7.18.0 and CURL_READFUNC_ABORT +was added in 7.12.1. + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.3 b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.3 deleted file mode 100644 index c45583d79..000000000 --- a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.3 +++ /dev/null @@ -1,117 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_REDIR_PROTOCOLS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_REDIR_PROTOCOLS \- protocols allowed to redirect to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS, long bitmask); -.fi -.SH DESCRIPTION -This option is deprecated. We strongly recommend using -\fICURLOPT_REDIR_PROTOCOLS_STR(3)\fP instead because this option cannot -control all available protocols! - -Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask -limits what protocols libcurl may use in a transfer that it follows to in a -redirect when \fICURLOPT_FOLLOWLOCATION(3)\fP is enabled. This allows you to -limit specific transfers to only be allowed to use a subset of protocols in -redirections. - -Protocols denied by \fICURLOPT_PROTOCOLS(3)\fP are not overridden by this -option. - -By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirect (7.65.2). -\fICURLPROTO_ALL\fP enables all protocols on redirect, including those -otherwise disabled for security. - -These are the available protocol defines: -.nf -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 -.fi -.SH DEFAULT -HTTP, HTTPS, FTP and FTPS (Added in 7.65.2). - -Older versions defaulted to all protocols except FILE, SCP and since 7.40.0 -SMB and SMBS. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(int argc, char **argv) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* pass in the URL from an external source */ - curl_easy_setopt(curl, CURLOPT_URL, argv[1]); - - /* only allow redirects to HTTP and HTTPS URLs */ - curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, - CURLPROTO_HTTP | CURLPROTO_HTTPS); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4, before then it would follow all protocols. Deprecated -since 7.85.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_SCHEME (3), -.BR CURLOPT_DEFAULT_PROTOCOL (3), -.BR CURLOPT_PROTOCOLS (3), -.BR CURLOPT_REDIR_PROTOCOLS_STR (3) diff --git a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.md b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.md new file mode 100644 index 000000000..4d06d4658 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS.md @@ -0,0 +1,115 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_REDIR_PROTOCOLS +Section: 3 +Source: libcurl +See-also: + - CURLINFO_SCHEME (3) + - CURLOPT_DEFAULT_PROTOCOL (3) + - CURLOPT_PROTOCOLS (3) + - CURLOPT_REDIR_PROTOCOLS_STR (3) +--- + +# NAME + +CURLOPT_REDIR_PROTOCOLS - protocols allowed to redirect to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS, long bitmask); +~~~ + +# DESCRIPTION + +This option is deprecated. We strongly recommend using +CURLOPT_REDIR_PROTOCOLS_STR(3) instead because this option cannot +control all available protocols! + +Pass a long that holds a bitmask of CURLPROTO_* defines. If used, this bitmask +limits what protocols libcurl may use in a transfer that it follows to in a +redirect when CURLOPT_FOLLOWLOCATION(3) is enabled. This allows you to +limit specific transfers to only be allowed to use a subset of protocols in +redirections. + +Protocols denied by CURLOPT_PROTOCOLS(3) are not overridden by this +option. + +By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirect (7.65.2). +*CURLPROTO_ALL* enables all protocols on redirect, including those +otherwise disabled for security. + +These are the available protocol defines: +~~~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 +~~~ + +# DEFAULT + +HTTP, HTTPS, FTP and FTPS (Added in 7.65.2). + +Older versions defaulted to all protocols except FILE, SCP and since 7.40.0 +SMB and SMBS. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(int argc, char **argv) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* pass in the URL from an external source */ + curl_easy_setopt(curl, CURLOPT_URL, argv[1]); + + /* only allow redirects to HTTP and HTTPS URLs */ + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, + CURLPROTO_HTTP | CURLPROTO_HTTPS); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4, before then it would follow all protocols. Deprecated +since 7.85.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.3 b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.3 deleted file mode 100644 index db243ad1d..000000000 --- a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_REDIR_PROTOCOLS_STR 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_REDIR_PROTOCOLS_STR \- protocols allowed to redirect to -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS_STR, - char *spec); -.fi -.SH DESCRIPTION -Pass a pointer to a string that holds a comma-separated list of case -insensitive protocol names (URL schemes). That list limits what protocols -libcurl may use in a transfer that it follows to in a redirect when -\fICURLOPT_FOLLOWLOCATION(3)\fP is enabled. This option allows applications to -limit specific transfers to only be allowed to use a subset of protocols in -redirections. - -Protocols denied by \fICURLOPT_PROTOCOLS_STR(3)\fP are not overridden by this -option. - -By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects (since -7.65.2). - -These are the available protocols: - -DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, -MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP, -SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS - -You can set "ALL" as a short-cut to enable all protocols. Note that by setting -all, you may enable protocols that were not supported the day you write this -but are introduced in a future libcurl version. - -If trying to set a non-existing protocol or if no matching protocol at all is -set, it returns error. -.SH DEFAULT -HTTP, HTTPS, FTP and FTPS (Added in 7.65.2). - -Older versions defaulted to all protocols except FILE, SCP and since 7.40.0 -SMB and SMBS. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(int argc, char **argv) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* pass in the URL from an external source */ - curl_easy_setopt(curl, CURLOPT_URL, argv[1]); - - /* only allow redirects to HTTP and HTTPS URLs */ - curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.85.0. -.SH RETURN VALUE -Returns CURLE_UNKNOWN_OPTION if the option is not implemented, -CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled, -CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_PROTOCOLS_STR (3), -.BR CURLINFO_SCHEME (3), -.BR CURLOPT_DEFAULT_PROTOCOL (3), -.BR CURLOPT_PROTOCOLS (3), -.BR CURLOPT_REDIR_PROTOCOLS (3) diff --git a/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.md b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.md new file mode 100644 index 000000000..9201a4b41 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_REDIR_PROTOCOLS_STR.md @@ -0,0 +1,94 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_REDIR_PROTOCOLS_STR +Section: 3 +Source: libcurl +See-also: + - CURLINFO_SCHEME (3) + - CURLOPT_DEFAULT_PROTOCOL (3) + - CURLOPT_PROTOCOLS (3) + - CURLOPT_PROTOCOLS_STR (3) + - CURLOPT_REDIR_PROTOCOLS (3) +--- + +# NAME + +CURLOPT_REDIR_PROTOCOLS_STR - protocols allowed to redirect to + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REDIR_PROTOCOLS_STR, + char *spec); +~~~ + +# DESCRIPTION + +Pass a pointer to a string that holds a comma-separated list of case +insensitive protocol names (URL schemes). That list limits what protocols +libcurl may use in a transfer that it follows to in a redirect when +CURLOPT_FOLLOWLOCATION(3) is enabled. This option allows applications to +limit specific transfers to only be allowed to use a subset of protocols in +redirections. + +Protocols denied by CURLOPT_PROTOCOLS_STR(3) are not overridden by this +option. + +By default libcurl allows HTTP, HTTPS, FTP and FTPS on redirects (since +7.65.2). + +These are the available protocols: + +DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, +MQTT, POP3, POP3S, RTMP, RTMPE, RTMPS, RTMPT, RTMPTE, RTMPTS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS, WSS + +You can set "ALL" as a short-cut to enable all protocols. Note that by setting +all, you may enable protocols that were not supported the day you write this +but are introduced in a future libcurl version. + +If trying to set a non-existing protocol or if no matching protocol at all is +set, it returns error. + +# DEFAULT + +HTTP, HTTPS, FTP and FTPS (Added in 7.65.2). + +Older versions defaulted to all protocols except FILE, SCP and since 7.40.0 +SMB and SMBS. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(int argc, char **argv) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* pass in the URL from an external source */ + curl_easy_setopt(curl, CURLOPT_URL, argv[1]); + + /* only allow redirects to HTTP and HTTPS URLs */ + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.85.0. + +# RETURN VALUE + +Returns CURLE_UNKNOWN_OPTION if the option is not implemented, +CURLE_UNSUPPORTED_PROTOCOL if a listed protocol is not supported or disabled, +CURLE_BAD_FUNCTION_ARGUMENT if no protocol is listed else CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_REFERER.3 b/docs/libcurl/opts/CURLOPT_REFERER.3 deleted file mode 100644 index 38d931b9f..000000000 --- a/docs/libcurl/opts/CURLOPT_REFERER.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_REFERER 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_REFERER \- the HTTP referer header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It is used to set the -Referer: header field in the HTTP request sent to the remote server. You can -set any custom header with \fICURLOPT_HTTPHEADER(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* tell it where we found the link to this place */ - curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html"); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -If built with HTTP support -.SH RETURN VALUE -Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLINFO_REFERER (3), -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_USERAGENT (3) diff --git a/docs/libcurl/opts/CURLOPT_REFERER.md b/docs/libcurl/opts/CURLOPT_REFERER.md new file mode 100644 index 000000000..6af19cb01 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_REFERER.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_REFERER +Section: 3 +Source: libcurl +See-also: + - CURLINFO_REDIRECT_URL (3) + - CURLINFO_REFERER (3) + - CURLOPT_HTTPHEADER (3) + - CURLOPT_USERAGENT (3) +--- + +# NAME + +CURLOPT_REFERER - the HTTP referer header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REFERER, char *where); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It is used to set the +Referer: header field in the HTTP request sent to the remote server. You can +set any custom header with CURLOPT_HTTPHEADER(3). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* tell it where we found the link to this place */ + curl_easy_setopt(curl, CURLOPT_REFERER, "https://example.org/me.html"); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +If built with HTTP support + +# RETURN VALUE + +Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.3 b/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.3 deleted file mode 100644 index f7a21feda..000000000 --- a/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_REQUEST_TARGET 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_REQUEST_TARGET \- alternative target for this request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string); -.fi -.SH DESCRIPTION -Pass a char * to string which libcurl uses in the upcoming request instead of -the path as extracted from the URL. - -libcurl passes on the verbatim string in its request without any filter or -other safe guards. That includes white space and control characters. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*"); - curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); - - /* issue an OPTIONS * request (no leading slash) */ - curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*"); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_HTTPGET (3), -.BR CURLOPT_PATH_AS_IS (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.md b/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.md new file mode 100644 index 000000000..cfc15d7b4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_REQUEST_TARGET.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_REQUEST_TARGET +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CUSTOMREQUEST (3) + - CURLOPT_HTTPGET (3) + - CURLOPT_PATH_AS_IS (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_REQUEST_TARGET - alternative target for this request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_REQUEST_TARGET, string); +~~~ + +# DESCRIPTION + +Pass a char pointer to string which libcurl uses in the upcoming request +instead of the path as extracted from the URL. + +libcurl passes on the verbatim string in its request without any filter or +other safe guards. That includes white space and control characters. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/*"); + curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); + + /* issue an OPTIONS * request (no leading slash) */ + curl_easy_setopt(curl, CURLOPT_REQUEST_TARGET, "*"); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RESOLVE.3 b/docs/libcurl/opts/CURLOPT_RESOLVE.3 deleted file mode 100644 index b0aa0e778..000000000 --- a/docs/libcurl/opts/CURLOPT_RESOLVE.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RESOLVE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RESOLVE \- provide custom host name to IP address resolves -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE, - struct curl_slist *hosts); -.SH DESCRIPTION -Pass a pointer to a linked list of strings with host name resolve information -to use for requests with this handle. The linked list should be a fully valid -list of \fBstruct curl_slist\fP structs properly filled in. Use -\fIcurl_slist_append(3)\fP to create the list and \fIcurl_slist_free_all(3)\fP -to clean up an entire list. - -Each resolve rule to add should be written using the format - -.nf - [+]HOST:PORT:ADDRESS[,ADDRESS] -.fi - -HOST is the name libcurl wants to resolve, PORT is the port number of the -service where libcurl wants to connect to the HOST and ADDRESS is one or more -numerical IP addresses. If you specify multiple IP addresses they need to be -separated by comma. If libcurl is built to support IPv6, each of the ADDRESS -entries can of course be either IPv4 or IPv6 style addressing. - -This option effectively populates the DNS cache with entries for the host+port -pair so redirects and everything that operations against the HOST+PORT instead -use your provided ADDRESS. - -The optional leading "+" specifies that the new entry should time-out. Entries -added without the leading plus character never times out whereas entries added -with "+HOST:..." times out just like ordinary DNS cache entries. - -If the DNS cache already has an entry for the given host+port pair, the new -entry overrides the former one. - -An ADDRESS provided by this option is only used if not restricted by the -setting of \fICURLOPT_IPRESOLVE(3)\fP to a different IP version. - -To remove names from the DNS cache again, to stop providing these fake -resolves, include a string in the linked list that uses the format - -.nf - -HOST:PORT -.fi - -The entry to remove must be prefixed with a dash, and the host name and port -number must exactly match what was added previously. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl; - struct curl_slist *host = NULL; - host = curl_slist_append(NULL, "example.com:443:127.0.0.1"); - - curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_RESOLVE, host); - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } - - curl_slist_free_all(host); -} -.fi -.SH AVAILABILITY -Added in 7.21.3. Removal support added in 7.42.0. - -Support for providing the ADDRESS within [brackets] was added in 7.57.0. - -Support for providing multiple IP addresses per entry was added in 7.59.0. - -Support for adding non-permanent entries by using the "+" prefix was added in -7.75.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CONNECT_TO (3), -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_IPRESOLVE (3) diff --git a/docs/libcurl/opts/CURLOPT_RESOLVE.md b/docs/libcurl/opts/CURLOPT_RESOLVE.md new file mode 100644 index 000000000..ce446bdbf --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RESOLVE.md @@ -0,0 +1,115 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RESOLVE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECT_TO (3) + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_IPRESOLVE (3) +--- + +# NAME + +CURLOPT_RESOLVE - provide custom hostname to IP address resolves + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVE, + struct curl_slist *hosts); +~~~ + +# DESCRIPTION + +Pass a pointer to a linked list of strings with hostname resolve information +to use for requests with this handle. The linked list should be a fully valid +list of **struct curl_slist** structs properly filled in. Use +curl_slist_append(3) to create the list and curl_slist_free_all(3) to clean up +an entire list. + +Each resolve rule to add should be written using the format + +~~~c + [+]HOST:PORT:ADDRESS[,ADDRESS] +~~~ + +HOST is the name libcurl wants to resolve, PORT is the port number of the +service where libcurl wants to connect to the HOST and ADDRESS is one or more +numerical IP addresses. If you specify multiple IP addresses they need to be +separated by comma. If libcurl is built to support IPv6, each of the ADDRESS +entries can of course be either IPv4 or IPv6 style addressing. + +This option effectively populates the DNS cache with entries for the host+port +pair so redirects and everything that operations against the HOST+PORT instead +use your provided ADDRESS. + +The optional leading "+" specifies that the new entry should time-out. Entries +added without the leading plus character never times out whereas entries added +with "+HOST:..." times out just like ordinary DNS cache entries. + +If the DNS cache already has an entry for the given host+port pair, the new +entry overrides the former one. + +An ADDRESS provided by this option is only used if not restricted by the +setting of CURLOPT_IPRESOLVE(3) to a different IP version. + +To remove names from the DNS cache again, to stop providing these fake +resolves, include a string in the linked list that uses the format + +~~~c + -HOST:PORT +~~~ + +The entry to remove must be prefixed with a dash, and the hostname and port +number must exactly match what was added previously. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl; + struct curl_slist *host = NULL; + host = curl_slist_append(NULL, "example.com:443:127.0.0.1"); + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_RESOLVE, host); + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + + curl_slist_free_all(host); +} +~~~ + +# AVAILABILITY + +Added in 7.21.3. Removal support added in 7.42.0. + +Support for providing the ADDRESS within [brackets] was added in 7.57.0. + +Support for providing multiple IP addresses per entry was added in 7.59.0. + +Support for adding non-permanent entries by using the "+" prefix was added in +7.75.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.3 b/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.3 deleted file mode 100644 index 84bc081a6..000000000 --- a/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RESOLVER_START_DATA 3 "14 Feb 2018" libcurl libcurl -.SH NAME -CURLOPT_RESOLVER_START_DATA \- pointer passed to the resolver start callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVER_START_DATA, - void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP is be untouched by libcurl and passed as the third -argument in the resolver start callback set with -\fICURLOPT_RESOLVER_START_FUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -static int resolver_start_cb(void *resolver_state, void *reserved, - void *userdata) -{ - (void)reserved; - printf("Received resolver_state=%p userdata=%p\\n", - resolver_state, userdata); - return 0; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb); - curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl); - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.59.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PREREQFUNCTION (3), -.BR CURLOPT_RESOLVER_START_FUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.md b/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.md new file mode 100644 index 000000000..f34cf8bd6 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RESOLVER_START_DATA.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RESOLVER_START_DATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PREREQFUNCTION (3) + - CURLOPT_RESOLVER_START_FUNCTION (3) +--- + +# NAME + +CURLOPT_RESOLVER_START_DATA - pointer passed to the resolver start callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESOLVER_START_DATA, + void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* is be untouched by libcurl and passed as the third +argument in the resolver start callback set with +CURLOPT_RESOLVER_START_FUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +static int resolver_start_cb(void *resolver_state, void *reserved, + void *userdata) +{ + (void)reserved; + printf("Received resolver_state=%p userdata=%p\n", + resolver_state, userdata); + return 0; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb); + curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl); + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.59.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.3 deleted file mode 100644 index bd2c1189f..000000000 --- a/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RESOLVER_START_FUNCTION 3 "14 Feb 2018" libcurl libcurl -.SH NAME -CURLOPT_RESOLVER_START_FUNCTION \- callback called before a new name resolve is started -.SH SYNOPSIS -.nf -#include - -int resolver_start_cb(void *resolver_state, void *reserved, void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, - CURLOPT_RESOLVER_START_FUNCTION, - resolver_start_cb); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl every time before a new resolve -request is started. - -\fIresolver_state\fP points to a backend-specific resolver state. Currently -only the ares resolver backend has a resolver state. It can be used to set up -any desired option on the ares channel before it's used, for example setting up -socket callback options. - -\fIreserved\fP is reserved. - -\fIuserdata\fP is the user pointer set with the -\fICURLOPT_RESOLVER_START_DATA(3)\fP option. - -The callback must return 0 on success. Returning a non-zero value causes the -resolve to fail. -.SH DEFAULT -NULL (No callback) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -static int start_cb(void *resolver_state, void *reserved, - void *userdata) -{ - (void)reserved; - printf("Received resolver_state=%p userdata=%p\\n", - resolver_state, userdata); - return 0; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb); - curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl); - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.59.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PREREQFUNCTION (3), -.BR CURLOPT_RESOLVER_START_DATA (3) diff --git a/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.md b/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.md new file mode 100644 index 000000000..a9b490726 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RESOLVER_START_FUNCTION.md @@ -0,0 +1,88 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RESOLVER_START_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PREREQFUNCTION (3) + - CURLOPT_RESOLVER_START_DATA (3) +--- + +# NAME + +CURLOPT_RESOLVER_START_FUNCTION - callback called before a new name resolve is started + +# SYNOPSIS + +~~~c +#include + +int resolver_start_cb(void *resolver_state, void *reserved, void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, + CURLOPT_RESOLVER_START_FUNCTION, + resolver_start_cb); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl every time before a new resolve +request is started. + +*resolver_state* points to a backend-specific resolver state. Currently only +the ares resolver backend has a resolver state. It can be used to set up any +desired option on the ares channel before it is used, for example setting up +socket callback options. + +*reserved* is reserved. + +*userdata* is the user pointer set with the +CURLOPT_RESOLVER_START_DATA(3) option. + +The callback must return 0 on success. Returning a non-zero value causes the +resolve to fail. + +# DEFAULT + +NULL (No callback) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +static int start_cb(void *resolver_state, void *reserved, + void *userdata) +{ + (void)reserved; + printf("Received resolver_state=%p userdata=%p\n", + resolver_state, userdata); + return 0; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb); + curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl); + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.59.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM.3 b/docs/libcurl/opts/CURLOPT_RESUME_FROM.3 deleted file mode 100644 index 30c7fea9e..000000000 --- a/docs/libcurl/opts/CURLOPT_RESUME_FROM.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RESUME_FROM 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RESUME_FROM \- offset to resume transfer from -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM, long from); -.fi -.SH DESCRIPTION -Pass a long as parameter. It contains the offset in number of bytes that you -want the transfer to start from. Set this option to 0 to make the transfer -start from the beginning (effectively disabling resume). For FTP, set this -option to -1 to make the transfer start from the end of the target file -(useful to continue an interrupted upload). - -When doing uploads with FTP, the resume position is where in the local/source -file libcurl should try to resume the upload from and it then appends the -source file to the remote target file. - -If you need to resume a transfer beyond the 2GB limit, use -\fICURLOPT_RESUME_FROM_LARGE(3)\fP instead. -.SH DEFAULT -0, not used -.SH PROTOCOLS -HTTP, FTP, SFTP, FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - long size_of_file; - - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); - - /* resume upload at byte index 200 */ - curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L); - - /* ask for upload */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - - /* set total data amount to expect */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_RESUME_FROM_LARGE (3), -.BR CURLOPT_RANGE (3), -.BR CURLOPT_INFILESIZE (3) diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM.md b/docs/libcurl/opts/CURLOPT_RESUME_FROM.md new file mode 100644 index 000000000..c8de1ee6b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RESUME_FROM.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RESUME_FROM +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INFILESIZE (3) + - CURLOPT_RANGE (3) + - CURLOPT_RESUME_FROM_LARGE (3) +--- + +# NAME + +CURLOPT_RESUME_FROM - offset to resume transfer from + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM, long from); +~~~ + +# DESCRIPTION + +Pass a long as parameter. It contains the offset in number of bytes that you +want the transfer to start from. Set this option to 0 to make the transfer +start from the beginning (effectively disabling resume). For FTP, set this +option to -1 to make the transfer start from the end of the target file +(useful to continue an interrupted upload). + +When doing uploads with FTP, the resume position is where in the local/source +file libcurl should try to resume the upload from and it then appends the +source file to the remote target file. + +If you need to resume a transfer beyond the 2GB limit, use +CURLOPT_RESUME_FROM_LARGE(3) instead. + +# DEFAULT + +0, not used + +# PROTOCOLS + +HTTP, FTP, SFTP, FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + long size_of_file; + + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); + + /* resume upload at byte index 200 */ + curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L); + + /* ask for upload */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + + /* set total data amount to expect */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3 b/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3 deleted file mode 100644 index e5d91bb89..000000000 --- a/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RESUME_FROM_LARGE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RESUME_FROM_LARGE \- offset to resume transfer from -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM_LARGE, - curl_off_t from); -.SH DESCRIPTION -Pass a curl_off_t as parameter. It contains the offset in number of bytes that -you want the transfer to start from. Set this option to 0 to make the transfer -start from the beginning (effectively disabling resume). For FTP, set this -option to -1 to make the transfer start from the end of the target file -(useful to continue an interrupted upload). - -When doing uploads with FTP, the resume position is where in the local/source -file libcurl should try to resume the upload from and it appends the source -file to the remote target file. -.SH DEFAULT -0, not used -.SH PROTOCOLS -HTTP, FTP, SFTP, FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_off_t resume_position; /* get it somehow */ - curl_off_t file_size; /* get it somehow as well */ - - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); - - /* resuming upload at this position, possibly beyond 2GB */ - curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position); - - /* ask for upload */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - - /* set total data amount to expect */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.11.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_INFILESIZE_LARGE (3), -.BR CURLOPT_RANGE (3), -.BR CURLOPT_RESUME_FROM (3) diff --git a/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.md b/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.md new file mode 100644 index 000000000..950a4f496 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RESUME_FROM_LARGE.md @@ -0,0 +1,79 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RESUME_FROM_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INFILESIZE_LARGE (3) + - CURLOPT_RANGE (3) + - CURLOPT_RESUME_FROM (3) +--- + +# NAME + +CURLOPT_RESUME_FROM_LARGE - offset to resume transfer from + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM_LARGE, + curl_off_t from); +~~~ + +# DESCRIPTION + +Pass a curl_off_t as parameter. It contains the offset in number of bytes that +you want the transfer to start from. Set this option to 0 to make the transfer +start from the beginning (effectively disabling resume). For FTP, set this +option to -1 to make the transfer start from the end of the target file +(useful to continue an interrupted upload). + +When doing uploads with FTP, the resume position is where in the local/source +file libcurl should try to resume the upload from and it appends the source +file to the remote target file. + +# DEFAULT + +0, not used + +# PROTOCOLS + +HTTP, FTP, SFTP, FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_off_t resume_position; /* get it somehow */ + curl_off_t file_size; /* get it somehow as well */ + + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); + + /* resuming upload at this position, possibly beyond 2GB */ + curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position); + + /* ask for upload */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + + /* set total data amount to expect */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.11.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.3 b/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.3 deleted file mode 100644 index 4faf8020a..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_CLIENT_CSEQ 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_CLIENT_CSEQ \- RTSP client CSEQ number -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_CLIENT_CSEQ, long cseq); -.fi -.SH DESCRIPTION -Pass a long to set the CSEQ number to issue for the next RTSP request. Useful -if the application is resuming a previously broken connection. The CSEQ -increments from this new number henceforth. -.SH DEFAULT -0 -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 1234L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_RTSP_CLIENT_CSEQ (3), -.BR CURLINFO_RTSP_SERVER_CSEQ (3), -.BR CURLOPT_RTSP_REQUEST (3), -.BR CURLOPT_RTSP_SERVER_CSEQ (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.md b/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.md new file mode 100644 index 000000000..6c83663dc --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_CLIENT_CSEQ.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_CLIENT_CSEQ +Section: 3 +Source: libcurl +See-also: + - CURLINFO_RTSP_CLIENT_CSEQ (3) + - CURLINFO_RTSP_SERVER_CSEQ (3) + - CURLOPT_RTSP_REQUEST (3) + - CURLOPT_RTSP_SERVER_CSEQ (3) +--- + +# NAME + +CURLOPT_RTSP_CLIENT_CSEQ - RTSP client CSEQ number + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_CLIENT_CSEQ, long cseq); +~~~ + +# DESCRIPTION + +Pass a long to set the CSEQ number to issue for the next RTSP request. Useful +if the application is resuming a previously broken connection. The CSEQ +increments from this new number henceforth. + +# DEFAULT + +0 + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 1234L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.3 b/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.3 deleted file mode 100644 index d62cf1d18..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_REQUEST 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_REQUEST \- RTSP request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_REQUEST, long request); -.fi -.SH DESCRIPTION -Tell libcurl what kind of RTSP request to make. Pass one of the following RTSP -enum values as a long in the \fIrequest\fP argument. Unless noted otherwise, -commands require the Session ID to be initialized. -.IP CURL_RTSPREQ_OPTIONS -Used to retrieve the available methods of the server. The application is -responsible for parsing and obeying the response. The session ID is not needed -for this method. -.IP CURL_RTSPREQ_DESCRIBE -Used to get the low level description of a stream. The application should note -what formats it understands in the \fI'Accept:'\fP header. Unless set -manually, libcurl automatically adds in \fI'Accept: application/sdp'\fP. -Time-condition headers are added to Describe requests if the -\fICURLOPT_TIMECONDITION(3)\fP option is used. \fB(The session ID is not -needed for this method)\fP -.IP CURL_RTSPREQ_ANNOUNCE -When sent by a client, this method changes the description of the session. For -example, if a client is using the server to record a meeting, the client can -use Announce to inform the server of all the meta-information about the -session. ANNOUNCE acts like an HTTP PUT or POST just like -\fICURL_RTSPREQ_SET_PARAMETER\fP -.IP CURL_RTSPREQ_SETUP -Setup is used to initialize the transport layer for the session. The -application must set the desired Transport options for a session by using the -\fICURLOPT_RTSP_TRANSPORT(3)\fP option prior to calling setup. If no session -ID is currently set with \fICURLOPT_RTSP_SESSION_ID(3)\fP, libcurl extracts -and uses the session ID in the response to this request. The session ID is not -needed for this method. -.IP CURL_RTSPREQ_PLAY -Send a Play command to the server. Use the \fICURLOPT_RANGE(3)\fP option to -modify the playback time (e.g. \fInpt=10-15\fP). -.IP CURL_RTSPREQ_PAUSE -Send a Pause command to the server. Use the \fICURLOPT_RANGE(3)\fP option with -a single value to indicate when the stream should be -halted. (e.g. \fInpt=25\fP) -.IP CURL_RTSPREQ_TEARDOWN -This command terminates an RTSP session. Simply closing a connection does not -terminate the RTSP session since it is valid to control an RTSP session over -different connections. -.IP CURL_RTSPREQ_GET_PARAMETER -Retrieve a parameter from the server. By default, libcurl adds a -\fIContent-Type: text/parameters\fP header on all non-empty requests unless a -custom one is set. GET_PARAMETER acts just like an HTTP PUT or POST (see -\fICURL_RTSPREQ_SET_PARAMETER\fP). Applications wishing to send a heartbeat -message (e.g. in the presence of a server-specified timeout) should send use -an empty GET_PARAMETER request. -.IP CURL_RTSPREQ_SET_PARAMETER -Set a parameter on the server. By default, libcurl uses a -\fIContent-Type: text/parameters\fP header unless a custom one is set. -The interaction with SET_PARAMETER is much like an HTTP PUT or POST. An -application may either use \fICURLOPT_UPLOAD(3)\fP with -\fICURLOPT_READDATA(3)\fP like a HTTP PUT, or it may use -\fICURLOPT_POSTFIELDS(3)\fP like an HTTP POST. No chunked transfers are -allowed, so the application must set the \fICURLOPT_INFILESIZE(3)\fP in the -former and \fICURLOPT_POSTFIELDSIZE(3)\fP in the latter. Also, there is no use -of multi-part POSTs within RTSP. -.IP CURL_RTSPREQ_RECORD -Used to tell the server to record a session. Use the \fICURLOPT_RANGE(3)\fP -option to modify the record time. -.IP CURL_RTSPREQ_RECEIVE -This is a special request because it does not send any data to the server. The -application may call this function in order to receive interleaved RTP -data. It returns after processing one read buffer of data in order to give the -application a chance to run. -.SH DEFAULT -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - /* ask for options! */ - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_RTSP_SESSION_ID (3), -.BR CURLOPT_RTSP_STREAM_URI (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.md b/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.md new file mode 100644 index 000000000..d56b34dc9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_REQUEST.md @@ -0,0 +1,139 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_REQUEST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_RTSP_SESSION_ID (3) + - CURLOPT_RTSP_STREAM_URI (3) +--- + +# NAME + +CURLOPT_RTSP_REQUEST - RTSP request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_REQUEST, long request); +~~~ + +# DESCRIPTION + +Tell libcurl what kind of RTSP request to make. Pass one of the following RTSP +enum values as a long in the *request* argument. Unless noted otherwise, +commands require the Session ID to be initialized. + +## CURL_RTSPREQ_OPTIONS + +Used to retrieve the available methods of the server. The application is +responsible for parsing and obeying the response. The session ID is not needed +for this method. + +## CURL_RTSPREQ_DESCRIBE + +Used to get the low level description of a stream. The application should note +what formats it understands in the *'Accept:'* header. Unless set manually, +libcurl automatically adds in *'Accept: application/sdp'*. Time-condition +headers are added to Describe requests if the CURLOPT_TIMECONDITION(3) +option is used. (The session ID is not needed for this method) + +## CURL_RTSPREQ_ANNOUNCE + +When sent by a client, this method changes the description of the session. For +example, if a client is using the server to record a meeting, the client can +use Announce to inform the server of all the meta-information about the +session. ANNOUNCE acts like an HTTP PUT or POST just like +*CURL_RTSPREQ_SET_PARAMETER* + +## CURL_RTSPREQ_SETUP + +Setup is used to initialize the transport layer for the session. The +application must set the desired Transport options for a session by using the +CURLOPT_RTSP_TRANSPORT(3) option prior to calling setup. If no session +ID is currently set with CURLOPT_RTSP_SESSION_ID(3), libcurl extracts +and uses the session ID in the response to this request. The session ID is not +needed for this method. + +## CURL_RTSPREQ_PLAY + +Send a Play command to the server. Use the CURLOPT_RANGE(3) option to +modify the playback time (e.g. *npt=10-15*). + +## CURL_RTSPREQ_PAUSE + +Send a Pause command to the server. Use the CURLOPT_RANGE(3) option with +a single value to indicate when the stream should be +halted. (e.g. *npt=25*) + +## CURL_RTSPREQ_TEARDOWN + +This command terminates an RTSP session. Simply closing a connection does not +terminate the RTSP session since it is valid to control an RTSP session over +different connections. + +## CURL_RTSPREQ_GET_PARAMETER + +Retrieve a parameter from the server. By default, libcurl adds a +*Content-Type: text/parameters* header on all non-empty requests unless a +custom one is set. GET_PARAMETER acts just like an HTTP PUT or POST (see +*CURL_RTSPREQ_SET_PARAMETER*). Applications wishing to send a heartbeat +message (e.g. in the presence of a server-specified timeout) should send use +an empty GET_PARAMETER request. + +## CURL_RTSPREQ_SET_PARAMETER + +Set a parameter on the server. By default, libcurl uses a *Content-Type: +text/parameters* header unless a custom one is set. The interaction with +SET_PARAMETER is much like an HTTP PUT or POST. An application may either use +CURLOPT_UPLOAD(3) with CURLOPT_READDATA(3) like an HTTP PUT, or it may use +CURLOPT_POSTFIELDS(3) like an HTTP POST. No chunked transfers are allowed, so +the application must set the CURLOPT_INFILESIZE(3) in the former and +CURLOPT_POSTFIELDSIZE(3) in the latter. Also, there is no use of multi-part +POSTs within RTSP. + +## CURL_RTSPREQ_RECORD + +Used to tell the server to record a session. Use the CURLOPT_RANGE(3) +option to modify the record time. + +## CURL_RTSPREQ_RECEIVE + +This is a special request because it does not send any data to the server. The +application may call this function in order to receive interleaved RTP +data. It returns after processing one read buffer of data in order to give the +application a chance to run. + +# DEFAULT + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + /* ask for options! */ + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.3 b/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.3 deleted file mode 100644 index 5c75bd149..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_SERVER_CSEQ 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_SERVER_CSEQ \- RTSP server CSEQ number -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_SERVER_CSEQ, long cseq); -.fi -.SH DESCRIPTION -Pass a long to set the CSEQ number to expect for the next RTSP Server->Client -request. \fBNOTE\fP: this feature (listening for Server requests) is -unimplemented. -.SH DEFAULT -0 -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - curl_easy_setopt(curl, CURLOPT_RTSP_SERVER_CSEQ, 1234L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLINFO_RTSP_SERVER_CSEQ (3), -.BR CURLOPT_RTSP_CLIENT_CSEQ (3), -.BR CURLOPT_RTSP_STREAM_URI (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.md b/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.md new file mode 100644 index 000000000..521084388 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_SERVER_CSEQ.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_SERVER_CSEQ +Section: 3 +Source: libcurl +See-also: + - CURLINFO_RTSP_SERVER_CSEQ (3) + - CURLOPT_RTSP_CLIENT_CSEQ (3) + - CURLOPT_RTSP_STREAM_URI (3) +--- + +# NAME + +CURLOPT_RTSP_SERVER_CSEQ - RTSP server CSEQ number + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_SERVER_CSEQ, long cseq); +~~~ + +# DESCRIPTION + +Pass a long to set the CSEQ number to expect for the next RTSP Server->Client +request. **NOTE**: this feature (listening for Server requests) is +unimplemented. + +# DEFAULT + +0 + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + curl_easy_setopt(curl, CURLOPT_RTSP_SERVER_CSEQ, 1234L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.3 b/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.3 deleted file mode 100644 index acb8e3611..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_SESSION_ID 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_SESSION_ID \- RTSP session ID -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_SESSION_ID, char *id); -.fi -.SH DESCRIPTION -Pass a char * as a parameter to set the value of the current RTSP Session ID -for the handle. Useful for resuming an in-progress session. Once this value is -set to any non-NULL value, libcurl returns \fICURLE_RTSP_SESSION_ERROR\fP if -ID received from the server does not match. If unset (or set to NULL), libcurl -automatically sets the ID the first time the server sets it in a response. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - char *prev_id; /* saved from before somehow */ - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, prev_id); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_RTSP_REQUEST (3), -.BR CURLOPT_RTSP_STREAM_URI (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.md b/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.md new file mode 100644 index 000000000..8af7f7c59 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_SESSION_ID.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_SESSION_ID +Section: 3 +Source: libcurl +See-also: + - CURLOPT_RTSP_REQUEST (3) + - CURLOPT_RTSP_STREAM_URI (3) +--- + +# NAME + +CURLOPT_RTSP_SESSION_ID - RTSP session ID + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_SESSION_ID, char *id); +~~~ + +# DESCRIPTION + +Pass a char pointer as a parameter to set the value of the current RTSP +Session ID for the handle. Useful for resuming an in-progress session. Once +this value is set to any non-NULL value, libcurl returns +*CURLE_RTSP_SESSION_ERROR* if ID received from the server does not match. If +unset (or set to NULL), libcurl automatically sets the ID the first time the +server sets it in a response. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + char *prev_id; /* saved from before somehow */ + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, prev_id); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.3 b/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.3 deleted file mode 100644 index d2c7a49da..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_STREAM_URI 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_STREAM_URI \- RTSP stream URI -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_STREAM_URI, char *URI); -.fi -.SH DESCRIPTION -Set the stream \fIURI\fP to operate on by passing a char * . For example, a -single session may be controlling \fIrtsp://foo/twister/audio\fP and -\fIrtsp://foo/twister/video\fP and the application can switch to the -appropriate stream using this option. If unset, libcurl defaults to operating -on generic server options by passing '*' in the place of the RTSP Stream -URI. This option is distinct from \fICURLOPT_URL(3)\fP. When working with -RTSP, the \fICURLOPT_RTSP_STREAM_URI(3)\fP indicates what URL to send to the -server in the request header while the \fICURLOPT_URL(3)\fP indicates where to -make the connection to. (e.g. the \fICURLOPT_URL(3)\fP for the above examples -might be set to \fIrtsp://foo/twister\fP - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -\&'*' -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, - "rtsp://foo.example.com/twister/video"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_RTSP_REQUEST (3), -.BR CURLOPT_RTSP_TRANSPORT (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.md b/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.md new file mode 100644 index 000000000..e138a3cd9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_STREAM_URI.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_STREAM_URI +Section: 3 +Source: libcurl +See-also: + - CURLOPT_RTSP_REQUEST (3) + - CURLOPT_RTSP_TRANSPORT (3) +--- + +# NAME + +CURLOPT_RTSP_STREAM_URI - RTSP stream URI + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_STREAM_URI, char *URI); +~~~ + +# DESCRIPTION + +Set the stream *URI* to operate on by passing a char * . For example, a single +session may be controlling *rtsp://foo/twister/audio* and +*rtsp://foo/twister/video* and the application can switch to the appropriate +stream using this option. If unset, libcurl defaults to operating on generic +server options by passing '*' in the place of the RTSP Stream URI. This option +is distinct from CURLOPT_URL(3). When working with RTSP, the +CURLOPT_RTSP_STREAM_URI(3) indicates what URL to send to the server in the +request header while the CURLOPT_URL(3) indicates where to make the connection +to. (e.g. the CURLOPT_URL(3) for the above examples might be set to +*rtsp://foo/twister* + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +"*" + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, + "rtsp://foo.example.com/twister/video"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.3 b/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.3 deleted file mode 100644 index 9017f9154..000000000 --- a/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_RTSP_TRANSPORT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_RTSP_TRANSPORT \- RTSP Transport: header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_TRANSPORT, - char *transport); -.SH DESCRIPTION -Pass a char * to tell libcurl what to pass for the Transport: header for this -RTSP session. This is mainly a convenience method to avoid needing to set a -custom Transport: header for every SETUP request. The application must set a -Transport: header before issuing a SETUP request. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -RTSP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "RTP/AVP;unicast;client_port=4588-4589"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.20.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_RTSP_REQUEST (3), -.BR CURLOPT_RTSP_SESSION_ID (3) diff --git a/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.md b/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.md new file mode 100644 index 000000000..b8083967d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_RTSP_TRANSPORT.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_RTSP_TRANSPORT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_RTSP_REQUEST (3) + - CURLOPT_RTSP_SESSION_ID (3) +--- + +# NAME + +CURLOPT_RTSP_TRANSPORT - RTSP Transport: header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RTSP_TRANSPORT, + char *transport); +~~~ + +# DESCRIPTION + +Pass a char pointer to tell libcurl what to pass for the Transport: header for +this RTSP session. This is mainly a convenience method to avoid needing to set +a custom Transport: header for every SETUP request. The application must set a +Transport: header before issuing a SETUP request. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +RTSP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "rtsp://example.com/"); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "RTP/AVP;unicast;client_port=4588-4589"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.20.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.3 b/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.3 deleted file mode 100644 index c06a665e2..000000000 --- a/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SASL_AUTHZID 3 "11 Sep 2019" libcurl libcurl -.SH NAME -CURLOPT_SASL_AUTHZID \- authorization identity (identity to act as) -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SASL_AUTHZID, char *authzid); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -authorization identity (\fIauthzid\fP) for the transfer. Only applicable to -the PLAIN SASL authentication mechanism where it is optional. - -When not specified only the authentication identity (\fIauthcid\fP) as -specified by the username is sent to the server, along with the password. The -server derives a \fIauthzid\fP from the \fIauthcid\fP when not provided, which -it then uses internally. - -When the \fIauthzid\fP is specified, the use of which is server dependent, it -can be used to access another user's inbox, that the user has been granted -access to, or a shared mailbox for example. -.SH DEFAULT -blank -.SH PROTOCOLS -IMAP, LDAP, POP3 and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "imap://example.com/"); - curl_easy_setopt(curl, CURLOPT_USERNAME, "Kurt"); - curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq"); - curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "Ursel"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.66.0. Support for OpenLDAP added in 7.82.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_USERNAME (3), -.BR CURLOPT_USERPWD (3) diff --git a/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.md b/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.md new file mode 100644 index 000000000..5ff67c6ab --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SASL_AUTHZID.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SASL_AUTHZID +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PASSWORD (3) + - CURLOPT_USERNAME (3) + - CURLOPT_USERPWD (3) +--- + +# NAME + +CURLOPT_SASL_AUTHZID - authorization identity (identity to act as) + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SASL_AUTHZID, char *authzid); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the +null-terminated authorization identity (*authzid*) for the transfer. Only +applicable to the PLAIN SASL authentication mechanism where it is optional. + +When not specified only the authentication identity (*authcid*) as +specified by the username is sent to the server, along with the password. The +server derives a *authzid* from the *authcid* when not provided, which +it then uses internally. + +When the *authzid* is specified, the use of which is server dependent, it +can be used to access another user's inbox, that the user has been granted +access to, or a shared mailbox for example. + +# DEFAULT + +blank + +# PROTOCOLS + +IMAP, LDAP, POP3 and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "imap://example.com/"); + curl_easy_setopt(curl, CURLOPT_USERNAME, "Kurt"); + curl_easy_setopt(curl, CURLOPT_PASSWORD, "xipj3plmq"); + curl_easy_setopt(curl, CURLOPT_SASL_AUTHZID, "Ursel"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.66.0. Support for OpenLDAP added in 7.82.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SASL_IR.3 b/docs/libcurl/opts/CURLOPT_SASL_IR.3 deleted file mode 100644 index 50ec074a0..000000000 --- a/docs/libcurl/opts/CURLOPT_SASL_IR.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SASL_IR 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SASL_IR \- send initial response in first packet -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SASL_IR, long enable); -.fi -.SH DESCRIPTION -Pass a long. If the value is 1, curl sends the initial response to the server -in the first authentication packet in order to reduce the number of ping pong -requests. Only applicable to the following supporting SASL authentication -mechanisms: - -* Login -* Plain -* GSSAPI -* NTLM -* OAuth 2.0 - -Note: Whilst IMAP supports this option there is no need to explicitly set it, -as libcurl can determine the feature itself when the server supports the -SASL-IR CAPABILITY. -.SH DEFAULT -0 -.SH PROTOCOLS -IMAP, POP3 and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); - curl_easy_setopt(curl, CURLOPT_SASL_IR, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.31.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_AUTH (3), -.BR CURLOPT_MAIL_FROM (3), -.BR CURLOPT_SASL_AUTHZID (3) diff --git a/docs/libcurl/opts/CURLOPT_SASL_IR.md b/docs/libcurl/opts/CURLOPT_SASL_IR.md new file mode 100644 index 000000000..204734d01 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SASL_IR.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SASL_IR +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_AUTH (3) + - CURLOPT_MAIL_FROM (3) + - CURLOPT_SASL_AUTHZID (3) +--- + +# NAME + +CURLOPT_SASL_IR - send initial response in first packet + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SASL_IR, long enable); +~~~ + +# DESCRIPTION + +Pass a long. If the value is 1, curl sends the initial response to the server +in the first authentication packet in order to reduce the number of ping pong +requests. Only applicable to the following supporting SASL authentication +mechanisms: + +* Login +* Plain +* GSSAPI +* NTLM +* OAuth 2.0 + +Note: Whilst IMAP supports this option there is no need to explicitly set it, +as libcurl can determine the feature itself when the server supports the +SASL-IR CAPABILITY. + +# DEFAULT + +0 + +# PROTOCOLS + +IMAP, POP3 and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); + curl_easy_setopt(curl, CURLOPT_SASL_IR, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.31.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SEEKDATA.3 b/docs/libcurl/opts/CURLOPT_SEEKDATA.3 deleted file mode 100644 index eed02af19..000000000 --- a/docs/libcurl/opts/CURLOPT_SEEKDATA.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SEEKDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SEEKDATA \- pointer passed to the seek callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SEEKDATA, void *pointer); -.fi -.SH DESCRIPTION -Data \fIpointer\fP to pass to the seek callback function. If you use the -\fICURLOPT_SEEKFUNCTION(3)\fP option, this is the pointer you get as input. -.SH DEFAULT -If you do not set this, NULL is passed to the callback. -.SH PROTOCOLS -HTTP, FTP, SFTP -.SH EXAMPLE -.nf -#include /* for lseek() */ - -struct data { - int our_fd; -}; - -static int seek_cb(void *clientp, curl_off_t offset, int origin) -{ - struct data *d = (struct data *)clientp; - lseek(d->our_fd, offset, origin); - return CURL_SEEKFUNC_OK; -} - -int main(void) -{ - struct data seek_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb); - curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data); - } -} -.fi -.SH AVAILABILITY -Added in 7.18.0 -.SH RETURN VALUE -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_IOCTLFUNCTION (3), -.BR CURLOPT_SEEKFUNCTION (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_SEEKDATA.md b/docs/libcurl/opts/CURLOPT_SEEKDATA.md new file mode 100644 index 000000000..9392c2366 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SEEKDATA.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SEEKDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_IOCTLFUNCTION (3) + - CURLOPT_SEEKFUNCTION (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_SEEKDATA - pointer passed to the seek callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SEEKDATA, void *pointer); +~~~ + +# DESCRIPTION + +Data *pointer* to pass to the seek callback function. If you use the +CURLOPT_SEEKFUNCTION(3) option, this is the pointer you get as input. + +# DEFAULT + +If you do not set this, NULL is passed to the callback. + +# PROTOCOLS + +HTTP, FTP, SFTP + +# EXAMPLE + +~~~c +#include /* for lseek() */ + +struct data { + int our_fd; +}; + +static int seek_cb(void *clientp, curl_off_t offset, int origin) +{ + struct data *d = (struct data *)clientp; + lseek(d->our_fd, offset, origin); + return CURL_SEEKFUNC_OK; +} + +int main(void) +{ + struct data seek_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb); + curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data); + } +} +~~~ + +# AVAILABILITY + +Added in 7.18.0 + +# RETURN VALUE + diff --git a/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.3 b/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.3 deleted file mode 100644 index 649eb2ae2..000000000 --- a/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SEEKFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SEEKFUNCTION \- user callback for seeking in input stream -.SH SYNOPSIS -.nf -#include - -/* These are the return codes for the seek callbacks */ -#define CURL_SEEKFUNC_OK 0 -#define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */ -#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking cannot be done, so - libcurl might try other means instead */ - -int seek_callback(void *clientp, curl_off_t offset, int origin); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This function gets called by libcurl to seek to a certain position in the -input stream and can be used to fast forward a file in a resumed upload -(instead of reading all uploaded bytes with the normal read -function/callback). It is also called to rewind a stream when data has already -been sent to the server and needs to be sent again. This may happen when doing -an HTTP PUT or POST with a multi-pass authentication method, or when an -existing HTTP connection is reused too late and the server closes the -connection. The function shall work like fseek(3) or lseek(3) and it gets -SEEK_SET, SEEK_CUR or SEEK_END as argument for \fIorigin\fP, although libcurl -currently only passes SEEK_SET. - -\fIclientp\fP is the pointer you set with \fICURLOPT_SEEKDATA(3)\fP. - -The callback function must return \fICURL_SEEKFUNC_OK\fP on success, -\fICURL_SEEKFUNC_FAIL\fP to cause the upload operation to fail or -\fICURL_SEEKFUNC_CANTSEEK\fP to indicate that while the seek failed, libcurl -is free to work around the problem if possible. The latter can sometimes be -done by instead reading from the input or similar. - -If you forward the input arguments directly to fseek(3) or lseek(3), note that -the data type for \fIoffset\fP is not the same as defined for curl_off_t on -many systems! -.SH DEFAULT -By default, this is NULL and unused. -.SH PROTOCOLS -HTTP, FTP, SFTP -.SH EXAMPLE -.nf -#include /* for lseek */ - -struct data { - int our_fd; -}; -static int seek_cb(void *clientp, curl_off_t offset, int origin) -{ - struct data *d = (struct data *)clientp; - lseek(d->our_fd, offset, origin); - return CURL_SEEKFUNC_OK; -} - -int main(void) -{ - struct data seek_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb); - curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data); - } -} -.fi -.SH AVAILABILITY -Added in 7.18.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_IOCTLFUNCTION (3), -.BR CURLOPT_SEEKDATA (3), -.BR CURLOPT_STDERR (3) diff --git a/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.md b/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.md new file mode 100644 index 000000000..102bdcfc7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.md @@ -0,0 +1,102 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SEEKFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_IOCTLFUNCTION (3) + - CURLOPT_SEEKDATA (3) + - CURLOPT_STDERR (3) +--- + +# NAME + +CURLOPT_SEEKFUNCTION - user callback for seeking in input stream + +# SYNOPSIS + +~~~c +#include + +/* These are the return codes for the seek callbacks */ +#define CURL_SEEKFUNC_OK 0 +#define CURL_SEEKFUNC_FAIL 1 /* fail the entire transfer */ +#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking cannot be done, so + libcurl might try other means instead */ + +int seek_callback(void *clientp, curl_off_t offset, int origin); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This function gets called by libcurl to seek to a certain position in the +input stream and can be used to fast forward a file in a resumed upload +(instead of reading all uploaded bytes with the normal read +function/callback). It is also called to rewind a stream when data has already +been sent to the server and needs to be sent again. This may happen when doing +an HTTP PUT or POST with a multi-pass authentication method, or when an +existing HTTP connection is reused too late and the server closes the +connection. The function shall work like fseek(3) or lseek(3) and it gets +SEEK_SET, SEEK_CUR or SEEK_END as argument for *origin*, although libcurl +currently only passes SEEK_SET. + +*clientp* is the pointer you set with CURLOPT_SEEKDATA(3). + +The callback function must return *CURL_SEEKFUNC_OK* on success, +*CURL_SEEKFUNC_FAIL* to cause the upload operation to fail or +*CURL_SEEKFUNC_CANTSEEK* to indicate that while the seek failed, libcurl +is free to work around the problem if possible. The latter can sometimes be +done by instead reading from the input or similar. + +If you forward the input arguments directly to fseek(3) or lseek(3), note that +the data type for *offset* is not the same as defined for curl_off_t on +many systems! + +# DEFAULT + +By default, this is NULL and unused. + +# PROTOCOLS + +HTTP, FTP, SFTP + +# EXAMPLE + +~~~c +#include /* for lseek */ + +struct data { + int our_fd; +}; +static int seek_cb(void *clientp, curl_off_t offset, int origin) +{ + struct data *d = (struct data *)clientp; + lseek(d->our_fd, offset, origin); + return CURL_SEEKFUNC_OK; +} + +int main(void) +{ + struct data seek_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_cb); + curl_easy_setopt(curl, CURLOPT_SEEKDATA, &seek_data); + } +} +~~~ + +# AVAILABILITY + +Added in 7.18.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.3 b/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.3 deleted file mode 100644 index 72b2a6264..000000000 --- a/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SERVER_RESPONSE_TIMEOUT 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SERVER_RESPONSE_TIMEOUT \- time allowed to wait for server response -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVER_RESPONSE_TIMEOUT, - long timeout); -.fi -.SH DESCRIPTION -Pass a long. Causes libcurl to set a \fItimeout\fP period (in seconds) on the -amount of time that the server is allowed to take in order to send a response -message for a command before the session is considered dead. While libcurl is -waiting for a response, this value overrides \fICURLOPT_TIMEOUT(3)\fP. It is -recommended that if used in conjunction with \fICURLOPT_TIMEOUT(3)\fP, you set -\fICURLOPT_SERVER_RESPONSE_TIMEOUT(3)\fP to a value smaller than -\fICURLOPT_TIMEOUT(3)\fP. - -This option was formerly known as CURLOPT_FTP_RESPONSE_TIMEOUT. -.SH DEFAULT -None -.SH PROTOCOLS -FTP, IMAP, POP3, SMTP, and SSH -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt"); - /* wait no more than 23 seconds */ - curl_easy_setopt(curl, CURLOPT_SERVER_RESPONSE_TIMEOUT, 23L); - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.10.8. Used under this name since 7.20.0 - -Support for SSH is predicated on a new enough (1.11.0) version of libssh2 -being available when compiling libcurl. -.SH RETURN VALUE -Returns CURLE_OK if supported, and CURLE_UNKNOWN_OPTION if not. Returns -CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when -converted to milliseconds is too large. -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.md b/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.md new file mode 100644 index 000000000..5385d521e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SERVER_RESPONSE_TIMEOUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_SERVER_RESPONSE_TIMEOUT - time allowed to wait for server response + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVER_RESPONSE_TIMEOUT, + long timeout); +~~~ + +# DESCRIPTION + +Pass a long. Causes libcurl to set a *timeout* period (in seconds) on the +amount of time that the server is allowed to take in order to send a response +message for a command before the session is considered dead. While libcurl is +waiting for a response, this value overrides CURLOPT_TIMEOUT(3). It is +recommended that if used in conjunction with CURLOPT_TIMEOUT(3), you set +CURLOPT_SERVER_RESPONSE_TIMEOUT(3) to a value smaller than +CURLOPT_TIMEOUT(3). + +This option was formerly known as CURLOPT_FTP_RESPONSE_TIMEOUT. + +# DEFAULT + +None + +# PROTOCOLS + +FTP, IMAP, POP3, SMTP, and SSH + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt"); + /* wait no more than 23 seconds */ + curl_easy_setopt(curl, CURLOPT_SERVER_RESPONSE_TIMEOUT, 23L); + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.10.8. Used under this name since 7.20.0 + +Support for SSH is predicated on a new enough (1.11.0) version of libssh2 +being available when compiling libcurl. + +# RETURN VALUE + +Returns CURLE_OK if supported, and CURLE_UNKNOWN_OPTION if not. Returns +CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when +converted to milliseconds is too large. diff --git a/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT_MS.md new file mode 100644 index 000000000..a7d9c9137 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SERVER_RESPONSE_TIMEOUT_MS.md @@ -0,0 +1,74 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SERVER_RESPONSE_TIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_SERVER_RESPONSE_TIMEOUT_MS - time allowed to wait for server response + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, + long timeout); +~~~ + +# DESCRIPTION + +Pass a long. Causes libcurl to set a *timeout* period (in milliseconds) on the +amount of time that the server is allowed to take in order to send a response +message for a command before the session is considered dead. While libcurl is +waiting for a response, this value overrides CURLOPT_TIMEOUT(3). It is +recommended that if used in conjunction with CURLOPT_TIMEOUT(3), you set +CURLOPT_SERVER_RESPONSE_TIMEOUT_MS(3) to a value smaller than +CURLOPT_TIMEOUT(3). + +The maximum accepted value is 2147483648. + +This is the millisecond version of CURLOPT_SERVER_RESPONSE_TIMEOUT(3). + +# DEFAULT + +None + +# PROTOCOLS + +FTP, IMAP, POP3, SMTP, and SSH + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/slow.txt"); + /* wait no more than 237 milliseconds */ + curl_easy_setopt(curl, CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, 237L); + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 8.6.0. + +# RETURN VALUE + +Returns CURLE_OK if supported, and CURLE_UNKNOWN_OPTION if not. Returns +CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when +converted to milliseconds is too large. diff --git a/docs/libcurl/opts/CURLOPT_SERVICE_NAME.3 b/docs/libcurl/opts/CURLOPT_SERVICE_NAME.3 deleted file mode 100644 index 02d18494d..000000000 --- a/docs/libcurl/opts/CURLOPT_SERVICE_NAME.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SERVICE_NAME 3 "17 Jun 2015" libcurl libcurl -.SH NAME -CURLOPT_SERVICE_NAME \- authentication service name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVICE_NAME, char *name); -.fi -.SH DESCRIPTION -Pass a char * as parameter to a string holding the \fIname\fP of the service -for DIGEST-MD5, SPNEGO and Kerberos 5 authentication mechanisms. The default -service names are "ftp", "HTTP", "imap", "ldap", "pop" and "smtp". This option -allows you to change them. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -See above -.SH PROTOCOLS -HTTP, FTP, IMAP, LDAP, POP3 and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode ret; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_SERVICE_NAME, "custom"); - ret = curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.43.0 for HTTP, 7.49.0 for FTP, IMAP, POP3 and SMTP, -7.82.0 for OpenLDAP. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXY_SERVICE_NAME (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_SERVICE_NAME.md b/docs/libcurl/opts/CURLOPT_SERVICE_NAME.md new file mode 100644 index 000000000..0e13ca712 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SERVICE_NAME.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SERVICE_NAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYTYPE (3) + - CURLOPT_PROXY_SERVICE_NAME (3) +--- + +# NAME + +CURLOPT_SERVICE_NAME - authentication service name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SERVICE_NAME, char *name); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter to a string holding the *name* of the service +for DIGEST-MD5, SPNEGO and Kerberos 5 authentication mechanisms. The default +service names are "ftp", "HTTP", "imap", "ldap", "pop" and "smtp". This option +allows you to change them. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +See above + +# PROTOCOLS + +HTTP, FTP, IMAP, LDAP, POP3 and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode ret; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_SERVICE_NAME, "custom"); + ret = curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.43.0 for HTTP, 7.49.0 for FTP, IMAP, POP3 and SMTP, +7.82.0 for OpenLDAP. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SHARE.3 b/docs/libcurl/opts/CURLOPT_SHARE.3 deleted file mode 100644 index 22a662ac6..000000000 --- a/docs/libcurl/opts/CURLOPT_SHARE.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SHARE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SHARE \- share handle to use -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SHARE, CURLSH *share); -.fi -.SH DESCRIPTION -Pass a \fIshare\fP handle as a parameter. The share handle must have been -created by a previous call to \fIcurl_share_init(3)\fP. Setting this option, -makes this curl handle use the data from the shared handle instead of keeping -the data to itself. This enables several curl handles to share data. If the -curl handles are used simultaneously in multiple threads, you \fBMUST\fP use -the locking methods in the share handle. See \fIcurl_share_setopt(3)\fP for -details. - -If you add a share that is set to share cookies, your easy handle uses that -cookie cache and get the cookie engine enabled. If you stop sharing an object -that was using cookies (or change to another object that does not share -cookies), the easy handle gets its cookie engine disabled. - -Data that the share object is not set to share is dealt with the usual way, as -if no share was used. - -Set this option to NULL again to stop using that share object. -.SH DEFAULT -NULL -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - CURL *curl2 = curl_easy_init(); /* a second handle */ - if(curl) { - CURLcode res; - CURLSH *shobject = curl_share_init(); - curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); - curl_easy_setopt(curl, CURLOPT_SHARE, shobject); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - - /* the second handle shares cookies from the first */ - curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second"); - curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, ""); - curl_easy_setopt(curl2, CURLOPT_SHARE, shobject); - res = curl_easy_perform(curl2); - curl_easy_cleanup(curl2); - - curl_share_cleanup(shobject); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_COOKIE (3), -.BR CURLSHOPT_SHARE (3) diff --git a/docs/libcurl/opts/CURLOPT_SHARE.md b/docs/libcurl/opts/CURLOPT_SHARE.md new file mode 100644 index 000000000..3c0e7d259 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SHARE.md @@ -0,0 +1,88 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SHARE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_COOKIE (3) + - CURLSHOPT_SHARE (3) +--- + +# NAME + +CURLOPT_SHARE - share handle to use + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SHARE, CURLSH *share); +~~~ + +# DESCRIPTION + +Pass a *share* handle as a parameter. The share handle must have been +created by a previous call to curl_share_init(3). Setting this option, +makes this curl handle use the data from the shared handle instead of keeping +the data to itself. This enables several curl handles to share data. If the +curl handles are used simultaneously in multiple threads, you **MUST** use +the locking methods in the share handle. See curl_share_setopt(3) for +details. + +If you add a share that is set to share cookies, your easy handle uses that +cookie cache and get the cookie engine enabled. If you stop sharing an object +that was using cookies (or change to another object that does not share +cookies), the easy handle gets its cookie engine disabled. + +Data that the share object is not set to share is dealt with the usual way, as +if no share was used. + +Set this option to NULL again to stop using that share object. + +# DEFAULT + +NULL + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + CURL *curl2 = curl_easy_init(); /* a second handle */ + if(curl) { + CURLcode res; + CURLSH *shobject = curl_share_init(); + curl_share_setopt(shobject, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); + curl_easy_setopt(curl, CURLOPT_SHARE, shobject); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + + /* the second handle shares cookies from the first */ + curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/second"); + curl_easy_setopt(curl2, CURLOPT_COOKIEFILE, ""); + curl_easy_setopt(curl2, CURLOPT_SHARE, shobject); + res = curl_easy_perform(curl2); + curl_easy_cleanup(curl2); + + curl_share_cleanup(shobject); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.3 b/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.3 deleted file mode 100644 index f671aa989..000000000 --- a/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SOCKOPTDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SOCKOPTDATA \- pointer to pass to sockopt callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the first -argument in the sockopt callback set with \fICURLOPT_SOCKOPTFUNCTION(3)\fP. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -static int sockopt_callback(void *clientp, curl_socket_t curlfd, - curlsocktype purpose) -{ - int val = *(int *)clientp; - setsockopt((int)curlfd, SOL_SOCKET, SO_RCVBUF, - (const char *)&val, sizeof(val)); - return CURL_SOCKOPT_OK; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - int recvbuffersize = 256 * 1024; - - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - - /* call this function to set options for the socket */ - curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); - curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.0 -.SH RETURN VALUE -Returns \fICURLE_OK\fP if the option is supported, and \fICURLE_UNKNOWN_OPTION\fP if not. -.SH "SEE ALSO" -.BR CURLOPT_OPENSOCKETFUNCTION (3), -.BR CURLOPT_SOCKOPTFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.md b/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.md new file mode 100644 index 000000000..f44bf532d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SOCKOPTDATA.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SOCKOPTDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_OPENSOCKETFUNCTION (3) + - CURLOPT_SOCKOPTFUNCTION (3) +--- + +# NAME + +CURLOPT_SOCKOPTDATA - pointer to pass to sockopt callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the first +argument in the sockopt callback set with CURLOPT_SOCKOPTFUNCTION(3). + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +static int sockopt_callback(void *clientp, curl_socket_t curlfd, + curlsocktype purpose) +{ + int val = *(int *)clientp; + setsockopt((int)curlfd, SOL_SOCKET, SO_RCVBUF, + (const char *)&val, sizeof(val)); + return CURL_SOCKOPT_OK; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + int recvbuffersize = 256 * 1024; + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + + /* call this function to set options for the socket */ + curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); + curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.0 + +# RETURN VALUE + +Returns *CURLE_OK* if the option is supported, and *CURLE_UNKNOWN_OPTION* if not. diff --git a/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.3 b/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.3 deleted file mode 100644 index 269490f85..000000000 --- a/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.3 +++ /dev/null @@ -1,133 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SOCKOPTFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SOCKOPTFUNCTION \- callback for setting socket options -.SH SYNOPSIS -.nf -#include - -typedef enum { - CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ - CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ - CURLSOCKTYPE_LAST /* never use */ -} curlsocktype; - -#define CURL_SOCKOPT_OK 0 -#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return - CURLE_ABORTED_BY_CALLBACK */ -#define CURL_SOCKOPT_ALREADY_CONNECTED 2 - -int sockopt_callback(void *clientp, - curl_socket_t curlfd, - curlsocktype purpose); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -When set, this callback function gets called by libcurl when the socket has -been created, but before the connect call to allow applications to change -specific socket options. The callback's \fIpurpose\fP argument identifies the -exact purpose for this particular socket: - -\fICURLSOCKTYPE_IPCXN\fP for actively created connections or since 7.28.0 -\fICURLSOCKTYPE_ACCEPT\fP for FTP when the connection was setup with PORT/EPSV -(in earlier versions these sockets were not passed to this callback). - -Future versions of libcurl may support more purposes. libcurl passes the newly -created socket descriptor to the callback in the \fIcurlfd\fP parameter so -additional setsockopt() calls can be done at the user's discretion. - -The \fIclientp\fP pointer contains whatever user-defined value set using the -\fICURLOPT_SOCKOPTDATA(3)\fP function. - -Return \fICURL_SOCKOPT_OK\fP from the callback on success. Return -\fICURL_SOCKOPT_ERROR\fP from the callback function to signal an unrecoverable -error to the library and it closes the socket and returns -\fICURLE_COULDNT_CONNECT\fP. Alternatively, the callback function can return -\fICURL_SOCKOPT_ALREADY_CONNECTED\fP, to tell libcurl that the socket is -already connected and then libcurl does no attempt to connect. This allows an -application to pass in an already connected socket with -\fICURLOPT_OPENSOCKETFUNCTION(3)\fP and then have this function make libcurl -not attempt to connect (again). -.SH DEFAULT -By default, this callback is NULL and unused. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -/* make libcurl use the already established socket 'sockfd' */ - -static curl_socket_t opensocket(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *address) -{ - curl_socket_t sockfd; - sockfd = *(curl_socket_t *)clientp; - /* the actual externally set socket is passed in via the OPENSOCKETDATA - option */ - return sockfd; -} - -static int sockopt_callback(void *clientp, curl_socket_t curlfd, - curlsocktype purpose) -{ - /* This return code was added in libcurl 7.21.5 */ - return CURL_SOCKOPT_ALREADY_CONNECTED; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - int sockfd; /* our custom file descriptor */ - /* libcurl thinks that you connect to the host - * and port that you specify in the URL option. */ - curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); - /* call this function to get a socket */ - curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); - curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); - - /* call this function to set options for the socket */ - curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.0. The \fICURL_SOCKOPT_ALREADY_CONNECTED\fP return code was -added in 7.21.5. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_OPENSOCKETFUNCTION (3), -.BR CURLOPT_SEEKFUNCTION (3), -.BR CURLOPT_SOCKOPTDATA (3) diff --git a/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.md b/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.md new file mode 100644 index 000000000..f5de31685 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SOCKOPTFUNCTION.md @@ -0,0 +1,132 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SOCKOPTFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_OPENSOCKETFUNCTION (3) + - CURLOPT_SEEKFUNCTION (3) + - CURLOPT_SOCKOPTDATA (3) +--- + +# NAME + +CURLOPT_SOCKOPTFUNCTION - callback for setting socket options + +# SYNOPSIS + +~~~c +#include + +typedef enum { + CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ + CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */ + CURLSOCKTYPE_LAST /* never use */ +} curlsocktype; + +#define CURL_SOCKOPT_OK 0 +#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return + CURLE_ABORTED_BY_CALLBACK */ +#define CURL_SOCKOPT_ALREADY_CONNECTED 2 + +int sockopt_callback(void *clientp, + curl_socket_t curlfd, + curlsocktype purpose); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +When set, this callback function gets called by libcurl when the socket has +been created, but before the connect call to allow applications to change +specific socket options. The callback's *purpose* argument identifies the +exact purpose for this particular socket: + +*CURLSOCKTYPE_IPCXN* for actively created connections or since 7.28.0 +*CURLSOCKTYPE_ACCEPT* for FTP when the connection was setup with PORT/EPSV +(in earlier versions these sockets were not passed to this callback). + +Future versions of libcurl may support more purposes. libcurl passes the newly +created socket descriptor to the callback in the *curlfd* parameter so +additional setsockopt() calls can be done at the user's discretion. + +The *clientp* pointer contains whatever user-defined value set using the +CURLOPT_SOCKOPTDATA(3) function. + +Return *CURL_SOCKOPT_OK* from the callback on success. Return +*CURL_SOCKOPT_ERROR* from the callback function to signal an unrecoverable +error to the library and it closes the socket and returns +*CURLE_COULDNT_CONNECT*. Alternatively, the callback function can return +*CURL_SOCKOPT_ALREADY_CONNECTED*, to tell libcurl that the socket is +already connected and then libcurl does no attempt to connect. This allows an +application to pass in an already connected socket with +CURLOPT_OPENSOCKETFUNCTION(3) and then have this function make libcurl +not attempt to connect (again). + +# DEFAULT + +By default, this callback is NULL and unused. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +/* make libcurl use the already established socket 'sockfd' */ + +static curl_socket_t opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *address) +{ + curl_socket_t sockfd; + sockfd = *(curl_socket_t *)clientp; + /* the actual externally set socket is passed in via the OPENSOCKETDATA + option */ + return sockfd; +} + +static int sockopt_callback(void *clientp, curl_socket_t curlfd, + curlsocktype purpose) +{ + /* This return code was added in libcurl 7.21.5 */ + return CURL_SOCKOPT_ALREADY_CONNECTED; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + int sockfd; /* our custom file descriptor */ + /* libcurl thinks that you connect to the host + * and port that you specify in the URL option. */ + curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); + /* call this function to get a socket */ + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); + curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); + + /* call this function to set options for the socket */ + curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.0. The *CURL_SOCKOPT_ALREADY_CONNECTED* return code was +added in 7.21.5. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.3 b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.3 deleted file mode 100644 index d2276cffc..000000000 --- a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SOCKS5_AUTH 3 "27 April 2017" libcurl libcurl -.SH NAME -CURLOPT_SOCKS5_AUTH \- methods for SOCKS5 proxy authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_AUTH, long bitmask); -.fi -.SH DESCRIPTION -Pass a long as parameter, which is set to a bitmask, to tell libcurl which -authentication method(s) are allowed for SOCKS5 proxy authentication. The only -supported flags are \fICURLAUTH_BASIC\fP, which allows username/password -authentication, \fICURLAUTH_GSSAPI\fP, which allows GSS-API authentication, and -\fICURLAUTH_NONE\fP, which allows no authentication. Set the actual user name -and password with the \fICURLOPT_PROXYUSERPWD(3)\fP option. -.SH DEFAULT -CURLAUTH_BASIC|CURLAUTH_GSSAPI -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* request to use a SOCKS5 proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com"); - - /* enable username/password authentication only */ - curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, (long)CURLAUTH_BASIC); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.55.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_NOT_BUILT_IN if the bitmask contains unsupported flags. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md new file mode 100644 index 000000000..457ef9940 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SOCKS5_AUTH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_SOCKS5_AUTH - methods for SOCKS5 proxy authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_AUTH, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long as parameter, which is set to a bitmask, to tell libcurl which +authentication method(s) are allowed for SOCKS5 proxy authentication. The only +supported flags are *CURLAUTH_BASIC*, which allows username/password +authentication, *CURLAUTH_GSSAPI*, which allows GSS-API authentication, and +*CURLAUTH_NONE*, which allows no authentication. Set the actual user name and +password with the CURLOPT_PROXYUSERPWD(3) option. + +# DEFAULT + +CURLAUTH_BASIC|CURLAUTH_GSSAPI + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* request to use a SOCKS5 proxy */ + curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://user:pass@myproxy.com"); + + /* enable username/password authentication only */ + curl_easy_setopt(curl, CURLOPT_SOCKS5_AUTH, (long)CURLAUTH_BASIC); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.55.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_NOT_BUILT_IN if the bitmask contains unsupported flags. diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.3 b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.3 deleted file mode 100644 index bc9ea693d..000000000 --- a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SOCKS5_GSSAPI_NEC 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SOCKS5_GSSAPI_NEC \- SOCKS proxy GSSAPI negotiation protection -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_GSSAPI_NEC, long nec); -.fi -.SH DESCRIPTION -Pass a long set to 1 to enable or 0 to disable. As part of the GSSAPI -negotiation a protection mode is negotiated. The RFC 1961 says in section -4.3/4.4 it should be protected, but the NEC reference implementation does not. -If enabled, this option allows the unprotected exchange of the protection mode -negotiation. -.SH DEFAULT -? -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -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://proxy"); - curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SOCKS5_GSSAPI_SERVICE (3), -.BR CURLOPT_PROXY (3) - - diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.md b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.md new file mode 100644 index 000000000..08a1ced6a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_NEC.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SOCKS5_GSSAPI_NEC +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_SOCKS5_GSSAPI_SERVICE (3) +--- + +# NAME + +CURLOPT_SOCKS5_GSSAPI_NEC - SOCKS proxy GSSAPI negotiation protection + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_GSSAPI_NEC, long nec); +~~~ + +# DESCRIPTION + +Pass a long set to 1 to enable or 0 to disable. As part of the GSSAPI +negotiation a protection mode is negotiated. The RFC 1961 says in section +4.3/4.4 it should be protected, but the NEC reference implementation does not. +If enabled, this option allows the unprotected exchange of the protection mode +negotiation. + +# DEFAULT + +? + +# PROTOCOLS + +Most + +# 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://proxy"); + curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.3 b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.3 deleted file mode 100644 index c5b32ec2a..000000000 --- a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SOCKS5_GSSAPI_SERVICE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SOCKS5_GSSAPI_SERVICE \- SOCKS5 proxy authentication service name -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_GSSAPI_SERVICE, - char *name); -.fi -.SH DESCRIPTION -Deprecated since 7.49.0. Use \fICURLOPT_PROXY_SERVICE_NAME(3)\fP instead. - -Pass a \fBchar *\fP as parameter to a string holding the \fIname\fP of the -service. The default service name for a SOCKS5 server is \fI"rcmd"\fP. This -option allows you to change it. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -See above -.SH PROTOCOLS -All network protocols -.SH EXAMPLE -.nf -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://proxy"); - curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE, "rcmd-special"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4, deprecated in 7.49.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY (3), -.BR CURLOPT_PROXYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.md b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.md new file mode 100644 index 000000000..47f6e28db --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SOCKS5_GSSAPI_SERVICE.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SOCKS5_GSSAPI_SERVICE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY (3) + - CURLOPT_PROXYTYPE (3) +--- + +# NAME + +CURLOPT_SOCKS5_GSSAPI_SERVICE - SOCKS5 proxy authentication service name + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKS5_GSSAPI_SERVICE, + char *name); +~~~ + +# DESCRIPTION + +Deprecated since 7.49.0. Use CURLOPT_PROXY_SERVICE_NAME(3) instead. + +Pass a char pointer as parameter to a string holding the *name* of the +service. The default service name for a SOCKS5 server is *rcmd*. This option +allows you to change it. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +See above + +# PROTOCOLS + +All network 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://proxy"); + curl_easy_setopt(curl, CURLOPT_SOCKS5_GSSAPI_SERVICE, "rcmd-special"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4, deprecated in 7.49.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.3 b/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.3 deleted file mode 100644 index a6c16c846..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_AUTH_TYPES 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_AUTH_TYPES \- auth types for SFTP and SCP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_AUTH_TYPES, long bitmask); -.fi -.SH DESCRIPTION -Pass a long set to a bitmask consisting of one or more of -CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, -CURLSSH_AUTH_KEYBOARD and CURLSSH_AUTH_AGENT. - -Set \fICURLSSH_AUTH_ANY\fP to let libcurl pick a suitable one. Currently -CURLSSH_AUTH_HOST has no effect. If CURLSSH_AUTH_AGENT is used, libcurl -attempts to connect to ssh-agent or pageant and let the agent attempt the -authentication. -.SH DEFAULT -CURLSSH_AUTH_ANY (all available) -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, - CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -CURLSSH_AUTH_HOST was added in 7.16.1, CURLSSH_AUTH_AGENT was added in 7.28.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3), -.BR CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 (3), -.BR CURLOPT_SSH_PUBLIC_KEYFILE (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.md b/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.md new file mode 100644 index 000000000..205e94d19 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_AUTH_TYPES.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_AUTH_TYPES +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3) + - CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 (3) + - CURLOPT_SSH_PUBLIC_KEYFILE (3) +--- + +# NAME + +CURLOPT_SSH_AUTH_TYPES - auth types for SFTP and SCP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_AUTH_TYPES, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long set to a bitmask consisting of one or more of +CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, +CURLSSH_AUTH_KEYBOARD and CURLSSH_AUTH_AGENT. + +Set *CURLSSH_AUTH_ANY* to let libcurl pick a suitable one. Currently +CURLSSH_AUTH_HOST has no effect. If CURLSSH_AUTH_AGENT is used, libcurl +attempts to connect to ssh-agent or pageant and let the agent attempt the +authentication. + +# DEFAULT + +CURLSSH_AUTH_ANY (all available) + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, + CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +CURLSSH_AUTH_HOST was added in 7.16.1, CURLSSH_AUTH_AGENT was added in 7.28.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.3 b/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.3 deleted file mode 100644 index 9a1fab01d..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_COMPRESSION 3 "05 Aug 2017" libcurl libcurl -.SH NAME -CURLOPT_SSH_COMPRESSION \- enable SSH compression -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_COMPRESSION, long enable); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1L to enable or 0L to disable. - -Enables built-in SSH compression. This is a request, not an order; the server -may or may not do it. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -All SSH based protocols: SCP, SFTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com"); - - /* enable built-in compression */ - curl_easy_setopt(curl, CURLOPT_SSH_COMPRESSION, 1L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.56.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_ACCEPT_ENCODING (3), -.BR CURLOPT_TRANSFER_ENCODING (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.md b/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.md new file mode 100644 index 000000000..5e2b2785d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_COMPRESSION.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_COMPRESSION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ACCEPT_ENCODING (3) + - CURLOPT_TRANSFER_ENCODING (3) +--- + +# NAME + +CURLOPT_SSH_COMPRESSION - enable SSH compression + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_COMPRESSION, long enable); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1L to enable or 0L to disable. + +Enables built-in SSH compression. This is a request, not an order; the server +may or may not do it. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +All SSH based protocols: SCP, SFTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com"); + + /* enable built-in compression */ + curl_easy_setopt(curl, CURLOPT_SSH_COMPRESSION, 1L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.56.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.3 b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.3 deleted file mode 100644 index c0a5720c5..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_KEYDATA 3 "4 Nov 2021" libcurl libcurl -.SH NAME -CURLOPT_SSH_HOSTKEYDATA \- pointer to pass to the SSH host key callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a void * as parameter. This \fIpointer\fP is passed along untouched to -the callback set with \fICURLOPT_SSH_HOSTKEYFUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -SCP and SFTP -.SH EXAMPLE -.nf -struct mine { - void *custom; -}; - -static int hostkeycb(void *clientp, /* CURLOPT_SSH_HOSTKEYDATA */ - int keytype, /* CURLKHTYPE */ - const char *key, /* host key to check */ - size_t keylen) /* length of the key */ -{ - /* 'clientp' points to the callback_data struct */ - /* investigate the situation and return the correct value */ - return CURLKHMATCH_OK; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct mine callback_data; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); - curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb); - curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.84.0, works only with libssh2 backend. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSH_HOSTKEYFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.md b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.md new file mode 100644 index 000000000..39cbd0ddd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYDATA.md @@ -0,0 +1,73 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_KEYDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_HOSTKEYFUNCTION (3) +--- + +# NAME + +CURLOPT_SSH_HOSTKEYDATA - pointer to pass to the SSH host key callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a void * as parameter. This *pointer* is passed along untouched to +the callback set with CURLOPT_SSH_HOSTKEYFUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +SCP and SFTP + +# EXAMPLE + +~~~c +struct mine { + void *custom; +}; + +static int hostkeycb(void *clientp, /* CURLOPT_SSH_HOSTKEYDATA */ + int keytype, /* CURLKHTYPE */ + const char *key, /* host key to check */ + size_t keylen) /* length of the key */ +{ + /* 'clientp' points to the callback_data struct */ + /* investigate the situation and return the correct value */ + return CURLKHMATCH_OK; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct mine callback_data; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); + curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb); + curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.84.0, works only with libssh2 backend. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.3 b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.3 deleted file mode 100644 index 132e9e94d..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_HOSTKEYFUNCTION 3 "4 Nov 2021" libcurl libcurl -.SH NAME -CURLOPT_SSH_HOSTKEYFUNCTION \- callback to check host key -.SH SYNOPSIS -.nf -#include - -int keycallback(void *clientp, - int keytype, - const char *key, - size_t keylen); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYFUNCTION, - keycallback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. It overrides \fICURLOPT_SSH_KNOWNHOSTS(3)\fP. - -This callback gets called when the verification of the SSH host key is needed. - -\fBkey\fP is \fBkeylen\fP bytes long and is the key to check. \fBkeytype\fP -says what type it is, from the \fBCURLKHTYPE_*\fP series in the -\fBcurl_khtype\fP enum. - -\fBclientp\fP is a custom pointer set with \fICURLOPT_SSH_HOSTKEYDATA(3)\fP. - -The callback MUST return one of the following return codes to tell libcurl how -to act: -.IP CURLKHMATCH_OK -The host key is accepted, the connection should continue. -.IP CURLKHMATCH_MISMATCH -the host key is rejected, the connection is canceled. -.SH DEFAULT -NULL -.SH PROTOCOLS -SCP and SFTP -.SH EXAMPLE -.nf -struct mine { - void *custom; -}; - -int hostkeycb(void *clientp, /* passed with CURLOPT_SSH_HOSTKEYDATA */ - int keytype, /* CURLKHTYPE */ - const char *key, /* host key to check */ - size_t keylen) /* length of the key */ -{ - /* 'clientp' points to the callback_data struct */ - /* investigate the situation and return the correct value */ - return CURLKHMATCH_OK; -} -int main(void) -{ - struct mine callback_data; - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); - curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb); - curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.84.0 , work only with libssh2 backend. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSH_HOSTKEYDATA (3), -.BR CURLOPT_SSH_KNOWNHOSTS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.md b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.md new file mode 100644 index 000000000..ed5797520 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_HOSTKEYFUNCTION.md @@ -0,0 +1,98 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_HOSTKEYFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_HOSTKEYDATA (3) + - CURLOPT_SSH_KNOWNHOSTS (3) +--- + +# NAME + +CURLOPT_SSH_HOSTKEYFUNCTION - callback to check host key + +# SYNOPSIS + +~~~c +#include + +int keycallback(void *clientp, + int keytype, + const char *key, + size_t keylen); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYFUNCTION, + keycallback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. It overrides CURLOPT_SSH_KNOWNHOSTS(3). + +This callback gets called when the verification of the SSH host key is needed. + +**key** is **keylen** bytes long and is the key to check. **keytype** +says what type it is, from the **CURLKHTYPE_*** series in the +**curl_khtype** enum. + +**clientp** is a custom pointer set with CURLOPT_SSH_HOSTKEYDATA(3). + +The callback MUST return one of the following return codes to tell libcurl how +to act: + +## CURLKHMATCH_OK + +The host key is accepted, the connection should continue. + +## CURLKHMATCH_MISMATCH + +the host key is rejected, the connection is canceled. + +# DEFAULT + +NULL + +# PROTOCOLS + +SCP and SFTP + +# EXAMPLE + +~~~c +struct mine { + void *custom; +}; + +int hostkeycb(void *clientp, /* passed with CURLOPT_SSH_HOSTKEYDATA */ + int keytype, /* CURLKHTYPE */ + const char *key, /* host key to check */ + size_t keylen) /* length of the key */ +{ + /* 'clientp' points to the callback_data struct */ + /* investigate the situation and return the correct value */ + return CURLKHMATCH_OK; +} +int main(void) +{ + struct mine callback_data; + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); + curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb); + curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.84.0 , work only with libssh2 backend. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.3 b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.3 deleted file mode 100644 index e0b2586ed..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 \- MD5 checksum of SSH server public key -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, - char *md5); -.SH DESCRIPTION -Pass a char * pointing to a string containing 32 hexadecimal digits. The -string should be the 128 bit MD5 checksum of the remote host's public key, and -libcurl aborts the connection to the host unless the MD5 checksum match. - -MD5 is a weak algorithm. We strongly recommend using -\fICURLOPT_SSH_HOST_PUBLIC_KEY_SHA256(3)\fP instead. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -SCP and SFTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, - "afe17cd62a0f3b61f1ab9cb22ba269a7"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.17.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_AUTH_TYPES (3), -.BR CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 (3), -.BR CURLOPT_SSH_PUBLIC_KEYFILE (3), -.BR CURLOPT_SSH_KNOWNHOSTS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.md b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.md new file mode 100644 index 000000000..4b7876501 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_AUTH_TYPES (3) + - CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 (3) + - CURLOPT_SSH_KNOWNHOSTS (3) + - CURLOPT_SSH_PUBLIC_KEYFILE (3) +--- + +# NAME + +CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 - MD5 checksum of SSH server public key + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, + char *md5); +~~~ + +# DESCRIPTION + +Pass a char pointer pointing to a string containing 32 hexadecimal digits. The +string should be the 128 bit MD5 checksum of the remote host's public key, and +libcurl aborts the connection to the host unless the MD5 checksum match. + +MD5 is a weak algorithm. We strongly recommend using +CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256(3) instead. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +SCP and SFTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, + "afe17cd62a0f3b61f1ab9cb22ba269a7"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.17.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.3 b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.3 deleted file mode 100644 index 266b7b0ac..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 3 "27 Aug 2021" libcurl libcurl -.SH NAME -CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 \- SHA256 hash of SSH server public key -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, - char *sha256); -.SH DESCRIPTION -Pass a char * pointing to a string containing a Base64-encoded SHA256 hash of -the remote host's public key. The transfer fails if the given hash does not -match the hash the remote host provides. - -.SH DEFAULT -NULL -.SH PROTOCOLS -SCP and SFTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, - "NDVkMTQxMGQ1ODdmMjQ3MjczYjAyOTY5MmRkMjVmNDQ="); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.80.0 -Requires the libssh2 backend. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_AUTH_TYPES (3), -.BR CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3), -.BR CURLOPT_SSH_PUBLIC_KEYFILE (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.md b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.md new file mode 100644 index 000000000..41562db63 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_AUTH_TYPES (3) + - CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3) + - CURLOPT_SSH_PUBLIC_KEYFILE (3) +--- + +# NAME + +CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 - SHA256 hash of SSH server public key + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, + char *sha256); +~~~ + +# DESCRIPTION + +Pass a char pointer pointing to a string containing a Base64-encoded SHA256 +hash of the remote host's public key. The transfer fails if the given hash +does not match the hash the remote host provides. + +# DEFAULT + +NULL + +# PROTOCOLS + +SCP and SFTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, + "NDVkMTQxMGQ1ODdmMjQ3MjczYjAyOTY5MmRkMjVmNDQ="); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.80.0 +Requires the libssh2 backend. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.3 b/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.3 deleted file mode 100644 index 04ae0a557..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_KEYDATA 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_KEYDATA \- pointer passed to the SSH key callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a void * as parameter. This \fIpointer\fP is passed along verbatim to the -callback set with \fICURLOPT_SSH_KEYFUNCTION(3)\fP. -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -struct mine { - void *custom; -}; -static int keycb(CURL *easy, - const struct curl_khkey *knownkey, - const struct curl_khkey *foundkey, - enum curl_khmatch match, - void *clientp) -{ - /* 'clientp' points to the callback_data struct */ - /* investigate the situation and return the correct value */ - return CURLKHSTAT_FINE_ADD_TO_FILE; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct mine callback_data; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); - curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb); - curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data); - curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts"); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.6 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSH_KEYDATA (3), -.BR CURLOPT_SSH_KNOWNHOSTS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.md b/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.md new file mode 100644 index 000000000..e90cace34 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_KEYDATA.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_KEYDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_KEYDATA (3) + - CURLOPT_SSH_KNOWNHOSTS (3) +--- + +# NAME + +CURLOPT_SSH_KEYDATA - pointer passed to the SSH key callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a void * as parameter. This *pointer* is passed along verbatim to the +callback set with CURLOPT_SSH_KEYFUNCTION(3). + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +struct mine { + void *custom; +}; +static int keycb(CURL *easy, + const struct curl_khkey *knownkey, + const struct curl_khkey *foundkey, + enum curl_khmatch match, + void *clientp) +{ + /* 'clientp' points to the callback_data struct */ + /* investigate the situation and return the correct value */ + return CURLKHSTAT_FINE_ADD_TO_FILE; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct mine callback_data; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); + curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb); + curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data); + curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts"); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.6 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.3 b/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.3 deleted file mode 100644 index 1abe37d63..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.3 +++ /dev/null @@ -1,143 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_KEYFUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_KEYFUNCTION \- callback for known host matching logic -.SH SYNOPSIS -.nf -#include - -enum curl_khstat { - CURLKHSTAT_FINE_ADD_TO_FILE, - CURLKHSTAT_FINE, - CURLKHSTAT_REJECT, /* reject the connection, return an error */ - CURLKHSTAT_DEFER, /* do not accept it, but we cannot answer right - now. Causes a CURLE_PEER_FAILED_VERIFICATION error but - the connection is left intact */ - CURLKHSTAT_FINE_REPLACE -}; - -enum curl_khmatch { - CURLKHMATCH_OK, /* match */ - CURLKHMATCH_MISMATCH, /* host found, key mismatch! */ - CURLKHMATCH_MISSING, /* no matching host/key found */ -}; - -struct curl_khkey { - const char *key; /* points to a null-terminated string encoded with - base64 if len is zero, otherwise to the "raw" - data */ - size_t len; - enum curl_khtype keytype; -}; - -int ssh_keycallback(CURL *easy, - const struct curl_khkey *knownkey, - const struct curl_khkey *foundkey, - enum curl_khmatch match, - void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYFUNCTION, - ssh_keycallback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -It gets called when the known_host matching has been done, to allow the -application to act and decide for libcurl how to proceed. The callback is only -called if \fICURLOPT_SSH_KNOWNHOSTS(3)\fP is also set. - -This callback function gets passed the CURL handle, the key from the -known_hosts file \fIknownkey\fP, the key from the remote site \fIfoundkey\fP, -info from libcurl on the matching status and a custom pointer (set with -\fICURLOPT_SSH_KEYDATA(3)\fP). It MUST return one of the following return -codes to tell libcurl how to act: -.IP CURLKHSTAT_FINE_REPLACE -The new host+key is accepted and libcurl replaces the old host+key into the -known_hosts file before continuing with the connection. This also adds the new -host+key combo to the known_host pool kept in memory if it was not already -present there. The adding of data to the file is done by completely replacing -the file with a new copy, so the permissions of the file must allow -this. (Added in 7.73.0) -.IP CURLKHSTAT_FINE_ADD_TO_FILE -The host+key is accepted and libcurl appends it to the known_hosts file before -continuing with the connection. This also adds the host+key combo to the -known_host pool kept in memory if it was not already present there. The adding -of data to the file is done by completely replacing the file with a new copy, -so the permissions of the file must allow this. -.IP CURLKHSTAT_FINE -The host+key is accepted libcurl continues with the connection. This also adds -the host+key combo to the known_host pool kept in memory if it was not already -present there. -.IP CURLKHSTAT_REJECT -The host+key is rejected. libcurl denies the connection to continue and it is -closed. -.IP CURLKHSTAT_DEFER -The host+key is rejected, but the SSH connection is asked to be kept alive. -This feature could be used when the app wants to somehow return back and act -on the host+key situation and then retry without needing the overhead of -setting it up from scratch again. -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -struct mine { - void *custom; -}; - -static int keycb(CURL *easy, - const struct curl_khkey *knownkey, - const struct curl_khkey *foundkey, - enum curl_khmatch match, - void *clientp) -{ - /* 'clientp' points to the callback_data struct */ - /* investigate the situation and return the correct value */ - return CURLKHSTAT_FINE_ADD_TO_FILE; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct mine callback_data; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); - curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb); - curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data); - curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts"); - - curl_easy_perform(curl); -} -} -.fi -.SH AVAILABILITY -Added in 7.19.6 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSH_KEYDATA (3), -.BR CURLOPT_SSH_KNOWNHOSTS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.md b/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.md new file mode 100644 index 000000000..5fc40060e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_KEYFUNCTION.md @@ -0,0 +1,152 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_KEYFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_KEYDATA (3) + - CURLOPT_SSH_KNOWNHOSTS (3) +--- + +# NAME + +CURLOPT_SSH_KEYFUNCTION - callback for known host matching logic + +# SYNOPSIS + +~~~c +#include + +enum curl_khstat { + CURLKHSTAT_FINE_ADD_TO_FILE, + CURLKHSTAT_FINE, + CURLKHSTAT_REJECT, /* reject the connection, return an error */ + CURLKHSTAT_DEFER, /* do not accept it, but we cannot answer right + now. Causes a CURLE_PEER_FAILED_VERIFICATION error but + the connection is left intact */ + CURLKHSTAT_FINE_REPLACE +}; + +enum curl_khmatch { + CURLKHMATCH_OK, /* match */ + CURLKHMATCH_MISMATCH, /* host found, key mismatch! */ + CURLKHMATCH_MISSING, /* no matching host/key found */ +}; + +struct curl_khkey { + const char *key; /* points to a null-terminated string encoded with + base64 if len is zero, otherwise to the "raw" + data */ + size_t len; + enum curl_khtype keytype; +}; + +int ssh_keycallback(CURL *easy, + const struct curl_khkey *knownkey, + const struct curl_khkey *foundkey, + enum curl_khmatch match, + void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYFUNCTION, + ssh_keycallback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +It gets called when the known_host matching has been done, to allow the +application to act and decide for libcurl how to proceed. The callback is only +called if CURLOPT_SSH_KNOWNHOSTS(3) is also set. + +This callback function gets passed the CURL handle, the key from the +known_hosts file *knownkey*, the key from the remote site *foundkey*, +info from libcurl on the matching status and a custom pointer (set with +CURLOPT_SSH_KEYDATA(3)). It MUST return one of the following return +codes to tell libcurl how to act: + +## CURLKHSTAT_FINE_REPLACE + +The new host+key is accepted and libcurl replaces the old host+key into the +known_hosts file before continuing with the connection. This also adds the new +host+key combo to the known_host pool kept in memory if it was not already +present there. The adding of data to the file is done by completely replacing +the file with a new copy, so the permissions of the file must allow +this. (Added in 7.73.0) + +## CURLKHSTAT_FINE_ADD_TO_FILE + +The host+key is accepted and libcurl appends it to the known_hosts file before +continuing with the connection. This also adds the host+key combo to the +known_host pool kept in memory if it was not already present there. The adding +of data to the file is done by completely replacing the file with a new copy, +so the permissions of the file must allow this. + +## CURLKHSTAT_FINE + +The host+key is accepted libcurl continues with the connection. This also adds +the host+key combo to the known_host pool kept in memory if it was not already +present there. + +## CURLKHSTAT_REJECT + +The host+key is rejected. libcurl denies the connection to continue and it is +closed. + +## CURLKHSTAT_DEFER + +The host+key is rejected, but the SSH connection is asked to be kept alive. +This feature could be used when the app wants to return and act on the +host+key situation and then retry without needing the overhead of setting it +up from scratch again. + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +struct mine { + void *custom; +}; + +static int keycb(CURL *easy, + const struct curl_khkey *knownkey, + const struct curl_khkey *foundkey, + enum curl_khmatch match, + void *clientp) +{ + /* 'clientp' points to the callback_data struct */ + /* investigate the situation and return the correct value */ + return CURLKHSTAT_FINE_ADD_TO_FILE; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct mine callback_data; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); + curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb); + curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data); + curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts"); + + curl_easy_perform(curl); +} +} +~~~ + +# AVAILABILITY + +Added in 7.19.6 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.3 b/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.3 deleted file mode 100644 index 8984fedb7..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_KNOWNHOSTS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_KNOWNHOSTS \- file name holding the SSH known hosts -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char *fname); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string holding the file name of the -known_host file to use. The known_hosts file should use the OpenSSH file -format as supported by libssh2. If this file is specified, libcurl only -accepts connections with hosts that are known and present in that file, with a -matching public key. Use \fICURLOPT_SSH_KEYFUNCTION(3)\fP to alter the default -behavior on host and key matches and mismatches. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, - "/home/clarkkent/.ssh/known_hosts"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.6 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_AUTH_TYPES (3), -.BR CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.md b/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.md new file mode 100644 index 000000000..5a5fcbf33 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_KNOWNHOSTS.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_KNOWNHOSTS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_AUTH_TYPES (3) + - CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3) +--- + +# NAME + +CURLOPT_SSH_KNOWNHOSTS - filename holding the SSH known hosts + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char *fname); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string holding the filename of the +known_host file to use. The known_hosts file should use the OpenSSH file +format as supported by libssh2. If this file is specified, libcurl only +accepts connections with hosts that are known and present in that file, with a +matching public key. Use CURLOPT_SSH_KEYFUNCTION(3) to alter the default +behavior on host and key matches and mismatches. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, + "/home/clarkkent/.ssh/known_hosts"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.6 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.3 b/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.3 deleted file mode 100644 index 12cc5410d..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_PRIVATE_KEYFILE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_PRIVATE_KEYFILE \- private key file for SSH auth -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE, - char *filename); -.SH DESCRIPTION -Pass a char * pointing to a \fIfilename\fP for your private key. If not used, -libcurl defaults to \fB$HOME/.ssh/id_rsa\fP or \fB$HOME/.ssh/id_dsa\fP if the -HOME environment variable is set, and just \fB"id_rsa"\fP or \fB"id_dsa"\fP in -the current directory if HOME is not set. - -If the file is password-protected, set the password with -\fICURLOPT_KEYPASSWD(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -As explained above -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, - "/home/clarkkent/.ssh/id_rsa"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_PUBLIC_KEYFILE (3), -.BR CURLOPT_SSH_AUTH_TYPES (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.md b/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.md new file mode 100644 index 000000000..e8a40079b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_PRIVATE_KEYFILE.md @@ -0,0 +1,76 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_PRIVATE_KEYFILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_AUTH_TYPES (3) + - CURLOPT_SSH_PUBLIC_KEYFILE (3) +--- + +# NAME + +CURLOPT_SSH_PRIVATE_KEYFILE - private key file for SSH auth + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE, + char *filename); +~~~ + +# DESCRIPTION + +Pass a char pointer pointing to a *filename* for your private key. If not +used, libcurl defaults to **$HOME/.ssh/id_rsa** or **$HOME/.ssh/id_dsa** if +the HOME environment variable is set, and in the current directory if HOME is +not set. + +If the file is password-protected, set the password with +CURLOPT_KEYPASSWD(3). + +The SSH library derives the public key from this private key when possible. If +the SSH library cannot derive the public key from the private one and no +public one is provided with CURLOPT_SSH_PUBLIC_KEYFILE(3), the transfer +fails. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +As explained above + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, + "/home/clarkkent/.ssh/id_rsa"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.3 b/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.3 deleted file mode 100644 index 93d9241e0..000000000 --- a/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSH_PUBLIC_KEYFILE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSH_PUBLIC_KEYFILE \- public key file for SSH auth -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PUBLIC_KEYFILE, - char *filename); -.SH DESCRIPTION -Pass a char * pointing to a \fIfilename\fP for your public key. If not used, -libcurl defaults to \fB$HOME/.ssh/id_dsa.pub\fP if the HOME environment -variable is set, and just "id_dsa.pub" in the current directory if HOME is not -set. - -If NULL (or an empty string) is passed, libcurl passes no public key to -libssh2, which then computes it from the private key. This is known to work -with libssh2 1.4.0+ linked against OpenSSL. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -SFTP and SCP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); - curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, - "/home/clarkkent/.ssh/id_rsa.pub"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -The "" trick was added in 7.26.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSH_PRIVATE_KEYFILE (3), -.BR CURLOPT_SSH_AUTH_TYPES (3) diff --git a/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.md b/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.md new file mode 100644 index 000000000..35d65ad93 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSH_PUBLIC_KEYFILE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSH_PUBLIC_KEYFILE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSH_AUTH_TYPES (3) + - CURLOPT_SSH_PRIVATE_KEYFILE (3) +--- + +# NAME + +CURLOPT_SSH_PUBLIC_KEYFILE - public key file for SSH auth + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PUBLIC_KEYFILE, + char *filename); +~~~ + +# DESCRIPTION + +Pass a char pointer pointing to a *filename* for your public key. If not used, +libcurl defaults to **$HOME/.ssh/id_dsa.pub** if the HOME environment variable +is set, and just "id_dsa.pub" in the current directory if HOME is not set. + +If NULL (or an empty string) is passed to this option, libcurl passes no +public key to the SSH library, which then rather derives it from the private +key. If the SSH library cannot derive the public key from the private one and +no public one is provided, the transfer fails. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +SFTP and SCP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); + curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, + "/home/clarkkent/.ssh/id_rsa.pub"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +The "" trick was added in 7.26.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLCERT.3 b/docs/libcurl/opts/CURLOPT_SSLCERT.3 deleted file mode 100644 index d3ded42fa..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLCERT.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLCERT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLCERT \- SSL client certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT, char *cert); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the file name of your client certificate. The default format is "P12" on -Secure Transport and "PEM" on other engines, and can be changed with -\fICURLOPT_SSLCERTTYPE(3)\fP. - -With Secure Transport, this can also be the nickname of the certificate you -wish to authenticate with as it is named in the security database. If you want -to use a file from the current directory, please precede it with "./" prefix, -in order to avoid confusion with a nickname. - -(Schannel only) Client certificates can be specified by a path expression to a -certificate store. (You can import \fIPFX\fP to a store first). You can use -"\\\\" to refer to a certificate in -the system certificates store, for example, -\fB"CurrentUser\\MY\\934a7ac6f8a5d579285a74fa"\fP. The thumbprint is usually a -SHA-1 hex string which you can see in certificate details. Following store -locations are supported: \fBCurrentUser\fP, \fBLocalMachine\fP, -\fBCurrentService\fP, \fBServices\fP, \fBCurrentUserGroupPolicy\fP, -\fBLocalMachineGroupPolicy\fP, \fBLocalMachineEnterprise\fP. Schannel also -support P12 certificate file, with the string "P12" specified with -\fICURLOPT_SSLCERTTYPE(3)\fP. - -When using a client certificate, you most likely also need to provide a -private key with \fICURLOPT_SSLKEY(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLCERTTYPE (3), -.BR CURLOPT_SSLKEY (3), -.BR CURLOPT_KEYPASSWD (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLCERT.md b/docs/libcurl/opts/CURLOPT_SSLCERT.md new file mode 100644 index 000000000..21f052ff7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLCERT.md @@ -0,0 +1,87 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLCERT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_KEYPASSWD (3) + - CURLOPT_SSLCERTTYPE (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_SSLCERT - SSL client certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT, char *cert); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the filename of your client certificate. The default format is "P12" on Secure +Transport and "PEM" on other engines, and can be changed with +CURLOPT_SSLCERTTYPE(3). + +With Secure Transport, this can also be the nickname of the certificate you +wish to authenticate with as it is named in the security database. If you want +to use a file from the current directory, please precede it with "./" prefix, +in order to avoid confusion with a nickname. + +(Schannel only) Client certificates can be specified by a path expression to a +certificate store. (You can import *PFX* to a store first). You can use +"" to refer to a certificate in the +system certificates store, for example, +**"CurrentUserMY934a7ac6f8a5d579285a74fa"**. The thumbprint is usually a SHA-1 +hex string which you can see in certificate details. Following store locations +are supported: **CurrentUser**, **LocalMachine**, **CurrentService**, +**Services**, **CurrentUserGroupPolicy**, **LocalMachineGroupPolicy**, +**LocalMachineEnterprise**. Schannel also support P12 certificate file, with +the string "P12" specified with CURLOPT_SSLCERTTYPE(3). + +When using a client certificate, you most likely also need to provide a +private key with CURLOPT_SSLKEY(3). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.3 b/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.3 deleted file mode 100644 index e800c5cbd..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLCERTTYPE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLCERTTYPE \- type of client SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERTTYPE, char *type); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the format of your certificate. - -Supported formats are "PEM" and "DER", except with Secure Transport or -Schannel. OpenSSL (versions 0.9.3 and later), Secure Transport (on iOS 5 or -later, or OS X 10.7 or later) and Schannel support "P12" for PKCS#12-encoded -files. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -"PEM" -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. Added in 7.9.3 -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLCERT (3), -.BR CURLOPT_SSLKEY (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.md b/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.md new file mode 100644 index 000000000..420ca4f86 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLCERTTYPE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLCERTTYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLCERT (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_SSLCERTTYPE - type of client SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERTTYPE, char *type); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the format of your certificate. + +Supported formats are "PEM" and "DER", except with Secure Transport or +Schannel. OpenSSL (versions 0.9.3 and later), Secure Transport (on iOS 5 or +later, or OS X 10.7 or later) and Schannel support "P12" for PKCS#12-encoded +files. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +"PEM" + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); + curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. Added in 7.9.3 + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.3 b/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.3 deleted file mode 100644 index 37a53362e..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLCERT_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_SSLCERT_BLOB \- SSL client certificate from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT_BLOB, - struct curl_blob *stblob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure, which contains (pointer and size) a -client certificate. The format must be "P12" on Secure Transport or -Schannel. The format must be "P12" or "PEM" on OpenSSL. The format must be -"DER" or "PEM" on mbedTLS. The format must be specified with -\fICURLOPT_SSLCERTTYPE(3)\fP. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -This option is an alternative to \fICURLOPT_SSLCERT(3)\fP which instead -expects a file name as input. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf - -extern char *certificateData; /* point to data */ -extern size_t filesize; /* size of data */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob stblob; - stblob.data = certificateData; - stblob.len = filesize; - stblob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &stblob); - curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "P12"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL, Secure Transport, -Schannel and mbedTLS (since 7.78.0) backends. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLCERTTYPE (3), -.BR CURLOPT_SSLKEY (3), -.BR CURLOPT_KEYPASSWD (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.md new file mode 100644 index 000000000..1f3ed56ed --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLCERT_BLOB.md @@ -0,0 +1,83 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLCERT_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_KEYPASSWD (3) + - CURLOPT_SSLCERTTYPE (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_SSLCERT_BLOB - SSL client certificate from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLCERT_BLOB, + struct curl_blob *stblob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure, which contains (pointer and size) a +client certificate. The format must be "P12" on Secure Transport or +Schannel. The format must be "P12" or "PEM" on OpenSSL. The format must be +"DER" or "PEM" on mbedTLS. The format must be specified with +CURLOPT_SSLCERTTYPE(3). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +This option is an alternative to CURLOPT_SSLCERT(3) which instead +expects a filename as input. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c + +extern char *certificateData; /* point to data */ +extern size_t filesize; /* size of data */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob stblob; + stblob.data = certificateData; + stblob.len = filesize; + stblob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &stblob); + curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "P12"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL, Secure Transport, +Schannel and mbedTLS (since 7.78.0) backends. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLENGINE.3 b/docs/libcurl/opts/CURLOPT_SSLENGINE.3 deleted file mode 100644 index 495841da9..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLENGINE.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLENGINE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLENGINE \- SSL engine identifier -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE, char *id); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It is used as the -identifier for the crypto engine you want to use for your private key. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLENGINE, "dynamic"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Only if the SSL backend is OpenSSL built with engine support. -.SH RETURN VALUE -CURLE_OK - Engine found. - -CURLE_SSL_ENGINE_NOTFOUND - Engine not found, or OpenSSL was not built with -engine support. - -CURLE_SSL_ENGINE_INITFAILED - Engine found but initialization failed. - -CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend. - -CURLE_UNKNOWN_OPTION - Option not recognized. - -CURLE_OUT_OF_MEMORY - Insufficient heap space. -.SH "SEE ALSO" -.BR CURLINFO_SSL_ENGINES (3), -.BR CURLOPT_SSLENGINE_DEFAULT (3), -.BR CURLOPT_SSLKEY (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLENGINE.md b/docs/libcurl/opts/CURLOPT_SSLENGINE.md new file mode 100644 index 000000000..45ccc42c5 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLENGINE.md @@ -0,0 +1,74 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLENGINE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_SSL_ENGINES (3) + - CURLOPT_SSLENGINE_DEFAULT (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_SSLENGINE - SSL engine identifier + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE, char *id); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It is used as the +identifier for the crypto engine you want to use for your private key. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLENGINE, "dynamic"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Only if the SSL backend is OpenSSL built with engine support. + +# RETURN VALUE + +CURLE_OK - Engine found. + +CURLE_SSL_ENGINE_NOTFOUND - Engine not found, or OpenSSL was not built with +engine support. + +CURLE_SSL_ENGINE_INITFAILED - Engine found but initialization failed. + +CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend. + +CURLE_UNKNOWN_OPTION - Option not recognized. + +CURLE_OUT_OF_MEMORY - Insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.3 b/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.3 deleted file mode 100644 index 0e904c67f..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLENGINE_DEFAULT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLENGINE_DEFAULT \- make SSL engine default -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE_DEFAULT, long val); -.fi -.SH DESCRIPTION -Pass a long set to 1 to make the already specified crypto engine the default -for (asymmetric) crypto operations. - -This option has no effect unless set after \fICURLOPT_SSLENGINE(3)\fP. -.SH DEFAULT -None -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLENGINE, "dynamic"); - curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Only if the SSL backend is OpenSSL built with engine support. -.SH RETURN VALUE -CURLE_OK - Engine set as default. - -CURLE_SSL_ENGINE_SETFAILED - Engine could not be set as default. - -CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend. - -CURLE_UNKNOWN_OPTION - Option not recognized. - -CURLE_OUT_OF_MEMORY - Insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLENGINE (3), -.BR CURLOPT_SSLCERT (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.md b/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.md new file mode 100644 index 000000000..d082f7b54 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLENGINE_DEFAULT.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLENGINE_DEFAULT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLCERT (3) + - CURLOPT_SSLENGINE (3) +--- + +# NAME + +CURLOPT_SSLENGINE_DEFAULT - make SSL engine default + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLENGINE_DEFAULT, long val); +~~~ + +# DESCRIPTION + +Pass a long set to 1 to make the already specified crypto engine the default +for (asymmetric) crypto operations. + +This option has no effect unless set after CURLOPT_SSLENGINE(3). + +# DEFAULT + +None + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLENGINE, "dynamic"); + curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Only if the SSL backend is OpenSSL built with engine support. + +# RETURN VALUE + +CURLE_OK - Engine set as default. + +CURLE_SSL_ENGINE_SETFAILED - Engine could not be set as default. + +CURLE_NOT_BUILT_IN - Option not built in, OpenSSL is not the SSL backend. + +CURLE_UNKNOWN_OPTION - Option not recognized. + +CURLE_OUT_OF_MEMORY - Insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLKEY.3 b/docs/libcurl/opts/CURLOPT_SSLKEY.3 deleted file mode 100644 index 7f54c4eaf..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLKEY.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLKEY 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLKEY \- private key file for TLS and SSL client cert -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY, char *keyfile); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the file name of your private key. The default format is "PEM" and can be -changed with \fICURLOPT_SSLKEYTYPE(3)\fP. - -(Windows, iOS and Mac OS X) This option is ignored by Secure Transport and -Schannel SSL backends because they expect the private key to be already present -in the key-chain or PKCS#12 file containing the certificate. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLCERT (3), -.BR CURLOPT_SSLKEY_BLOB (3), -.BR CURLOPT_SSLKEYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLKEY.md b/docs/libcurl/opts/CURLOPT_SSLKEY.md new file mode 100644 index 000000000..292258fd7 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLKEY.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLKEY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLCERT (3) + - CURLOPT_SSLKEYTYPE (3) + - CURLOPT_SSLKEY_BLOB (3) +--- + +# NAME + +CURLOPT_SSLKEY - private key file for TLS and SSL client cert + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY, char *keyfile); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the filename of your private key. The default format is "PEM" and can be +changed with CURLOPT_SSLKEYTYPE(3). + +(Windows, iOS and Mac OS X) This option is ignored by Secure Transport and +Schannel SSL backends because they expect the private key to be already present +in the key-chain or PKCS#12 file containing the certificate. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.3 b/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.3 deleted file mode 100644 index 957d175ea..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLKEYTYPE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLKEYTYPE \- type of the private key file -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEYTYPE, char *type); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the format of your private key. Supported formats are "PEM", "DER" and "ENG". - -The format "ENG" enables you to load the private key from a crypto engine. In -this case \fICURLOPT_SSLKEY(3)\fP is used as an identifier passed to the -engine. You have to set the crypto engine with \fICURLOPT_SSLENGINE(3)\fP. -\&"DER" format key file currently does not work because of a bug in OpenSSL. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -"PEM" -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSLCERT, "client.pem"); - curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); - curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLCERT (3), -.BR CURLOPT_SSLKEY (3), -.BR CURLOPT_PROXY_SSLKEYTYPE (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.md b/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.md new file mode 100644 index 000000000..b3f114109 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLKEYTYPE.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLKEYTYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLKEYTYPE (3) + - CURLOPT_SSLCERT (3) + - CURLOPT_SSLKEY (3) +--- + +# NAME + +CURLOPT_SSLKEYTYPE - type of the private key file + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEYTYPE, char *type); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the format of your private key. Supported formats are "PEM", "DER" and "ENG". + +The format "ENG" enables you to load the private key from a crypto engine. In +this case CURLOPT_SSLKEY(3) is used as an identifier passed to the engine. You +have to set the crypto engine with CURLOPT_SSLENGINE(3). "DER" format key file +currently does not work because of a bug in OpenSSL. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +"PEM" + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSLCERT, "client.pem"); + curl_easy_setopt(curl, CURLOPT_SSLKEY, "key.pem"); + curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.3 b/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.3 deleted file mode 100644 index 8d3f21da3..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLKEY_BLOB 3 "24 Jun 2020" libcurl libcurl -.SH NAME -CURLOPT_SSLKEY_BLOB \- private key for client cert from memory blob -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY_BLOB, - struct curl_blob *blob); -.fi -.SH DESCRIPTION -Pass a pointer to a curl_blob structure, which contains information (pointer -and size) for a private key. Compatible with OpenSSL. The format (like "PEM") -must be specified with \fICURLOPT_SSLKEYTYPE(3)\fP. - -If the blob is initialized with the flags member of struct curl_blob set to -CURL_BLOB_COPY, the application does not have to keep the buffer around after -setting this. - -This option is an alternative to \fICURLOPT_SSLKEY(3)\fP which instead expects -a file name as input. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf - -extern char *certificateData; /* point to cert */ -extern size_t filesize; /* size of cert */ - -extern char *privateKeyData; /* point to key */ -extern size_t privateKeySize; /* size of key */ - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_blob blob; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - blob.data = certificateData; - blob.len = filesize; - blob.flags = CURL_BLOB_COPY; - curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob); - curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); - - blob.data = privateKeyData; - blob.len = privateKeySize; - curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob); - curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); - curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.71.0. This option is supported by the OpenSSL backends. -.SH RETURN VALUE -Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_SSLKEYTYPE (3), -.BR CURLOPT_SSLKEY (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.md b/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.md new file mode 100644 index 000000000..74425692b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLKEY_BLOB.md @@ -0,0 +1,87 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLKEY_BLOB +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLKEY (3) + - CURLOPT_SSLKEYTYPE (3) +--- + +# NAME + +CURLOPT_SSLKEY_BLOB - private key for client cert from memory blob + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLKEY_BLOB, + struct curl_blob *blob); +~~~ + +# DESCRIPTION + +Pass a pointer to a curl_blob structure, which contains information (pointer +and size) for a private key. Compatible with OpenSSL. The format (like "PEM") +must be specified with CURLOPT_SSLKEYTYPE(3). + +If the blob is initialized with the flags member of struct curl_blob set to +CURL_BLOB_COPY, the application does not have to keep the buffer around after +setting this. + +This option is an alternative to CURLOPT_SSLKEY(3) which instead expects a +filename as input. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c + +extern char *certificateData; /* point to cert */ +extern size_t filesize; /* size of cert */ + +extern char *privateKeyData; /* point to key */ +extern size_t privateKeySize; /* size of key */ + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_blob blob; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + blob.data = certificateData; + blob.len = filesize; + blob.flags = CURL_BLOB_COPY; + curl_easy_setopt(curl, CURLOPT_SSLCERT_BLOB, &blob); + curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); + + blob.data = privateKeyData; + blob.len = privateKeySize; + curl_easy_setopt(curl, CURLOPT_SSLKEY_BLOB, &blob); + curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "s3cret"); + curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.71.0. This option is supported by the OpenSSL backends. + +# RETURN VALUE + +Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSLVERSION.3 b/docs/libcurl/opts/CURLOPT_SSLVERSION.3 deleted file mode 100644 index 2031b6803..000000000 --- a/docs/libcurl/opts/CURLOPT_SSLVERSION.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSLVERSION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSLVERSION \- preferred TLS/SSL version -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLVERSION, long version); -.fi -.SH DESCRIPTION -Pass a long as parameter to control which version range of SSL/TLS versions to -use. - -The SSL and TLS versions have typically developed from the most insecure -version to be more and more secure in this order through history: SSL v2, -SSLv3, TLS v1.0, TLS v1.1, TLS v1.2 and the most recent TLS v1.3. - -Use one of the available defines for this purpose. The available options are: -.RS -.IP CURL_SSLVERSION_DEFAULT -The default acceptable version range. The minimum acceptable version is by -default TLS v1.0 since 7.39.0 (unless the TLS library has a stricter rule). -.IP CURL_SSLVERSION_TLSv1 -TLS v1.0 or later -.IP CURL_SSLVERSION_SSLv2 -SSL v2 - refused -.IP CURL_SSLVERSION_SSLv3 -SSL v3 - refused -.IP CURL_SSLVERSION_TLSv1_0 -TLS v1.0 or later (Added in 7.34.0) -.IP CURL_SSLVERSION_TLSv1_1 -TLS v1.1 or later (Added in 7.34.0) -.IP CURL_SSLVERSION_TLSv1_2 -TLS v1.2 or later (Added in 7.34.0) -.IP CURL_SSLVERSION_TLSv1_3 -TLS v1.3 or later (Added in 7.52.0) -.RE - -The maximum TLS version can be set by using \fIone\fP of the -CURL_SSLVERSION_MAX_ macros below. It is also possible to OR \fIone\fP of the -CURL_SSLVERSION_ macros with \fIone\fP of the CURL_SSLVERSION_MAX_ macros. -The MAX macros are not supported for WolfSSL. -.RS -.IP CURL_SSLVERSION_MAX_DEFAULT -The flag defines the maximum supported TLS version by libcurl, or the default -value from the SSL library is used. libcurl uses a sensible default maximum, -which was TLS v1.2 up to before 7.61.0 and is TLS v1.3 since then - assuming -the TLS library support it. (Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_0 -The flag defines maximum supported TLS version as TLS v1.0. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_1 -The flag defines maximum supported TLS version as TLS v1.1. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_2 -The flag defines maximum supported TLS version as TLS v1.2. -(Added in 7.54.0) -.IP CURL_SSLVERSION_MAX_TLSv1_3 -The flag defines maximum supported TLS version as TLS v1.3. -(Added in 7.54.0) -.RE - -In versions of curl prior to 7.54 the CURL_SSLVERSION_TLS options were -documented to allow \fIonly\fP the specified TLS version, but behavior was -inconsistent depending on the TLS library. - -.SH DEFAULT -CURL_SSLVERSION_DEFAULT -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* ask libcurl to use TLS version 1.0 or later */ - curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -SSLv2 and SSLv3 are refused completely since curl 7.77.0 - -SSLv2 is disabled by default since 7.18.1. Other SSL versions availability may -vary depending on which backend libcurl has been built to use. - -SSLv3 is disabled by default since 7.39.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_IPRESOLVE (3), -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_SSLVERSION.md b/docs/libcurl/opts/CURLOPT_SSLVERSION.md new file mode 100644 index 000000000..f64a13b5f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSLVERSION.md @@ -0,0 +1,143 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSLVERSION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_IPRESOLVE (3) + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_SSLVERSION - preferred TLS/SSL version + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLVERSION, long version); +~~~ + +# DESCRIPTION + +Pass a long as parameter to control which version range of SSL/TLS versions to +use. + +The SSL and TLS versions have typically developed from the most insecure +version to be more and more secure in this order through history: SSL v2, +SSLv3, TLS v1.0, TLS v1.1, TLS v1.2 and the most recent TLS v1.3. + +Use one of the available defines for this purpose. The available options are: + +## CURL_SSLVERSION_DEFAULT + +The default acceptable version range. The minimum acceptable version is by +default TLS v1.0 since 7.39.0 (unless the TLS library has a stricter rule). + +## CURL_SSLVERSION_TLSv1 + +TLS v1.0 or later + +## CURL_SSLVERSION_SSLv2 + +SSL v2 - refused + +## CURL_SSLVERSION_SSLv3 + +SSL v3 - refused + +## CURL_SSLVERSION_TLSv1_0 + +TLS v1.0 or later (Added in 7.34.0) + +## CURL_SSLVERSION_TLSv1_1 + +TLS v1.1 or later (Added in 7.34.0) + +## CURL_SSLVERSION_TLSv1_2 + +TLS v1.2 or later (Added in 7.34.0) + +## CURL_SSLVERSION_TLSv1_3 + +TLS v1.3 or later (Added in 7.52.0) + +The maximum TLS version can be set by using *one* of the +CURL_SSLVERSION_MAX_ macros below. It is also possible to OR *one* of the +CURL_SSLVERSION_ macros with *one* of the CURL_SSLVERSION_MAX_ macros. +The MAX macros are not supported for WolfSSL. + +## CURL_SSLVERSION_MAX_DEFAULT + +The flag defines the maximum supported TLS version by libcurl, or the default +value from the SSL library is used. libcurl uses a sensible default maximum, +which was TLS v1.2 up to before 7.61.0 and is TLS v1.3 since then - assuming +the TLS library support it. (Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_0 + +The flag defines maximum supported TLS version as TLS v1.0. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_1 + +The flag defines maximum supported TLS version as TLS v1.1. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_2 + +The flag defines maximum supported TLS version as TLS v1.2. +(Added in 7.54.0) + +## CURL_SSLVERSION_MAX_TLSv1_3 + +The flag defines maximum supported TLS version as TLS v1.3. +(Added in 7.54.0) + +In versions of curl prior to 7.54 the CURL_SSLVERSION_TLS options were +documented to allow *only* the specified TLS version, but behavior was +inconsistent depending on the TLS library. + +# DEFAULT + +CURL_SSLVERSION_DEFAULT + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* ask libcurl to use TLS version 1.0 or later */ + curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +SSLv2 and SSLv3 are refused completely since curl 7.77.0 + +SSLv2 is disabled by default since 7.18.1. Other SSL versions availability may +vary depending on which backend libcurl has been built to use. + +SSLv3 is disabled by default since 7.39.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3 b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3 deleted file mode 100644 index 8196b5529..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_CIPHER_LIST 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_CIPHER_LIST \- ciphers to use for TLS -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CIPHER_LIST, char *list); -.fi -.SH DESCRIPTION -Pass a char *, pointing to a null-terminated string holding the list of -ciphers to use for the SSL connection. The list must be syntactically correct, -it consists of one or more cipher strings separated by colons. Commas or -spaces are also acceptable separators but colons are normally used, \&!, \&- -and \&+ can be used as operators. - -For OpenSSL and GnuTLS valid examples of cipher lists include \fBRC4-SHA\fP, -\fBSHA1+DES\fP, \fBTLSv1\fP and \fBDEFAULT\fP. The default list is normally -set when you compile OpenSSL. - -For WolfSSL, valid examples of cipher lists include \fBECDHE-RSA-RC4-SHA\fP, -\fBAES256-SHA:AES256-SHA256\fP, etc. - -For BearSSL, valid examples of cipher lists include -\fBECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256\fP, or when using IANA names -\fBTLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\fP, -etc. -With BearSSL you do not add/remove ciphers. If one uses this option then all -known ciphers are disabled and only those passed in are enabled. - -For Schannel, you can use this option to set algorithms but not specific cipher -suites. Refer to the ciphers lists document for algorithms. - -Find more details about cipher lists on this URL: - - https://curl.se/docs/ssl-ciphers.html - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, use internal default -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_SSL_CIPHER_LIST, "TLSv1"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.9, in 7.83.0 for BearSSL - -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_TLS13_CIPHERS (3), -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_PROXY_SSL_CIPHER_LIST (3), -.BR CURLOPT_PROXY_TLS13_CIPHERS (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md new file mode 100644 index 000000000..c96c93f3e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md @@ -0,0 +1,92 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_CIPHER_LIST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSL_CIPHER_LIST (3) + - CURLOPT_PROXY_TLS13_CIPHERS (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_TLS13_CIPHERS (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_SSL_CIPHER_LIST - ciphers to use for TLS + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CIPHER_LIST, char *list); +~~~ + +# DESCRIPTION + +Pass a char pointer, pointing to a null-terminated string holding the list of +ciphers to use for the SSL connection. The list must be syntactically correct, +it consists of one or more cipher strings separated by colons. Commas or +spaces are also acceptable separators but colons are normally used, !, - and ++ can be used as operators. + +For OpenSSL and GnuTLS valid examples of cipher lists include **RC4-SHA**, +**SHA1+DES**, **TLSv1** and **DEFAULT**. The default list is normally set when +you compile OpenSSL. + +For WolfSSL, valid examples of cipher lists include **ECDHE-RSA-RC4-SHA**, +**AES256-SHA:AES256-SHA256**, etc. + +For BearSSL, valid examples of cipher lists include +**ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256**, or when using +IANA names +**TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256**, +etc. With BearSSL you do not add/remove ciphers. If one uses this option then +all known ciphers are disabled and only those passed in are enabled. + +For Schannel, you can use this option to set algorithms but not specific +cipher suites. Refer to the ciphers lists document for algorithms. + +Find more details about cipher lists on this URL: + + https://curl.se/docs/ssl-ciphers.html + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, use internal default + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_SSL_CIPHER_LIST, "TLSv1"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.9, in 7.83.0 for BearSSL + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3 b/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3 deleted file mode 100644 index 6abe2a9bf..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.3 +++ /dev/null @@ -1,126 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_CTX_DATA 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_CTX_DATA \- pointer passed to SSL context callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_DATA, void *pointer); -.fi -.SH DESCRIPTION -Data \fIpointer\fP to pass to the ssl context callback set by the option -\fICURLOPT_SSL_CTX_FUNCTION(3)\fP, this is the pointer you get as third -parameter. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -/* OpenSSL specific */ - -#include -#include -#include - -static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) -{ - X509_STORE *store; - X509 *cert = NULL; - BIO *bio; - char *mypem = parm; - /* get a BIO */ - bio = BIO_new_mem_buf(mypem, -1); - /* use it to read the PEM formatted certificate from memory into an - * X509 structure that SSL can use - */ - PEM_read_bio_X509(bio, &cert, 0, NULL); - if(!cert) - printf("PEM_read_bio_X509 failed...\\n"); - - /* get a pointer to the X509 certificate store (which may be empty) */ - store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); - - /* add our certificate to this store */ - if(X509_STORE_add_cert(store, cert) == 0) - printf("error adding certificate\\n"); - - /* decrease reference counts */ - X509_free(cert); - BIO_free(bio); - - /* all set to go */ - return CURLE_OK; -} - -int main(void) -{ - CURL *ch; - CURLcode rv; - char *mypem = /* example CA cert PEM - shortened */ - "-----BEGIN CERTIFICATE-----\\n" - "MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\\n" - "IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\\n" - "IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\\n" - "Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\\n" - "GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\\n" - "zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\\n" - "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\\n" - "-----END CERTIFICATE-----\\n"; - - curl_global_init(CURL_GLOBAL_ALL); - ch = curl_easy_init(); - - curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); - curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); - - curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); - curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem); - rv = curl_easy_perform(ch); - if(!rv) - printf("*** transfer succeeded ***\\n"); - else - printf("*** transfer failed ***\\n"); - - curl_easy_cleanup(ch); - curl_global_cleanup(); - return rv; -} -.fi -.SH AVAILABILITY -Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS, -in 7.83.0 in BearSSL. Other SSL backends are not supported. -.SH RETURN VALUE -CURLE_OK if supported; or an error such as: - -CURLE_NOT_BUILT_IN - Not supported by the SSL backend - -CURLE_UNKNOWN_OPTION -.SH "SEE ALSO" -.BR CURLOPT_SSL_CTX_FUNCTION (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.md b/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.md new file mode 100644 index 000000000..6e328a5bd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_CTX_DATA.md @@ -0,0 +1,124 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_CTX_DATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CTX_FUNCTION (3) +--- + +# NAME + +CURLOPT_SSL_CTX_DATA - pointer passed to SSL context callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_DATA, void *pointer); +~~~ + +# DESCRIPTION + +Data *pointer* to pass to the ssl context callback set by the option +CURLOPT_SSL_CTX_FUNCTION(3), this is the pointer you get as third +parameter. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +/* OpenSSL specific */ + +#include +#include +#include + +static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) +{ + X509_STORE *store; + X509 *cert = NULL; + BIO *bio; + char *mypem = parm; + /* get a BIO */ + bio = BIO_new_mem_buf(mypem, -1); + /* use it to read the PEM formatted certificate from memory into an + * X509 structure that SSL can use + */ + PEM_read_bio_X509(bio, &cert, 0, NULL); + if(!cert) + printf("PEM_read_bio_X509 failed...\n"); + + /* get a pointer to the X509 certificate store (which may be empty) */ + store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); + + /* add our certificate to this store */ + if(X509_STORE_add_cert(store, cert) == 0) + printf("error adding certificate\n"); + + /* decrease reference counts */ + X509_free(cert); + BIO_free(bio); + + /* all set to go */ + return CURLE_OK; +} + +int main(void) +{ + CURL *ch; + CURLcode rv; + char *mypem = /* example CA cert PEM - shortened */ + "-----BEGIN CERTIFICATE-----\n" + "MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\n" + "IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\n" + "IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\n" + "Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\n" + "GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\n" + "zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\n" + "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n" + "-----END CERTIFICATE-----\n"; + + curl_global_init(CURL_GLOBAL_ALL); + ch = curl_easy_init(); + + curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); + curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); + curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); + + curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); + curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem); + rv = curl_easy_perform(ch); + if(!rv) + printf("*** transfer succeeded ***\n"); + else + printf("*** transfer failed ***\n"); + + curl_easy_cleanup(ch); + curl_global_cleanup(); + return rv; +} +~~~ + +# AVAILABILITY + +Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS, +in 7.83.0 in BearSSL. Other SSL backends are not supported. + +# RETURN VALUE + +CURLE_OK if supported; or an error such as: + +CURLE_NOT_BUILT_IN - Not supported by the SSL backend + +CURLE_UNKNOWN_OPTION diff --git a/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.3 b/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.3 deleted file mode 100644 index 3ec1c95e5..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.3 +++ /dev/null @@ -1,168 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_CTX_FUNCTION 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_CTX_FUNCTION \- SSL context callback for OpenSSL, wolfSSL or mbedTLS -.SH SYNOPSIS -.nf -#include - -CURLcode ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *clientp); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_FUNCTION, - ssl_ctx_callback); -.SH DESCRIPTION -This option only works for libcurl powered by OpenSSL, wolfSSL, mbedTLS or -BearSSL. If libcurl was built against another SSL library this functionality -is absent. - -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl just before the initialization -of an SSL connection after having processed all other SSL related options to -give a last chance to an application to modify the behavior of the SSL -initialization. The \fIssl_ctx\fP parameter is actually a pointer to the SSL -library's \fISSL_CTX\fP for OpenSSL or wolfSSL, a pointer to -\fImbedtls_ssl_config\fP for mbedTLS or a pointer to -\fIbr_ssl_client_context\fP for BearSSL. If an error is returned from the -callback no attempt to establish a connection is made and the perform -operation returns the callback's error code. Set the \fIclientp\fP argument -with the \fICURLOPT_SSL_CTX_DATA(3)\fP option. - -This function gets called on all new connections made to a server, during the -SSL negotiation. The \fIssl_ctx\fP points to a newly initialized object each -time, but note the pointer may be the same as from a prior call. - -To use this properly, a non-trivial amount of knowledge of your SSL library is -necessary. For example, you can use this function to call library-specific -callbacks to add additional validation code for certificates, and even to -change the actual URI of an HTTPS request. - -For OpenSSL, asynchronous certificate verification via -\fISSL_set_retry_verify\fP is supported. (Added in 8.3.0) - -WARNING: The \fICURLOPT_SSL_CTX_FUNCTION(3)\fP callback allows the application -to reach in and modify SSL details in the connection without libcurl itself -knowing anything about it, which then subsequently can lead to libcurl -unknowingly reusing SSL connections with different properties. To remedy this -you may set \fICURLOPT_FORBID_REUSE(3)\fP from the callback function. - -WARNING: If you are using DNS-over-HTTPS (DoH) via \fICURLOPT_DOH_URL(3)\fP -then this callback is also called for those transfers and the curl handle is -set to an internal handle. \fBThis behavior is subject to change.\fP We -recommend before performing your transfer set \fICURLOPT_PRIVATE(3)\fP on your -curl handle so you can identify it in the context callback. If you have a -reason to modify DoH SSL context please let us know on the curl-library -mailing list because we are considering removing this capability. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -/* OpenSSL specific */ - -#include -#include -#include - -static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) -{ - X509_STORE *store; - X509 *cert = NULL; - BIO *bio; - char *mypem = parm; - /* get a BIO */ - bio = BIO_new_mem_buf(mypem, -1); - /* use it to read the PEM formatted certificate from memory into an - * X509 structure that SSL can use - */ - PEM_read_bio_X509(bio, &cert, 0, NULL); - if(!cert) - printf("PEM_read_bio_X509 failed...\\n"); - - /* get a pointer to the X509 certificate store (which may be empty) */ - store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); - - /* add our certificate to this store */ - if(X509_STORE_add_cert(store, cert) == 0) - printf("error adding certificate\\n"); - - /* decrease reference counts */ - X509_free(cert); - BIO_free(bio); - - /* all set to go */ - return CURLE_OK; -} - -int main(void) -{ - CURL *ch; - CURLcode rv; - char *mypem = /* example CA cert PEM - shortened */ - "-----BEGIN CERTIFICATE-----\\n" - "MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\\n" - "IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\\n" - "IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\\n" - "Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\\n" - "GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\\n" - "zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\\n" - "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\\n" - "-----END CERTIFICATE-----\\n"; - - curl_global_init(CURL_GLOBAL_ALL); - ch = curl_easy_init(); - - curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); - curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); - curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); - - curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); - curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem); - rv = curl_easy_perform(ch); - if(!rv) - printf("*** transfer succeeded ***\\n"); - else - printf("*** transfer failed ***\\n"); - - curl_easy_cleanup(ch); - curl_global_cleanup(); - return rv; -} -.fi -.SH AVAILABILITY -Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS, -in 7.83.0 in BearSSL. Other SSL backends are not supported. -.SH RETURN VALUE -CURLE_OK if supported; or an error such as: - -CURLE_NOT_BUILT_IN - Not supported by the SSL backend - -CURLE_UNKNOWN_OPTION -.SH "SEE ALSO" -.BR CURLOPT_SSL_CTX_DATA (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.md b/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.md new file mode 100644 index 000000000..ae8b8bbad --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.md @@ -0,0 +1,167 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_CTX_FUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSL_CTX_DATA (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_SSL_CTX_FUNCTION - SSL context callback for OpenSSL, wolfSSL or mbedTLS + +# SYNOPSIS + +~~~c +#include + +CURLcode ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *clientp); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_CTX_FUNCTION, + ssl_ctx_callback); +~~~ + +# DESCRIPTION + +This option only works for libcurl powered by OpenSSL, wolfSSL, mbedTLS or +BearSSL. If libcurl was built against another SSL library this functionality +is absent. + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl just before the initialization +of an SSL connection after having processed all other SSL related options to +give a last chance to an application to modify the behavior of the SSL +initialization. The *ssl_ctx* parameter is actually a pointer to the SSL +library's *SSL_CTX* for OpenSSL or wolfSSL, a pointer to +*mbedtls_ssl_config* for mbedTLS or a pointer to +*br_ssl_client_context* for BearSSL. If an error is returned from the +callback no attempt to establish a connection is made and the perform +operation returns the callback's error code. Set the *clientp* argument +with the CURLOPT_SSL_CTX_DATA(3) option. + +This function gets called on all new connections made to a server, during the +SSL negotiation. The *ssl_ctx* points to a newly initialized object each +time, but note the pointer may be the same as from a prior call. + +To use this properly, a non-trivial amount of knowledge of your SSL library is +necessary. For example, you can use this function to call library-specific +callbacks to add additional validation code for certificates, and even to +change the actual URI of an HTTPS request. + +For OpenSSL, asynchronous certificate verification via +*SSL_set_retry_verify* is supported. (Added in 8.3.0) + +WARNING: The CURLOPT_SSL_CTX_FUNCTION(3) callback allows the application +to reach in and modify SSL details in the connection without libcurl itself +knowing anything about it, which then subsequently can lead to libcurl +unknowingly reusing SSL connections with different properties. To remedy this +you may set CURLOPT_FORBID_REUSE(3) from the callback function. + +WARNING: If you are using DNS-over-HTTPS (DoH) via CURLOPT_DOH_URL(3) +then this callback is also called for those transfers and the curl handle is +set to an internal handle. **This behavior is subject to change.** We +recommend before performing your transfer set CURLOPT_PRIVATE(3) on your +curl handle so you can identify it in the context callback. If you have a +reason to modify DoH SSL context please let us know on the curl-library +mailing list because we are considering removing this capability. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +/* OpenSSL specific */ + +#include +#include +#include + +static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) +{ + X509_STORE *store; + X509 *cert = NULL; + BIO *bio; + char *mypem = parm; + /* get a BIO */ + bio = BIO_new_mem_buf(mypem, -1); + /* use it to read the PEM formatted certificate from memory into an + * X509 structure that SSL can use + */ + PEM_read_bio_X509(bio, &cert, 0, NULL); + if(!cert) + printf("PEM_read_bio_X509 failed...\n"); + + /* get a pointer to the X509 certificate store (which may be empty) */ + store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); + + /* add our certificate to this store */ + if(X509_STORE_add_cert(store, cert) == 0) + printf("error adding certificate\n"); + + /* decrease reference counts */ + X509_free(cert); + BIO_free(bio); + + /* all set to go */ + return CURLE_OK; +} + +int main(void) +{ + CURL *ch; + CURLcode rv; + char *mypem = /* example CA cert PEM - shortened */ + "-----BEGIN CERTIFICATE-----\n" + "MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290\n" + "IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB\n" + "IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA\n" + "Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO\n" + "GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk\n" + "zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW\n" + "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n" + "-----END CERTIFICATE-----\n"; + + curl_global_init(CURL_GLOBAL_ALL); + ch = curl_easy_init(); + + curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); + curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); + curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); + + curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); + curl_easy_setopt(ch, CURLOPT_SSL_CTX_DATA, mypem); + rv = curl_easy_perform(ch); + if(!rv) + printf("*** transfer succeeded ***\n"); + else + printf("*** transfer failed ***\n"); + + curl_easy_cleanup(ch); + curl_global_cleanup(); + return rv; +} +~~~ + +# AVAILABILITY + +Added in 7.11.0 for OpenSSL, in 7.42.0 for wolfSSL, in 7.54.0 for mbedTLS, +in 7.83.0 in BearSSL. Other SSL backends are not supported. + +# RETURN VALUE + +CURLE_OK if supported; or an error such as: + +CURLE_NOT_BUILT_IN - Not supported by the SSL backend + +CURLE_UNKNOWN_OPTION diff --git a/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.3 b/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.3 deleted file mode 100644 index 65b5407d5..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_EC_CURVES 3 "29 Aug 2020" libcurl libcurl -.SH NAME -CURLOPT_SSL_EC_CURVES \- key exchange curves -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_EC_CURVES, char *alg_list); -.fi -.SH DESCRIPTION -Pass a string as parameter with a colon delimited list of (EC) algorithms. This -option defines the client's key exchange algorithms in the SSL handshake (if -the SSL backend libcurl is built to use supports it). -.SH DEFAULT -"", embedded in SSL backend -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -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_SSL_EC_CURVES, "X25519:P-521"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.73.0. Supported by the OpenSSL backend. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSL_OPTIONS (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_TLS13_CIPHERS (3) - diff --git a/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.md b/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.md new file mode 100644 index 000000000..adfaae34c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_EC_CURVES.md @@ -0,0 +1,61 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_EC_CURVES +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSL_CIPHER_LIST (3) + - CURLOPT_SSL_OPTIONS (3) + - CURLOPT_TLS13_CIPHERS (3) +--- + +# NAME + +CURLOPT_SSL_EC_CURVES - key exchange curves + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_EC_CURVES, char *alg_list); +~~~ + +# DESCRIPTION + +Pass a string as parameter with a colon delimited list of (EC) algorithms. This +option defines the client's key exchange algorithms in the SSL handshake (if +the SSL backend libcurl is built to use supports it). + +# DEFAULT + +"", embedded in SSL backend + +# PROTOCOLS + +HTTP + +# 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_SSL_EC_CURVES, "X25519:P-521"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.73.0. Supported by the OpenSSL backend. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.3 b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.3 deleted file mode 100644 index 346ca32bf..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.3 +++ /dev/null @@ -1,62 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_ENABLE_ALPN 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_ENABLE_ALPN \- Application Layer Protocol Negotiation -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_ENABLE_ALPN, long npn); -.fi -.SH DESCRIPTION -Pass a long as parameter, 0 or 1 where 1 is for enable and 0 for disable. This -option enables/disables ALPN in the SSL handshake (if the SSL backend libcurl -is built to use supports it), which can be used to negotiate http2. -.SH DEFAULT -1, enabled -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -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_SSL_ENABLE_ALPN, 0L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.36.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSL_ENABLE_NPN (3), -.BR CURLOPT_SSL_OPTIONS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.md b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.md new file mode 100644 index 000000000..e1b456a06 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_ALPN.md @@ -0,0 +1,60 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_ENABLE_ALPN +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSL_ENABLE_NPN (3) + - CURLOPT_SSL_OPTIONS (3) +--- + +# NAME + +CURLOPT_SSL_ENABLE_ALPN - Application Layer Protocol Negotiation + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_ENABLE_ALPN, long npn); +~~~ + +# DESCRIPTION + +Pass a long as parameter, 0 or 1 where 1 is for enable and 0 for disable. This +option enables/disables ALPN in the SSL handshake (if the SSL backend libcurl +is built to use supports it), which can be used to negotiate http2. + +# DEFAULT + +1, enabled + +# PROTOCOLS + +HTTP + +# 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_SSL_ENABLE_ALPN, 0L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.36.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.3 b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.3 deleted file mode 100644 index 69fd82671..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_ENABLE_NPN 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_ENABLE_NPN \- use NPN -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_ENABLE_NPN, long npn); -.fi -.SH DESCRIPTION -Deprecated in 7.86.0. Setting this option has no function. - -Pass a long as parameter, 0 or 1 where 1 is for enable and 0 for disable. This -option enables/disables NPN in the SSL handshake (if the SSL backend libcurl -is built to use supports it), which can be used to negotiate http2. -.SH DEFAULT -1, enabled -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -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_SSL_ENABLE_NPN, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.36.0. Deprecated in 7.86.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSL_ENABLE_ALPN (3), -.BR CURLOPT_SSL_OPTIONS (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.md b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.md new file mode 100644 index 000000000..36221cabd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_ENABLE_NPN.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_ENABLE_NPN +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSL_ENABLE_ALPN (3) + - CURLOPT_SSL_OPTIONS (3) +--- + +# NAME + +CURLOPT_SSL_ENABLE_NPN - use NPN + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_ENABLE_NPN, long npn); +~~~ + +# DESCRIPTION + +Deprecated in 7.86.0. Setting this option has no function. + +Pass a long as parameter, 0 or 1 where 1 is for enable and 0 for disable. This +option enables/disables NPN in the SSL handshake (if the SSL backend libcurl +is built to use supports it), which can be used to negotiate http2. + +# DEFAULT + +1, enabled + +# PROTOCOLS + +HTTP + +# 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_SSL_ENABLE_NPN, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.36.0. Deprecated in 7.86.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.3 b/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.3 deleted file mode 100644 index 34d6633fc..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.3 +++ /dev/null @@ -1,64 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_FALSESTART 3 "14 Feb 2015" libcurl libcurl -.SH NAME -CURLOPT_SSL_FALSESTART \- TLS false start -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_FALSESTART, long enable); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1L to enable or 0 to disable. - -This option determines whether libcurl should use false start during the TLS -handshake. False start is a mode where a TLS client starts sending application -data before verifying the server's Finished message, thus saving a round trip -when performing a full handshake. -.SH DEFAULT -0 -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_SSL_FALSESTART, 1L); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.42.0. This option is currently only supported by the Secure -Transport (on iOS 7.0 or later, or OS X 10.9 or later) TLS backend. -.SH RETURN VALUE -Returns CURLE_OK if false start is supported by the SSL backend, otherwise -returns CURLE_NOT_BUILT_IN. -.SH SEE ALSO -.BR CURLOPT_TCP_FASTOPEN "(3), " diff --git a/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.md b/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.md new file mode 100644 index 000000000..084728c70 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_FALSESTART.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_FALSESTART +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TCP_FASTOPEN (3) +--- + +# NAME + +CURLOPT_SSL_FALSESTART - TLS false start + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_FALSESTART, long enable); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1L to enable or 0 to disable. + +This option determines whether libcurl should use false start during the TLS +handshake. False start is a mode where a TLS client starts sending application +data before verifying the server's Finished message, thus saving a round trip +when performing a full handshake. + +# DEFAULT + +0 + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_SSL_FALSESTART, 1L); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.42.0. This option is currently only supported by the Secure +Transport (on iOS 7.0 or later, or OS X 10.9 or later) TLS backend. + +# RETURN VALUE + +Returns CURLE_OK if false start is supported by the SSL backend, otherwise +returns CURLE_NOT_BUILT_IN. diff --git a/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.3 deleted file mode 100644 index d131ac5d6..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.3 +++ /dev/null @@ -1,106 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_OPTIONS 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_OPTIONS \- SSL behavior options -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_OPTIONS, long bitmask); -.fi -.SH DESCRIPTION -Pass a long with a bitmask to tell libcurl about specific SSL -behaviors. Available bits: -.IP CURLSSLOPT_ALLOW_BEAST -Tells libcurl to not attempt to use any workarounds for a security flaw in the -SSL3 and TLS1.0 protocols. If this option is not used or this bit is set to 0, -the SSL layer libcurl uses may use a work-around for this flaw although it -might cause interoperability problems with some (older) SSL implementations. -WARNING: avoiding this work-around lessens the security, and by setting this -option to 1 you ask for exactly that. This option is only supported for -Secure Transport and OpenSSL. -.IP CURLSSLOPT_NO_REVOKE -Tells libcurl to disable certificate revocation checks for those SSL backends -where such behavior is present. This option is only supported for Schannel -(the native Windows SSL library), with an exception in the case of Windows' -Untrusted Publishers block list which it seems cannot be bypassed. (Added in -7.44.0) -.IP CURLSSLOPT_NO_PARTIALCHAIN -Tells libcurl to not accept "partial" certificate chains, which it otherwise -does by default. This option is only supported for OpenSSL and fails the -certificate verification if the chain ends with an intermediate certificate -and not with a root cert. (Added in 7.68.0) -.IP CURLSSLOPT_REVOKE_BEST_EFFORT -Tells libcurl to ignore certificate revocation checks in case of missing or -offline distribution points for those SSL backends where such behavior is -present. This option is only supported for Schannel (the native Windows SSL -library). If combined with \fICURLSSLOPT_NO_REVOKE\fP, the latter takes -precedence. (Added in 7.70.0) -.IP CURLSSLOPT_NATIVE_CA -Tell libcurl to use the operating system's native CA store for certificate -verification. If you set this option and also set a CA certificate file or -directory then during verification those certificates are searched in addition -to the native CA store. - -Works with wolfSSL on Windows, Linux (Debian, Ubuntu, Gentoo, Fedora, RHEL), -macOS, Android and iOS (added in 8.3.0), with GnuTLS (added in 8.5.0) or on -Windows when built to use OpenSSL (Added in 7.71.0). -.IP CURLSSLOPT_AUTO_CLIENT_CERT -Tell libcurl to automatically locate and use a client certificate for -authentication, when requested by the server. This option is only supported -for Schannel (the native Windows SSL library). Prior to 7.77.0 this was the -default behavior in libcurl with Schannel. Since the server can request any -certificate that supports client authentication in the OS certificate store it -could be a privacy violation and unexpected. -(Added in 7.77.0) -.SH DEFAULT -0 -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* weaken TLS only for use with silly servers */ - curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_ALLOW_BEAST | - CURLSSLOPT_NO_REVOKE); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.25.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_OPTIONS (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md b/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md new file mode 100644 index 000000000..ffc62c33c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md @@ -0,0 +1,116 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSL_OPTIONS (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CIPHER_LIST (3) +--- + +# NAME + +CURLOPT_SSL_OPTIONS - SSL behavior options + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_OPTIONS, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long with a bitmask to tell libcurl about specific SSL +behaviors. Available bits: + +## CURLSSLOPT_ALLOW_BEAST + +Tells libcurl to not attempt to use any workarounds for a security flaw in the +SSL3 and TLS1.0 protocols. If this option is not used or this bit is set to 0, +the SSL layer libcurl uses may use a work-around for this flaw although it +might cause interoperability problems with some (older) SSL implementations. +WARNING: avoiding this work-around lessens the security, and by setting this +option to 1 you ask for exactly that. This option is only supported for Secure +Transport and OpenSSL. + +## CURLSSLOPT_NO_REVOKE + +Tells libcurl to disable certificate revocation checks for those SSL backends +where such behavior is present. This option is only supported for Schannel +(the native Windows SSL library), with an exception in the case of Windows' +Untrusted Publishers block list which it seems cannot be bypassed. (Added in +7.44.0) + +## CURLSSLOPT_NO_PARTIALCHAIN + +Tells libcurl to not accept "partial" certificate chains, which it otherwise +does by default. This option is only supported for OpenSSL and fails the +certificate verification if the chain ends with an intermediate certificate +and not with a root cert. (Added in 7.68.0) + +## CURLSSLOPT_REVOKE_BEST_EFFORT + +Tells libcurl to ignore certificate revocation checks in case of missing or +offline distribution points for those SSL backends where such behavior is +present. This option is only supported for Schannel (the native Windows SSL +library). If combined with *CURLSSLOPT_NO_REVOKE*, the latter takes +precedence. (Added in 7.70.0) + +## CURLSSLOPT_NATIVE_CA + +Tell libcurl to use the operating system's native CA store for certificate +verification. If you set this option and also set a CA certificate file or +directory then during verification those certificates are searched in addition +to the native CA store. + +Works with wolfSSL on Windows, Linux (Debian, Ubuntu, Gentoo, Fedora, RHEL), +macOS, Android and iOS (added in 8.3.0), with GnuTLS (added in 8.5.0) or on +Windows when built to use OpenSSL (Added in 7.71.0). + +## CURLSSLOPT_AUTO_CLIENT_CERT + +Tell libcurl to automatically locate and use a client certificate for +authentication, when requested by the server. This option is only supported +for Schannel (the native Windows SSL library). Prior to 7.77.0 this was the +default behavior in libcurl with Schannel. Since the server can request any +certificate that supports client authentication in the OS certificate store it +could be a privacy violation and unexpected. +(Added in 7.77.0) + +# DEFAULT + +0 + +# PROTOCOLS + +All TLS-based protocols + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* weaken TLS only for use with silly servers */ + curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_ALLOW_BEAST | + CURLSSLOPT_NO_REVOKE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.25.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.3 b/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.3 deleted file mode 100644 index de2839098..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_SESSIONID_CACHE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_SESSIONID_CACHE \- use the SSL session-ID cache -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_SESSIONID_CACHE, - long enabled); -.SH DESCRIPTION -Pass a long set to 0 to disable libcurl's use of SSL session-ID caching. Set -this to 1 to enable it. By default all transfers are done using the cache -enabled. While nothing ever should get hurt by attempting to reuse SSL -session-IDs, there seem to be or have been broken SSL implementations in the -wild that may require you to disable this in order for you to succeed. -.SH DEFAULT -1 -.SH PROTOCOLS -All TLS-based -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* switch off session-id use! */ - curl_easy_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE, 0L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.16.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_DNS_CACHE_TIMEOUT (3), -.BR CURLOPT_MAXAGE_CONN (3), -.BR CURLOPT_MAXLIFETIME_CONN (3), -.BR CURLOPT_SSLVERSION (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.md b/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.md new file mode 100644 index 000000000..a6b3cf195 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_SESSIONID_CACHE.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_SESSIONID_CACHE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DNS_CACHE_TIMEOUT (3) + - CURLOPT_MAXAGE_CONN (3) + - CURLOPT_MAXLIFETIME_CONN (3) + - CURLOPT_SSLVERSION (3) +--- + +# NAME + +CURLOPT_SSL_SESSIONID_CACHE - use the SSL session-ID cache + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_SESSIONID_CACHE, + long enabled); +~~~ + +# DESCRIPTION + +Pass a long set to 0 to disable libcurl's use of SSL session-ID caching. Set +this to 1 to enable it. By default all transfers are done using the cache +enabled. While nothing ever should get hurt by attempting to reuse SSL +session-IDs, there seem to be or have been broken SSL implementations in the +wild that may require you to disable this in order for you to succeed. + +# DEFAULT + +1 + +# PROTOCOLS + +All TLS-based + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* switch off session-id use! */ + curl_easy_setopt(curl, CURLOPT_SSL_SESSIONID_CACHE, 0L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.16.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.3 b/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.3 deleted file mode 100644 index 3bdf665de..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.3 +++ /dev/null @@ -1,115 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_VERIFYHOST 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_VERIFYHOST \- verify the certificate's name against host -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter specifying what to \fIverify\fP. - -This option determines whether libcurl verifies that the server cert is for -the server it is known as. - -When negotiating TLS and SSL connections, the server sends a certificate -indicating its identity. - -When \fICURLOPT_SSL_VERIFYHOST(3)\fP is 2, that certificate must indicate that -the server is the server to which you meant to connect, or the connection -fails. Simply put, it means it has to have the same name in the certificate as -is in the URL you operate against. - -Curl considers the server the intended one when the Common Name field or a -Subject Alternate Name field in the certificate matches the host name in the -URL to which you told Curl to connect. - -If \fIverify\fP value is set to 1: - -In 7.28.0 and earlier: treated as a debug option of some sorts, not supported -anymore due to frequently leading to programmer mistakes. - -From 7.28.1 to 7.65.3: setting it to 1 made \fIcurl_easy_setopt(3)\fP return -an error and leaving the flag untouched. - -From 7.66.0: treats 1 and 2 the same. - -When the \fIverify\fP value is 0, the connection succeeds regardless of the -names in the certificate. Use that ability with caution! - -The default value for this option is 2. - -This option controls checking the server's certificate's claimed identity. -The server could be lying. To control lying, see -\fICURLOPT_SSL_VERIFYPEER(3)\fP. - -WARNING: disabling verification of the certificate allows bad guys to -man-in-the-middle the communication without you knowing it. Disabling -verification makes the communication insecure. Just having encryption on a -transfer is not enough as you cannot be sure that you are communicating with -the correct end-point. - -When libcurl uses secure protocols it trusts responses and allows for example -HSTS and Alt-Svc information to be stored and used subsequently. Disabling -certificate verification can make libcurl trust and use such information from -malicious servers. -.SH LIMITATIONS -Secure Transport: If \fIverify\fP value is 0, then SNI is also disabled. SNI is -a TLS extension that sends the hostname to the server. The server may use that -information to do such things as sending back a specific certificate for the -hostname, or forwarding the request to a specific origin server. Some hostnames -may be inaccessible if SNI is not sent. -.SH DEFAULT -2 -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* Set the default value: strict name check please */ - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not. - -If 1 is set as argument, \fICURLE_BAD_FUNCTION_ARGUMENT\fP is returned. -.SH "SEE ALSO" -.BR CURLOPT_CAINFO (3), -.BR CURLOPT_PINNEDPUBLICKEY (3), -.BR CURLOPT_SSL_VERIFYPEER (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.md b/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.md new file mode 100644 index 000000000..75648a11b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_VERIFYHOST.md @@ -0,0 +1,114 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_VERIFYHOST +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_PINNEDPUBLICKEY (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_SSL_VERIFYHOST - verify the certificate's name against host + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYHOST, long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter specifying what to *verify*. + +This option determines whether libcurl verifies that the server cert is for +the server it is known as. + +When negotiating TLS and SSL connections, the server sends a certificate +indicating its identity. + +When CURLOPT_SSL_VERIFYHOST(3) is 2, that certificate must indicate that +the server is the server to which you meant to connect, or the connection +fails. Simply put, it means it has to have the same name in the certificate as +is in the URL you operate against. + +Curl considers the server the intended one when the Common Name field or a +Subject Alternate Name field in the certificate matches the hostname in the +URL to which you told Curl to connect. + +If *verify* value is set to 1: + +In 7.28.0 and earlier: treated as a debug option of some sorts, not supported +anymore due to frequently leading to programmer mistakes. + +From 7.28.1 to 7.65.3: setting it to 1 made curl_easy_setopt(3) return +an error and leaving the flag untouched. + +From 7.66.0: treats 1 and 2 the same. + +When the *verify* value is 0, the connection succeeds regardless of the +names in the certificate. Use that ability with caution! + +The default value for this option is 2. + +This option controls checking the server's certificate's claimed identity. +The server could be lying. To control lying, see CURLOPT_SSL_VERIFYPEER(3). + +WARNING: disabling verification of the certificate allows bad guys to +man-in-the-middle the communication without you knowing it. Disabling +verification makes the communication insecure. Just having encryption on a +transfer is not enough as you cannot be sure that you are communicating with +the correct end-point. + +When libcurl uses secure protocols it trusts responses and allows for example +HSTS and Alt-Svc information to be stored and used subsequently. Disabling +certificate verification can make libcurl trust and use such information from +malicious servers. + +# LIMITATIONS + +Secure Transport: If *verify* value is 0, then SNI is also disabled. SNI is +a TLS extension that sends the hostname to the server. The server may use that +information to do such things as sending back a specific certificate for the +hostname, or forwarding the request to a specific origin server. Some hostnames +may be inaccessible if SNI is not sent. + +# DEFAULT + +2 + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* Set the default value: strict name check please */ + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if TLS is supported, and CURLE_UNKNOWN_OPTION if not. + +If 1 is set as argument, *CURLE_BAD_FUNCTION_ARGUMENT* is returned. diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.3 b/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.3 deleted file mode 100644 index a5ec49b0a..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_VERIFYPEER 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_VERIFYPEER \- verify the peer's SSL certificate -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter to enable or disable. - -This option determines whether curl verifies the authenticity of the peer's -certificate. A value of 1 means curl verifies; 0 (zero) means it does not. - -When negotiating a TLS or SSL connection, the server sends a certificate -indicating its identity. Curl verifies whether the certificate is authentic, -i.e. that you can trust that the server is who the certificate says it is. -This trust is based on a chain of digital signatures, rooted in certification -authority (CA) certificates you supply. curl uses a default bundle of CA -certificates (the path for that is determined at build time) and you can -specify alternate certificates with the \fICURLOPT_CAINFO(3)\fP option or the -\fICURLOPT_CAPATH(3)\fP option. - -When \fICURLOPT_SSL_VERIFYPEER(3)\fP is enabled, and the verification fails to -prove that the certificate is signed by a CA, the connection fails. - -When this option is disabled (set to zero), the CA certificates are not loaded -and the peer certificate verification is simply skipped. - -Authenticating the certificate is not enough to be sure about the server. You -typically also want to ensure that the server is the server you mean to be -talking to. Use \fICURLOPT_SSL_VERIFYHOST(3)\fP for that. The check that the -host name in the certificate is valid for the host name you are connecting to -is done independently of the \fICURLOPT_SSL_VERIFYPEER(3)\fP option. - -WARNING: disabling verification of the certificate allows bad guys to -man-in-the-middle the communication without you knowing it. Disabling -verification makes the communication insecure. Just having encryption on a -transfer is not enough as you cannot be sure that you are communicating with -the correct end-point. - -When libcurl uses secure protocols it trusts responses and allows for example -HSTS and Alt-Svc information to be stored and used subsequently. Disabling -certificate verification can make libcurl trust and use such information from -malicious servers. -.SH DEFAULT -1 - enabled -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* Set the default value: strict certificate check please */ - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -If built TLS enabled. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_PROXY_SSL_VERIFYPEER (3), -.BR CURLOPT_PROXY_SSL_VERIFYHOST (3), -.BR CURLOPT_CAINFO (3), -.BR CURLINFO_CAINFO (3), -.BR CURLINFO_CAPATH (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.md b/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.md new file mode 100644 index 000000000..c9884ceb9 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_VERIFYPEER.md @@ -0,0 +1,98 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_VERIFYPEER +Section: 3 +Source: libcurl +See-also: + - CURLINFO_CAINFO (3) + - CURLINFO_CAPATH (3) + - CURLOPT_CAINFO (3) + - CURLOPT_PROXY_SSL_VERIFYHOST (3) + - CURLOPT_PROXY_SSL_VERIFYPEER (3) + - CURLOPT_SSL_VERIFYHOST (3) +--- + +# NAME + +CURLOPT_SSL_VERIFYPEER - verify the peer's SSL certificate + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYPEER, long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter to enable or disable. + +This option determines whether curl verifies the authenticity of the peer's +certificate. A value of 1 means curl verifies; 0 (zero) means it does not. + +When negotiating a TLS or SSL connection, the server sends a certificate +indicating its identity. Curl verifies whether the certificate is authentic, +i.e. that you can trust that the server is who the certificate says it is. +This trust is based on a chain of digital signatures, rooted in certification +authority (CA) certificates you supply. curl uses a default bundle of CA +certificates (the path for that is determined at build time) and you can +specify alternate certificates with the CURLOPT_CAINFO(3) option or the +CURLOPT_CAPATH(3) option. + +When CURLOPT_SSL_VERIFYPEER(3) is enabled, and the verification fails to +prove that the certificate is signed by a CA, the connection fails. + +When this option is disabled (set to zero), the CA certificates are not loaded +and the peer certificate verification is simply skipped. + +Authenticating the certificate is not enough to be sure about the server. You +typically also want to ensure that the server is the server you mean to be +talking to. Use CURLOPT_SSL_VERIFYHOST(3) for that. The check that the host +name in the certificate is valid for the hostname you are connecting to is +done independently of the CURLOPT_SSL_VERIFYPEER(3) option. + +WARNING: disabling verification of the certificate allows bad guys to +man-in-the-middle the communication without you knowing it. Disabling +verification makes the communication insecure. Just having encryption on a +transfer is not enough as you cannot be sure that you are communicating with +the correct end-point. + +When libcurl uses secure protocols it trusts responses and allows for example +HSTS and Alt-Svc information to be stored and used subsequently. Disabling +certificate verification can make libcurl trust and use such information from +malicious servers. + +# DEFAULT + +1 - enabled + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* Set the default value: strict certificate check please */ + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +If built TLS enabled. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.3 b/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.3 deleted file mode 100644 index 0bfe7da12..000000000 --- a/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SSL_VERIFYSTATUS 3 "04 Dec 2014" libcurl libcurl -.SH NAME -CURLOPT_SSL_VERIFYSTATUS \- verify the certificate's status -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYSTATUS, long verify); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1 to enable or 0 to disable. - -This option determines whether libcurl verifies the status of the server cert -using the "Certificate Status Request" TLS extension (aka. OCSP stapling). - -Note that if this option is enabled but the server does not support the TLS -extension, the verification fails. -.SH DEFAULT -0 -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* ask for OCSP stapling! */ - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.41.0. This option is currently only supported by the OpenSSL and -GnuTLS TLS backends. -.SH RETURN VALUE -Returns CURLE_OK if OCSP stapling is supported by the SSL backend, otherwise -returns CURLE_NOT_BUILT_IN. -.SH "SEE ALSO" -.BR CURLOPT_SSL_VERIFYHOST (3), -.BR CURLOPT_SSL_VERIFYPEER (3), -.BR CURLOPT_CAINFO (3) diff --git a/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.md b/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.md new file mode 100644 index 000000000..66dbd7465 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SSL_VERIFYSTATUS.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SSL_VERIFYSTATUS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CAINFO (3) + - CURLOPT_SSL_VERIFYHOST (3) + - CURLOPT_SSL_VERIFYPEER (3) +--- + +# NAME + +CURLOPT_SSL_VERIFYSTATUS - verify the certificate's status + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSL_VERIFYSTATUS, long verify); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1 to enable or 0 to disable. + +This option determines whether libcurl verifies the status of the server cert +using the "Certificate Status Request" TLS extension (aka. OCSP stapling). + +Note that if this option is enabled but the server does not support the TLS +extension, the verification fails. + +# DEFAULT + +0 + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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 OCSP stapling! */ + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.41.0. This option is currently only supported by the OpenSSL and +GnuTLS TLS backends. + +# RETURN VALUE + +Returns CURLE_OK if OCSP stapling is supported by the SSL backend, otherwise +returns CURLE_NOT_BUILT_IN. diff --git a/docs/libcurl/opts/CURLOPT_STDERR.3 b/docs/libcurl/opts/CURLOPT_STDERR.3 deleted file mode 100644 index 949841dda..000000000 --- a/docs/libcurl/opts/CURLOPT_STDERR.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_STDERR 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_STDERR \- redirect stderr to another stream -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STDERR, FILE *stream); -.fi -.SH DESCRIPTION -Pass a FILE * as parameter. Tell libcurl to use this \fIstream\fP instead of -stderr when showing the progress meter and displaying \fICURLOPT_VERBOSE(3)\fP -data. - -If you are using libcurl as a Windows DLL, this option causes an exception and -a crash in the library since it cannot access a FILE * passed on from the -application. A work-around is to instead use \fICURLOPT_DEBUGFUNCTION(3)\fP. -.SH DEFAULT -stderr -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - FILE *filep = fopen("dump", "wb"); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_STDERR, filep); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_VERBOSE (3), -.BR CURLOPT_NOPROGRESS (3), -.BR CURLOPT_DEBUGFUNCTION (3) - diff --git a/docs/libcurl/opts/CURLOPT_STDERR.md b/docs/libcurl/opts/CURLOPT_STDERR.md new file mode 100644 index 000000000..a20e50366 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_STDERR.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_STDERR +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_NOPROGRESS (3) + - CURLOPT_VERBOSE (3) +--- + +# NAME + +CURLOPT_STDERR - redirect stderr to another stream + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STDERR, FILE *stream); +~~~ + +# DESCRIPTION + +Pass a FILE * as parameter. Tell libcurl to use this *stream* instead of +stderr when showing the progress meter and displaying CURLOPT_VERBOSE(3) +data. + +If you are using libcurl as a Windows DLL, this option causes an exception and +a crash in the library since it cannot access a FILE * passed on from the +application. A work-around is to instead use CURLOPT_DEBUGFUNCTION(3). + +# DEFAULT + +stderr + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + FILE *filep = fopen("dump", "wb"); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_STDERR, filep); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.3 b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.3 deleted file mode 100644 index 48276467c..000000000 --- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_STREAM_DEPENDS 3 "13 Sep 2015" libcurl libcurl -.SH NAME -CURLOPT_STREAM_DEPENDS \- stream this transfer depends on -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_DEPENDS, - CURL *dephandle); -.fi -.SH DESCRIPTION -Pass a CURL * pointer in \fIdephandle\fP to identify the stream within the -same connection that this stream is depending upon. This option clears the -exclusive bit and is mutually exclusive to the -\fICURLOPT_STREAM_DEPENDS_E(3)\fP option. - -The spec says "Including a dependency expresses a preference to allocate -resources to the identified stream rather than to the dependent stream." - -This option can be set during transfer. - -\fIdephandle\fP must not be the same as \fIhandle\fP, that makes this function -return an error. It must be another easy handle, and it also needs to be a -handle of a transfer that is about to be sent over the same HTTP/2 connection -for this option to have an actual effect. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP/2 -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - CURL *curl2 = curl_easy_init(); /* a second handle */ - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); - - /* the second depends on the first */ - curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); - curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS, curl); - - /* then add both to a multi handle and transfer them! */ - } -} -.fi -.SH AVAILABILITY -Added in 7.46.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_STREAM_DEPENDS_E (3), -.BR CURLOPT_STREAM_WEIGHT (3) diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md new file mode 100644 index 000000000..ba2489a30 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_STREAM_DEPENDS +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_PIPELINING (3) + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_STREAM_DEPENDS_E (3) + - CURLOPT_STREAM_WEIGHT (3) +--- + +# NAME + +CURLOPT_STREAM_DEPENDS - stream this transfer depends on + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_DEPENDS, + CURL *dephandle); +~~~ + +# DESCRIPTION + +Pass a CURL pointer in *dephandle* to identify the stream within the same +connection that this stream is depending upon. This option clears the +exclusive bit and is mutually exclusive to the CURLOPT_STREAM_DEPENDS_E(3) +option. + +The spec says "Including a dependency expresses a preference to allocate +resources to the identified stream rather than to the dependent stream." + +This option can be set during transfer. + +*dephandle* must not be the same as *handle*, that makes this function return +an error. It must be another easy handle, and it also needs to be a handle of +a transfer that is about to be sent over the same HTTP/2 connection for this +option to have an actual effect. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP/2 + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + CURL *curl2 = curl_easy_init(); /* a second handle */ + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); + + /* the second depends on the first */ + curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); + curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS, curl); + + /* then add both to a multi handle and transfer them! */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.46.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.3 b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.3 deleted file mode 100644 index c84173d85..000000000 --- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_STREAM_DEPENDS_E 3 "13 Sep 2015" libcurl libcurl -.SH NAME -CURLOPT_STREAM_DEPENDS_E \- stream this transfer depends on exclusively -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_DEPENDS_E, - CURL *dephandle); -.fi -.SH DESCRIPTION -Pass a CURL * pointer in \fIdephandle\fP to identify the stream within the -same connection that this stream is depending upon exclusively. That means it -depends on it and sets the Exclusive bit. - -The spec says "Including a dependency expresses a preference to allocate -resources to the identified stream rather than to the dependent stream." - -Setting a dependency with the exclusive flag for a reprioritized stream causes -all the dependencies of the new parent stream to become dependent on the -reprioritized stream. - -This option can be set during transfer. - -\fIdephandle\fP must not be the same as \fIhandle\fP, that makes this function -return an error. It must be another easy handle, and it also needs to be a -handle of a transfer that is about to be sent over the same HTTP/2 connection -for this option to have an actual effect. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP/2 -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - CURL *curl2 = curl_easy_init(); /* a second handle */ - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); - - /* the second depends on the first */ - curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); - curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS_E, curl); - - /* then add both to a multi handle and transfer them! */ - } -} -.fi -.SH AVAILABILITY -Added in 7.46.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLOPT_HTTP_VERSION (3), -.BR CURLOPT_STREAM_DEPENDS (3), -.BR CURLOPT_STREAM_WEIGHT (3) - diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md new file mode 100644 index 000000000..e8dbc113f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_STREAM_DEPENDS_E +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_PIPELINING (3) + - CURLOPT_HTTP_VERSION (3) + - CURLOPT_STREAM_DEPENDS (3) + - CURLOPT_STREAM_WEIGHT (3) +--- + +# NAME + +CURLOPT_STREAM_DEPENDS_E - stream this transfer depends on exclusively + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_DEPENDS_E, + CURL *dephandle); +~~~ + +# DESCRIPTION + +Pass a CURL pointer in *dephandle* to identify the stream within the same +connection that this stream is depending upon exclusively. That means it +depends on it and sets the Exclusive bit. + +The spec says "Including a dependency expresses a preference to allocate +resources to the identified stream rather than to the dependent stream." + +Setting a dependency with the exclusive flag for a reprioritized stream causes +all the dependencies of the new parent stream to become dependent on the +reprioritized stream. + +This option can be set during transfer. + +*dephandle* must not be the same as *handle*, that makes this function return +an error. It must be another easy handle, and it also needs to be a handle of +a transfer that is about to be sent over the same HTTP/2 connection for this +option to have an actual effect. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP/2 + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + CURL *curl2 = curl_easy_init(); /* a second handle */ + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); + + /* the second depends on the first */ + curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); + curl_easy_setopt(curl2, CURLOPT_STREAM_DEPENDS_E, curl); + + /* then add both to a multi handle and transfer them! */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.46.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.3 b/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.3 deleted file mode 100644 index 7534d1d59..000000000 --- a/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_STREAM_WEIGHT 3 "13 Sep 2015" libcurl libcurl -.SH NAME -CURLOPT_STREAM_WEIGHT \- numerical stream weight -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_WEIGHT, long weight); -.fi -.SH DESCRIPTION -Set the long \fIweight\fP to a number between 1 and 256. - -When using HTTP/2, this option sets the individual weight for this particular -stream used by the easy \fIhandle\fP. Setting and using weights only makes -sense and is only usable when doing multiple streams over the same -connections, which thus implies that you use \fICURLMOPT_PIPELINING(3)\fP. - -This option can be set during transfer and causes the updated weight info get -sent to the server the next time an HTTP/2 frame is sent to the server. - -See section 5.3 of RFC 7540 for protocol details. - -Streams with the same parent should be allocated resources proportionally -based on their weight. So if you have two streams going, stream A with weight -16 and stream B with weight 32, stream B gets two thirds (32/48) of the -available bandwidth (assuming the server can send off the data equally for -both streams). -.SH DEFAULT -If nothing is set, the HTTP/2 protocol itself uses its own default which is -16. -.SH PROTOCOLS -HTTP/2 -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - CURL *curl2 = curl_easy_init(); /* a second handle */ - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); - curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L); - - /* the second has twice the weight */ - curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); - curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L); - - /* then add both to a multi handle and transfer them! */ - } -} -.fi -.SH AVAILABILITY -Added in 7.46.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLMOPT_PIPELINING (3), -.BR CURLOPT_PIPEWAIT (3), -.BR CURLOPT_STREAM_DEPENDS (3), -.BR CURLOPT_STREAM_DEPENDS_E (3) diff --git a/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.md b/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.md new file mode 100644 index 000000000..914a4263d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_STREAM_WEIGHT.md @@ -0,0 +1,81 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_STREAM_WEIGHT +Section: 3 +Source: libcurl +See-also: + - CURLMOPT_PIPELINING (3) + - CURLOPT_PIPEWAIT (3) + - CURLOPT_STREAM_DEPENDS (3) + - CURLOPT_STREAM_DEPENDS_E (3) +--- + +# NAME + +CURLOPT_STREAM_WEIGHT - numerical stream weight + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_WEIGHT, long weight); +~~~ + +# DESCRIPTION + +Set the long *weight* to a number between 1 and 256. + +When using HTTP/2, this option sets the individual weight for this particular +stream used by the easy *handle*. Setting and using weights only makes +sense and is only usable when doing multiple streams over the same +connections, which thus implies that you use CURLMOPT_PIPELINING(3). + +This option can be set during transfer and causes the updated weight info get +sent to the server the next time an HTTP/2 frame is sent to the server. + +See section 5.3 of RFC 7540 for protocol details. + +Streams with the same parent should be allocated resources proportionally +based on their weight. If you have two streams going, stream A with weight 16 +and stream B with weight 32, stream B gets two thirds (32/48) of the available +bandwidth (assuming the server can send off the data equally for both +streams). + +# DEFAULT + +If nothing is set, the HTTP/2 protocol itself uses its own default which is +16. + +# PROTOCOLS + +HTTP/2 + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + CURL *curl2 = curl_easy_init(); /* a second handle */ + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one"); + curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L); + + /* the second has twice the weight */ + curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two"); + curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L); + + /* then add both to a multi handle and transfer them! */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.46.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.3 b/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.3 deleted file mode 100644 index 15b73917d..000000000 --- a/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_SUPPRESS_CONNECT_HEADERS 3 "13 February 2017" libcurl libcurl -.SH NAME -CURLOPT_SUPPRESS_CONNECT_HEADERS \- suppress proxy CONNECT response headers from user callbacks -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SUPPRESS_CONNECT_HEADERS, long onoff); -.fi -.SH DESCRIPTION -When \fICURLOPT_HTTPPROXYTUNNEL(3)\fP is used and a CONNECT request is made, -suppress proxy CONNECT response headers from the user callback functions -\fICURLOPT_HEADERFUNCTION(3)\fP and \fICURLOPT_WRITEFUNCTION(3)\fP. - -Proxy CONNECT response headers can complicate header processing since it's -essentially a separate set of headers. You can enable this option to suppress -those headers. - -For example let's assume an HTTPS URL is to be retrieved via CONNECT. On -success there would normally be two sets of headers, and each header line sent -to the header function and/or the write function. The data given to the -callbacks would look like this: - -.nf -HTTP/1.1 200 Connection established -{headers}... - -HTTP/1.1 200 OK -Content-Type: application/json -{headers}... - -{body}... -.fi - -However by enabling this option the CONNECT response headers are suppressed, so -the data given to the callbacks would look like this: - -.nf -HTTP/1.1 200 OK -Content-Type: application/json -{headers}... - -{body}... -.fi - -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128"); - curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L); - - curl_easy_perform(curl); - - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.54.0 -.SH RETURN VALUE -CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. -.SH "SEE ALSO" -.BR CURLOPT_HEADER (3), -.BR CURLOPT_PROXY (3), -.BR CURLOPT_HTTPPROXYTUNNEL (3) diff --git a/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md b/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md new file mode 100644 index 000000000..730192585 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md @@ -0,0 +1,103 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_SUPPRESS_CONNECT_HEADERS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADER (3) + - CURLOPT_HTTPPROXYTUNNEL (3) + - CURLOPT_PROXY (3) +--- + +# NAME + +CURLOPT_SUPPRESS_CONNECT_HEADERS - suppress proxy CONNECT response headers + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SUPPRESS_CONNECT_HEADERS, long onoff); +~~~ + +# DESCRIPTION + +When CURLOPT_HTTPPROXYTUNNEL(3) is used and a CONNECT request is made, +suppress proxy CONNECT response headers from the user callback functions +CURLOPT_HEADERFUNCTION(3) and CURLOPT_WRITEFUNCTION(3). + +Proxy CONNECT response headers can complicate header processing since it is +essentially a separate set of headers. You can enable this option to suppress +those headers. + +For example let's assume an HTTPS URL is to be retrieved via CONNECT. On +success there would normally be two sets of headers, and each header line sent +to the header function and/or the write function. The data given to the +callbacks would look like this: + +~~~c +HTTP/1.1 200 Connection established +{headers} +... + +HTTP/1.1 200 OK +Content-Type: application/json +{headers} +... + +{body} +... +~~~ + +However by enabling this option the CONNECT response headers are suppressed, +so the data given to the callbacks would look like this: + +~~~c +HTTP/1.1 200 OK +Content-Type: application/json +{headers} +... + +{body} +... +~~~ + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128"); + curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); + curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L); + + curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.54.0 + +# RETURN VALUE + +CURLE_OK or an error such as CURLE_UNKNOWN_OPTION. diff --git a/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3 b/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3 deleted file mode 100644 index 53e0fc59d..000000000 --- a/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TCP_FASTOPEN 3 "16 Feb 2016" libcurl libcurl -.SH NAME -CURLOPT_TCP_FASTOPEN \- TCP Fast Open -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable); -.fi -.SH DESCRIPTION -Pass a long as parameter set to 1L to enable or 0 to disable. - -TCP Fast Open (RFC 7413) is a mechanism that allows data to be carried in the -SYN and SYN-ACK packets and consumed by the receiving end during the initial -connection handshake, saving up to one full round-trip time (RTT). - -Beware: the TLS session cache does not work when TCP Fast Open is enabled. TCP -Fast Open is also known to be problematic on or across certain networks. -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.49.0. This option is currently only supported on Linux and macOS -10.11 or later. -.SH RETURN VALUE -Returns CURLE_OK if fast open is supported by the operating system, otherwise -returns CURLE_NOT_BUILT_IN. -.SH SEE ALSO -.BR CURLOPT_SSL_FALSESTART "(3), " diff --git a/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.md b/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.md new file mode 100644 index 000000000..4db103b4b --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TCP_FASTOPEN.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TCP_FASTOPEN +Section: 3 +Source: libcurl +See-also: + - CURLOPT_SSL_FALSESTART (3) +--- + +# NAME + +CURLOPT_TCP_FASTOPEN - TCP Fast Open + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable); +~~~ + +# DESCRIPTION + +Pass a long as parameter set to 1L to enable or 0 to disable. + +TCP Fast Open (RFC 7413) is a mechanism that allows data to be carried in the +SYN and SYN-ACK packets and consumed by the receiving end during the initial +connection handshake, saving up to one full round-trip time (RTT). + +Beware: the TLS session cache does not work when TCP Fast Open is enabled. TCP +Fast Open is also known to be problematic on or across certain networks. + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.49.0. This option is currently only supported on Linux and macOS +10.11 or later. + +# RETURN VALUE + +Returns CURLE_OK if fast open is supported by the operating system, otherwise +returns CURLE_NOT_BUILT_IN. diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.3 b/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.3 deleted file mode 100644 index 04e3ecb58..000000000 --- a/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TCP_KEEPALIVE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TCP_KEEPALIVE \- TCP keep-alive probing -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long probe); -.fi -.SH DESCRIPTION -Pass a long. If set to 1, TCP keepalive probes are used. The delay and -frequency of these probes can be controlled by the -\fICURLOPT_TCP_KEEPIDLE(3)\fP and \fICURLOPT_TCP_KEEPINTVL(3)\fP options, -provided the operating system supports them. Set to 0 (default behavior) to -disable keepalive probes -.SH DEFAULT -0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* enable TCP keep-alive for this transfer */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); - - /* keep-alive idle time to 120 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); - - /* interval time between keep-alive probes: 60 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.25.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_TCP_KEEPIDLE (3), -.BR CURLOPT_TCP_KEEPINTVL (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_MAX_RECV_SPEED_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.md b/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.md new file mode 100644 index 000000000..090431993 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TCP_KEEPALIVE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TCP_KEEPALIVE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_MAX_RECV_SPEED_LARGE (3) + - CURLOPT_TCP_KEEPIDLE (3) + - CURLOPT_TCP_KEEPINTVL (3) +--- + +# NAME + +CURLOPT_TCP_KEEPALIVE - TCP keep-alive probing + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPALIVE, long probe); +~~~ + +# DESCRIPTION + +Pass a long. If set to 1, TCP keepalive probes are used. The delay and +frequency of these probes can be controlled by the +CURLOPT_TCP_KEEPIDLE(3) and CURLOPT_TCP_KEEPINTVL(3) options, +provided the operating system supports them. Set to 0 (default behavior) to +disable keepalive probes + +# DEFAULT + +0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* enable TCP keep-alive for this transfer */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); + + /* keep-alive idle time to 120 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); + + /* interval time between keep-alive probes: 60 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.25.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 b/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 deleted file mode 100644 index f845b73c5..000000000 --- a/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TCP_KEEPIDLE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TCP_KEEPIDLE \- TCP keep-alive idle time wait -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay); -.fi -.SH DESCRIPTION -Pass a long. Sets the \fIdelay\fP, in seconds, to wait while the connection is -idle before sending keepalive probes. Not all operating systems support this -option. - -The maximum value this accepts is 2147483648. Any larger value is capped to -this amount. -.SH DEFAULT -60 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* enable TCP keep-alive for this transfer */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); - - /* set keep-alive idle time to 120 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); - - /* interval time between keep-alive probes: 60 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.25.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_TCP_KEEPALIVE (3), -.BR CURLOPT_TCP_KEEPINTVL (3) diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.md b/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.md new file mode 100644 index 000000000..d8418ffb2 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TCP_KEEPIDLE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TCP_KEEPALIVE (3) + - CURLOPT_TCP_KEEPINTVL (3) +--- + +# NAME + +CURLOPT_TCP_KEEPIDLE - TCP keep-alive idle time wait + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay); +~~~ + +# DESCRIPTION + +Pass a long. Sets the *delay*, in seconds, to wait while the connection is +idle before sending keepalive probes. Not all operating systems support this +option. + +The maximum value this accepts is 2147483648. Any larger value is capped to +this amount. + +# DEFAULT + +60 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* enable TCP keep-alive for this transfer */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); + + /* set keep-alive idle time to 120 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); + + /* interval time between keep-alive probes: 60 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.25.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 b/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 deleted file mode 100644 index e3bbbc24d..000000000 --- a/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TCP_KEEPINTVL 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TCP_KEEPINTVL \- TCP keep-alive interval -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPINTVL, long interval); -.fi -.SH DESCRIPTION -Pass a long. Sets the interval, in seconds, to wait between sending keepalive -probes. Not all operating systems support this option. (Added in 7.25.0) - -The maximum value this accepts is 2147483648. Any larger value is capped to -this amount. -.SH DEFAULT -60 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* enable TCP keep-alive for this transfer */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); - - /* set keep-alive idle time to 120 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); - - /* interval time between keep-alive probes: 60 seconds */ - curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_TCP_KEEPALIVE (3), -.BR CURLOPT_TCP_KEEPIDLE (3) diff --git a/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.md b/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.md new file mode 100644 index 000000000..d560cf516 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TCP_KEEPINTVL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TCP_KEEPALIVE (3) + - CURLOPT_TCP_KEEPIDLE (3) +--- + +# NAME + +CURLOPT_TCP_KEEPINTVL - TCP keep-alive interval + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPINTVL, long interval); +~~~ + +# DESCRIPTION + +Pass a long. Sets the interval, in seconds, to wait between sending keepalive +probes. Not all operating systems support this option. (Added in 7.25.0) + +The maximum value this accepts is 2147483648. Any larger value is capped to +this amount. + +# DEFAULT + +60 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* enable TCP keep-alive for this transfer */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); + + /* set keep-alive idle time to 120 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); + + /* interval time between keep-alive probes: 60 seconds */ + curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TCP_NODELAY.3 b/docs/libcurl/opts/CURLOPT_TCP_NODELAY.3 deleted file mode 100644 index 6166f7847..000000000 --- a/docs/libcurl/opts/CURLOPT_TCP_NODELAY.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TCP_NODELAY 3 "30 Jun 2016" libcurl libcurl -.SH NAME -CURLOPT_TCP_NODELAY \- the TCP_NODELAY option -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_NODELAY, long nodelay); -.fi -.SH DESCRIPTION -Pass a long specifying whether the \fITCP_NODELAY\fP option is to be set or -cleared (1L = set, 0 = clear). The option is set by default. This has no -effect after the connection has been established. - -Setting this option to 1L disables TCP's Nagle algorithm on connections -created using this handle. The purpose of this algorithm is to try to minimize -the number of small packets on the network (where "small packets" means TCP -segments less than the Maximum Segment Size for the network). - -Maximizing the amount of data sent per TCP segment is good because it -amortizes the overhead of the send. However, in some cases small segments may -need to be sent without delay. This is less efficient than sending larger -amounts of data at a time, and can contribute to congestion on the network if -overdone. -.SH DEFAULT -1 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - /* leave Nagle enabled */ - curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always. The default was changed to 1 from 0 in 7.50.2. -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_BUFFERSIZE (3), -.BR CURLOPT_SOCKOPTFUNCTION (3), -.BR CURLOPT_TCP_KEEPALIVE (3) diff --git a/docs/libcurl/opts/CURLOPT_TCP_NODELAY.md b/docs/libcurl/opts/CURLOPT_TCP_NODELAY.md new file mode 100644 index 000000000..7fe286d26 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TCP_NODELAY.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TCP_NODELAY +Section: 3 +Source: libcurl +See-also: + - CURLOPT_BUFFERSIZE (3) + - CURLOPT_SOCKOPTFUNCTION (3) + - CURLOPT_TCP_KEEPALIVE (3) +--- + +# NAME + +CURLOPT_TCP_NODELAY - the TCP_NODELAY option + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_NODELAY, long nodelay); +~~~ + +# DESCRIPTION + +Pass a long specifying whether the *TCP_NODELAY* option is to be set or +cleared (1L = set, 0 = clear). The option is set by default. This has no +effect after the connection has been established. + +Setting this option to 1L disables TCP's Nagle algorithm on connections +created using this handle. The purpose of this algorithm is to try to minimize +the number of small packets on the network (where "small packets" means TCP +segments less than the Maximum Segment Size for the network). + +Maximizing the amount of data sent per TCP segment is good because it +amortizes the overhead of the send. However, in some cases small segments may +need to be sent without delay. This is less efficient than sending larger +amounts of data at a time, and can contribute to congestion on the network if +overdone. + +# DEFAULT + +1 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + /* leave Nagle enabled */ + curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always. The default was changed to 1 from 0 in 7.50.2. + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.3 b/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.3 deleted file mode 100644 index f42e5a42a..000000000 --- a/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TELNETOPTIONS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TELNETOPTIONS \- set of telnet options -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TELNETOPTIONS, - struct curl_slist *cmds); -.fi -.SH DESCRIPTION -Provide a pointer to a curl_slist with variables to pass to the telnet -negotiations. The variables should be in the format . libcurl -supports the options \fBTTYPE\fP, \fBXDISPLOC\fP and \fBNEW_ENV\fP. See the -TELNET standard for details. -.SH DEFAULT -NULL -.SH PROTOCOLS -TELNET -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - struct curl_slist *options; - options = curl_slist_append(NULL, "TTTYPE=vt100"); - options = curl_slist_append(options, "USER=foobar"); - curl_easy_setopt(curl, CURLOPT_URL, "telnet://example.com/"); - curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, options); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - curl_slist_free_all(options); - } -} -.fi -.SH AVAILABILITY -Along with TELNET -.SH RETURN VALUE -Returns CURLE_OK if TELNET is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_QUOTE (3) diff --git a/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.md b/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.md new file mode 100644 index 000000000..e1db12ed8 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TELNETOPTIONS.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TELNETOPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPHEADER (3) + - CURLOPT_QUOTE (3) +--- + +# NAME + +CURLOPT_TELNETOPTIONS - set of telnet options + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TELNETOPTIONS, + struct curl_slist *cmds); +~~~ + +# DESCRIPTION + +Provide a pointer to a curl_slist with variables to pass to the telnet +negotiations. The variables should be in the format . libcurl +supports the options **TTYPE**, **XDISPLOC** and **NEW_ENV**. See the +TELNET standard for details. + +# DEFAULT + +NULL + +# PROTOCOLS + +TELNET + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + struct curl_slist *options; + options = curl_slist_append(NULL, "TTTYPE=vt100"); + options = curl_slist_append(options, "USER=foobar"); + curl_easy_setopt(curl, CURLOPT_URL, "telnet://example.com/"); + curl_easy_setopt(curl, CURLOPT_TELNETOPTIONS, options); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_slist_free_all(options); + } +} +~~~ + +# AVAILABILITY + +Along with TELNET + +# RETURN VALUE + +Returns CURLE_OK if TELNET is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.3 b/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.3 deleted file mode 100644 index dcd3ea79a..000000000 --- a/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TFTP_BLKSIZE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TFTP_BLKSIZE \- TFTP block size -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_BLKSIZE, long blocksize); -.fi -.SH DESCRIPTION -Specify \fIblocksize\fP to use for TFTP data transmission. Valid range as per -RFC 2348 is 8-65464 bytes. The default of 512 bytes is used if this option is -not specified. The specified block size is only used if supported by the -remote server. If the server does not return an option acknowledgment or -returns an option acknowledgment with no block size, the default of 512 bytes -is used. -.SH DEFAULT -512 -.SH PROTOCOLS -TFTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/bootimage"); - /* try using larger blocks */ - curl_easy_setopt(curl, CURLOPT_TFTP_BLKSIZE, 2048L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_MAXFILESIZE (3) - diff --git a/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.md b/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.md new file mode 100644 index 000000000..07cbebae4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TFTP_BLKSIZE.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TFTP_BLKSIZE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAXFILESIZE (3) +--- + +# NAME + +CURLOPT_TFTP_BLKSIZE - TFTP block size + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_BLKSIZE, long blocksize); +~~~ + +# DESCRIPTION + +Specify *blocksize* to use for TFTP data transmission. Valid range as per +RFC 2348 is 8-65464 bytes. The default of 512 bytes is used if this option is +not specified. The specified block size is only used if supported by the +remote server. If the server does not return an option acknowledgment or +returns an option acknowledgment with no block size, the default of 512 bytes +is used. + +# DEFAULT + +512 + +# PROTOCOLS + +TFTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/bootimage"); + /* try using larger blocks */ + curl_easy_setopt(curl, CURLOPT_TFTP_BLKSIZE, 2048L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.3 deleted file mode 100644 index 70d4c3f44..000000000 --- a/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TFTP_NO_OPTIONS 3 "23 Feb 2016" libcurl libcurl -.SH NAME -CURLOPT_TFTP_NO_OPTIONS \- send no TFTP options requests -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_NO_OPTIONS, long onoff); -.fi -.SH DESCRIPTION -Set \fIonoff\fP to 1L to exclude all TFTP options defined in RFC 2347, -RFC 2348 and RFC 2349 from read and write requests. - -This option improves interoperability with legacy servers that do not -acknowledge or properly implement TFTP options. When this option is used -\fICURLOPT_TFTP_BLKSIZE(3)\fP is ignored. -.SH DEFAULT -0 -.SH PROTOCOLS -TFTP -.SH EXAMPLE -.nf -size_t write_callback(char *ptr, size_t size, size_t nmemb, void *fp) -{ - return fwrite(ptr, size, nmemb, (FILE *)fp); -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - FILE *fp = fopen("foo.bin", "wb"); - if(fp) { - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); - - curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/foo.bin"); - - /* do not send TFTP options requests */ - curl_easy_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L); - - /* Perform the request */ - curl_easy_perform(curl); - - fclose(fp); - } - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.48.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH SEE ALSO -.BR CURLOPT_TFTP_BLKSIZE "(3), " diff --git a/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.md b/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.md new file mode 100644 index 000000000..fd4e4921f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TFTP_NO_OPTIONS.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TFTP_NO_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TFTP_BLKSIZE (3) +--- + +# NAME + +CURLOPT_TFTP_NO_OPTIONS - send no TFTP options requests + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_NO_OPTIONS, long onoff); +~~~ + +# DESCRIPTION + +Set *onoff* to 1L to exclude all TFTP options defined in RFC 2347, +RFC 2348 and RFC 2349 from read and write requests. + +This option improves interoperability with legacy servers that do not +acknowledge or properly implement TFTP options. When this option is used +CURLOPT_TFTP_BLKSIZE(3) is ignored. + +# DEFAULT + +0 + +# PROTOCOLS + +TFTP + +# EXAMPLE + +~~~c +size_t write_callback(char *ptr, size_t size, size_t nmemb, void *fp) +{ + return fwrite(ptr, size, nmemb, (FILE *)fp); +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + FILE *fp = fopen("foo.bin", "wb"); + if(fp) { + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + + curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/foo.bin"); + + /* do not send TFTP options requests */ + curl_easy_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L); + + /* Perform the request */ + curl_easy_perform(curl); + + fclose(fp); + } + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.48.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TIMECONDITION.3 b/docs/libcurl/opts/CURLOPT_TIMECONDITION.3 deleted file mode 100644 index 14c901a16..000000000 --- a/docs/libcurl/opts/CURLOPT_TIMECONDITION.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TIMECONDITION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TIMECONDITION \- select condition for a time request -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long cond); -.fi -.SH DESCRIPTION -Pass a long as parameter. This defines how the \fICURLOPT_TIMEVALUE(3)\fP time -value is treated. You can set this parameter to \fICURL_TIMECOND_IFMODSINCE\fP -or \fICURL_TIMECOND_IFUNMODSINCE\fP. - -The last modification time of a file is not always known and in such instances -this feature has no effect even if the given time condition would not have -been met. \fIcurl_easy_getinfo(3)\fP with the \fICURLINFO_CONDITION_UNMET\fP -option can be used after a transfer to learn if a zero-byte successful -"transfer" was due to this condition not matching. -.SH DEFAULT -CURL_TIMECOND_NONE (0) -.SH PROTOCOLS -HTTP, FTP, RTSP, and FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - 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, - (long)CURL_TIMECOND_IFMODSINCE); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_TIMEVALUE (3), -.BR CURLINFO_FILETIME (3) diff --git a/docs/libcurl/opts/CURLOPT_TIMECONDITION.md b/docs/libcurl/opts/CURLOPT_TIMECONDITION.md new file mode 100644 index 000000000..80d93a516 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TIMECONDITION.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TIMECONDITION +Section: 3 +Source: libcurl +See-also: + - CURLINFO_FILETIME (3) + - CURLOPT_TIMEVALUE (3) +--- + +# NAME + +CURLOPT_TIMECONDITION - select condition for a time request + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long cond); +~~~ + +# DESCRIPTION + +Pass a long as parameter. This defines how the CURLOPT_TIMEVALUE(3) time +value is treated. You can set this parameter to *CURL_TIMECOND_IFMODSINCE* +or *CURL_TIMECOND_IFUNMODSINCE*. + +The last modification time of a file is not always known and in such instances +this feature has no effect even if the given time condition would not have +been met. curl_easy_getinfo(3) with the *CURLINFO_CONDITION_UNMET* +option can be used after a transfer to learn if a zero-byte successful +"transfer" was due to this condition not matching. + +# DEFAULT + +CURL_TIMECOND_NONE (0) + +# PROTOCOLS + +HTTP, FTP, RTSP, and FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + 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, + (long)CURL_TIMECOND_IFMODSINCE); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_TIMEOUT.3 b/docs/libcurl/opts/CURLOPT_TIMEOUT.3 deleted file mode 100644 index 3d608bab4..000000000 --- a/docs/libcurl/opts/CURLOPT_TIMEOUT.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TIMEOUT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TIMEOUT \- maximum time the transfer is allowed to complete -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT, long timeout); -.fi -.SH DESCRIPTION -Pass a long as parameter containing \fItimeout\fP - the maximum time in -seconds that you allow the entire transfer operation to take. The whole thing, -from start to end. Normally, name lookups can take a considerable time and -limiting operations risk aborting perfectly normal operations. - -\fICURLOPT_TIMEOUT_MS(3)\fP is the same function but set in milliseconds. - -If both \fICURLOPT_TIMEOUT(3)\fP and \fICURLOPT_TIMEOUT_MS(3)\fP are set, the -value set last is used. - -Since this option puts a hard limit on how long time a request is allowed to -take, it has limited use in dynamic use cases with varying transfer -times. That is especially apparent when using the multi interface, which may -queue the transfer, and that time is included. You are advised to explore -\fICURLOPT_LOW_SPEED_LIMIT(3)\fP, \fICURLOPT_LOW_SPEED_TIME(3)\fP or using -\fICURLOPT_PROGRESSFUNCTION(3)\fP to implement your own timeout logic. - -The connection timeout set with \fICURLOPT_CONNECTTIMEOUT(3)\fP is included in -this general all-covering timeout. - -With \fICURLOPT_CONNECTTIMEOUT(3)\fP set to 3 and \fICURLOPT_TIMEOUT(3)\fP set -to 5, the operation can never last longer than 5 seconds. - -With \fICURLOPT_CONNECTTIMEOUT(3)\fP set to 4 and \fICURLOPT_TIMEOUT(3)\fP set -to 2, the operation can never last longer than 2 seconds. - -This option may cause libcurl to use the SIGALRM signal to timeout system -calls on builds not using asynch DNS. In unix-like systems, this might cause -signals to be used unless \fICURLOPT_NOSIGNAL(3)\fP is set. -.SH DEFAULT -Default timeout is 0 (zero) which means it never times out during transfer. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* complete within 20 seconds */ - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative -value or a value that when converted to milliseconds is too large. -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_TCP_KEEPALIVE (3), -.BR CURLOPT_TIMEOUT_MS (3) diff --git a/docs/libcurl/opts/CURLOPT_TIMEOUT.md b/docs/libcurl/opts/CURLOPT_TIMEOUT.md new file mode 100644 index 000000000..02a3d3dbe --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TIMEOUT.md @@ -0,0 +1,90 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TIMEOUT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TCP_KEEPALIVE (3) + - CURLOPT_TIMEOUT_MS (3) +--- + +# NAME + +CURLOPT_TIMEOUT - maximum time the transfer is allowed to complete + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT, long timeout); +~~~ + +# DESCRIPTION + +Pass a long as parameter containing *timeout* - the maximum time in +seconds that you allow the entire transfer operation to take. The whole thing, +from start to end. Normally, name lookups can take a considerable time and +limiting operations risk aborting perfectly normal operations. + +CURLOPT_TIMEOUT_MS(3) is the same function but set in milliseconds. + +If both CURLOPT_TIMEOUT(3) and CURLOPT_TIMEOUT_MS(3) are set, the +value set last is used. + +Since this option puts a hard limit on how long time a request is allowed to +take, it has limited use in dynamic use cases with varying transfer +times. That is especially apparent when using the multi interface, which may +queue the transfer, and that time is included. You are advised to explore +CURLOPT_LOW_SPEED_LIMIT(3), CURLOPT_LOW_SPEED_TIME(3) or using +CURLOPT_PROGRESSFUNCTION(3) to implement your own timeout logic. + +The connection timeout set with CURLOPT_CONNECTTIMEOUT(3) is included in +this general all-covering timeout. + +With CURLOPT_CONNECTTIMEOUT(3) set to 3 and CURLOPT_TIMEOUT(3) set +to 5, the operation can never last longer than 5 seconds. + +With CURLOPT_CONNECTTIMEOUT(3) set to 4 and CURLOPT_TIMEOUT(3) set +to 2, the operation can never last longer than 2 seconds. + +This option may cause libcurl to use the SIGALRM signal to timeout system +calls on builds not using asynch DNS. In unix-like systems, this might cause +signals to be used unless CURLOPT_NOSIGNAL(3) is set. + +# DEFAULT + +Default timeout is 0 (zero) which means it never times out during transfer. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* complete within 20 seconds */ + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative +value or a value that when converted to milliseconds is too large. diff --git a/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.3 b/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.3 deleted file mode 100644 index a829881eb..000000000 --- a/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TIMEOUT_MS 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TIMEOUT_MS \- maximum time the transfer is allowed to complete -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT_MS, long timeout); -.fi -.SH DESCRIPTION -Pass a long as parameter containing \fItimeout\fP - the maximum time in -milliseconds that you allow the libcurl transfer operation to take. - -See \fICURLOPT_TIMEOUT(3)\fP for details. -.SH DEFAULT -Default timeout is 0 (zero) which means it never times out during transfer. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* complete within 20000 milliseconds */ - curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_CONNECTTIMEOUT (3), -.BR CURLOPT_LOW_SPEED_LIMIT (3), -.BR CURLOPT_TCP_KEEPALIVE (3), -.BR CURLOPT_TIMEOUT (3) diff --git a/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.md b/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.md new file mode 100644 index 000000000..0bb037f7c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TIMEOUT_MS.md @@ -0,0 +1,64 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TIMEOUT_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECTTIMEOUT (3) + - CURLOPT_LOW_SPEED_LIMIT (3) + - CURLOPT_TCP_KEEPALIVE (3) + - CURLOPT_TIMEOUT (3) +--- + +# NAME + +CURLOPT_TIMEOUT_MS - maximum time the transfer is allowed to complete + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT_MS, long timeout); +~~~ + +# DESCRIPTION + +Pass a long as parameter containing *timeout* - the maximum time in +milliseconds that you allow the libcurl transfer operation to take. + +See CURLOPT_TIMEOUT(3) for details. + +# DEFAULT + +Default timeout is 0 (zero) which means it never times out during transfer. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* complete within 20000 milliseconds */ + curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_TIMEVALUE.3 b/docs/libcurl/opts/CURLOPT_TIMEVALUE.3 deleted file mode 100644 index cf899e0ca..000000000 --- a/docs/libcurl/opts/CURLOPT_TIMEVALUE.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TIMEVALUE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TIMEVALUE \- time value for conditional -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE, long val); -.fi -.SH DESCRIPTION -Pass a long \fIval\fP as parameter. This should be the time counted as seconds -since 1 Jan 1970, and the time is used in a condition as specified with -\fICURLOPT_TIMECONDITION(3)\fP. - -On systems with 32 bit 'long' variables (such as Windows), this option cannot -set dates beyond the year 2038. Consider \fICURLOPT_TIMEVALUE_LARGE(3)\fP -instead. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP, FTP, RTSP, and FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - 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 */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_TIMECONDITION (3), -.BR CURLOPT_TIMEVALUE_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_TIMEVALUE.md b/docs/libcurl/opts/CURLOPT_TIMEVALUE.md new file mode 100644 index 000000000..cc8f6032c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TIMEVALUE.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TIMEVALUE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TIMECONDITION (3) + - CURLOPT_TIMEVALUE_LARGE (3) +--- + +# NAME + +CURLOPT_TIMEVALUE - time value for conditional + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE, long val); +~~~ + +# DESCRIPTION + +Pass a long *val* as parameter. This should be the time counted as seconds +since 1 Jan 1970, and the time is used in a condition as specified with +CURLOPT_TIMECONDITION(3). + +On systems with 32 bit 'long' variables (such as Windows), this option cannot +set dates beyond the year 2038. Consider CURLOPT_TIMEVALUE_LARGE(3) +instead. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP, FTP, RTSP, and FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + 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 */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.3 b/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.3 deleted file mode 100644 index e3b7759d5..000000000 --- a/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TIMEVALUE_LARGE 3 "25 Jan 2018" libcurl libcurl -.SH NAME -CURLOPT_TIMEVALUE_LARGE \- time value for conditional -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE_LARGE, - curl_off_t val); -.fi -.SH DESCRIPTION -Pass a curl_off_t \fIval\fP as parameter. This should be the time counted as -seconds since 1 Jan 1970, and the time is used in a condition as specified -with \fICURLOPT_TIMECONDITION(3)\fP. - -The difference between this option and \fICURLOPT_TIMEVALUE(3)\fP is the type -of the argument. On systems where 'long' is only 32 bit wide, this option has -to be used to set dates beyond the year 2038. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP, FTP, RTSP, and FILE -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* January 1, 2020 is 1577833200 */ - curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)1577833200); - - /* If-Modified-Since the above time stamp */ - curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.59.0. -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_TIMECONDITION (3), -.BR CURLOPT_TIMEVALUE (3), -.BR CURLINFO_FILETIME (3) diff --git a/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.md b/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.md new file mode 100644 index 000000000..1424f6617 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TIMEVALUE_LARGE +Section: 3 +Source: libcurl +See-also: + - CURLINFO_FILETIME (3) + - CURLOPT_TIMECONDITION (3) + - CURLOPT_TIMEVALUE (3) +--- + +# NAME + +CURLOPT_TIMEVALUE_LARGE - time value for conditional + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE_LARGE, + curl_off_t val); +~~~ + +# DESCRIPTION + +Pass a curl_off_t *val* as parameter. This should be the time counted as +seconds since 1 Jan 1970, and the time is used in a condition as specified +with CURLOPT_TIMECONDITION(3). + +The difference between this option and CURLOPT_TIMEVALUE(3) is the type +of the argument. On systems where 'long' is only 32 bit wide, this option has +to be used to set dates beyond the year 2038. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP, FTP, RTSP, and FILE + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* January 1, 2020 is 1577833200 */ + curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)1577833200); + + /* If-Modified-Since the above time stamp */ + curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.59.0. + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.3 b/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.3 deleted file mode 100644 index d7450e154..000000000 --- a/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TLS13_CIPHERS 3 "25 May 2018" libcurl libcurl -.SH NAME -CURLOPT_TLS13_CIPHERS \- ciphers suites to use for TLS 1.3 -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLS13_CIPHERS, char *list); -.fi -.SH DESCRIPTION -Pass a char *, pointing to a null-terminated string holding the list of cipher -suites to use for the TLS 1.3 connection. The list must be syntactically -correct, it consists of one or more cipher suite strings separated by colons. - -Find more details about cipher lists on this URL: - - https://curl.se/docs/ssl-ciphers.html - -This option is currently used only when curl is built to use OpenSSL 1.1.1 or -later, or Schannel. If you are using a different SSL backend you can try -setting TLS 1.3 cipher suites by using the \fICURLOPT_SSL_CIPHER_LIST(3)\fP -option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, use internal default -.SH PROTOCOLS -All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. -.SH EXAMPLE -.nf -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_TLS13_CIPHERS, - "TLS_CHACHA20_POLY1305_SHA256"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.61.0 for OpenSSL. Available when built with OpenSSL >= 1.1.1. - -Added in 7.85.0 for Schannel. -.SH RETURN VALUE -Returns CURLE_OK if supported, CURLE_NOT_BUILT_IN otherwise. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_SSL_CIPHER_LIST (3), -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_PROXY_TLS13_CIPHERS (3), -.BR CURLOPT_SSL_CIPHER_LIST (3), -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_USE_SSL (3) diff --git a/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md b/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md new file mode 100644 index 000000000..add1f2f8e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TLS13_CIPHERS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_PROXY_SSL_CIPHER_LIST (3) + - CURLOPT_PROXY_TLS13_CIPHERS (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_CIPHER_LIST (3) + - CURLOPT_USE_SSL (3) +--- + +# NAME + +CURLOPT_TLS13_CIPHERS - ciphers suites to use for TLS 1.3 + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLS13_CIPHERS, char *list); +~~~ + +# DESCRIPTION + +Pass a char pointer, pointing to a null-terminated string holding the list of +cipher suites to use for the TLS 1.3 connection. The list must be +syntactically correct, it consists of one or more cipher suite strings +separated by colons. + +Find more details about cipher lists on this URL: + + https://curl.se/docs/ssl-ciphers.html + +This option is currently used only when curl is built to use OpenSSL 1.1.1 or +later, or Schannel. If you are using a different SSL backend you can try +setting TLS 1.3 cipher suites by using the CURLOPT_SSL_CIPHER_LIST(3) +option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, use internal default + +# PROTOCOLS + +All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc. + +# 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_TLS13_CIPHERS, + "TLS_CHACHA20_POLY1305_SHA256"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.61.0 for OpenSSL. Available when built with OpenSSL >= 1.1.1. + +Added in 7.85.0 for Schannel. + +# RETURN VALUE + +Returns CURLE_OK if supported, CURLE_NOT_BUILT_IN otherwise. diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.3 b/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.3 deleted file mode 100644 index 3170bff2d..000000000 --- a/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TLSAUTH_PASSWORD 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TLSAUTH_PASSWORD \- password to use for TLS authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_PASSWORD, char *pwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should point to the null-terminated password -to use for the TLS authentication method specified with the -\fICURLOPT_TLSAUTH_TYPE(3)\fP option. Requires that the -\fICURLOPT_TLSAUTH_USERNAME(3)\fP option also be set. - -The application does not have to keep the string around after setting this -option. - -This feature relies in TLS SRP which does not work with TLS 1.3. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.4, with the OpenSSL and GnuTLS backends only -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_PROXY_TLSAUTH_PASSWORD (3), -.BR CURLOPT_TLSAUTH_TYPE (3), -.BR CURLOPT_TLSAUTH_USERNAME (3) diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.md b/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.md new file mode 100644 index 000000000..1d0e1d01d --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TLSAUTH_PASSWORD.md @@ -0,0 +1,70 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TLSAUTH_PASSWORD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_TLSAUTH_PASSWORD (3) + - CURLOPT_TLSAUTH_TYPE (3) + - CURLOPT_TLSAUTH_USERNAME (3) +--- + +# NAME + +CURLOPT_TLSAUTH_PASSWORD - password to use for TLS authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_PASSWORD, char *pwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should point to the null-terminated +password to use for the TLS authentication method specified with the +CURLOPT_TLSAUTH_TYPE(3) option. Requires that the +CURLOPT_TLSAUTH_USERNAME(3) option also be set. + +The application does not have to keep the string around after setting this +option. + +This feature relies in TLS SRP which does not work with TLS 1.3. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based 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_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.4, with the OpenSSL and GnuTLS backends only + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.3 b/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.3 deleted file mode 100644 index ec743c372..000000000 --- a/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TLSAUTH_TYPE 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TLSAUTH_TYPE \- TLS authentication methods -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_TYPE, char *type); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. The string should be -the method of the TLS authentication. Supported method is "SRP". - -.IP SRP -TLS-SRP authentication. Secure Remote Password authentication for TLS is -defined in RFC 5054 and provides mutual authentication if both sides have a -shared secret. To use TLS-SRP, you must also set the -\fICURLOPT_TLSAUTH_USERNAME(3)\fP and \fICURLOPT_TLSAUTH_PASSWORD(3)\fP -options. - -The application does not have to keep the string around after setting this -option. - -TLS SRP does not work with TLS 1.3. -.SH DEFAULT -blank -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -You need to build libcurl with GnuTLS or OpenSSL with TLS-SRP support for this -to work. Added in 7.21.4 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_TLSAUTH_USERNAME (3), -.BR CURLOPT_TLSAUTH_PASSWORD (3) diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.md b/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.md new file mode 100644 index 000000000..f3e0803d4 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TLSAUTH_TYPE.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TLSAUTH_TYPE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TLSAUTH_PASSWORD (3) + - CURLOPT_TLSAUTH_USERNAME (3) +--- + +# NAME + +CURLOPT_TLSAUTH_TYPE - TLS authentication methods + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_TYPE, char *type); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. The string should be +the method of the TLS authentication. Supported method is "SRP". + +## SRP + +TLS-SRP authentication. Secure Remote Password authentication for TLS is +defined in RFC 5054 and provides mutual authentication if both sides have a +shared secret. To use TLS-SRP, you must also set the +CURLOPT_TLSAUTH_USERNAME(3) and CURLOPT_TLSAUTH_PASSWORD(3) +options. + +The application does not have to keep the string around after setting this +option. + +TLS SRP does not work with TLS 1.3. + +# DEFAULT + +blank + +# PROTOCOLS + +All TLS-based 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_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +You need to build libcurl with GnuTLS or OpenSSL with TLS-SRP support for this +to work. Added in 7.21.4 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.3 b/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.3 deleted file mode 100644 index a604c1ef0..000000000 --- a/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TLSAUTH_USERNAME 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TLSAUTH_USERNAME \- user name to use for TLS authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_USERNAME, char *user); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should point to the null-terminated username -to use for the TLS authentication method specified with the -\fICURLOPT_TLSAUTH_TYPE(3)\fP option. Requires that the -\fICURLOPT_TLSAUTH_PASSWORD(3)\fP option also be set. - -The application does not have to keep the string around after setting this -option. - -This feature relies in TLS SRP which does not work with TLS 1.3. -.SH DEFAULT -NULL -.SH PROTOCOLS -All TLS-based protocols -.SH EXAMPLE -.nf -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_TLSAUTH_TYPE, "SRP"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); - curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.4, with the OpenSSL and GnuTLS backends only -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_TLSAUTH_TYPE (3), -.BR CURLOPT_TLSAUTH_PASSWORD (3) diff --git a/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.md b/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.md new file mode 100644 index 000000000..1127046af --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TLSAUTH_USERNAME.md @@ -0,0 +1,69 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TLSAUTH_USERNAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TLSAUTH_PASSWORD (3) + - CURLOPT_TLSAUTH_TYPE (3) +--- + +# NAME + +CURLOPT_TLSAUTH_USERNAME - user name to use for TLS authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TLSAUTH_USERNAME, char *user); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should point to the null-terminated +username to use for the TLS authentication method specified with the +CURLOPT_TLSAUTH_TYPE(3) option. Requires that the +CURLOPT_TLSAUTH_PASSWORD(3) option also be set. + +The application does not have to keep the string around after setting this +option. + +This feature relies in TLS SRP which does not work with TLS 1.3. + +# DEFAULT + +NULL + +# PROTOCOLS + +All TLS-based 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_TLSAUTH_TYPE, "SRP"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, "user"); + curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, "secret"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.4, with the OpenSSL and GnuTLS backends only + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_TRAILERDATA.3 b/docs/libcurl/opts/CURLOPT_TRAILERDATA.3 deleted file mode 100644 index d35523239..000000000 --- a/docs/libcurl/opts/CURLOPT_TRAILERDATA.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TRAILERDATA 3 "14 Aug 2018" libcurl libcurl -.SH NAME -CURLOPT_TRAILERDATA \- pointer passed to trailing headers callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERDATA, void *userdata); -.fi -.SH DESCRIPTION -Data pointer to be passed to the HTTP trailer callback function. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -struct MyData { - void *custom; -}; - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct MyData data; - curl_easy_setopt(curl, CURLOPT_TRAILERDATA, &data); - } -} -.fi - -A more complete example can be found in examples/http_trailers.html -.SH AVAILABILITY -This option was added in curl 7.64.0 and is present if HTTP support is enabled -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_TRAILERFUNCTION (3), -.BR CURLOPT_WRITEFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_TRAILERDATA.md b/docs/libcurl/opts/CURLOPT_TRAILERDATA.md new file mode 100644 index 000000000..304b408e2 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TRAILERDATA.md @@ -0,0 +1,59 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TRAILERDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TRAILERFUNCTION (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_TRAILERDATA - pointer passed to trailing headers callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERDATA, void *userdata); +~~~ + +# DESCRIPTION + +Data pointer to be passed to the HTTP trailer callback function. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +struct MyData { + void *custom; +}; + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct MyData data; + curl_easy_setopt(curl, CURLOPT_TRAILERDATA, &data); + } +} +~~~ + +# AVAILABILITY + +This option was added in curl 7.64.0 and is present if HTTP support is enabled + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.3 b/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.3 deleted file mode 100644 index ed910a3d7..000000000 --- a/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.3 +++ /dev/null @@ -1,110 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TRAILERFUNCTION 3 "14 Aug 2018" libcurl libcurl -.SH NAME -CURLOPT_TRAILERFUNCTION \- callback for sending trailing headers -.SH SYNOPSIS -.nf -#include - -int curl_trailer_callback(struct curl_slist ** list, void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERFUNCTION, - curl_trailer_callback *func); -.fi -.SH DESCRIPTION -Pass a pointer to a callback function. - -This callback function is called once right before sending the final CR LF in -an HTTP chunked transfer to fill a list of trailing headers to be sent before -finishing the HTTP transfer. - -You can set the userdata argument with the \fICURLOPT_TRAILERDATA(3)\fP -option. - -The trailing headers included in the linked list must not be CRLF-terminated, -because libcurl adds the appropriate line termination characters after each -header item. - -If you use curl_slist_append to add trailing headers to the curl_slist then -libcurl duplicates the strings, and frees the curl_slist and the duplicates -once the trailers have been sent. - -If one of the trailing header fields is not formatted correctly it is ignored -and an info message is emitted. - -The return value can either be \fBCURL_TRAILERFUNC_OK\fP or -\fBCURL_TRAILERFUNC_ABORT\fP which would respectively instruct libcurl to -either continue with sending the trailers or to abort the request. - -If you set this option to NULL, then the transfer proceeds as usual -without any interruptions. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP -.SH EXAMPLE -#include - -static int trailer_cb(struct curl_slist **tr, void *data) -{ - /* libcurl frees the list */ - *tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff"); - return CURL_TRAILERFUNC_OK; -} - -CURL *curl = curl_easy_init(); -if(curl) { - /* Set the URL of the request */ - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - /* Now set it as a put */ - curl_easy_setopt(curl, CURLOPT_PUT, 1L); - - /* Assuming we have a function that returns the data to be pushed - Let that function be read_cb */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); - - struct curl_slist *headers = NULL; - headers = curl_slist_append(headers, "Trailer: My-super-awesome-trailer"); - res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - - /* Set the trailers filling callback */ - curl_easy_setopt(curl, CURLOPT_TRAILERFUNCTION, trailer_cb); - - /* Perform the transfer */ - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - - curl_slist_free_all(headers); -} -.SH AVAILABILITY -This option was added in curl 7.64.0 and is present if HTTP support is enabled -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_TRAILERDATA (3), -.BR CURLOPT_WRITEFUNCTION (3) - diff --git a/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.md b/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.md new file mode 100644 index 000000000..5d79214bf --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TRAILERFUNCTION.md @@ -0,0 +1,110 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TRAILERFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TRAILERDATA (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_TRAILERFUNCTION - callback for sending trailing headers + +# SYNOPSIS + +~~~c +#include + +int curl_trailer_callback(struct curl_slist ** list, void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERFUNCTION, + curl_trailer_callback *func); +~~~ + +# DESCRIPTION + +Pass a pointer to a callback function. + +This callback function is called once right before sending the final CR LF in +an HTTP chunked transfer to fill a list of trailing headers to be sent before +finishing the HTTP transfer. + +You can set the userdata argument with the CURLOPT_TRAILERDATA(3) +option. + +The trailing headers included in the linked list must not be CRLF-terminated, +because libcurl adds the appropriate line termination characters after each +header item. + +If you use curl_slist_append(3) to add trailing headers to the *curl_slist* +then libcurl duplicates the strings, and frees the *curl_slist* once the +trailers have been sent. + +If one of the trailing header fields is not formatted correctly it is ignored +and an info message is emitted. + +The return value can either be **CURL_TRAILERFUNC_OK** or +**CURL_TRAILERFUNC_ABORT** which would respectively instruct libcurl to +either continue with sending the trailers or to abort the request. + +If you set this option to NULL, then the transfer proceeds as usual +without any interruptions. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP + +# EXAMPLE +~~~c +static int trailer_cb(struct curl_slist **tr, void *data) +{ + /* libcurl frees the list */ + *tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff"); + return CURL_TRAILERFUNC_OK; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + + /* Set the URL of the request */ + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + /* Now set it as a put */ + curl_easy_setopt(curl, CURLOPT_PUT, 1L); + + /* Assuming we have a function that returns the data to be pushed + Let that function be read_cb */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, trailer_cb); + + struct curl_slist *headers = NULL; + headers = curl_slist_append(headers, "Trailer: My-super-awesome-trailer"); + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + + /* Set the trailers filling callback */ + curl_easy_setopt(curl, CURLOPT_TRAILERFUNCTION, trailer_cb); + + /* Perform the transfer */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + + curl_slist_free_all(headers); + } +} +~~~ +# AVAILABILITY + +This option was added in curl 7.64.0 and is present if HTTP support is enabled. + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.3 b/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.3 deleted file mode 100644 index 020bfec9e..000000000 --- a/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TRANSFERTEXT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TRANSFERTEXT \- request a text based transfer for FTP -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFERTEXT, long text); -.fi -.SH DESCRIPTION -A parameter set to 1 tells the library to use ASCII mode for FTP transfers, -instead of the default binary transfer. For win32 systems it does not set the -stdout to binary mode. This option can be usable when transferring text data -between systems with different views on certain characters, such as newlines -or similar. - -libcurl does not do a complete ASCII conversion when doing ASCII transfers -over FTP. This is a known limitation/flaw that nobody has rectified. libcurl -simply sets the mode to ASCII and performs a standard transfer. -.SH DEFAULT -0, disabled -.SH PROTOCOLS -FTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/textfile"); - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Along with FTP -.SH RETURN VALUE -Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CRLF (3) - diff --git a/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.md b/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.md new file mode 100644 index 000000000..4f6d00485 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TRANSFERTEXT.md @@ -0,0 +1,65 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TRANSFERTEXT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CRLF (3) +--- + +# NAME + +CURLOPT_TRANSFERTEXT - request a text based transfer for FTP + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFERTEXT, long text); +~~~ + +# DESCRIPTION + +A parameter set to 1 tells the library to use ASCII mode for FTP transfers, +instead of the default binary transfer. For win32 systems it does not set the +stdout to binary mode. This option can be usable when transferring text data +between systems with different views on certain characters, such as newlines +or similar. + +libcurl does not do a complete ASCII conversion when doing ASCII transfers +over FTP. This is a known limitation/flaw that nobody has rectified. libcurl +simply sets the mode to ASCII and performs a standard transfer. + +# DEFAULT + +0, disabled + +# PROTOCOLS + +FTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/textfile"); + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Along with FTP + +# RETURN VALUE + +Returns CURLE_OK if FTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.3 b/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.3 deleted file mode 100644 index c472b7a88..000000000 --- a/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TRANSFER_ENCODING 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TRANSFER_ENCODING \- ask for HTTP Transfer Encoding -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFER_ENCODING, - long enable); -.fi -.SH DESCRIPTION -Pass a long set to 1L to \fIenable\fP or 0 to disable. - -Adds a request for compressed Transfer Encoding in the outgoing HTTP -request. If the server supports this and so desires, it can respond with the -HTTP response sent using a compressed Transfer-Encoding that is automatically -uncompressed by libcurl on reception. - -Transfer-Encoding differs slightly from the Content-Encoding you ask for with -\fICURLOPT_ACCEPT_ENCODING(3)\fP in that a Transfer-Encoding is strictly meant -to be for the transfer and thus MUST be decoded before the data arrives in the -client. Traditionally, Transfer-Encoding has been much less used and supported -by both HTTP clients and HTTP servers. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.21.6 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ACCEPT_ENCODING (3), -.BR CURLOPT_HTTP_TRANSFER_DECODING (3) diff --git a/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.md b/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.md new file mode 100644 index 000000000..7fd38487a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_TRANSFER_ENCODING.md @@ -0,0 +1,68 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_TRANSFER_ENCODING +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ACCEPT_ENCODING (3) + - CURLOPT_HTTP_TRANSFER_DECODING (3) +--- + +# NAME + +CURLOPT_TRANSFER_ENCODING - ask for HTTP Transfer Encoding + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRANSFER_ENCODING, + long enable); +~~~ + +# DESCRIPTION + +Pass a long set to 1L to *enable* or 0 to disable. + +Adds a request for compressed Transfer Encoding in the outgoing HTTP +request. If the server supports this and so desires, it can respond with the +HTTP response sent using a compressed Transfer-Encoding that is automatically +uncompressed by libcurl on reception. + +Transfer-Encoding differs slightly from the Content-Encoding you ask for with +CURLOPT_ACCEPT_ENCODING(3) in that a Transfer-Encoding is strictly meant +to be for the transfer and thus MUST be decoded before the data arrives in the +client. Traditionally, Transfer-Encoding has been much less used and supported +by both HTTP clients and HTTP servers. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_TRANSFER_ENCODING, 1L); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.6 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.3 b/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.3 deleted file mode 100644 index 534ae813b..000000000 --- a/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.3 +++ /dev/null @@ -1,89 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_UNIX_SOCKET_PATH 3 "09 Oct 2014" libcurl libcurl -.SH NAME -CURLOPT_UNIX_SOCKET_PATH \- Unix domain socket -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNIX_SOCKET_PATH, char *path); -.fi -.SH DESCRIPTION -Enables the use of Unix domain sockets as connection endpoint and sets the -path to \fIpath\fP. If \fIpath\fP is NULL, then Unix domain sockets are -disabled. - -When enabled, curl connects to the Unix domain socket instead of establishing -a TCP connection to the host. Since no network connection is created, curl -does not resolve the DNS hostname in the URL. - -The maximum path length on Cygwin, Linux and Solaris is 107. On other platforms -it might be even less. - -Proxy and TCP options such as \fICURLOPT_TCP_NODELAY(3)\fP are not -supported. Proxy options such as \fICURLOPT_PROXY(3)\fP have no effect either -as these are TCP-oriented, and asking a proxy server to connect to a certain -Unix domain socket is not possible. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -Default is NULL, meaning that no Unix domain sockets are used. -.SH PROTOCOLS -All protocols except for FILE and FTP are supported in theory. HTTP, IMAP, -POP3 and SMTP should in particular work (including their SSL/TLS variants). -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, "/tmp/httpd.sock"); - curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/"); - - curl_easy_perform(curl); - } -} -.fi - -If you are on Linux and somehow have a need for paths larger than 107 bytes, -you can use the proc filesystem to bypass the limitation: - -.nf - int dirfd = open(long_directory_path_to_socket, O_DIRECTORY | O_RDONLY); - char path[108]; - snprintf(path, sizeof(path), "/proc/self/fd/%d/httpd.sock", dirfd); - curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, path); - /* Be sure to keep dirfd valid until you discard the handle */ -.fi -.SH AVAILABILITY -Added in 7.40.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_ABSTRACT_UNIX_SOCKET (3), -.BR CURLOPT_OPENSOCKETFUNCTION (3), -.BR unix (7) diff --git a/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.md b/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.md new file mode 100644 index 000000000..0ef3ec176 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_UNIX_SOCKET_PATH.md @@ -0,0 +1,87 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_UNIX_SOCKET_PATH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_ABSTRACT_UNIX_SOCKET (3) + - CURLOPT_OPENSOCKETFUNCTION (3) + - unix (7) +--- + +# NAME + +CURLOPT_UNIX_SOCKET_PATH - Unix domain socket + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNIX_SOCKET_PATH, char *path); +~~~ + +# DESCRIPTION + +Enables the use of Unix domain sockets as connection endpoint and sets the +path to *path*. If *path* is NULL, then Unix domain sockets are +disabled. + +When enabled, curl connects to the Unix domain socket instead of establishing +a TCP connection to the host. Since no network connection is created, curl +does not resolve the DNS hostname in the URL. + +The maximum path length on Cygwin, Linux and Solaris is 107. On other platforms +it might be even less. + +Proxy and TCP options such as CURLOPT_TCP_NODELAY(3) are not +supported. Proxy options such as CURLOPT_PROXY(3) have no effect either +as these are TCP-oriented, and asking a proxy server to connect to a certain +Unix domain socket is not possible. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +Default is NULL, meaning that no Unix domain sockets are used. + +# PROTOCOLS + +All protocols except for FILE and FTP are supported in theory. HTTP, IMAP, +POP3 and SMTP should in particular work (including their SSL/TLS variants). + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, "/tmp/httpd.sock"); + curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/"); + + curl_easy_perform(curl); + } +} +~~~ + +If you are on Linux and somehow have a need for paths larger than 107 bytes, +you can use the proc filesystem to bypass the limitation: + +~~~c + int dirfd = open(long_directory_path_to_socket, O_DIRECTORY | O_RDONLY); + char path[108]; + snprintf(path, sizeof(path), "/proc/self/fd/%d/httpd.sock", dirfd); + curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, path); + /* Be sure to keep dirfd valid until you discard the handle */ +~~~ + +# AVAILABILITY + +Added in 7.40.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.3 b/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.3 deleted file mode 100644 index d16f4eab5..000000000 --- a/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_UNRESTRICTED_AUTH 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_UNRESTRICTED_AUTH \- send credentials to other hosts too -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNRESTRICTED_AUTH, - long goahead); -.SH DESCRIPTION -Set the long \fIgohead\fP parameter to 1L to make libcurl continue to send -authentication (user+password) credentials when following locations, even when -hostname changed. This option is meaningful only when setting -\fICURLOPT_FOLLOWLOCATION(3)\fP. - -Further, when this option is not used or set to \fB0L\fP, libcurl does not -send custom nor internally generated Authentication: headers on requests done -to other hosts than the one used for the initial URL. - -By default, libcurl only sends credentials and Authentication headers to the -initial host name as given in the original URL, to avoid leaking username + -password to other sites. - -This option should be used with caution: when curl follows redirects it -blindly fetches the next URL as instructed by the server. Setting -\fICURLOPT_UNRESTRICTED_AUTH(3)\fP to 1L therefore also makes curl trust the -server and sends possibly sensitive credentials to any host the server points -out. And then maybe again and again as the following hosts can keep -redirecting to new hosts. -.SH DEFAULT -0 -.SH PROTOCOLS -HTTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L); - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Along with HTTP -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_FOLLOWLOCATION (3), -.BR CURLOPT_USERPWD (3), -.BR CURLOPT_MAXREDIRS (3), -.BR CURLOPT_REDIR_PROTOCOLS_STR (3), -.BR CURLINFO_REDIRECT_COUNT (3) diff --git a/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.md b/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.md new file mode 100644 index 000000000..53b584fd0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_UNRESTRICTED_AUTH.md @@ -0,0 +1,78 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_UNRESTRICTED_AUTH +Section: 3 +Source: libcurl +See-also: + - CURLINFO_REDIRECT_COUNT (3) + - CURLOPT_FOLLOWLOCATION (3) + - CURLOPT_MAXREDIRS (3) + - CURLOPT_REDIR_PROTOCOLS_STR (3) + - CURLOPT_USERPWD (3) +--- + +# NAME + +CURLOPT_UNRESTRICTED_AUTH - send credentials to other hosts too + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNRESTRICTED_AUTH, + long goahead); +~~~ + +# DESCRIPTION + +Set the long *gohead* parameter to 1L to make libcurl continue to send +authentication (user+password) credentials when following locations, even when +hostname changed. This option is meaningful only when setting +CURLOPT_FOLLOWLOCATION(3). + +Further, when this option is not used or set to **0L**, libcurl does not +send custom nor internally generated Authentication: headers on requests done +to other hosts than the one used for the initial URL. + +By default, libcurl only sends credentials and Authentication headers to the +initial hostname as given in the original URL, to avoid leaking username + +password to other sites. + +This option should be used with caution: when curl follows redirects it +blindly fetches the next URL as instructed by the server. Setting +CURLOPT_UNRESTRICTED_AUTH(3) to 1L makes curl trust the server and sends +possibly sensitive credentials to any host the server points to, possibly +again and again as the following hosts can keep redirecting to new hosts. + +# DEFAULT + +0 + +# PROTOCOLS + +HTTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L); + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Along with HTTP + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.3 b/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.3 deleted file mode 100644 index 9af2e03ba..000000000 --- a/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_UPKEEP_INTERVAL_MS 3 "31 Oct 2018" libcurl libcurl -.SH NAME -CURLOPT_UPKEEP_INTERVAL_MS \- connection upkeep interval -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPKEEP_INTERVAL_MS, - long upkeep_interval_ms); -.fi -.SH DESCRIPTION -Some protocols have "connection upkeep" mechanisms. These mechanisms usually -send some traffic on existing connections in order to keep them alive; this -can prevent connections from being closed due to overzealous firewalls, for -example. - -The user needs to explicitly call \fIcurl_easy_upkeep(3)\fP in order to -perform the upkeep work. - -Currently the only protocol with a connection upkeep mechanism is HTTP/2: when -the connection upkeep interval is exceeded and \fIcurl_easy_upkeep(3)\fP -is called, an HTTP/2 PING frame is sent on the connection. - -.SH DEFAULT -CURL_UPKEEP_INTERVAL_DEFAULT (currently defined as 60000L, which is 60 seconds) -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* Make a connection to an HTTP/2 server. */ - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* Set the interval to 30000ms / 30s */ - curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L); - - curl_easy_perform(curl); - - /* Perform more work here. */ - - /* While the connection is being held open, curl_easy_upkeep() can be - called. If curl_easy_upkeep() is called and the time since the last - upkeep exceeds the interval, then an HTTP/2 PING is sent. */ - curl_easy_upkeep(curl); - - /* Perform more work here. */ - - /* always cleanup */ - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.62.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH SEE ALSO -.BR CURLOPT_TCP_KEEPALIVE "(3), " diff --git a/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.md b/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.md new file mode 100644 index 000000000..283efa73e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_UPKEEP_INTERVAL_MS.md @@ -0,0 +1,82 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_UPKEEP_INTERVAL_MS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_TCP_KEEPALIVE (3) +--- + +# NAME + +CURLOPT_UPKEEP_INTERVAL_MS - connection upkeep interval + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPKEEP_INTERVAL_MS, + long upkeep_interval_ms); +~~~ + +# DESCRIPTION + +Some protocols have "connection upkeep" mechanisms. These mechanisms usually +send some traffic on existing connections in order to keep them alive; this +can prevent connections from being closed due to overzealous firewalls, for +example. + +The user needs to explicitly call curl_easy_upkeep(3) in order to +perform the upkeep work. + +Currently the only protocol with a connection upkeep mechanism is HTTP/2: when +the connection upkeep interval is exceeded and curl_easy_upkeep(3) +is called, an HTTP/2 PING frame is sent on the connection. + +# DEFAULT + +CURL_UPKEEP_INTERVAL_DEFAULT (currently defined as 60000L, which is 60 seconds) + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* Make a connection to an HTTP/2 server. */ + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* Set the interval to 30000ms / 30s */ + curl_easy_setopt(curl, CURLOPT_UPKEEP_INTERVAL_MS, 30000L); + + curl_easy_perform(curl); + + /* Perform more work here. */ + + /* While the connection is being held open, curl_easy_upkeep() can be + called. If curl_easy_upkeep() is called and the time since the last + upkeep exceeds the interval, then an HTTP/2 PING is sent. */ + curl_easy_upkeep(curl); + + /* Perform more work here. */ + + /* always cleanup */ + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.62.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_UPLOAD.3 b/docs/libcurl/opts/CURLOPT_UPLOAD.3 deleted file mode 100644 index e02295e70..000000000 --- a/docs/libcurl/opts/CURLOPT_UPLOAD.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_UPLOAD 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_UPLOAD \- data upload -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD, long upload); -.fi -.SH DESCRIPTION -The long parameter \fIupload\fP set to 1 tells the library to prepare for and -perform an upload. The \fICURLOPT_READDATA(3)\fP and -\fICURLOPT_INFILESIZE(3)\fP or \fICURLOPT_INFILESIZE_LARGE(3)\fP options are -also interesting for uploads. If the protocol is HTTP, uploading means using -the PUT request unless you tell libcurl otherwise. - -Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue" header. -You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP as usual. - -If you use PUT to an HTTP 1.1 server, you can upload data without knowing the -size before starting the transfer. The library enables this by adding a header -"Transfer-Encoding: chunked". With HTTP 1.0 or if you prefer not to use chunked -transfer, you must specify the size of the data with -\fICURLOPT_INFILESIZE(3)\fP or \fICURLOPT_INFILESIZE_LARGE(3)\fP. -.SH DEFAULT -0, default is download -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata) -{ - FILE *src = userdata; - /* copy as much data as possible into the 'ptr' buffer, but no more than - 'size' * 'nmemb' bytes! */ - size_t retcode = fread(ptr, size, nmemb, src); - - return retcode; -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - FILE *src = fopen("local-file", "r"); - curl_off_t fsize; /* set this to the size of the input file */ - - /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); - - /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - - /* specify target */ - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); - - /* now specify which pointer to pass to our callback */ - curl_easy_setopt(curl, CURLOPT_READDATA, src); - - /* Set the size of the file to upload */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize); - - /* Now run off and do what you have been told! */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_PUT (3), -.BR CURLOPT_READFUNCTION (3), -.BR CURLOPT_INFILESIZE_LARGE (3) diff --git a/docs/libcurl/opts/CURLOPT_UPLOAD.md b/docs/libcurl/opts/CURLOPT_UPLOAD.md new file mode 100644 index 000000000..a54f2fd9f --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_UPLOAD.md @@ -0,0 +1,97 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_UPLOAD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_INFILESIZE_LARGE (3) + - CURLOPT_PUT (3) + - CURLOPT_READFUNCTION (3) +--- + +# NAME + +CURLOPT_UPLOAD - data upload + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD, long upload); +~~~ + +# DESCRIPTION + +The long parameter *upload* set to 1 tells the library to prepare for and +perform an upload. The CURLOPT_READDATA(3) and +CURLOPT_INFILESIZE(3) or CURLOPT_INFILESIZE_LARGE(3) options are +also interesting for uploads. If the protocol is HTTP, uploading means using +the PUT request unless you tell libcurl otherwise. + +Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue" header. +You can disable this header with CURLOPT_HTTPHEADER(3) as usual. + +If you use PUT to an HTTP 1.1 server, you can upload data without knowing the +size before starting the transfer. The library enables this by adding a header +"Transfer-Encoding: chunked". With HTTP 1.0 or if you prefer not to use chunked +transfer, you must specify the size of the data with +CURLOPT_INFILESIZE(3) or CURLOPT_INFILESIZE_LARGE(3). + +# DEFAULT + +0, default is download + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + FILE *src = userdata; + /* copy as much data as possible into the 'ptr' buffer, but no more than + 'size' * 'nmemb' bytes */ + size_t retcode = fread(ptr, size, nmemb, src); + + return retcode; +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + FILE *src = fopen("local-file", "r"); + curl_off_t fsize; /* set this to the size of the input file */ + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + + /* specify target */ + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile"); + + /* now specify which pointer to pass to our callback */ + curl_easy_setopt(curl, CURLOPT_READDATA, src); + + /* Set the size of the file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize); + + /* Now run off and do what you have been told! */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.3 b/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.3 deleted file mode 100644 index 521daaee1..000000000 --- a/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_UPLOAD_BUFFERSIZE 3 "18 Aug 2018" libcurl libcurl -.SH NAME -CURLOPT_UPLOAD_BUFFERSIZE \- upload buffer size -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD_BUFFERSIZE, long size); -.fi -.SH DESCRIPTION -Pass a long specifying your preferred \fIsize\fP (in bytes) for the upload -buffer in libcurl. It makes libcurl uses a larger buffer that gets passed to -the next layer in the stack to get sent off. In some setups and for some -protocols, there is a huge performance benefit of having a larger upload -buffer. - -This is just treated as a request, not an order. You cannot be guaranteed to -actually get the given size. - -The upload buffer size is by default 64 kilobytes. The maximum buffer size -allowed to be set is 2 megabytes. The minimum buffer size allowed to be set is -16 kilobytes. - -The upload buffer is allocated on-demand - so if the handle is not used for -upload, this buffer is not allocated at all. - -DO NOT set this option on a handle that is currently used for an active -transfer as that may lead to unintended consequences. -.SH DEFAULT -65536 bytes -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin"); - - /* ask libcurl to allocate a larger upload buffer */ - curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.62.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_BUFFERSIZE (3), -.BR CURLOPT_READFUNCTION (3), -.BR CURLOPT_TCP_NODELAY (3) diff --git a/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.md b/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.md new file mode 100644 index 000000000..f32a45f98 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_UPLOAD_BUFFERSIZE.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_UPLOAD_BUFFERSIZE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_BUFFERSIZE (3) + - CURLOPT_READFUNCTION (3) + - CURLOPT_TCP_NODELAY (3) +--- + +# NAME + +CURLOPT_UPLOAD_BUFFERSIZE - upload buffer size + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD_BUFFERSIZE, long size); +~~~ + +# DESCRIPTION + +Pass a long specifying your preferred *size* (in bytes) for the upload +buffer in libcurl. It makes libcurl uses a larger buffer that gets passed to +the next layer in the stack to get sent off. In some setups and for some +protocols, there is a huge performance benefit of having a larger upload +buffer. + +This is just treated as a request, not an order. You cannot be guaranteed to +actually get the given size. + +The upload buffer size is by default 64 kilobytes. The maximum buffer size +allowed to be set is 2 megabytes. The minimum buffer size allowed to be set is +16 kilobytes. + +The upload buffer is allocated on-demand - so if the handle is not used for +upload, this buffer is not allocated at all. + +DO NOT set this option on a handle that is currently used for an active +transfer as that may lead to unintended consequences. + +# DEFAULT + +65536 bytes + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin"); + + /* ask libcurl to allocate a larger upload buffer */ + curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.62.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_URL.3 b/docs/libcurl/opts/CURLOPT_URL.3 deleted file mode 100644 index 9ef6913d8..000000000 --- a/docs/libcurl/opts/CURLOPT_URL.3 +++ /dev/null @@ -1,144 +0,0 @@ - -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_URL 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_URL \- URL for this transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL); -.fi -.SH DESCRIPTION -Pass in a pointer to the \fIURL\fP to work with. The parameter should be a -char * to a null-terminated string which must be URL-encoded in the following -format: - -scheme://host:port/path - -For a greater explanation of the format please see RFC 3986. - -libcurl does not validate the syntax or use the URL until the transfer is -started. Even if you set a crazy value here, \fIcurl_easy_setopt(3)\fP might -still return \fICURLE_OK\fP. - -If the given URL is missing a scheme name (such as "http://" or "ftp://" etc) -then libcurl guesses based on the host. If the outermost subdomain name -matches DICT, FTP, IMAP, LDAP, POP3 or SMTP then that protocol gets used, -otherwise HTTP is used. Since 7.45.0 guessing can be disabled by setting a -default protocol, see \fICURLOPT_DEFAULT_PROTOCOL(3)\fP for details. - -Should the protocol, either as specified by the URL scheme or deduced by -libcurl from the host name, not be supported by libcurl then -\fICURLE_UNSUPPORTED_PROTOCOL\fP is returned from either the -\fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP functions when you -call them. Use \fIcurl_version_info(3)\fP for detailed information of which -protocols are supported by the build of libcurl you are using. - -\fICURLOPT_PROTOCOLS_STR(3)\fP can be used to limit what protocols libcurl may -use for this transfer, independent of what libcurl has been compiled to -support. That may be useful if you accept the URL from an external source and -want to limit the accessibility. - -The \fICURLOPT_URL(3)\fP string is ignored if \fICURLOPT_CURLU(3)\fP is set. - -Either \fICURLOPT_URL(3)\fP or \fICURLOPT_CURLU(3)\fP must be set before a -transfer is started. - -The application does not have to keep the string around after setting this -option. - -The parser used for handling the URL set with \fICURLOPT_URL(3)\fP is the same -that \fIcurl_url_set(3)\fP uses. -.SH ENCODING -The string pointed to in the \fICURLOPT_URL(3)\fP argument is generally -expected to be a sequence of characters using an ASCII compatible encoding. - -If libcurl is built with IDN support, the server name part of the URL can use -an "international name" by using the current encoding (according to locale) or -UTF-8 (when winidn is used; or a Windows Unicode build using libidn2). - -If libcurl is built without IDN support, the server name is used exactly as -specified when passed to the name resolver functions. -.SH DEFAULT -There is no default URL. If this option is not set, no transfer can be -performed. -.SH SECURITY CONCERNS -Applications may at times find it convenient to allow users to specify URLs -for various purposes and that string would then end up fed to this option. - -Getting a URL from an external untrusted party brings several security -concerns: - -If you have an application that runs as or in a server application, getting an -unfiltered URL can easily trick your application to access a local resource -instead of a remote. Protecting yourself against localhost accesses is hard -when accepting user provided URLs. - -Such custom URLs can also access other ports than you planned as port numbers -are part of the regular URL format. The combination of a local host and a -custom port number can allow external users to play tricks with your local -services. - -Accepting external URLs may also use other protocols than http:// or other -common ones. Restrict what accept with \fICURLOPT_PROTOCOLS(3)\fP. - -User provided URLs can also be made to point to sites that redirect further on -(possibly to other protocols too). Consider your -\fICURLOPT_FOLLOWLOCATION(3)\fP and \fICURLOPT_REDIR_PROTOCOLS(3)\fP settings. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -POP3 and SMTP were added in 7.31.0 -.SH RETURN VALUE -Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient -heap space. - -Note that \fIcurl_easy_setopt(3)\fP does not parse the given string so given a -bad URL, it is not detected until \fIcurl_easy_perform(3)\fP or similar is -called. -.SH "SEE ALSO" -.BR curl_easy_perform (3), -.BR curl_url_get (3), -.BR curl_url_set (3), -.BR CURLINFO_REDIRECT_URL (3), -.BR CURLOPT_CURLU (3), -.BR CURLOPT_FORBID_REUSE (3), -.BR CURLOPT_FRESH_CONNECT (3), -.BR CURLOPT_PATH_AS_IS (3), -.BR CURLOPT_PROTOCOLS (3) diff --git a/docs/libcurl/opts/CURLOPT_URL.md b/docs/libcurl/opts/CURLOPT_URL.md new file mode 100644 index 000000000..3a0691bfc --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_URL.md @@ -0,0 +1,145 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_URL +Section: 3 +Source: libcurl +See-also: + - CURLINFO_REDIRECT_URL (3) + - CURLOPT_CURLU (3) + - CURLOPT_FORBID_REUSE (3) + - CURLOPT_FRESH_CONNECT (3) + - CURLOPT_PATH_AS_IS (3) + - CURLOPT_PROTOCOLS (3) + - curl_easy_perform (3) + - curl_url_get (3) + - curl_url_set (3) +--- + +# NAME + +CURLOPT_URL - URL for this transfer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL); +~~~ + +# DESCRIPTION + +Pass in a pointer to the *URL* to work with. The parameter should be a +char * to a null-terminated string which must be URL-encoded in the following +format: + +scheme://host:port/path + +For a greater explanation of the format please see RFC 3986. + +libcurl does not validate the syntax or use the URL until the transfer is +started. Even if you set a crazy value here, curl_easy_setopt(3) might +still return *CURLE_OK*. + +If the given URL is missing a scheme name (such as "http://" or "ftp://" etc) +then libcurl guesses based on the host. If the outermost subdomain name +matches DICT, FTP, IMAP, LDAP, POP3 or SMTP then that protocol gets used, +otherwise HTTP is used. Since 7.45.0 guessing can be disabled by setting a +default protocol, see CURLOPT_DEFAULT_PROTOCOL(3) for details. + +Should the protocol, either as specified by the URL scheme or deduced by +libcurl from the hostname, not be supported by libcurl then +*CURLE_UNSUPPORTED_PROTOCOL* is returned from either the curl_easy_perform(3) +or curl_multi_perform(3) functions when you call them. Use +curl_version_info(3) for detailed information of which protocols are supported +by the build of libcurl you are using. + +CURLOPT_PROTOCOLS_STR(3) can be used to limit what protocols libcurl may +use for this transfer, independent of what libcurl has been compiled to +support. That may be useful if you accept the URL from an external source and +want to limit the accessibility. + +The CURLOPT_URL(3) string is ignored if CURLOPT_CURLU(3) is set. + +Either CURLOPT_URL(3) or CURLOPT_CURLU(3) must be set before a +transfer is started. + +The application does not have to keep the string around after setting this +option. + +The parser used for handling the URL set with CURLOPT_URL(3) is the same +that curl_url_set(3) uses. + +# ENCODING + +The string pointed to in the CURLOPT_URL(3) argument is generally +expected to be a sequence of characters using an ASCII compatible encoding. + +If libcurl is built with IDN support, the server name part of the URL can use +an "international name" by using the current encoding (according to locale) or +UTF-8 (when winidn is used; or a Windows Unicode build using libidn2). + +If libcurl is built without IDN support, the server name is used exactly as +specified when passed to the name resolver functions. + +# DEFAULT + +There is no default URL. If this option is not set, no transfer can be +performed. + +# SECURITY CONCERNS + +Applications may at times find it convenient to allow users to specify URLs +for various purposes and that string would then end up fed to this option. + +Getting a URL from an external untrusted party brings several security +concerns: + +If you have an application that runs as or in a server application, getting an +unfiltered URL can easily trick your application to access a local resource +instead of a remote. Protecting yourself against localhost accesses is hard +when accepting user provided URLs. + +Such custom URLs can also access other ports than you planned as port numbers +are part of the regular URL format. The combination of a local host and a +custom port number can allow external users to play tricks with your local +services. + +Accepting external URLs may also use other protocols than http:// or other +common ones. Restrict what accept with CURLOPT_PROTOCOLS(3). + +User provided URLs can also be made to point to sites that redirect further on +(possibly to other protocols too). Consider your +CURLOPT_FOLLOWLOCATION(3) and CURLOPT_REDIR_PROTOCOLS(3) settings. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +POP3 and SMTP were added in 7.31.0 + +# RETURN VALUE + +Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient +heap space. + +Note that curl_easy_setopt(3) does not parse the given string so given a +bad URL, it is not detected until curl_easy_perform(3) or similar is +called. diff --git a/docs/libcurl/opts/CURLOPT_USERAGENT.3 b/docs/libcurl/opts/CURLOPT_USERAGENT.3 deleted file mode 100644 index bcb6a3c63..000000000 --- a/docs/libcurl/opts/CURLOPT_USERAGENT.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_USERAGENT 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_USERAGENT \- HTTP user-agent header -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua); -.fi -.SH DESCRIPTION -Pass a pointer to a null-terminated string as parameter. It is used to set the -User-Agent: header field in the HTTP request sent to the remote server. You -can also set any custom header with \fICURLOPT_HTTPHEADER(3)\fP. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL, no User-Agent: header is used by default. -.SH PROTOCOLS -HTTP, HTTPS -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0"); - - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -As long as HTTP is supported -.SH RETURN VALUE -Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_CUSTOMREQUEST (3), -.BR CURLOPT_HTTPHEADER (3), -.BR CURLOPT_REFERER (3), -.BR CURLOPT_REQUEST_TARGET (3) - diff --git a/docs/libcurl/opts/CURLOPT_USERAGENT.md b/docs/libcurl/opts/CURLOPT_USERAGENT.md new file mode 100644 index 000000000..a5423def0 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_USERAGENT.md @@ -0,0 +1,66 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_USERAGENT +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CUSTOMREQUEST (3) + - CURLOPT_HTTPHEADER (3) + - CURLOPT_REFERER (3) + - CURLOPT_REQUEST_TARGET (3) +--- + +# NAME + +CURLOPT_USERAGENT - HTTP user-agent header + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua); +~~~ + +# DESCRIPTION + +Pass a pointer to a null-terminated string as parameter. It is used to set the +User-Agent: header field in the HTTP request sent to the remote server. You +can also set any custom header with CURLOPT_HTTPHEADER(3). + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL, no User-Agent: header is used by default. + +# PROTOCOLS + +HTTP, HTTPS + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0"); + + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +As long as HTTP is supported + +# RETURN VALUE + +Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_USERNAME.3 b/docs/libcurl/opts/CURLOPT_USERNAME.3 deleted file mode 100644 index a7e25e90b..000000000 --- a/docs/libcurl/opts/CURLOPT_USERNAME.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_USERNAME 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_USERNAME \- user name to use in authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERNAME, - char *username); -.SH DESCRIPTION -Pass a char * as parameter, which should be pointing to the null-terminated -user name to use for the transfer. - -\fICURLOPT_USERNAME(3)\fP sets the user name to be used in protocol -authentication. You should not use this option together with the (older) -\fICURLOPT_USERPWD(3)\fP option. - -When using Kerberos V5 authentication with a Windows based server, you should -include the domain name in order for the server to successfully obtain a -Kerberos Ticket. If you do not then the initial part of the authentication -handshake may fail. - -When using NTLM, the user name can be specified simply as the user name -without the domain name should the server be part of a single domain and -forest. - -To include the domain name use either Down-Level Logon Name or UPN (User -Principal Name) formats. For example, EXAMPLE\\user and user@example.com -respectively. - -Some HTTP servers (on Windows) support inclusion of the domain for Basic -authentication as well. - -To specify the password and login options, along with the user name, use the -\fICURLOPT_PASSWORD(3)\fP and \fICURLOPT_LOGIN_OPTIONS(3)\fP options. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -blank -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - curl_easy_setopt(curl, CURLOPT_USERNAME, "clark"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.19.1 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_USERPWD (3), -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_HTTPAUTH (3), -.BR CURLOPT_PROXYAUTH (3) diff --git a/docs/libcurl/opts/CURLOPT_USERNAME.md b/docs/libcurl/opts/CURLOPT_USERNAME.md new file mode 100644 index 000000000..f74817801 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_USERNAME.md @@ -0,0 +1,92 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_USERNAME +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HTTPAUTH (3) + - CURLOPT_PASSWORD (3) + - CURLOPT_PROXYAUTH (3) + - CURLOPT_USERPWD (3) +--- + +# NAME + +CURLOPT_USERNAME - user name to use in authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERNAME, + char *username); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should be pointing to the +null-terminated user name to use for the transfer. + +CURLOPT_USERNAME(3) sets the user name to be used in protocol +authentication. You should not use this option together with the (older) +CURLOPT_USERPWD(3) option. + +When using Kerberos V5 authentication with a Windows based server, you should +include the domain name in order for the server to successfully obtain a +Kerberos Ticket. If you do not then the initial part of the authentication +handshake may fail. + +When using NTLM, the user name can be specified simply as the user name +without the domain name should the server be part of a single domain and +forest. + +To include the domain name use either Down-Level Logon Name or UPN (User +Principal Name) formats. For example, **EXAMPLE\user** and +**user@example.com** respectively. + +Some HTTP servers (on Windows) support inclusion of the domain for Basic +authentication as well. + +To specify the password and login options, along with the user name, use the +CURLOPT_PASSWORD(3) and CURLOPT_LOGIN_OPTIONS(3) options. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +blank + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + curl_easy_setopt(curl, CURLOPT_USERNAME, "clark"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.19.1 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_USERPWD.3 b/docs/libcurl/opts/CURLOPT_USERPWD.3 deleted file mode 100644 index c63a98cc1..000000000 --- a/docs/libcurl/opts/CURLOPT_USERPWD.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_USERPWD 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_USERPWD \- user name and password to use in authentication -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERPWD, char *userpwd); -.fi -.SH DESCRIPTION -Pass a char * as parameter, pointing to a null-terminated login details string -for the connection. The format of which is: [user name]:[password]. - -When using Kerberos V5 authentication with a Windows based server, you should -specify the user name part with the domain name in order for the server to -successfully obtain a Kerberos Ticket. If you do not then the initial part of -the authentication handshake may fail. - -When using NTLM, the user name can be specified simply as the user name -without the domain name should the server be part of a single domain and -forest. - -To specify the domain name use either Down-Level Logon Name or UPN (User -Principal Name) formats. For example, EXAMPLE\\user and user@example.com -respectively. - -Some HTTP servers (on Windows) support inclusion of the domain for Basic -authentication as well. - -When using HTTP and \fICURLOPT_FOLLOWLOCATION(3)\fP, libcurl might perform -several requests to possibly different hosts. libcurl only sends this user and -password information to hosts using the initial host name (unless -\fICURLOPT_UNRESTRICTED_AUTH(3)\fP is set), so if libcurl follows redirects to -other hosts, it does not send the user and password to those. This is enforced -to prevent accidental information leakage. - -Use \fICURLOPT_HTTPAUTH(3)\fP to specify the authentication method for HTTP -based connections or \fICURLOPT_LOGIN_OPTIONS(3)\fP to control IMAP, POP3 and -SMTP options. - -The user and password strings are not URL decoded, so there is no way to send -in a user name containing a colon using this option. Use -\fICURLOPT_USERNAME(3)\fP for that, or include it in the URL. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -Most -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - - curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent"); - - res = curl_easy_perform(curl); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK on success or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_USERNAME (3), -.BR CURLOPT_PASSWORD (3), -.BR CURLOPT_PROXYUSERPWD (3) diff --git a/docs/libcurl/opts/CURLOPT_USERPWD.md b/docs/libcurl/opts/CURLOPT_USERPWD.md new file mode 100644 index 000000000..01c65207a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_USERPWD.md @@ -0,0 +1,98 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_USERPWD +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PASSWORD (3) + - CURLOPT_PROXYUSERPWD (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_USERPWD - user name and password to use in authentication + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERPWD, char *userpwd); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, pointing to a null-terminated login details +string for the connection. The format of which is: [user name]:[password]. + +When using Kerberos V5 authentication with a Windows based server, you should +specify the user name part with the domain name in order for the server to +successfully obtain a Kerberos Ticket. If you do not then the initial part of +the authentication handshake may fail. + +When using NTLM, the user name can be specified simply as the user name +without the domain name should the server be part of a single domain and +forest. + +To specify the domain name use either Down-Level Logon Name or UPN (User +Principal Name) formats. For example **EXAMPLE\user** and **user@example.com** +respectively. + +Some HTTP servers (on Windows) support inclusion of the domain for Basic +authentication as well. + +When using HTTP and CURLOPT_FOLLOWLOCATION(3), libcurl might perform several +requests to possibly different hosts. libcurl only sends this user and +password information to hosts using the initial hostname (unless +CURLOPT_UNRESTRICTED_AUTH(3) is set), so if libcurl follows redirects to other +hosts, it does not send the user and password to those. This is enforced to +prevent accidental information leakage. + +Use CURLOPT_HTTPAUTH(3) to specify the authentication method for HTTP +based connections or CURLOPT_LOGIN_OPTIONS(3) to control IMAP, POP3 and +SMTP options. + +The user and password strings are not URL decoded, so there is no way to send +in a user name containing a colon using this option. Use +CURLOPT_USERNAME(3) for that, or include it in the URL. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +Most + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); + + curl_easy_setopt(curl, CURLOPT_USERPWD, "clark:kent"); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK on success or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLOPT_USE_SSL.3 b/docs/libcurl/opts/CURLOPT_USE_SSL.3 deleted file mode 100644 index 837415ad7..000000000 --- a/docs/libcurl/opts/CURLOPT_USE_SSL.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_USE_SSL 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_USE_SSL \- request using SSL / TLS for the transfer -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USE_SSL, long level); -.fi -.SH DESCRIPTION -Pass a long using one of the values from below, to make libcurl use your -desired \fIlevel\fP of SSL for the transfer. - -These are all protocols that start out plain text and get "upgraded" to SSL -using the STARTTLS command. - -This is for enabling SSL/TLS when you use FTP, SMTP, POP3, IMAP etc. -.IP CURLUSESSL_NONE -do not attempt to use SSL. -.IP CURLUSESSL_TRY -Try using SSL, proceed as normal otherwise. Note that server may close the -connection if the negotiation does not succeed. -.IP CURLUSESSL_CONTROL -Require SSL for the control connection or fail with \fICURLE_USE_SSL_FAILED\fP. -.IP CURLUSESSL_ALL -Require SSL for all communication or fail with \fICURLE_USE_SSL_FAILED\fP. -.SH DEFAULT -CURLUSESSL_NONE -.SH PROTOCOLS -FTP, SMTP, POP3, IMAP, LDAP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext"); - - /* require use of SSL for this, or fail */ - curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.11.0. This option was known as CURLOPT_FTP_SSL up to 7.16.4, and -the constants were known as CURLFTPSSL_* -Handled by LDAP since 7.81.0. Fully supported by the OpenLDAP backend only. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_SSLVERSION (3), -.BR CURLOPT_PROXY_SSLVERSION (3), -.BR CURLOPT_SSL_OPTIONS (3) diff --git a/docs/libcurl/opts/CURLOPT_USE_SSL.md b/docs/libcurl/opts/CURLOPT_USE_SSL.md new file mode 100644 index 000000000..3e227fcfd --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_USE_SSL.md @@ -0,0 +1,86 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_USE_SSL +Section: 3 +Source: libcurl +See-also: + - CURLOPT_PROXY_SSLVERSION (3) + - CURLOPT_SSLVERSION (3) + - CURLOPT_SSL_OPTIONS (3) +--- + +# NAME + +CURLOPT_USE_SSL - request using SSL / TLS for the transfer + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USE_SSL, long level); +~~~ + +# DESCRIPTION + +Pass a long using one of the values from below, to make libcurl use your +desired *level* of SSL for the transfer. + +These are all protocols that start out plain text and get "upgraded" to SSL +using the STARTTLS command. + +This is for enabling SSL/TLS when you use FTP, SMTP, POP3, IMAP etc. + +## CURLUSESSL_NONE + +do not attempt to use SSL. + +## CURLUSESSL_TRY + +Try using SSL, proceed as normal otherwise. Note that server may close the +connection if the negotiation does not succeed. + +## CURLUSESSL_CONTROL + +Require SSL for the control connection or fail with *CURLE_USE_SSL_FAILED*. + +## CURLUSESSL_ALL + +Require SSL for all communication or fail with *CURLE_USE_SSL_FAILED*. + +# DEFAULT + +CURLUSESSL_NONE + +# PROTOCOLS + +FTP, SMTP, POP3, IMAP, LDAP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/file.ext"); + + /* require use of SSL for this, or fail */ + curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.11.0. This option was known as CURLOPT_FTP_SSL up to 7.16.4, and +the constants were known as CURLFTPSSL_* +Handled by LDAP since 7.81.0. Fully supported by the OpenLDAP backend only. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_VERBOSE.3 b/docs/libcurl/opts/CURLOPT_VERBOSE.3 deleted file mode 100644 index db1a756a3..000000000 --- a/docs/libcurl/opts/CURLOPT_VERBOSE.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_VERBOSE 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_VERBOSE \- verbose mode -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_VERBOSE, long onoff); -.fi -.SH DESCRIPTION -Set the \fIonoff\fP parameter to 1 to make the library display a lot of -verbose information about its operations on this \fIhandle\fP. Useful for -libcurl and/or protocol debugging and understanding. The verbose information -is sent to stderr, or the stream set with \fICURLOPT_STDERR(3)\fP. - -You hardly ever want this enabled in production use, you almost always want -this used when you debug/report problems. - -To also get all the protocol data sent and received, consider using the -\fICURLOPT_DEBUGFUNCTION(3)\fP. -.SH DEFAULT -0, meaning disabled. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - - /* ask libcurl to show us the verbose output */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - - /* Perform the request */ - curl_easy_perform(curl); - } -} -.fi -.SH AVAILABILITY -Always -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_STDERR (3), -.BR CURLOPT_DEBUGFUNCTION (3), -.BR CURLOPT_ERRORBUFFER (3), -.BR curl_global_trace (3) diff --git a/docs/libcurl/opts/CURLOPT_VERBOSE.md b/docs/libcurl/opts/CURLOPT_VERBOSE.md new file mode 100644 index 000000000..5ecc4b11a --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_VERBOSE.md @@ -0,0 +1,71 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_VERBOSE +Section: 3 +Source: libcurl +See-also: + - CURLOPT_DEBUGFUNCTION (3) + - CURLOPT_ERRORBUFFER (3) + - CURLOPT_STDERR (3) + - curl_global_trace (3) +--- + +# NAME + +CURLOPT_VERBOSE - verbose mode + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_VERBOSE, long onoff); +~~~ + +# DESCRIPTION + +Set the *onoff* parameter to 1 to make the library display a lot of +verbose information about its operations on this *handle*. Useful for +libcurl and/or protocol debugging and understanding. The verbose information +is sent to stderr, or the stream set with CURLOPT_STDERR(3). + +You hardly ever want this enabled in production use, you almost always want +this used when you debug/report problems. + +To also get all the protocol data sent and received, consider using the +CURLOPT_DEBUGFUNCTION(3). + +# DEFAULT + +0, meaning disabled. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + + /* ask libcurl to show us the verbose output */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* Perform the request */ + curl_easy_perform(curl); + } +} +~~~ + +# AVAILABILITY + +Always + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.3 b/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.3 deleted file mode 100644 index 75c5322f1..000000000 --- a/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.3 +++ /dev/null @@ -1,118 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_WILDCARDMATCH 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_WILDCARDMATCH \- directory wildcard transfers -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WILDCARDMATCH, long onoff); -.fi -.SH DESCRIPTION -Set \fIonoff\fP to 1 if you want to transfer multiple files according to a -file name pattern. The pattern can be specified as part of the -\fICURLOPT_URL(3)\fP option, using an \fBfnmatch\fP-like pattern (Shell -Pattern Matching) in the last part of URL (file name). - -By default, libcurl uses its internal wildcard matching implementation. You -can provide your own matching function by the -\fICURLOPT_FNMATCH_FUNCTION(3)\fP option. - -A brief introduction of its syntax follows: -.RS -.IP "* - ASTERISK" -.nf - ftp://example.com/some/path/*.txt -.fi -for all txt's from the root directory. Only two asterisks are allowed within -the same pattern string. -.RE -.RS -.IP "? - QUESTION MARK" -Question mark matches any (exactly one) character. -.nf - ftp://example.com/some/path/photo?.jpg -.fi -.RE -.RS -.IP "[ - BRACKET EXPRESSION" -The left bracket opens a bracket expression. The question mark and asterisk have -no special meaning in a bracket expression. Each bracket expression ends by the -right bracket and matches exactly one character. Some examples follow: - -\fB[a-zA-Z0\-9]\fP or \fB[f\-gF\-G]\fP \- character interval - -\fB[abc]\fP - character enumeration - -\fB[^abc]\fP or \fB[!abc]\fP - negation - -\fB[[:name:]]\fP class expression. Supported classes are -\fBalnum\fP,\fBlower\fP, \fBspace\fP, \fBalpha\fP, \fBdigit\fP, \fBprint\fP, -\fBupper\fP, \fBblank\fP, \fBgraph\fP, \fBxdigit\fP. - -\fB[][-!^]\fP - special case \- matches only '\-', ']', '[', '!' or '^'. These -characters have no special purpose. - -\fB[\\[\\]\\\\]\fP - escape syntax. Matches '[', ']' or '\e'. - -Using the rules above, a file name pattern can be constructed: -.nf - ftp://example.com/some/path/[a-z[:upper:]\\\\].jpg -.fi -.SH PROTOCOLS -This feature is only supported for FTP download. -.SH EXAMPLE -.nf - -extern long begin_cb(struct curl_fileinfo *, void *, int); -extern long end_cb(void *ptr); - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - /* turn on wildcard matching */ - curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); - - /* callback is called before download of concrete file started */ - curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, begin_cb); - - /* callback is called after data from the file have been transferred */ - curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, end_cb); - - /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */ - } -} -.fi -.SH AVAILABILITY -Added in 7.21.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_CHUNK_BGN_FUNCTION (3), -.BR CURLOPT_CHUNK_END_FUNCTION (3), -.BR CURLOPT_FNMATCH_FUNCTION (3), -.BR CURLOPT_URL (3) diff --git a/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.md b/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.md new file mode 100644 index 000000000..754126567 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_WILDCARDMATCH.md @@ -0,0 +1,111 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_WILDCARDMATCH +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CHUNK_BGN_FUNCTION (3) + - CURLOPT_CHUNK_END_FUNCTION (3) + - CURLOPT_FNMATCH_FUNCTION (3) + - CURLOPT_URL (3) +--- + +# NAME + +CURLOPT_WILDCARDMATCH - directory wildcard transfers + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WILDCARDMATCH, long onoff); +~~~ + +# DESCRIPTION + +Set *onoff* to 1 if you want to transfer multiple files according to a +filename pattern. The pattern can be specified as part of the CURLOPT_URL(3) +option, using an **fnmatch**-like pattern (Shell Pattern Matching) in the last +part of URL (filename). + +By default, libcurl uses its internal wildcard matching implementation. You +can provide your own matching function by the +CURLOPT_FNMATCH_FUNCTION(3) option. + +A brief introduction of its syntax follows: + +## * - ASTERISK + + ftp://example.com/some/path/*.txt + +for all txt's from the root directory. Only two asterisks are allowed within +the same pattern string. + +## ? - QUESTION MARK + +Question mark matches any (exactly one) character. + + ftp://example.com/some/path/photo?.jpg + +## [ - BRACKET EXPRESSION + +The left bracket opens a bracket expression. The question mark and asterisk have +no special meaning in a bracket expression. Each bracket expression ends by the +right bracket and matches exactly one character. Some examples follow: + +**[a-zA-Z0-9]** or **[f-gF-G]** - character interval + +**[abc]** - character enumeration + +**[^abc]** or **[!abc]** - negation + +**[[:name:]]** class expression. Supported classes are **alnum**,**lower**, +**space**, **alpha**, **digit**, **print**, **upper**, **blank**, **graph**, +**xdigit**. + +**[][-!^]** - special case - matches only '-', ']', '[', '!' or '^'. These +characters have no special purpose. + +**[[]]** - escape syntax. Matches '[', ']' or 'e'. + +Using the rules above, a filename pattern can be constructed: + + ftp://example.com/some/path/[a-z[:upper:]\\].jpg + +# PROTOCOLS + +This feature is only supported for FTP download. + +# EXAMPLE + +~~~c +extern long begin_cb(struct curl_fileinfo *, void *, int); +extern long end_cb(void *ptr); + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + /* turn on wildcard matching */ + curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); + + /* callback is called before download of concrete file started */ + curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, begin_cb); + + /* callback is called after data from the file have been transferred */ + curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, end_cb); + + /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */ + } +} +~~~ + +# AVAILABILITY + +Added in 7.21.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_WRITEDATA.3 b/docs/libcurl/opts/CURLOPT_WRITEDATA.3 deleted file mode 100644 index 6dc099506..000000000 --- a/docs/libcurl/opts/CURLOPT_WRITEDATA.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_WRITEDATA 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_WRITEDATA \- pointer passed to the write callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer); -.fi -.SH DESCRIPTION -A data \fIpointer\fP to pass to the write callback. If you use the -\fICURLOPT_WRITEFUNCTION(3)\fP option, this is the pointer you get in that -callback's fourth and last argument. If you do not use a write callback, you -must make \fIpointer\fP a 'FILE *' (cast to 'void *') as libcurl passes this -to \fIfwrite(3)\fP when writing data. - -The internal \fICURLOPT_WRITEFUNCTION(3)\fP writes the data to the FILE * -given with this option, or to stdout if this option has not been set. - -If you are using libcurl as a Windows DLL, you \fBMUST\fP use a -\fICURLOPT_WRITEFUNCTION(3)\fP if you set this option or you might experience -crashes. -.SH DEFAULT -By default, this is a FILE * to stdout. -.SH PROTOCOLS -Used for all protocols. -.SH EXAMPLE -A common technique is to use the write callback to store the incoming data -into a dynamically growing allocated buffer, and then this -\fICURLOPT_WRITEDATA(3)\fP is used to point to a struct or the buffer to store -data in. Like in the getinmemory example: -https://curl.se/libcurl/c/getinmemory.html -.SH AVAILABILITY -Available in all libcurl versions. This option was formerly known as -CURLOPT_FILE, the name \fICURLOPT_WRITEDATA(3)\fP was added in 7.9.7. -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_WRITEFUNCTION (3), -.BR CURLOPT_HEADERDATA (3), -.BR CURLOPT_READDATA (3) diff --git a/docs/libcurl/opts/CURLOPT_WRITEDATA.md b/docs/libcurl/opts/CURLOPT_WRITEDATA.md new file mode 100644 index 000000000..495c6bf9c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_WRITEDATA.md @@ -0,0 +1,63 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_WRITEDATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERDATA (3) + - CURLOPT_READDATA (3) + - CURLOPT_WRITEFUNCTION (3) +--- + +# NAME + +CURLOPT_WRITEDATA - pointer passed to the write callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer); +~~~ + +# DESCRIPTION + +A data *pointer* to pass to the write callback. If you use the +CURLOPT_WRITEFUNCTION(3) option, this is the pointer you get in that +callback's fourth and last argument. If you do not use a write callback, you +must make *pointer* a 'FILE *' (cast to 'void *') as libcurl passes this +to *fwrite(3)* when writing data. + +The internal CURLOPT_WRITEFUNCTION(3) writes the data to the FILE * +given with this option, or to stdout if this option has not been set. + +If you are using libcurl as a Windows DLL, you **MUST** use a +CURLOPT_WRITEFUNCTION(3) if you set this option or you might experience +crashes. + +# DEFAULT + +By default, this is a FILE * to stdout. + +# PROTOCOLS + +Used for all protocols. + +# EXAMPLE + +A common technique is to use the write callback to store the incoming data +into a dynamically growing allocated buffer, and then this +CURLOPT_WRITEDATA(3) is used to point to a struct or the buffer to store +data in. Like in the getinmemory example: +https://curl.se/libcurl/c/getinmemory.html + +# AVAILABILITY + +Available in all libcurl versions. This option was formerly known as +CURLOPT_FILE, the name CURLOPT_WRITEDATA(3) was added in 7.9.7. + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3 b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3 deleted file mode 100644 index d992bde20..000000000 --- a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3 +++ /dev/null @@ -1,138 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_WRITEFUNCTION 3 "16 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_WRITEFUNCTION \- callback for writing received data -.SH SYNOPSIS -.nf -#include - -size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEFUNCTION, write_callback); -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This callback function gets called by libcurl as soon as there is data -received that needs to be saved. For most transfers, this callback gets called -many times and each invoke delivers another chunk of data. \fIptr\fP points to -the delivered data, and the size of that data is \fInmemb\fP; \fIsize\fP is -always 1. - -The callback function is passed as much data as possible in all invokes, but -you must not make any assumptions. It may be one byte, it may be -thousands. The maximum amount of body data that is be passed to the write -callback is defined in the curl.h header file: \fICURL_MAX_WRITE_SIZE\fP (the -usual default is 16K). If \fICURLOPT_HEADER(3)\fP is enabled, which makes -header data get passed to the write callback, you can get up to -\fICURL_MAX_HTTP_HEADER\fP bytes of header data passed into it. This usually -means 100K. - -This function may be called with zero bytes data if the transferred file is -empty. - -The data passed to this function is not null-terminated! - -Set the \fIuserdata\fP argument with the \fICURLOPT_WRITEDATA(3)\fP option. - -Your callback should return the number of bytes actually taken care of. If -that amount differs from the amount passed to your callback function, it -signals an error condition to the library. This causes the transfer to get -aborted and the libcurl function used returns \fICURLE_WRITE_ERROR\fP. - -You can also abort the transfer by returning CURL_WRITEFUNC_ERROR (added in -7.87.0), which makes \fICURLE_WRITE_ERROR\fP get returned. - -If the callback function returns CURL_WRITEFUNC_PAUSE it pauses this -transfer. See \fIcurl_easy_pause(3)\fP for further details. - -Set this option to NULL to get the internal default function used instead of -your callback. The internal default function writes the data to the FILE * -given with \fICURLOPT_WRITEDATA(3)\fP. - -This option does not enable HSTS, you need to use \fICURLOPT_HSTS_CTRL(3)\fP to -do that. -.SH DEFAULT -libcurl uses 'fwrite' as a callback by default. -.SH PROTOCOLS -For all protocols -.SH EXAMPLE -.nf -#include /* for realloc */ -#include /* for memcpy */ - -struct memory { - char *response; - size_t size; -}; - -static size_t cb(void *data, size_t size, size_t nmemb, void *clientp) -{ - size_t realsize = size * nmemb; - struct memory *mem = (struct memory *)clientp; - - char *ptr = realloc(mem->response, mem->size + realsize + 1); - if(!ptr) - return 0; /* out of memory! */ - - mem->response = ptr; - memcpy(&(mem->response[mem->size]), data, realsize); - mem->size += realsize; - mem->response[mem->size] = 0; - - return realsize; -} - -int main(void) -{ - struct memory chunk = {0}; - CURLcode res; - CURL *curl = curl_easy_init(); - if(curl) { - /* send all data to this function */ - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb); - - /* we pass our 'chunk' struct to the callback function */ - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk); - - /* send a request */ - res = curl_easy_perform(curl); - - /* remember to free the buffer */ - free(chunk.response); - - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Support for the CURL_WRITEFUNC_PAUSE return code was added in version 7.18.0. -.SH RETURN VALUE -This returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_WRITEDATA (3), -.BR CURLOPT_READFUNCTION (3), -.BR CURLOPT_HEADERFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md new file mode 100644 index 000000000..8957439d3 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md @@ -0,0 +1,136 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_WRITEFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_HEADERFUNCTION (3) + - CURLOPT_READFUNCTION (3) + - CURLOPT_WRITEDATA (3) +--- + +# NAME + +CURLOPT_WRITEFUNCTION - callback for writing received data + +# SYNOPSIS + +~~~c +#include + +size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEFUNCTION, write_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This callback function gets called by libcurl as soon as there is data +received that needs to be saved. For most transfers, this callback gets called +many times and each invoke delivers another chunk of data. *ptr* points to the +delivered data, and the size of that data is *nmemb*; *size* is always 1. + +The data passed to this function is not null-terminated. + +The callback function is passed as much data as possible in all invokes, but +you must not make any assumptions. It may be one byte, it may be +thousands. The maximum amount of body data that is be passed to the write +callback is defined in the curl.h header file: *CURL_MAX_WRITE_SIZE* (the +usual default is 16K). If CURLOPT_HEADER(3) is enabled, which makes header +data get passed to the write callback, you can get up to +*CURL_MAX_HTTP_HEADER* bytes of header data passed into it. This usually means +100K. + +This function may be called with zero bytes data if the transferred file is +empty. + +Set the *userdata* argument with the CURLOPT_WRITEDATA(3) option. + +Your callback should return the number of bytes actually taken care of. If +that amount differs from the amount passed to your callback function, it +signals an error condition to the library. This causes the transfer to get +aborted and the libcurl function used returns *CURLE_WRITE_ERROR*. + +You can also abort the transfer by returning CURL_WRITEFUNC_ERROR (added in +7.87.0), which makes *CURLE_WRITE_ERROR* get returned. + +If the callback function returns CURL_WRITEFUNC_PAUSE it pauses this +transfer. See curl_easy_pause(3) for further details. + +Set this option to NULL to get the internal default function used instead of +your callback. The internal default function writes the data to the FILE * +given with CURLOPT_WRITEDATA(3). + +This option does not enable HSTS, you need to use CURLOPT_HSTS_CTRL(3) to +do that. + +# DEFAULT + +libcurl uses 'fwrite' as a callback by default. + +# PROTOCOLS + +For all protocols + +# EXAMPLE + +~~~c +#include /* for realloc */ +#include /* for memcpy */ + +struct memory { + char *response; + size_t size; +}; + +static size_t cb(void *data, size_t size, size_t nmemb, void *clientp) +{ + size_t realsize = size * nmemb; + struct memory *mem = (struct memory *)clientp; + + char *ptr = realloc(mem->response, mem->size + realsize + 1); + if(!ptr) + return 0; /* out of memory! */ + + mem->response = ptr; + memcpy(&(mem->response[mem->size]), data, realsize); + mem->size += realsize; + mem->response[mem->size] = 0; + + return realsize; +} + +int main(void) +{ + struct memory chunk = {0}; + CURLcode res; + CURL *curl = curl_easy_init(); + if(curl) { + /* send all data to this function */ + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb); + + /* we pass our 'chunk' struct to the callback function */ + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk); + + /* send a request */ + res = curl_easy_perform(curl); + + /* remember to free the buffer */ + free(chunk.response); + + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Support for the CURL_WRITEFUNC_PAUSE return code was added in version 7.18.0. + +# RETURN VALUE + +This returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_WS_OPTIONS.3 b/docs/libcurl/opts/CURLOPT_WS_OPTIONS.3 deleted file mode 100644 index 3031b9524..000000000 --- a/docs/libcurl/opts/CURLOPT_WS_OPTIONS.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_WS_OPTIONS 3 "10 Jun 2022" libcurl libcurl -.SH NAME -CURLOPT_WS_OPTIONS \- WebSocket behavior options -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask); -.fi -.SH DESCRIPTION -Pass a long with a bitmask to tell libcurl about specific WebSocket -behaviors. - -To detach a WebSocket connection and use the \fIcurl_ws_send(3)\fP and -\fIcurl_ws_recv(3)\fP functions after the HTTP upgrade procedure, set the -\fICURLOPT_CONNECT_ONLY(3)\fP option to 2L. - -Available bits in the bitmask -.IP "CURLWS_RAW_MODE (1)" -Deliver "raw" WebSocket traffic to the \fICURLOPT_WRITEFUNCTION(3)\fP -callback. - -In raw mode, libcurl does not handle pings or any other frame for the -application. -.SH DEFAULT -0 -.SH PROTOCOLS -WebSocket -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/"); - /* tell curl we deal with all the WebSocket magic ourselves */ - curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.86.0 -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR curl_ws_recv (3), -.BR curl_ws_send (3), -.BR CURLOPT_CONNECT_ONLY (3) diff --git a/docs/libcurl/opts/CURLOPT_WS_OPTIONS.md b/docs/libcurl/opts/CURLOPT_WS_OPTIONS.md new file mode 100644 index 000000000..04af5bca8 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_WS_OPTIONS.md @@ -0,0 +1,75 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_WS_OPTIONS +Section: 3 +Source: libcurl +See-also: + - CURLOPT_CONNECT_ONLY (3) + - curl_ws_recv (3) + - curl_ws_send (3) +--- + +# NAME + +CURLOPT_WS_OPTIONS - WebSocket behavior options + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WS_OPTIONS, long bitmask); +~~~ + +# DESCRIPTION + +Pass a long with a bitmask to tell libcurl about specific WebSocket +behaviors. + +To detach a WebSocket connection and use the curl_ws_send(3) and +curl_ws_recv(3) functions after the HTTP upgrade procedure, set the +CURLOPT_CONNECT_ONLY(3) option to 2L. + +Available bits in the bitmask + +## CURLWS_RAW_MODE (1) + +Deliver "raw" WebSocket traffic to the CURLOPT_WRITEFUNCTION(3) +callback. + +In raw mode, libcurl does not handle pings or any other frame for the +application. + +# DEFAULT + +0 + +# PROTOCOLS + +WebSocket + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "ws://example.com/"); + /* tell curl we deal with all the WebSocket magic ourselves */ + curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.86.0 + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. diff --git a/docs/libcurl/opts/CURLOPT_XFERINFODATA.3 b/docs/libcurl/opts/CURLOPT_XFERINFODATA.3 deleted file mode 100644 index 4a03b9ccf..000000000 --- a/docs/libcurl/opts/CURLOPT_XFERINFODATA.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_XFERINFODATA 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_XFERINFODATA \- pointer passed to the progress callback -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFODATA, void *pointer); -.fi -.SH DESCRIPTION -Pass a \fIpointer\fP that is untouched by libcurl and passed as the first -argument in the progress callback set with \fICURLOPT_XFERINFOFUNCTION(3)\fP. - -This is an alias for \fICURLOPT_PROGRESSDATA(3)\fP. -.SH DEFAULT -The default value of this parameter is NULL. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct progress { - char *private; - size_t size; -}; - -static size_t progress_cb(void *clientp, - curl_off_t dltotal, - curl_off_t dlnow, - curl_off_t ultotal, - curl_off_t ulnow) -{ - struct progress *memory = clientp; - printf("private ptr: %p\\n", memory->private); - /* use the values */ - - return 0; /* all is good */ -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct progress data; - - /* pass struct to callback */ - curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data); - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_cb); - } -} -.fi -.SH AVAILABILITY -Added in 7.32.0 -.SH RETURN VALUE -Returns CURLE_OK -.SH "SEE ALSO" -.BR CURLOPT_NOPROGRESS (3), -.BR CURLOPT_VERBOSE (3), -.BR CURLOPT_XFERINFOFUNCTION (3) diff --git a/docs/libcurl/opts/CURLOPT_XFERINFODATA.md b/docs/libcurl/opts/CURLOPT_XFERINFODATA.md new file mode 100644 index 000000000..145057c5c --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_XFERINFODATA.md @@ -0,0 +1,80 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_XFERINFODATA +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NOPROGRESS (3) + - CURLOPT_VERBOSE (3) + - CURLOPT_XFERINFOFUNCTION (3) +--- + +# NAME + +CURLOPT_XFERINFODATA - pointer passed to the progress callback + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFODATA, void *pointer); +~~~ + +# DESCRIPTION + +Pass a *pointer* that is untouched by libcurl and passed as the first +argument in the progress callback set with CURLOPT_XFERINFOFUNCTION(3). + +This is an alias for CURLOPT_PROGRESSDATA(3). + +# DEFAULT + +The default value of this parameter is NULL. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct progress { + char *private; + size_t size; +}; + +static size_t progress_cb(void *clientp, + curl_off_t dltotal, + curl_off_t dlnow, + curl_off_t ultotal, + curl_off_t ulnow) +{ + struct progress *memory = clientp; + printf("private ptr: %p\n", memory->private); + /* use the values */ + + return 0; /* all is good */ +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct progress data; + + /* pass struct to callback */ + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_cb); + } +} +~~~ + +# AVAILABILITY + +Added in 7.32.0 + +# RETURN VALUE + +Returns CURLE_OK diff --git a/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.3 b/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.3 deleted file mode 100644 index 61521f391..000000000 --- a/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_XFERINFOFUNCTION 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_XFERINFOFUNCTION \- progress meter callback -.SH SYNOPSIS -.nf -#include - -int progress_callback(void *clientp, - curl_off_t dltotal, - curl_off_t dlnow, - curl_off_t ultotal, - curl_off_t ulnow); - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFOFUNCTION, - progress_callback); -.fi -.SH DESCRIPTION -Pass a pointer to your callback function, which should match the prototype -shown above. - -This function gets called by libcurl instead of its internal equivalent with a -frequent interval. While data is being transferred it gets called frequently, -and during slow periods like when nothing is being transferred it can slow -down to about one call per second. - -\fIclientp\fP is the pointer set with \fICURLOPT_XFERINFODATA(3)\fP, it is not -used by libcurl but is only passed along from the application to the callback. - -The callback gets told how much data libcurl is about to transfer and has -already transferred, in number of bytes. \fIdltotal\fP is the total number of -bytes libcurl expects to download in this transfer. \fIdlnow\fP is the number -of bytes downloaded so far. \fIultotal\fP is the total number of bytes libcurl -expects to upload in this transfer. \fIulnow\fP is the number of bytes -uploaded so far. - -Unknown/unused argument values passed to the callback are set to zero (like if -you only download data, the upload size remains 0). Many times the callback is -called one or more times first, before it knows the data sizes so a program -must be made to handle that. - -If your callback function returns CURL_PROGRESSFUNC_CONTINUE it makes libcurl -to continue executing the default progress function. - -Returning any other non-zero value from this callback makes libcurl abort the -transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP. - -If you transfer data with the multi interface, this function is not called -during periods of idleness unless you call the appropriate libcurl function -that performs transfers. - -\fICURLOPT_NOPROGRESS(3)\fP must be set to 0 to make this function actually -get called. -.SH DEFAULT -By default, libcurl has an internal progress meter. That is rarely wanted by -users. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct progress { - char *private; - size_t size; -}; - -static size_t progress_callback(void *clientp, - curl_off_t dltotal, - curl_off_t dlnow, - curl_off_t ultotal, - curl_off_t ulnow) -{ - struct progress *memory = clientp; - printf("my ptr: %p\\n", memory->private); - - /* use the values */ - - return 0; /* all is good */ -} - -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - struct progress data; - - /* pass struct to callback */ - curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data); - - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); - } -} -.fi -.SH AVAILABILITY -Added in 7.32.0. This callback replaces \fICURLOPT_PROGRESSFUNCTION(3)\fP -.SH RETURN VALUE -Returns CURLE_OK. -.SH "SEE ALSO" -.BR CURLOPT_NOPROGRESS (3), -.BR CURLOPT_XFERINFODATA (3) diff --git a/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.md b/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.md new file mode 100644 index 000000000..b965db591 --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_XFERINFOFUNCTION.md @@ -0,0 +1,120 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_XFERINFOFUNCTION +Section: 3 +Source: libcurl +See-also: + - CURLOPT_NOPROGRESS (3) + - CURLOPT_XFERINFODATA (3) +--- + +# NAME + +CURLOPT_XFERINFOFUNCTION - progress meter callback + +# SYNOPSIS + +~~~c +#include + +int progress_callback(void *clientp, + curl_off_t dltotal, + curl_off_t dlnow, + curl_off_t ultotal, + curl_off_t ulnow); + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFOFUNCTION, + progress_callback); +~~~ + +# DESCRIPTION + +Pass a pointer to your callback function, which should match the prototype +shown above. + +This function gets called by libcurl instead of its internal equivalent with a +frequent interval. While data is being transferred it gets called frequently, +and during slow periods like when nothing is being transferred it can slow +down to about one call per second. + +*clientp* is the pointer set with CURLOPT_XFERINFODATA(3), it is not +used by libcurl but is only passed along from the application to the callback. + +The callback gets told how much data libcurl is about to transfer and has +already transferred, in number of bytes. *dltotal* is the total number of +bytes libcurl expects to download in this transfer. *dlnow* is the number +of bytes downloaded so far. *ultotal* is the total number of bytes libcurl +expects to upload in this transfer. *ulnow* is the number of bytes +uploaded so far. + +Unknown/unused argument values passed to the callback are set to zero (like if +you only download data, the upload size remains 0). Many times the callback is +called one or more times first, before it knows the data sizes so a program +must be made to handle that. + +If your callback function returns CURL_PROGRESSFUNC_CONTINUE it makes libcurl +to continue executing the default progress function. + +Returning any other non-zero value from this callback makes libcurl abort the +transfer and return *CURLE_ABORTED_BY_CALLBACK*. + +If you transfer data with the multi interface, this function is not called +during periods of idleness unless you call the appropriate libcurl function +that performs transfers. + +CURLOPT_NOPROGRESS(3) must be set to 0 to make this function actually +get called. + +# DEFAULT + +By default, libcurl has an internal progress meter. That is rarely wanted by +users. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct progress { + char *private; + size_t size; +}; + +static size_t progress_callback(void *clientp, + curl_off_t dltotal, + curl_off_t dlnow, + curl_off_t ultotal, + curl_off_t ulnow) +{ + struct progress *memory = clientp; + printf("my ptr: %p\n", memory->private); + + /* use the values */ + + return 0; /* all is good */ +} + +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + struct progress data; + + /* pass struct to callback */ + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data); + + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); + } +} +~~~ + +# AVAILABILITY + +Added in 7.32.0. This callback replaces CURLOPT_PROGRESSFUNCTION(3) + +# RETURN VALUE + +Returns CURLE_OK. diff --git a/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.3 b/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.3 deleted file mode 100644 index 0dc5242fd..000000000 --- a/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_XOAUTH2_BEARER 3 "19 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_XOAUTH2_BEARER \- OAuth 2.0 access token -.SH SYNOPSIS -.nf -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token); -.fi -.SH DESCRIPTION -Pass a char * as parameter, which should point to the null-terminated OAuth -2.0 Bearer Access Token for use with HTTP, IMAP, LDAP, POP3 and SMTP servers -that support the OAuth 2.0 Authorization Framework. - -Note: For IMAP, LDAP, POP3 and SMTP, the user name used to generate the -Bearer Token should be supplied via the \fICURLOPT_USERNAME(3)\fP option. - -The application does not have to keep the string around after setting this -option. -.SH DEFAULT -NULL -.SH PROTOCOLS -HTTP, IMAP, LDAP, POP3 and SMTP -.SH EXAMPLE -.nf -int main(void) -{ - CURL *curl = curl_easy_init(); - if(curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/"); - curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7"); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - } -} -.fi -.SH AVAILABILITY -Added in 7.33.0. Support for OpenLDAP added in 7.82.0. -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or -CURLE_OUT_OF_MEMORY if there was insufficient heap space. -.SH "SEE ALSO" -.BR CURLOPT_MAIL_AUTH (3), -.BR CURLOPT_USERNAME (3) - diff --git a/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.md b/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.md new file mode 100644 index 000000000..af91ea03e --- /dev/null +++ b/docs/libcurl/opts/CURLOPT_XOAUTH2_BEARER.md @@ -0,0 +1,67 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLOPT_XOAUTH2_BEARER +Section: 3 +Source: libcurl +See-also: + - CURLOPT_MAIL_AUTH (3) + - CURLOPT_USERNAME (3) +--- + +# NAME + +CURLOPT_XOAUTH2_BEARER - OAuth 2.0 access token + +# SYNOPSIS + +~~~c +#include + +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XOAUTH2_BEARER, char *token); +~~~ + +# DESCRIPTION + +Pass a char pointer as parameter, which should point to the null-terminated +OAuth 2.0 Bearer Access Token for use with HTTP, IMAP, LDAP, POP3 and SMTP +servers that support the OAuth 2.0 Authorization Framework. + +Note: For IMAP, LDAP, POP3 and SMTP, the user name used to generate the +Bearer Token should be supplied via the CURLOPT_USERNAME(3) option. + +The application does not have to keep the string around after setting this +option. + +# DEFAULT + +NULL + +# PROTOCOLS + +HTTP, IMAP, LDAP, POP3 and SMTP + +# EXAMPLE + +~~~c +int main(void) +{ + CURL *curl = curl_easy_init(); + if(curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "pop3://example.com/"); + curl_easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, "1ab9cb22ba269a7"); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } +} +~~~ + +# AVAILABILITY + +Added in 7.33.0. Support for OpenLDAP added in 7.82.0. + +# RETURN VALUE + +Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or +CURLE_OUT_OF_MEMORY if there was insufficient heap space. diff --git a/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.3 b/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.3 deleted file mode 100644 index 174326cb1..000000000 --- a/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH CURLSHOPT_LOCKFUNC 3 "8 Aug 2003" libcurl libcurl -.SH NAME -CURLSHOPT_LOCKFUNC - mutex lock callback -.SH SYNOPSIS -.nf -#include - -void lockcb(CURL *handle, curl_lock_data data, curl_lock_access access, - void *clientp); - -CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_LOCKFUNC, lockcb); -.fi -.SH DESCRIPTION -Set a mutex lock callback for the share object, to allow it to get used by -multiple threads concurrently. There is a corresponding -\fICURLSHOPT_UNLOCKFUNC(3)\fP callback called when the mutex is again released. - -The \fIlockcb\fP argument must be a pointer to a function matching the -prototype shown above. The arguments to the callback are: - -\fIhandle\fP is the currently active easy handle in use when the share object -is intended to get used. - -The \fIdata\fP argument tells what kind of data libcurl wants to lock. Make -sure that the callback uses a different lock for each kind of data. - -\fIaccess\fP defines what access type libcurl wants, shared or single. - -\fIclientp\fP is the private pointer you set with \fICURLSHOPT_USERDATA(3)\fP. -This pointer is not used by libcurl itself. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -extern void mutex_lock(CURL *handle, curl_lock_data data, - curl_lock_access access, void *clientp); - -int main(void) -{ - CURLSHcode sh; - CURLSH *share = curl_share_init(); - sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock); - if(sh) - printf("Error: %s\\n", curl_share_strerror(sh)); -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -CURLSHE_OK (zero) means that the option was set properly, non-zero means an -error occurred. See \fIlibcurl-errors(3)\fP for the full list with -descriptions. -.SH "SEE ALSO" -.BR curl_share_cleanup (3), -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR CURLSHOPT_UNLOCKFUNC (3) diff --git a/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.md b/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.md new file mode 100644 index 000000000..f41f86ebf --- /dev/null +++ b/docs/libcurl/opts/CURLSHOPT_LOCKFUNC.md @@ -0,0 +1,77 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLSHOPT_LOCKFUNC +Section: 3 +Source: libcurl +See-also: + - CURLSHOPT_UNLOCKFUNC (3) + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) +--- + +# NAME + +CURLSHOPT_LOCKFUNC - mutex lock callback + +# SYNOPSIS + +~~~c +#include + +void lockcb(CURL *handle, curl_lock_data data, curl_lock_access access, + void *clientp); + +CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_LOCKFUNC, lockcb); +~~~ + +# DESCRIPTION + +Set a mutex lock callback for the share object, to allow it to get used by +multiple threads concurrently. There is a corresponding +CURLSHOPT_UNLOCKFUNC(3) callback called when the mutex is again released. + +The *lockcb* argument must be a pointer to a function matching the +prototype shown above. The arguments to the callback are: + +*handle* is the currently active easy handle in use when the share object +is intended to get used. + +The *data* argument tells what kind of data libcurl wants to lock. Make +sure that the callback uses a different lock for each kind of data. + +*access* defines what access type libcurl wants, shared or single. + +*clientp* is the private pointer you set with CURLSHOPT_USERDATA(3). +This pointer is not used by libcurl itself. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +extern void mutex_lock(CURL *handle, curl_lock_data data, + curl_lock_access access, void *clientp); + +int main(void) +{ + CURLSHcode sh; + CURLSH *share = curl_share_init(); + sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock); + if(sh) + printf("Error: %s\n", curl_share_strerror(sh)); +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +CURLSHE_OK (zero) means that the option was set properly, non-zero means an +error occurred. See libcurl-errors(3) for the full list with +descriptions. diff --git a/docs/libcurl/opts/CURLSHOPT_SHARE.3 b/docs/libcurl/opts/CURLSHOPT_SHARE.3 deleted file mode 100644 index 49f976040..000000000 --- a/docs/libcurl/opts/CURLSHOPT_SHARE.3 +++ /dev/null @@ -1,108 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH CURLSHOPT_SHARE 3 "8 Aug 2003" libcurl libcurl -.SH NAME -CURLSHOPT_SHARE - add data to share -.SH SYNOPSIS -.nf -#include - -CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_SHARE, long type); -.fi -.SH DESCRIPTION -The \fItype\fP parameter specifies what specific data that should be shared -and kept in the share object that was created with \fIcurl_share_init(3)\fP. -The given \fItype\fP must be be one of the values described below. You can set -\fICURLSHOPT_SHARE(3)\fP multiple times with different data arguments to have -the share object share multiple types of data. Unset a type again by setting -\fICURLSHOPT_UNSHARE(3)\fP. -.IP CURL_LOCK_DATA_COOKIE -Cookie data is shared across the easy handles using this shared object. Note -that this does not activate an easy handle's cookie handling. You can do that -separately by using \fICURLOPT_COOKIEFILE(3)\fP for example. -.IP CURL_LOCK_DATA_DNS -Cached DNS hosts are shared across the easy handles using this shared -object. Note that when you use the multi interface, all easy handles added to -the same multi handle share DNS cache by default without using this option. -.IP CURL_LOCK_DATA_SSL_SESSION -SSL session IDs are shared across the easy handles using this shared -object. This reduces the time spent in the SSL handshake when reconnecting to -the same server. Note SSL session IDs are reused within the same easy handle -by default. Note this symbol was added in 7.10.3 but was not implemented until -7.23.0. -.IP CURL_LOCK_DATA_CONNECT -Put the connection cache in the share object and make all easy handles using -this share object share the connection cache. - -It is not supported to share connections between multiple concurrent threads. - -Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only -get additional transfers added to them if the existing connection is held by -the same multi or easy handle. libcurl does not support doing HTTP/2 streams -in different threads using a shared connection. - -Support for \fBCURL_LOCK_DATA_CONNECT\fP was added in 7.57.0, but the symbol -existed before this. - -Note that when you use the multi interface, all easy handles added to the same -multi handle shares connection cache by default without using this option. -.IP CURL_LOCK_DATA_PSL -The Public Suffix List stored in the share object is made available to all -easy handle bound to the later. Since the Public Suffix List is periodically -refreshed, this avoids updates in too many different contexts. - -Added in 7.61.0. - -Note that when you use the multi interface, all easy handles added to the same -multi handle shares PSL cache by default without using this option. -.IP CURL_LOCK_DATA_HSTS -The in-memory HSTS cache. - -It is not supported to share the HSTS between multiple concurrent threads. - -Added in 7.88.0 -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURLSHcode sh; - CURLSH *share = curl_share_init(); - sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); - if(sh) - printf("Error: %s\\n", curl_share_strerror(sh)); -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -CURLSHE_OK (zero) means that the option was set properly, non-zero means an -error occurred. See \fIlibcurl-errors(3)\fP for the full list with -descriptions. -.SH "SEE ALSO" -.BR curl_share_cleanup (3), -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR CURLSHOPT_UNSHARE (3) diff --git a/docs/libcurl/opts/CURLSHOPT_SHARE.md b/docs/libcurl/opts/CURLSHOPT_SHARE.md new file mode 100644 index 000000000..66ed27034 --- /dev/null +++ b/docs/libcurl/opts/CURLSHOPT_SHARE.md @@ -0,0 +1,117 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLSHOPT_SHARE +Section: 3 +Source: libcurl +See-also: + - CURLSHOPT_UNSHARE (3) + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) +--- + +# NAME + +CURLSHOPT_SHARE - add data to share + +# SYNOPSIS + +~~~c +#include + +CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_SHARE, long type); +~~~ + +# DESCRIPTION + +The *type* parameter specifies what specific data that should be shared +and kept in the share object that was created with curl_share_init(3). +The given *type* must be be one of the values described below. You can set +CURLSHOPT_SHARE(3) multiple times with different data arguments to have +the share object share multiple types of data. Unset a type again by setting +CURLSHOPT_UNSHARE(3). + +## CURL_LOCK_DATA_COOKIE + +Cookie data is shared across the easy handles using this shared object. Note +that this does not activate an easy handle's cookie handling. You can do that +separately by using CURLOPT_COOKIEFILE(3) for example. + +## CURL_LOCK_DATA_DNS + +Cached DNS hosts are shared across the easy handles using this shared +object. Note that when you use the multi interface, all easy handles added to +the same multi handle share DNS cache by default without using this option. + +## CURL_LOCK_DATA_SSL_SESSION + +SSL session IDs are shared across the easy handles using this shared +object. This reduces the time spent in the SSL handshake when reconnecting to +the same server. Note SSL session IDs are reused within the same easy handle +by default. Note this symbol was added in 7.10.3 but was not implemented until +7.23.0. + +## CURL_LOCK_DATA_CONNECT + +Put the connection cache in the share object and make all easy handles using +this share object share the connection cache. + +It is not supported to share connections between multiple concurrent threads. + +Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only +get additional transfers added to them if the existing connection is held by +the same multi or easy handle. libcurl does not support doing HTTP/2 streams +in different threads using a shared connection. + +Support for **CURL_LOCK_DATA_CONNECT** was added in 7.57.0, but the symbol +existed before this. + +Note that when you use the multi interface, all easy handles added to the same +multi handle shares connection cache by default without using this option. + +## CURL_LOCK_DATA_PSL + +The Public Suffix List stored in the share object is made available to all +easy handle bound to the later. Since the Public Suffix List is periodically +refreshed, this avoids updates in too many different contexts. + +Added in 7.61.0. + +Note that when you use the multi interface, all easy handles added to the same +multi handle shares PSL cache by default without using this option. + +## CURL_LOCK_DATA_HSTS + +The in-memory HSTS cache. + +It is not supported to share the HSTS between multiple concurrent threads. + +Added in 7.88.0 + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURLSHcode sh; + CURLSH *share = curl_share_init(); + sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + if(sh) + printf("Error: %s\n", curl_share_strerror(sh)); +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +CURLSHE_OK (zero) means that the option was set properly, non-zero means an +error occurred. See libcurl-errors(3) for the full list with +descriptions. diff --git a/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.3 b/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.3 deleted file mode 100644 index 1994b6fd9..000000000 --- a/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH CURLSHOPT_UNLOCKFUNC 3 "8 Aug 2003" libcurl libcurl -.SH NAME -CURLSHOPT_UNLOCKFUNC - mutex unlock callback -.SH SYNOPSIS -.nf -#include - -void unlockcb(CURL *handle, curl_lock_data data, void *clientp); - -CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNLOCKFUNC, unlockcb); -.fi -.SH DESCRIPTION -Set a mutex unlock callback for the share object. There is a corresponding -\fICURLSHOPT_LOCKFUNC(3)\fP callback called when the mutex is first locked. - -The \fIunlockcb\fP argument must be a pointer to a function matching the -prototype shown above. The arguments to the callback are: - -\fIhandle\fP is the currently active easy handle in use when the share object -is released. - -The \fIdata\fP argument tells what kind of data libcurl wants to unlock. Make -sure that the callback uses a different lock for each kind of data. - -\fIclientp\fP is the private pointer you set with \fICURLSHOPT_USERDATA(3)\fP. -This pointer is not used by libcurl itself. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -extern void mutex_unlock(CURL *, curl_lock_data, void *); - -int main(void) -{ - CURLSHcode sh; - CURLSH *share = curl_share_init(); - sh = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, mutex_unlock); - if(sh) - printf("Error: %s\\n", curl_share_strerror(sh)); -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -CURLSHE_OK (zero) means that the option was set properly, non-zero means an -error occurred. See \fIlibcurl-errors(3)\fP for the full list with -descriptions. -.SH "SEE ALSO" -.BR curl_share_cleanup (3), -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR CURLSHOPT_LOCKFUNC (3) diff --git a/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.md b/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.md new file mode 100644 index 000000000..16f9a377e --- /dev/null +++ b/docs/libcurl/opts/CURLSHOPT_UNLOCKFUNC.md @@ -0,0 +1,72 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLSHOPT_UNLOCKFUNC +Section: 3 +Source: libcurl +See-also: + - CURLSHOPT_LOCKFUNC (3) + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) +--- + +# NAME + +CURLSHOPT_UNLOCKFUNC - mutex unlock callback + +# SYNOPSIS + +~~~c +#include + +void unlockcb(CURL *handle, curl_lock_data data, void *clientp); + +CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNLOCKFUNC, unlockcb); +~~~ + +# DESCRIPTION + +Set a mutex unlock callback for the share object. There is a corresponding +CURLSHOPT_LOCKFUNC(3) callback called when the mutex is first locked. + +The *unlockcb* argument must be a pointer to a function matching the +prototype shown above. The arguments to the callback are: + +*handle* is the currently active easy handle in use when the share object +is released. + +The *data* argument tells what kind of data libcurl wants to unlock. Make +sure that the callback uses a different lock for each kind of data. + +*clientp* is the private pointer you set with CURLSHOPT_USERDATA(3). +This pointer is not used by libcurl itself. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +extern void mutex_unlock(CURL *, curl_lock_data, void *); + +int main(void) +{ + CURLSHcode sh; + CURLSH *share = curl_share_init(); + sh = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, mutex_unlock); + if(sh) + printf("Error: %s\n", curl_share_strerror(sh)); +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +CURLSHE_OK (zero) means that the option was set properly, non-zero means an +error occurred. See libcurl-errors(3) for the full list with +descriptions. diff --git a/docs/libcurl/opts/CURLSHOPT_UNSHARE.3 b/docs/libcurl/opts/CURLSHOPT_UNSHARE.3 deleted file mode 100644 index e0d252bf3..000000000 --- a/docs/libcurl/opts/CURLSHOPT_UNSHARE.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH CURLSHOPT_UNSHARE 3 "8 Aug 2003" libcurl libcurl -.SH NAME -CURLSHOPT_UNSHARE - remove data to share -.SH SYNOPSIS -.nf -#include - -CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNSHARE, long type); -.fi -.SH DESCRIPTION -The \fItype\fP parameter specifies what specific data that should no longer be -shared and kept in the share object that was created with -\fIcurl_share_init(3)\fP. In other words, stop sharing that data in this -shared object. The given \fItype\fP must be be one of the values described -below. You can set \fICURLSHOPT_UNSHARE(3)\fP multiple times with different -data arguments to remove multiple types from the shared object. Add data to -share again with \fICURLSHOPT_SHARE(3)\fP. -.IP CURL_LOCK_DATA_COOKIE -Cookie data is no longer shared across the easy handles using this shared -object. -.IP CURL_LOCK_DATA_DNS -Cached DNS hosts are no longer shared across the easy handles using this -shared object. -.IP CURL_LOCK_DATA_SSL_SESSION -SSL session IDs are no longer shared across the easy handles using this shared -object. -.IP CURL_LOCK_DATA_CONNECT -The connection cache is no longer shared. -.IP CURL_LOCK_DATA_PSL -The Public Suffix List is no longer shared. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -int main(void) -{ - CURLSHcode sh; - CURLSH *share = curl_share_init(); - sh = curl_share_setopt(share, CURLSHOPT_UNSHARE, CURL_LOCK_DATA_COOKIE); - if(sh) - printf("Error: %s\\n", curl_share_strerror(sh)); -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -CURLSHE_OK (zero) means that the option was set properly, non-zero means an -error occurred. See \fIlibcurl-errors(3)\fP for the full list with -descriptions. -.SH "SEE ALSO" -.BR curl_share_cleanup (3), -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR CURLSHOPT_SHARE (3) diff --git a/docs/libcurl/opts/CURLSHOPT_UNSHARE.md b/docs/libcurl/opts/CURLSHOPT_UNSHARE.md new file mode 100644 index 000000000..e3cf5988c --- /dev/null +++ b/docs/libcurl/opts/CURLSHOPT_UNSHARE.md @@ -0,0 +1,84 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLSHOPT_UNSHARE +Section: 3 +Source: libcurl +See-also: + - CURLSHOPT_SHARE (3) + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) +--- + +# NAME + +CURLSHOPT_UNSHARE - remove data to share + +# SYNOPSIS + +~~~c +#include + +CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNSHARE, long type); +~~~ + +# DESCRIPTION + +The *type* parameter specifies what specific data that should no longer be +shared and kept in the share object that was created with +curl_share_init(3). In other words, stop sharing that data in this +shared object. The given *type* must be be one of the values described +below. You can set CURLSHOPT_UNSHARE(3) multiple times with different +data arguments to remove multiple types from the shared object. Add data to +share again with CURLSHOPT_SHARE(3). + +## CURL_LOCK_DATA_COOKIE + +Cookie data is no longer shared across the easy handles using this shared +object. + +## CURL_LOCK_DATA_DNS + +Cached DNS hosts are no longer shared across the easy handles using this +shared object. + +## CURL_LOCK_DATA_SSL_SESSION + +SSL session IDs are no longer shared across the easy handles using this shared +object. + +## CURL_LOCK_DATA_CONNECT + +The connection cache is no longer shared. + +## CURL_LOCK_DATA_PSL + +The Public Suffix List is no longer shared. + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +int main(void) +{ + CURLSHcode sh; + CURLSH *share = curl_share_init(); + sh = curl_share_setopt(share, CURLSHOPT_UNSHARE, CURL_LOCK_DATA_COOKIE); + if(sh) + printf("Error: %s\n", curl_share_strerror(sh)); +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +CURLSHE_OK (zero) means that the option was set properly, non-zero means an +error occurred. See libcurl-errors(3) for the full list with +descriptions. diff --git a/docs/libcurl/opts/CURLSHOPT_USERDATA.3 b/docs/libcurl/opts/CURLSHOPT_USERDATA.3 deleted file mode 100644 index cb5347fe9..000000000 --- a/docs/libcurl/opts/CURLSHOPT_USERDATA.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.TH CURLSHOPT_USERDATA 3 "8 Aug 2003" libcurl libcurl -.SH NAME -CURLSHOPT_USERDATA - pointer passed to the lock and unlock mutex callbacks -.SH SYNOPSIS -.nf -#include - -CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_USERDATA, void *clientp); -.fi -.SH DESCRIPTION -The \fIclientp\fP parameter is held verbatim by libcurl and is passed on as -the \fIclientp\fP argument to the callbacks set with -\fICURLSHOPT_LOCKFUNC(3)\fP and \fICURLSHOPT_UNLOCKFUNC(3)\fP. -.SH PROTOCOLS -All -.SH EXAMPLE -.nf -struct secrets { - void *custom; -}; - -int main(void) -{ - CURLSHcode sh; - struct secrets private_stuff; - CURLSH *share = curl_share_init(); - sh = curl_share_setopt(share, CURLSHOPT_USERDATA, &private_stuff); - if(sh) - printf("Error: %s\\n", curl_share_strerror(sh)); -} -.fi -.SH AVAILABILITY -Added in 7.10 -.SH RETURN VALUE -CURLSHE_OK (zero) means that the option was set properly, non-zero means an -error occurred. See \fIlibcurl-errors(3)\fP for the full list with -descriptions. -.SH "SEE ALSO" -.BR curl_share_cleanup (3), -.BR curl_share_init (3), -.BR curl_share_setopt (3), -.BR CURLSHOPT_LOCKFUNC (3) diff --git a/docs/libcurl/opts/CURLSHOPT_USERDATA.md b/docs/libcurl/opts/CURLSHOPT_USERDATA.md new file mode 100644 index 000000000..d0ec7772d --- /dev/null +++ b/docs/libcurl/opts/CURLSHOPT_USERDATA.md @@ -0,0 +1,62 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: CURLSHOPT_USERDATA +Section: 3 +Source: libcurl +See-also: + - CURLSHOPT_LOCKFUNC (3) + - curl_share_cleanup (3) + - curl_share_init (3) + - curl_share_setopt (3) +--- + +# NAME + +CURLSHOPT_USERDATA - pointer passed to the lock and unlock mutex callbacks + +# SYNOPSIS + +~~~c +#include + +CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_USERDATA, void *clientp); +~~~ + +# DESCRIPTION + +The *clientp* parameter is held verbatim by libcurl and is passed on as +the *clientp* argument to the callbacks set with +CURLSHOPT_LOCKFUNC(3) and CURLSHOPT_UNLOCKFUNC(3). + +# PROTOCOLS + +All + +# EXAMPLE + +~~~c +struct secrets { + void *custom; +}; + +int main(void) +{ + CURLSHcode sh; + struct secrets private_stuff; + CURLSH *share = curl_share_init(); + sh = curl_share_setopt(share, CURLSHOPT_USERDATA, &private_stuff); + if(sh) + printf("Error: %s\n", curl_share_strerror(sh)); +} +~~~ + +# AVAILABILITY + +Added in 7.10 + +# RETURN VALUE + +CURLSHE_OK (zero) means that the option was set properly, non-zero means an +error occurred. See libcurl-errors(3) for the full list with +descriptions. diff --git a/docs/libcurl/opts/Makefile.am b/docs/libcurl/opts/Makefile.am index 250937fd1..42f9db4c5 100644 --- a/docs/libcurl/opts/Makefile.am +++ b/docs/libcurl/opts/Makefile.am @@ -26,38 +26,19 @@ AUTOMAKE_OPTIONS = foreign no-dependencies include Makefile.inc -man_DISTMANS = $(man_MANS:.3=.3.dist) +CURLPAGES = $(man_MANS:.3=.md) +CLEANFILES = $(man_MANS) +nodist_MANS = $(man_MANS) -HTMLPAGES = $(man_MANS:.3=.html) +EXTRA_DIST = $(CURLPAGES) CMakeLists.txt -PDFPAGES = $(man_MANS:.3=.pdf) +CD2NROFF = $(top_srcdir)/scripts/cd2nroff $< >$@ +CD2 = $(CD2_$(V)) +CD2_0 = @echo " RENDER " $@; +CD2_1 = +CD2_ = $(CD2_0) -CLEANFILES = $(HTMLPAGES) $(PDFPAGES) $(man_DISTMANS) +SUFFIXES = .3 .md -EXTRA_DIST = $(man_MANS) CMakeLists.txt -MAN2HTML= roffit --mandir=. $< >$@ - -SUFFIXES = .3 .html - -html: $(HTMLPAGES) - -.3.html: - $(MAN2HTML) - -pdf: $(PDFPAGES) - -.3.pdf: - @(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \ - groff -Tps -man $< >$$foo.ps; \ - ps2pdf $$foo.ps $@; \ - rm $$foo.ps; \ - echo "converted $< to $@") - -mancheck: - @(cd $(top_srcdir)/docs/libcurl/opts && ls `awk -F, '!/OBSOLETE/ && /^ CINIT/ { a=substr($$1, 9); print "CURLOPT_" a ".3"}' $(top_srcdir)/include/curl/curl.h`) - rm -f in_temp - @(for a in $(man_MANS); do echo $$a >>in_temp; done) - sort in_temp > in_makefile - ls CURL*.3 > in_directory - -diff -u in_makefile in_directory - rm in_temp in_directory in_makefile +.md.3: + $(CD2)$(CD2NROFF) diff --git a/docs/libcurl/opts/Makefile.inc b/docs/libcurl/opts/Makefile.inc index 9fe780677..be7035bf0 100644 --- a/docs/libcurl/opts/Makefile.inc +++ b/docs/libcurl/opts/Makefile.inc @@ -65,6 +65,7 @@ man_MANS = \ CURLINFO_PROXY_ERROR.3 \ CURLINFO_PROXY_SSL_VERIFYRESULT.3 \ CURLINFO_PROXYAUTH_AVAIL.3 \ + CURLINFO_QUEUE_TIME_T.3 \ CURLINFO_REDIRECT_COUNT.3 \ CURLINFO_REDIRECT_TIME.3 \ CURLINFO_REDIRECT_TIME_T.3 \ @@ -332,6 +333,7 @@ man_MANS = \ CURLOPT_SEEKDATA.3 \ CURLOPT_SEEKFUNCTION.3 \ CURLOPT_SERVER_RESPONSE_TIMEOUT.3 \ + CURLOPT_SERVER_RESPONSE_TIMEOUT_MS.3 \ CURLOPT_SERVICE_NAME.3 \ CURLOPT_SHARE.3 \ CURLOPT_SOCKOPTDATA.3 \ diff --git a/docs/libcurl/opts/template.3 b/docs/libcurl/opts/template.3 deleted file mode 100644 index 495cb82e0..000000000 --- a/docs/libcurl/opts/template.3 +++ /dev/null @@ -1,41 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH CURLOPT_TEMPLATE 3 "17 Jun 2014" libcurl libcurl -.SH NAME -CURLOPT_TEMPLATE \- [short description] -.SH SYNOPSIS -#include - -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TEMPLATE, [argument]); -.SH DESCRIPTION -.SH DEFAULT -.SH PROTOCOLS -.SH EXAMPLE -.SH AVAILABILITY -.SH RETURN VALUE -Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. -.SH "SEE ALSO" -.BR CURLOPT_STDERR (3), -.BR CURLOPT_DEBUGFUNCTION (3) diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions index dc0e0629f..c20008a73 100644 --- a/docs/libcurl/symbols-in-versions +++ b/docs/libcurl/symbols-in-versions @@ -328,6 +328,7 @@ CURLE_TFTP_NOSUCHUSER 7.15.0 CURLE_TFTP_NOTFOUND 7.15.0 CURLE_TFTP_PERM 7.15.0 CURLE_TFTP_UNKNOWNID 7.15.0 +CURLE_TOO_LARGE 8.6.0 CURLE_TOO_MANY_REDIRECTS 7.5 CURLE_UNKNOWN_OPTION 7.21.5 CURLE_UNKNOWN_TELNET_OPTION 7.7 7.21.5 @@ -468,6 +469,7 @@ CURLINFO_PROXY_ERROR 7.73.0 CURLINFO_PROXY_SSL_VERIFYRESULT 7.52.0 CURLINFO_PROXYAUTH_AVAIL 7.10.8 CURLINFO_PTR 7.54.1 +CURLINFO_QUEUE_TIME_T 8.6.0 CURLINFO_REDIRECT_COUNT 7.9.7 CURLINFO_REDIRECT_TIME 7.9.7 CURLINFO_REDIRECT_TIME_T 7.61.0 @@ -800,6 +802,7 @@ CURLOPT_SASL_IR 7.31.0 CURLOPT_SEEKDATA 7.18.0 CURLOPT_SEEKFUNCTION 7.18.0 CURLOPT_SERVER_RESPONSE_TIMEOUT 7.20.0 +CURLOPT_SERVER_RESPONSE_TIMEOUT_MS 8.6.0 CURLOPT_SERVICE_NAME 7.43.0 CURLOPT_SHARE 7.10 CURLOPT_SOCKOPTDATA 7.16.0 @@ -1094,6 +1097,7 @@ CURLUE_NO_USER 7.62.0 CURLUE_NO_ZONEID 7.81.0 CURLUE_OK 7.62.0 CURLUE_OUT_OF_MEMORY 7.62.0 +CURLUE_TOO_LARGE 8.6.0 CURLUE_UNKNOWN_PART 7.62.0 CURLUE_UNSUPPORTED_SCHEME 7.62.0 CURLUE_URLDECODE 7.62.0 diff --git a/docs/mk-ca-bundle.1 b/docs/mk-ca-bundle.1 deleted file mode 100644 index e6db0504c..000000000 --- a/docs/mk-ca-bundle.1 +++ /dev/null @@ -1,120 +0,0 @@ -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , 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 -.\" * -.\" ************************************************************************** -.\" -.TH mk-ca-bundle 1 "24 Oct 2016" mk-ca-bundle mk-ca-bundle -.SH NAME -mk-ca-bundle \- convert Mozilla's certificate bundle to PEM format -.SH SYNOPSIS -mk-ca-bundle [options] -.I [outputfile] -.SH DESCRIPTION -The mk-ca-bundle tool downloads the \fIcertdata.txt\fP file from Mozilla's -source tree over HTTPS, then parses \fIcertdata.txt\fP and extracts -certificates into PEM format. By default, only CA root certificates trusted to -issue SSL server authentication certificates are extracted. These are then -processed with the OpenSSL command line tool to produce the final ca-bundle -file. - -The default \fIoutputfile\fP name is \fBca-bundle.crt\fP. By setting it to '-' -(a single dash) you will get the output sent to STDOUT instead of a file. - -The PEM format this scripts uses for output makes the result readily available -for use by just about all OpenSSL or GnuTLS powered applications, such as curl -and others. -.SH OPTIONS -The following options are supported: -.IP -b -backup an existing version of \fIoutputfilename\fP -.IP "-d [name]" -specify which Mozilla tree to pull \fIcertdata.txt\fP from (or a custom -URL). Valid names are: aurora, beta, central, Mozilla, nss, release -(default). They are shortcuts for which source tree to get the certificates -data from. -.IP -f -force rebuild even if \fIcertdata.txt\fP is current (Added in version 1.17) -.IP -i -print version info about used modules -.IP -k -Allow insecure data transfer. By default (since 1.27) this command will fail -if the HTTPS transfer fails. This overrides that decision (and opens for -man-in-the-middle attacks). -.IP -l -print license info about \fIcertdata.txt\fP -.IP -m -(Added in 1.26) Include meta data comments in the output. The meta data is -specific information about each certificate that is stored in the original -file as comments and using this option will make those comments get passed on -to the output file. The meta data is not parsed in any way by mk-ca-bundle. -.IP -n -no download of \fIcertdata.txt\fP (to use existing) -.IP "-p [purposes]:[levels]" -list of Mozilla trust purposes and levels for certificates to include in -output. Takes the form of a comma separated list of purposes, a colon, and a -comma separated list of levels. The default is to include all certificates -trusted to issue SSL Server certificates -(\fISERVER_AUTH:TRUSTED_DELEGATOR\fP). - -(Added in version 1.21, Perl only) - -Valid purposes are: -.RS -\fIALL\fP, \fIDIGITAL_SIGNATURE\fP, \fINON_REPUDIATION\fP, -\fIKEY_ENCIPHERMENT\fP, \fIDATA_ENCIPHERMENT\fP, \fIKEY_AGREEMENT\fP, -\fIKEY_CERT_SIGN\fP, \fICRL_SIGN\fP, \fISERVER_AUTH\fP (default), -\fICLIENT_AUTH\fP, \fICODE_SIGNING\fP, \fIEMAIL_PROTECTION\fP, -\fIIPSEC_END_SYSTEM\fP, \fIIPSEC_TUNNEL\fP, \fIIPSEC_USER\fP, -\fITIME_STAMPING\fP, \fISTEP_UP_APPROVED\fP -.RE -.IP -Valid trust levels are: -.RS -\fIALL\fP, \fITRUSTED_DELEGATOR\fP (default), \fINOT_TRUSTED\fP, \fIMUST_VERIFY_TRUST\fP, \fITRUSTED\fP -.RE -.IP -q -be really quiet (no progress output at all) -.IP -t -include plain text listing of certificates -.IP "-s [algorithms]" -comma separated list of signature algorithms with which to hash/fingerprint -each certificate and output when run in plain text mode. - -(Added in version 1.21, Perl only) - -Valid algorithms are: -.RS -ALL, NONE, MD5 (default), SHA1, SHA256, SHA384, SHA512 -.RE -.IP -u -unlink (remove) \fIcertdata.txt\fP after processing -.IP -v -be verbose and print out processed certificate authorities -.SH EXIT STATUS -Returns 0 on success. Returns 1 if it fails to download data. -.SH FILE FORMAT -The file format used by Mozilla for this trust information is documented here: -.nf -https://p11-glue.freedesktop.org/doc/storing-trust-policy/storing-trust-existing.html -.fi -.SH SEE ALSO -.BR curl (1) diff --git a/docs/mk-ca-bundle.md b/docs/mk-ca-bundle.md new file mode 100644 index 000000000..bacfce08b --- /dev/null +++ b/docs/mk-ca-bundle.md @@ -0,0 +1,128 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Title: mk-ca-bundle +Section: 1 +Source: mk-ca-bundle +See-also: + - curl (1) +--- + +# NAME + +mk-ca-bundle - convert Mozilla's certificate bundle to PEM format + +# SYNOPSIS + +mk-ca-bundle [options] +*[outputfile]* + +# DESCRIPTION + +The mk-ca-bundle tool downloads the *certdata.txt* file from Mozilla's source +tree over HTTPS, then parses *certdata.txt* and extracts certificates into PEM +format. By default, only CA root certificates trusted to issue SSL server +authentication certificates are extracted. These are then processed with the +OpenSSL command line tool to produce the final ca-bundle file. + +The default *outputfile* name is **ca-bundle.crt**. By setting it to '-' (a +single dash) you will get the output sent to STDOUT instead of a file. + +The PEM format this scripts uses for output makes the result readily available +for use by just about all OpenSSL or GnuTLS powered applications, such as curl +and others. + +# OPTIONS + +The following options are supported: + +## -b + +backup an existing version of *outputfilename* + +## -d [name] + +specify which Mozilla tree to pull *certdata.txt* from (or a custom +URL). Valid names are: aurora, beta, central, Mozilla, nss, release +(default). They are shortcuts for which source tree to get the certificates +data from. + +## -f + +force rebuild even if *certdata.txt* is current (Added in version 1.17) + +## -i + +print version info about used modules + +## -k + +Allow insecure data transfer. By default (since 1.27) this command will fail +if the HTTPS transfer fails. This overrides that decision (and opens for +man-in-the-middle attacks). + +## -l + +print license info about *certdata.txt* + +## -m + +(Added in 1.26) Include meta data comments in the output. The meta data is +specific information about each certificate that is stored in the original +file as comments and using this option will make those comments get passed on +to the output file. The meta data is not parsed in any way by mk-ca-bundle. + +## -n + +no download of *certdata.txt* (to use existing) + +## -p [purposes]:[levels] + +list of Mozilla trust purposes and levels for certificates to include in +output. Takes the form of a comma separated list of purposes, a colon, and a +comma separated list of levels. The default is to include all certificates +trusted to issue SSL Server certificates (*SERVER_AUTH:TRUSTED_DELEGATOR*). + +Valid purposes are: *ALL*, *DIGITAL_SIGNATURE*, *NON_REPUDIATION*, +*KEY_ENCIPHERMENT*, *DATA_ENCIPHERMENT*, *KEY_AGREEMENT*, *KEY_CERT_SIGN*, +*CRL_SIGN*, *SERVER_AUTH* (default), *CLIENT_AUTH*, *CODE_SIGNING*, +*EMAIL_PROTECTION*, *IPSEC_END_SYSTEM*, *IPSEC_TUNNEL*, *IPSEC_USER*, +*TIME_STAMPING*, *STEP_UP_APPROVED* + +Valid trust levels are: *ALL*, *TRUSTED_DELEGATOR* (default), *NOT_TRUSTED*, +*MUST_VERIFY_TRUST*, *TRUSTED* + +## -q + +be really quiet (no progress output at all) + +## -t + +include plain text listing of certificates + +## -s [algorithms] + +comma separated list of signature algorithms with which to hash/fingerprint +each certificate and output when run in plain text mode. + +Valid algorithms are: +ALL, NONE, MD5 (default), SHA1, SHA256, SHA384, SHA512 + +## -u + +unlink (remove) *certdata.txt* after processing + +## -v + +be verbose and print out processed certificate authorities + +# EXIT STATUS + +Returns 0 on success. Returns 1 if it fails to download data. + +# FILE FORMAT + +The file format used by Mozilla for this trust information is documented here: +~~~c +https://p11-glue.freedesktop.org/doc/storing-trust-policy/storing-trust-existing.html +~~~ diff --git a/include/curl/curl.h b/include/curl/curl.h index cc24c0506..eb0602250 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -631,6 +631,7 @@ typedef enum { CURLE_PROXY, /* 97 - proxy handshake error */ CURLE_SSL_CLIENTCERT, /* 98 - client-side certificate required */ CURLE_UNRECOVERABLE_POLL, /* 99 - poll/select returned fatal error */ + CURLE_TOO_LARGE, /* 100 - a value/data met its maximum */ CURL_LAST /* never use! */ } CURLcode; @@ -1845,7 +1846,8 @@ typedef enum { /* allow GSSAPI credential delegation */ CURLOPT(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_VALUES, 210), - /* Set the name servers to use for DNS resolution */ + /* Set the name servers to use for DNS resolution. + * Only supported by the c-ares DNS backend */ CURLOPT(CURLOPT_DNS_SERVERS, CURLOPTTYPE_STRINGPOINT, 211), /* Time-out accept operations (currently for FTP only) after this amount @@ -2201,6 +2203,9 @@ typedef enum { /* set a specific client IP for HAProxy PROXY protocol header? */ CURLOPT(CURLOPT_HAPROXY_CLIENT_IP, CURLOPTTYPE_STRINGPOINT, 323), + /* millisecond version */ + CURLOPT(CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, CURLOPTTYPE_LONG, 324), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -2932,7 +2937,8 @@ typedef enum { CURLINFO_CAPATH = CURLINFO_STRING + 62, CURLINFO_XFER_ID = CURLINFO_OFF_T + 63, CURLINFO_CONN_ID = CURLINFO_OFF_T + 64, - CURLINFO_LASTONE = 64 + CURLINFO_QUEUE_TIME_T = CURLINFO_OFF_T + 65, + CURLINFO_LASTONE = 65 } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as diff --git a/include/curl/curlver.h b/include/curl/curlver.h index dcf19ae30..1e660cbf5 100644 --- a/include/curl/curlver.h +++ b/include/curl/curlver.h @@ -32,12 +32,12 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "8.5.0" +#define LIBCURL_VERSION "8.6.0" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 8 -#define LIBCURL_VERSION_MINOR 5 +#define LIBCURL_VERSION_MINOR 6 #define LIBCURL_VERSION_PATCH 0 /* This is the numeric version of the libcurl version number, meant for easier @@ -59,7 +59,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x080500 +#define LIBCURL_VERSION_NUM 0x080600 /* * This is the date and time when the full source package was created. The @@ -70,7 +70,7 @@ * * "2007-11-23" */ -#define LIBCURL_TIMESTAMP "2022-12-21" +#define LIBCURL_TIMESTAMP "2024-01-31" #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #define CURL_AT_LEAST_VERSION(x,y,z) \ diff --git a/include/curl/mprintf.h b/include/curl/mprintf.h index dc5664bc5..4f704548d 100644 --- a/include/curl/mprintf.h +++ b/include/curl/mprintf.h @@ -34,19 +34,27 @@ extern "C" { #if (defined(__GNUC__) || defined(__clang__)) && \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__MINGW32__) && !defined(CURL_NO_FMT_CHECKS) -#define CURL_TEMP_PRINTF(a,b) __attribute__ ((format(printf, a, b))) + !defined(CURL_NO_FMT_CHECKS) +#if defined(__MINGW32__) && !defined(__clang__) +#define CURL_TEMP_PRINTF(fmt, arg) \ + __attribute__((format(gnu_printf, fmt, arg))) #else -#define CURL_TEMP_PRINTF(a,b) +#define CURL_TEMP_PRINTF(fmt, arg) \ + __attribute__((format(printf, fmt, arg))) +#endif +#else +#define CURL_TEMP_PRINTF(fmt, arg) #endif -CURL_EXTERN int curl_mprintf(const char *format, ...) CURL_TEMP_PRINTF(1, 2); +CURL_EXTERN int curl_mprintf(const char *format, ...) + CURL_TEMP_PRINTF(1, 2); CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...) CURL_TEMP_PRINTF(2, 3); CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...) CURL_TEMP_PRINTF(2, 3); CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, - const char *format, ...) CURL_TEMP_PRINTF(3, 4); + const char *format, ...) + CURL_TEMP_PRINTF(3, 4); CURL_EXTERN int curl_mvprintf(const char *format, va_list args) CURL_TEMP_PRINTF(1, 0); CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args) diff --git a/include/curl/system.h b/include/curl/system.h index f2554b4a9..81a1b817d 100644 --- a/include/curl/system.h +++ b/include/curl/system.h @@ -184,9 +184,8 @@ # define CURL_FORMAT_CURL_OFF_TU PRIu64 # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_TYPEOF_CURL_SOCKLEN_T int # define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_WS2TCPIP_H 1 #elif defined(__VMS) # if defined(__VAX) @@ -417,15 +416,6 @@ #define CURL_PULL_SYS_POLL_H #endif - -/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */ -/* ws2tcpip.h is required here to properly make type definitions below. */ -#ifdef CURL_PULL_WS2TCPIP_H -# include -# include -# include -#endif - /* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ /* sys/types.h is required here to properly make type definitions below. */ #ifdef CURL_PULL_SYS_TYPES_H diff --git a/include/curl/urlapi.h b/include/curl/urlapi.h index 88cdeb3bc..91f8c4548 100644 --- a/include/curl/urlapi.h +++ b/include/curl/urlapi.h @@ -63,6 +63,7 @@ typedef enum { CURLUE_BAD_SLASHES, /* 28 */ CURLUE_BAD_USER, /* 29 */ CURLUE_LACKS_IDN, /* 30 */ + CURLUE_TOO_LARGE, /* 31 */ CURLUE_LAST } CURLUcode; diff --git a/lib/Makefile.inc b/lib/Makefile.inc index e568ef953..627148abe 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -78,15 +78,19 @@ LIB_VTLS_HFILES = \ LIB_VQUIC_CFILES = \ vquic/curl_msh3.c \ vquic/curl_ngtcp2.c \ + vquic/curl_osslq.c \ vquic/curl_quiche.c \ - vquic/vquic.c + vquic/vquic.c \ + vquic/vquic-tls.c LIB_VQUIC_HFILES = \ vquic/curl_msh3.h \ vquic/curl_ngtcp2.h \ + vquic/curl_osslq.h \ vquic/curl_quiche.h \ vquic/vquic.h \ - vquic/vquic_int.h + vquic/vquic_int.h \ + vquic/vquic-tls.h LIB_VSSH_CFILES = \ vssh/libssh.c \ diff --git a/lib/Makefile.mk b/lib/Makefile.mk index 1513cafef..95f281b7d 100644 --- a/lib/Makefile.mk +++ b/lib/Makefile.mk @@ -24,8 +24,8 @@ # Makefile to build curl parts with GCC-like toolchains and optional features. # -# Usage: [mingw32-]make -f Makefile.mk CFG=-feat1[-feat2][-feat3][...] -# Example: [mingw32-]make -f Makefile.mk CFG=-zlib-ssl-libssh2-ipv6 +# Usage: make -f Makefile.mk CFG=-feat1[-feat2][-feat3][...] +# Example: make -f Makefile.mk CFG=-zlib-ssl-libssh2-ipv6 # # Look for ' ?=' to find all accepted customization variables. @@ -40,10 +40,7 @@ endif CFLAGS ?= CPPFLAGS ?= -RCFLAGS ?= LDFLAGS ?= -CURL_LDFLAGS_BIN ?= -CURL_LDFLAGS_LIB ?= LIBS ?= CROSSPREFIX ?= @@ -53,46 +50,21 @@ ifeq ($(CC),cc) endif CC := $(CROSSPREFIX)$(CC) AR := $(CROSSPREFIX)$(AR) -RC ?= $(CROSSPREFIX)windres - -# For compatibility -ARCH ?= -ifeq ($(ARCH),w64) - TRIPLET := x86_64-w64-mingw32 - CFLAGS += -m64 - LDFLAGS += -m64 - RCFLAGS += --target=pe-x86-64 -else ifdef ARCH - TRIPLET := i686-w64-mingw32 - CFLAGS += -m32 - LDFLAGS += -m32 - RCFLAGS += --target=pe-i386 -else - TRIPLET ?= $(shell $(CC) -dumpmachine) -endif -BIN_EXT := .exe +TRIPLET ?= $(shell $(CC) -dumpmachine) -ifneq ($(findstring -w,$(TRIPLET)),) - WIN32 := 1 -else ifneq ($(findstring msdos,$(TRIPLET)),) +BIN_EXT := + +ifneq ($(findstring msdos,$(TRIPLET)),) # Cross-tools: https://github.com/andrewwutw/build-djgpp MSDOS := 1 + BIN_EXT := .exe else ifneq ($(findstring amigaos,$(TRIPLET)),) # Cross-tools: https://github.com/bebbo/amiga-gcc AMIGA := 1 endif CPPFLAGS += -I. -I$(PROOT)/include -RCFLAGS += -I$(PROOT)/include - -ifndef WIN32 - DYN := -endif - -ifdef AMIGA - BIN_EXT := -endif ### Deprecated settings. For compatibility. @@ -115,40 +87,26 @@ ifneq ($(findstring -map,$(CFG)),) MAP := 1 endif -ifdef WIN32 - ifneq ($(findstring -unicode,$(CFG)),) - CPPFLAGS += -DUNICODE -D_UNICODE - CURL_LDFLAGS_BIN += -municode - endif -endif - # CPPFLAGS below are only necessary when building libcurl via 'lib' (see # comments below about exceptions). Always include them anyway to match # behavior of other build systems. -# Linker options to exclude for shared mode executables. -_LDFLAGS := -_LIBS := - ifneq ($(findstring -sync,$(CFG)),) CPPFLAGS += -DUSE_SYNC_DNS else ifneq ($(findstring -ares,$(CFG)),) LIBCARES_PATH ?= $(PROOT)/../c-ares CPPFLAGS += -DUSE_ARES CPPFLAGS += -I"$(LIBCARES_PATH)/include" - _LDFLAGS += -L"$(LIBCARES_PATH)/lib" - _LIBS += -lcares + LDFLAGS += -L"$(LIBCARES_PATH)/lib" + LIBS += -lcares endif ifneq ($(findstring -rtmp,$(CFG)),) LIBRTMP_PATH ?= $(PROOT)/../librtmp CPPFLAGS += -DUSE_LIBRTMP CPPFLAGS += -I"$(LIBRTMP_PATH)" - _LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp" - _LIBS += -lrtmp - ifdef WIN32 - _LIBS += -lwinmm - endif + LDFLAGS += -L"$(LIBRTMP_PATH)/librtmp" + LIBS += -lrtmp ZLIB := 1 endif @@ -156,23 +114,20 @@ ifneq ($(findstring -ssh2,$(CFG)),) LIBSSH2_PATH ?= $(PROOT)/../libssh2 CPPFLAGS += -DUSE_LIBSSH2 CPPFLAGS += -I"$(LIBSSH2_PATH)/include" - _LDFLAGS += -L"$(LIBSSH2_PATH)/lib" - ifdef WIN32 - _LDFLAGS += -L"$(LIBSSH2_PATH)/win32" - endif - _LIBS += -lssh2 + LDFLAGS += -L"$(LIBSSH2_PATH)/lib" + LIBS += -lssh2 else ifneq ($(findstring -libssh,$(CFG)),) LIBSSH_PATH ?= $(PROOT)/../libssh CPPFLAGS += -DUSE_LIBSSH CPPFLAGS += -I"$(LIBSSH_PATH)/include" - _LDFLAGS += -L"$(LIBSSH_PATH)/lib" - _LIBS += -lssh + LDFLAGS += -L"$(LIBSSH_PATH)/lib" + LIBS += -lssh else ifneq ($(findstring -wolfssh,$(CFG)),) WOLFSSH_PATH ?= $(PROOT)/../wolfssh CPPFLAGS += -DUSE_WOLFSSH CPPFLAGS += -I"$(WOLFSSH_PATH)/include" - _LDFLAGS += -L"$(WOLFSSH_PATH)/lib" - _LIBS += -lwolfssh + LDFLAGS += -L"$(WOLFSSH_PATH)/lib" + LIBS += -lwolfssh endif ifneq ($(findstring -ssl,$(CFG)),) @@ -182,9 +137,9 @@ ifneq ($(findstring -ssl,$(CFG)),) OPENSSL_INCLUDE ?= $(OPENSSL_PATH)/include OPENSSL_LIBPATH ?= $(OPENSSL_PATH)/lib CPPFLAGS += -I"$(OPENSSL_INCLUDE)" - _LDFLAGS += -L"$(OPENSSL_LIBPATH)" + LDFLAGS += -L"$(OPENSSL_LIBPATH)" OPENSSL_LIBS ?= -lssl -lcrypto - _LIBS += $(OPENSSL_LIBS) + LIBS += $(OPENSSL_LIBS) ifneq ($(findstring -srp,$(CFG)),) ifneq ($(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h),) @@ -199,20 +154,16 @@ ifneq ($(findstring -wolfssl,$(CFG)),) CPPFLAGS += -DUSE_WOLFSSL CPPFLAGS += -DSIZEOF_LONG_LONG=8 CPPFLAGS += -I"$(WOLFSSL_PATH)/include" - _LDFLAGS += -L"$(WOLFSSL_PATH)/lib" - _LIBS += -lwolfssl + LDFLAGS += -L"$(WOLFSSL_PATH)/lib" + LIBS += -lwolfssl SSLLIBS += 1 endif ifneq ($(findstring -mbedtls,$(CFG)),) MBEDTLS_PATH ?= $(PROOT)/../mbedtls CPPFLAGS += -DUSE_MBEDTLS CPPFLAGS += -I"$(MBEDTLS_PATH)/include" - _LDFLAGS += -L"$(MBEDTLS_PATH)/lib" - _LIBS += -lmbedtls -lmbedx509 -lmbedcrypto - SSLLIBS += 1 -endif -ifneq ($(findstring -schannel,$(CFG)),) - CPPFLAGS += -DUSE_SCHANNEL + LDFLAGS += -L"$(MBEDTLS_PATH)/lib" + LIBS += -lmbedtls -lmbedx509 -lmbedcrypto SSLLIBS += 1 endif @@ -220,21 +171,21 @@ ifneq ($(findstring -nghttp2,$(CFG)),) NGHTTP2_PATH ?= $(PROOT)/../nghttp2 CPPFLAGS += -DUSE_NGHTTP2 CPPFLAGS += -I"$(NGHTTP2_PATH)/include" - _LDFLAGS += -L"$(NGHTTP2_PATH)/lib" - _LIBS += -lnghttp2 + LDFLAGS += -L"$(NGHTTP2_PATH)/lib" + LIBS += -lnghttp2 endif ifeq ($(findstring -nghttp3,$(CFG))$(findstring -ngtcp2,$(CFG)),-nghttp3-ngtcp2) NGHTTP3_PATH ?= $(PROOT)/../nghttp3 CPPFLAGS += -DUSE_NGHTTP3 CPPFLAGS += -I"$(NGHTTP3_PATH)/include" - _LDFLAGS += -L"$(NGHTTP3_PATH)/lib" - _LIBS += -lnghttp3 + LDFLAGS += -L"$(NGHTTP3_PATH)/lib" + LIBS += -lnghttp3 NGTCP2_PATH ?= $(PROOT)/../ngtcp2 CPPFLAGS += -DUSE_NGTCP2 CPPFLAGS += -I"$(NGTCP2_PATH)/include" - _LDFLAGS += -L"$(NGTCP2_PATH)/lib" + LDFLAGS += -L"$(NGTCP2_PATH)/lib" NGTCP2_LIBS ?= ifeq ($(NGTCP2_LIBS),) @@ -249,7 +200,7 @@ ifeq ($(findstring -nghttp3,$(CFG))$(findstring -ngtcp2,$(CFG)),-nghttp3-ngtcp2) endif endif - _LIBS += -lngtcp2 $(NGTCP2_LIBS) + LIBS += -lngtcp2 $(NGTCP2_LIBS) endif ifneq ($(findstring -zlib,$(CFG))$(ZLIB),) @@ -257,59 +208,51 @@ ifneq ($(findstring -zlib,$(CFG))$(ZLIB),) # These CPPFLAGS are also required when compiling the curl tool via 'src'. CPPFLAGS += -DHAVE_LIBZ CPPFLAGS += -I"$(ZLIB_PATH)/include" - _LDFLAGS += -L"$(ZLIB_PATH)/lib" + LDFLAGS += -L"$(ZLIB_PATH)/lib" ZLIB_LIBS ?= -lz - _LIBS += $(ZLIB_LIBS) + LIBS += $(ZLIB_LIBS) ZLIB := 1 endif ifneq ($(findstring -zstd,$(CFG)),) ZSTD_PATH ?= $(PROOT)/../zstd CPPFLAGS += -DHAVE_ZSTD CPPFLAGS += -I"$(ZSTD_PATH)/include" - _LDFLAGS += -L"$(ZSTD_PATH)/lib" + LDFLAGS += -L"$(ZSTD_PATH)/lib" ZSTD_LIBS ?= -lzstd - _LIBS += $(ZSTD_LIBS) + LIBS += $(ZSTD_LIBS) endif ifneq ($(findstring -brotli,$(CFG)),) BROTLI_PATH ?= $(PROOT)/../brotli CPPFLAGS += -DHAVE_BROTLI CPPFLAGS += -I"$(BROTLI_PATH)/include" - _LDFLAGS += -L"$(BROTLI_PATH)/lib" + LDFLAGS += -L"$(BROTLI_PATH)/lib" BROTLI_LIBS ?= -lbrotlidec -lbrotlicommon - _LIBS += $(BROTLI_LIBS) + LIBS += $(BROTLI_LIBS) endif ifneq ($(findstring -gsasl,$(CFG)),) LIBGSASL_PATH ?= $(PROOT)/../gsasl CPPFLAGS += -DUSE_GSASL CPPFLAGS += -I"$(LIBGSASL_PATH)/include" - _LDFLAGS += -L"$(LIBGSASL_PATH)/lib" - _LIBS += -lgsasl + LDFLAGS += -L"$(LIBGSASL_PATH)/lib" + LIBS += -lgsasl endif ifneq ($(findstring -idn2,$(CFG)),) LIBIDN2_PATH ?= $(PROOT)/../libidn2 CPPFLAGS += -DUSE_LIBIDN2 CPPFLAGS += -I"$(LIBIDN2_PATH)/include" - _LDFLAGS += -L"$(LIBIDN2_PATH)/lib" - _LIBS += -lidn2 + LDFLAGS += -L"$(LIBIDN2_PATH)/lib" + LIBS += -lidn2 ifneq ($(findstring -psl,$(CFG)),) LIBPSL_PATH ?= $(PROOT)/../libpsl CPPFLAGS += -DUSE_LIBPSL CPPFLAGS += -I"$(LIBPSL_PATH)/include" - _LDFLAGS += -L"$(LIBPSL_PATH)/lib" - _LIBS += -lpsl + LDFLAGS += -L"$(LIBPSL_PATH)/lib" + LIBS += -lpsl endif -else ifneq ($(findstring -winidn,$(CFG)),) - CPPFLAGS += -DUSE_WIN32_IDN - _LIBS += -lnormaliz endif -ifneq ($(findstring -sspi,$(CFG)),) - ifdef WIN32 - CPPFLAGS += -DUSE_WINDOWS_SSPI - endif -endif ifneq ($(findstring -ipv6,$(CFG)),) CPPFLAGS += -DENABLE_IPV6 endif @@ -317,26 +260,14 @@ endif ifneq ($(findstring -watt,$(CFG))$(MSDOS),) WATT_PATH ?= $(PROOT)/../watt CPPFLAGS += -I"$(WATT_PATH)/inc" - _LDFLAGS += -L"$(WATT_PATH)/lib" - _LIBS += -lwatt -endif - -ifdef WIN32 - ifeq ($(findstring -lldap,$(LIBS)),) - _LIBS += -lwldap32 - endif - _LIBS += -lws2_32 -lcrypt32 -lbcrypt + LDFLAGS += -L"$(WATT_PATH)/lib" + LIBS += -lwatt endif ifneq ($(findstring 11,$(subst $(subst ,, ),,$(SSLLIBS))),) CPPFLAGS += -DCURL_WITH_MULTI_SSL endif -ifndef DYN - LDFLAGS += $(_LDFLAGS) - LIBS += $(_LIBS) -endif - ### Common rules OBJ_DIR := $(TRIPLET) @@ -363,9 +294,6 @@ $(OBJ_DIR): $(OBJ_DIR)/%.o: %.c $(CC) -W -Wall $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -$(OBJ_DIR)/%.res: %.rc - $(RC) -O coff $(RCFLAGS) -i $< -o $@ - clean: @$(call DEL, $(TOCLEAN)) @$(RMDIR) $(OBJ_DIR) @@ -378,42 +306,23 @@ distclean vclean: clean ifdef LOCAL CPPFLAGS += -DBUILDING_LIBCURL -ifdef WIN32 -CPPFLAGS += -DCURL_STATICLIB -endif ### Sources and targets -# Provides CSOURCES, HHEADERS, LIB_RCFILES +# Provides CSOURCES, HHEADERS include Makefile.inc vpath %.c vauth vquic vssh vtls libcurl_a_LIBRARY := libcurl.a -ifdef WIN32 -CURL_DLL_SUFFIX ?= -libcurl_dll_LIBRARY := libcurl$(CURL_DLL_SUFFIX).dll -libcurl_dll_a_LIBRARY := libcurl.dll.a -ifeq ($(findstring -trackmem,$(CFG)),) -CURL_LDFLAGS_LIB += $(PROOT)/libcurl.def -endif -ifdef MAP -libcurl_map_LIBRARY := libcurl$(CURL_DLL_SUFFIX).map -CURL_LDFLAGS_LIB += -Wl,-Map,$(libcurl_map_LIBRARY) -endif -endif -TARGETS := $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) +TARGETS := $(libcurl_a_LIBRARY) libcurl_a_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(strip $(CSOURCES)))) libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS)) -ifdef WIN32 -libcurl_dll_OBJECTS := $(libcurl_a_OBJECTS) -libcurl_dll_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(LIB_RCFILES))) -endif -TOCLEAN := $(libcurl_dll_OBJECTS) -TOVCLEAN := $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY) $(libcurl_map_LIBRARY) +TOCLEAN := +TOVCLEAN := ### Rules @@ -421,9 +330,5 @@ $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES) @$(call DEL, $@) $(AR) rcs $@ $(libcurl_a_OBJECTS) -$(libcurl_dll_LIBRARY): $(libcurl_dll_OBJECTS) - $(CC) $(LDFLAGS) -shared $(CURL_LDFLAGS_LIB) -o $@ $(libcurl_dll_OBJECTS) $(LIBS) \ - -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) - all: $(OBJ_DIR) $(TARGETS) endif diff --git a/lib/altsvc.c b/lib/altsvc.c index 35450d6b1..e9f62bf0e 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -106,9 +106,11 @@ static struct altsvc *altsvc_createid(const char *srchost, dlen = strlen(dsthost); DEBUGASSERT(hlen); DEBUGASSERT(dlen); - if(!hlen || !dlen) + if(!hlen || !dlen) { /* bad input */ + free(as); return NULL; + } if((hlen > 2) && srchost[0] == '[') { /* IPv6 address, strip off brackets */ srchost++; @@ -123,11 +125,11 @@ static struct altsvc *altsvc_createid(const char *srchost, dlen -= 2; } - as->src.host = Curl_strndup(srchost, hlen); + as->src.host = Curl_memdup0(srchost, hlen); if(!as->src.host) goto error; - as->dst.host = Curl_strndup(dsthost, dlen); + as->dst.host = Curl_memdup0(dsthost, dlen); if(!as->dst.host) goto error; @@ -333,9 +335,6 @@ CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file) CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl) { DEBUGASSERT(asi); - if(!ctrl) - /* unexpected */ - return CURLE_BAD_FUNCTION_ARGUMENT; asi->flags = ctrl; return CURLE_OK; } diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 437c9337f..76efba78a 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -173,10 +173,26 @@ CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver) int status; struct ares_options options; int optmask = ARES_OPT_SOCK_STATE_CB; + static int ares_ver = 0; options.sock_state_cb = sock_state_cb; options.sock_state_cb_data = easy; - options.timeout = CARES_TIMEOUT_PER_ATTEMPT; - optmask |= ARES_OPT_TIMEOUTMS; + if(ares_ver == 0) + ares_version(&ares_ver); + + if(ares_ver < 0x011400) { /* c-ares included similar change since 1.20.0 */ + options.timeout = CARES_TIMEOUT_PER_ATTEMPT; + optmask |= ARES_OPT_TIMEOUTMS; + } + + /* + if c ares < 1.20.0: curl set timeout to CARES_TIMEOUT_PER_ATTEMPT (2s) + + if c-ares >= 1.20.0 it already has the timeout to 2s, curl does not need + to set the timeout value; + + if c-ares >= 1.24.0, user can set the timeout via /etc/resolv.conf to + overwrite c-ares' timeout. + */ status = ares_init_options((ares_channel*)resolver, &options, optmask); if(status != ARES_SUCCESS) { @@ -228,9 +244,9 @@ static void destroy_async_data(struct Curl_async *async); void Curl_resolver_cancel(struct Curl_easy *data) { DEBUGASSERT(data); - if(data->conn->resolve_async.resolver) - ares_cancel((ares_channel)data->conn->resolve_async.resolver); - destroy_async_data(&data->conn->resolve_async); + if(data->state.async.resolver) + ares_cancel((ares_channel)data->state.async.resolver); + destroy_async_data(&data->state.async); } /* @@ -278,14 +294,14 @@ int Curl_resolver_getsock(struct Curl_easy *data, struct timeval timebuf; struct timeval *timeout; long milli; - int max = ares_getsock((ares_channel)data->conn->resolve_async.resolver, + int max = ares_getsock((ares_channel)data->state.async.resolver, (ares_socket_t *)socks, MAX_SOCKSPEREASYHANDLE); maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; maxtime.tv_usec = 0; - timeout = ares_timeout((ares_channel)data->conn->resolve_async.resolver, - &maxtime, &timebuf); + timeout = ares_timeout((ares_channel)data->state.async.resolver, &maxtime, + &timebuf); milli = (long)curlx_tvtoms(timeout); if(milli == 0) milli += 10; @@ -313,8 +329,8 @@ static int waitperform(struct Curl_easy *data, timediff_t timeout_ms) int i; int num = 0; - bitmask = ares_getsock((ares_channel)data->conn->resolve_async.resolver, - socks, ARES_GETSOCK_MAXNUM); + bitmask = ares_getsock((ares_channel)data->state.async.resolver, socks, + ARES_GETSOCK_MAXNUM); for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) { pfd[i].events = 0; @@ -344,12 +360,12 @@ static int waitperform(struct Curl_easy *data, timediff_t timeout_ms) if(!nfds) /* Call ares_process() unconditionally here, even if we simply timed out above, as otherwise the ares name resolve won't timeout! */ - ares_process_fd((ares_channel)data->conn->resolve_async.resolver, - ARES_SOCKET_BAD, ARES_SOCKET_BAD); + ares_process_fd((ares_channel)data->state.async.resolver, ARES_SOCKET_BAD, + ARES_SOCKET_BAD); else { /* move through the descriptors and ask for processing on them */ for(i = 0; i < num; i++) - ares_process_fd((ares_channel)data->conn->resolve_async.resolver, + ares_process_fd((ares_channel)data->state.async.resolver, (pfd[i].revents & (POLLRDNORM|POLLIN))? pfd[i].fd:ARES_SOCKET_BAD, (pfd[i].revents & (POLLWRNORM|POLLOUT))? @@ -368,7 +384,7 @@ static int waitperform(struct Curl_easy *data, timediff_t timeout_ms) CURLcode Curl_resolver_is_resolved(struct Curl_easy *data, struct Curl_dns_entry **dns) { - struct thread_data *res = data->conn->resolve_async.tdata; + struct thread_data *res = data->state.async.tdata; CURLcode result = CURLE_OK; DEBUGASSERT(dns); @@ -397,7 +413,7 @@ CURLcode Curl_resolver_is_resolved(struct Curl_easy *data, ARES_ECANCELLED synchronously for all pending responses. This will leave us with res->num_pending == 0, which is perfect for the next block. */ - ares_cancel((ares_channel)data->conn->resolve_async.resolver); + ares_cancel((ares_channel)data->state.async.resolver); DEBUGASSERT(res->num_pending == 0); } #endif @@ -408,12 +424,12 @@ CURLcode Curl_resolver_is_resolved(struct Curl_easy *data, them */ res->temp_ai = NULL; - if(!data->conn->resolve_async.dns) + if(!data->state.async.dns) result = Curl_resolver_error(data); else - *dns = data->conn->resolve_async.dns; + *dns = data->state.async.dns; - destroy_async_data(&data->conn->resolve_async); + destroy_async_data(&data->state.async); } return result; @@ -464,8 +480,7 @@ CURLcode Curl_resolver_wait_resolv(struct Curl_easy *data, store.tv_sec = itimeout/1000; store.tv_usec = (itimeout%1000)*1000; - tvp = ares_timeout((ares_channel)data->conn->resolve_async.resolver, - &store, &tv); + tvp = ares_timeout((ares_channel)data->state.async.resolver, &store, &tv); /* use the timeout period ares returned to us above if less than one second is left, otherwise just use 1000ms to make sure the progress @@ -479,7 +494,7 @@ CURLcode Curl_resolver_wait_resolv(struct Curl_easy *data, return CURLE_UNRECOVERABLE_POLL; result = Curl_resolver_is_resolved(data, entry); - if(result || data->conn->resolve_async.done) + if(result || data->state.async.done) break; if(Curl_pgrsUpdate(data)) @@ -500,12 +515,12 @@ CURLcode Curl_resolver_wait_resolv(struct Curl_easy *data, } if(result) /* failure, so we cancel the ares operation */ - ares_cancel((ares_channel)data->conn->resolve_async.resolver); + ares_cancel((ares_channel)data->state.async.resolver); /* Operation complete, if the lookup was successful we now have the entry in the cache. */ if(entry) - *entry = data->conn->resolve_async.dns; + *entry = data->state.async.dns; if(result) /* close the connection, since we can't return failure here without @@ -572,13 +587,12 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */ be valid so only defer it when we know the 'status' says its fine! */ return; - res = data->conn->resolve_async.tdata; + res = data->state.async.tdata; if(res) { res->num_pending--; if(CURL_ASYNC_SUCCESS == status) { - struct Curl_addrinfo *ai = Curl_he2ai(hostent, - data->conn->resolve_async.port); + struct Curl_addrinfo *ai = Curl_he2ai(hostent, data->state.async.port); if(ai) { compound_results(res, ai); } @@ -729,16 +743,14 @@ static void addrinfo_cb(void *arg, int status, int timeouts, struct ares_addrinfo *result) { struct Curl_easy *data = (struct Curl_easy *)arg; - if(data->conn) { - struct thread_data *res = data->conn->resolve_async.tdata; - (void)timeouts; - if(ARES_SUCCESS == status) { - res->temp_ai = ares2addr(result->nodes); - res->last_status = CURL_ASYNC_SUCCESS; - ares_freeaddrinfo(result); - } - res->num_pending--; + struct thread_data *res = data->state.async.tdata; + (void)timeouts; + if(ARES_SUCCESS == status) { + res->temp_ai = ares2addr(result->nodes); + res->last_status = CURL_ASYNC_SUCCESS; + ares_freeaddrinfo(result); } + res->num_pending--; } #endif @@ -762,12 +774,12 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, res = calloc(1, sizeof(struct thread_data) + namelen); if(res) { strcpy(res->hostname, hostname); - data->conn->resolve_async.hostname = res->hostname; - data->conn->resolve_async.port = port; - data->conn->resolve_async.done = FALSE; /* not done */ - data->conn->resolve_async.status = 0; /* clear */ - data->conn->resolve_async.dns = NULL; /* clear */ - data->conn->resolve_async.tdata = res; + data->state.async.hostname = res->hostname; + data->state.async.port = port; + data->state.async.done = FALSE; /* not done */ + data->state.async.status = 0; /* clear */ + data->state.async.dns = NULL; /* clear */ + data->state.async.tdata = res; /* initial status - failed */ res->last_status = ARES_ENOTFOUND; @@ -797,8 +809,8 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, hints.ai_flags = ARES_AI_NUMERICSERV; msnprintf(service, sizeof(service), "%d", port); res->num_pending = 1; - ares_getaddrinfo((ares_channel)data->conn->resolve_async.resolver, - hostname, service, &hints, addrinfo_cb, data); + ares_getaddrinfo((ares_channel)data->state.async.resolver, hostname, + service, &hints, addrinfo_cb, data); } #else @@ -808,10 +820,10 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, res->num_pending = 2; /* areschannel is already setup in the Curl_open() function */ - ares_gethostbyname((ares_channel)data->conn->resolve_async.resolver, - hostname, PF_INET, query_completed_cb, data); - ares_gethostbyname((ares_channel)data->conn->resolve_async.resolver, - hostname, PF_INET6, query_completed_cb, data); + ares_gethostbyname((ares_channel)data->state.async.resolver, hostname, + PF_INET, query_completed_cb, data); + ares_gethostbyname((ares_channel)data->state.async.resolver, hostname, + PF_INET6, query_completed_cb, data); } else #endif @@ -819,7 +831,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, res->num_pending = 1; /* areschannel is already setup in the Curl_open() function */ - ares_gethostbyname((ares_channel)data->conn->resolve_async.resolver, + ares_gethostbyname((ares_channel)data->state.async.resolver, hostname, PF_INET, query_completed_cb, data); } @@ -833,7 +845,6 @@ CURLcode Curl_set_dns_servers(struct Curl_easy *data, char *servers) { CURLcode result = CURLE_NOT_BUILT_IN; - ares_channel channel, lchannel = NULL; int ares_result; /* If server is NULL or empty, this would purge all DNS servers @@ -846,23 +857,11 @@ CURLcode Curl_set_dns_servers(struct Curl_easy *data, return CURLE_OK; #ifdef HAVE_CARES_SERVERS_CSV - if(data->conn) - channel = data->conn->resolve_async.resolver; - else { - /* we are called by setopt on a data without a connection (yet). In that - * case we set the value on a local instance for checking. - * The configured data options are set when the connection for this - * transfer is created. */ - result = Curl_resolver_init(data, (void **)&lchannel); - if(result) - goto out; - channel = lchannel; - } - #ifdef HAVE_CARES_PORTS_CSV - ares_result = ares_set_servers_ports_csv(channel, servers); + ares_result = ares_set_servers_ports_csv(data->state.async.resolver, + servers); #else - ares_result = ares_set_servers_csv(channel, servers); + ares_result = ares_set_servers_csv(data->state.async.resolver, servers); #endif switch(ares_result) { case ARES_SUCCESS: @@ -875,12 +874,10 @@ CURLcode Curl_set_dns_servers(struct Curl_easy *data, case ARES_ENODATA: case ARES_EBADSTR: default: + DEBUGF(infof(data, "bad servers set")); result = CURLE_BAD_FUNCTION_ARGUMENT; break; } -out: - if(lchannel) - Curl_resolver_cleanup(lchannel); #else /* too old c-ares version! */ (void)data; (void)(ares_result); @@ -892,14 +889,11 @@ CURLcode Curl_set_dns_interface(struct Curl_easy *data, const char *interf) { #ifdef HAVE_CARES_LOCAL_DEV - if(data->conn) { - /* not a setopt test run, set the value */ - if(!interf) - interf = ""; + if(!interf) + interf = ""; + + ares_set_local_dev((ares_channel)data->state.async.resolver, interf); - ares_set_local_dev((ares_channel)data->conn->resolve_async.resolver, - interf); - } return CURLE_OK; #else /* c-ares version too old! */ (void)data; @@ -919,15 +913,13 @@ CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data, } else { if(Curl_inet_pton(AF_INET, local_ip4, &a4) != 1) { + DEBUGF(infof(data, "bad DNS IPv4 address")); return CURLE_BAD_FUNCTION_ARGUMENT; } } - if(data->conn) { - /* not a setopt test run, set the value */ - ares_set_local_ip4((ares_channel)data->conn->resolve_async.resolver, - ntohl(a4.s_addr)); - } + ares_set_local_ip4((ares_channel)data->state.async.resolver, + ntohl(a4.s_addr)); return CURLE_OK; #else /* c-ares version too old! */ @@ -949,14 +941,12 @@ CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data, } else { if(Curl_inet_pton(AF_INET6, local_ip6, a6) != 1) { + DEBUGF(infof(data, "bad DNS IPv6 address")); return CURLE_BAD_FUNCTION_ARGUMENT; } } - if(data->conn) { - /* not a setopt test run, set the value */ - ares_set_local_ip6((ares_channel)data->conn->resolve_async.resolver, a6); - } + ares_set_local_ip6((ares_channel)data->state.async.resolver, a6); return CURLE_OK; #else /* c-ares version too old! */ diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c index 63414b617..d4d382add 100644 --- a/lib/asyn-thread.c +++ b/lib/asyn-thread.c @@ -54,6 +54,7 @@ # define RESOLVER_ENOMEM ENOMEM #endif +#include "system_win32.h" #include "urldata.h" #include "sendf.h" #include "hostip.h" @@ -136,7 +137,7 @@ static void destroy_async_data(struct Curl_async *); */ void Curl_resolver_cancel(struct Curl_easy *data) { - destroy_async_data(&data->conn->resolve_async); + destroy_async_data(&data->state.async); } /* This function is used to init a threaded resolve */ @@ -144,9 +145,22 @@ static bool init_resolve_thread(struct Curl_easy *data, const char *hostname, int port, const struct addrinfo *hints); +#ifdef _WIN32 +/* Thread sync data used by GetAddrInfoExW for win8+ */ +struct thread_sync_data_w8 +{ + OVERLAPPED overlapped; + ADDRINFOEXW_ *res; + HANDLE cancel_ev; + ADDRINFOEXW_ hints; +}; +#endif /* Data for synchronization between resolver thread and its parent */ struct thread_sync_data { +#ifdef _WIN32 + struct thread_sync_data_w8 w8; +#endif curl_mutex_t *mtx; int done; int port; @@ -165,6 +179,9 @@ struct thread_sync_data { }; struct thread_data { +#ifdef _WIN32 + HANDLE complete_ev; +#endif curl_thread_t thread_hnd; unsigned int poll_interval; timediff_t interval_end; @@ -173,7 +190,7 @@ struct thread_data { static struct thread_sync_data *conn_thread_sync_data(struct Curl_easy *data) { - return &(data->conn->resolve_async.tdata->tsd); + return &(data->state.async.tdata->tsd); } /* Destroy resolver thread synchronization data */ @@ -276,6 +293,151 @@ static CURLcode getaddrinfo_complete(struct Curl_easy *data) return result; } +#ifdef _WIN32 +static VOID WINAPI +query_complete(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlapped) +{ + size_t ss_size; + const ADDRINFOEXW_ *ai; + struct Curl_addrinfo *ca; + struct Curl_addrinfo *cafirst = NULL; + struct Curl_addrinfo *calast = NULL; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-align" +#endif + struct thread_sync_data *tsd = + CONTAINING_RECORD(overlapped, struct thread_sync_data, w8.overlapped); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + struct thread_data *td = tsd->td; + const ADDRINFOEXW_ *res = tsd->w8.res; + int error = (int)err; + (void)bytes; + + if(error == ERROR_SUCCESS) { + /* traverse the addrinfo list */ + + for(ai = res; ai != NULL; ai = ai->ai_next) { + size_t namelen = ai->ai_canonname ? wcslen(ai->ai_canonname) + 1 : 0; + /* ignore elements with unsupported address family, */ + /* settle family-specific sockaddr structure size. */ + if(ai->ai_family == AF_INET) + ss_size = sizeof(struct sockaddr_in); +#ifdef ENABLE_IPV6 + else if(ai->ai_family == AF_INET6) + ss_size = sizeof(struct sockaddr_in6); +#endif + else + continue; + + /* ignore elements without required address info */ + if(!ai->ai_addr || !(ai->ai_addrlen > 0)) + continue; + + /* ignore elements with bogus address size */ + if((size_t)ai->ai_addrlen < ss_size) + continue; + + ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen); + if(!ca) { + error = EAI_MEMORY; + break; + } + + /* copy each structure member individually, member ordering, */ + /* size, or padding might be different for each platform. */ + ca->ai_flags = ai->ai_flags; + ca->ai_family = ai->ai_family; + ca->ai_socktype = ai->ai_socktype; + ca->ai_protocol = ai->ai_protocol; + ca->ai_addrlen = (curl_socklen_t)ss_size; + ca->ai_addr = NULL; + ca->ai_canonname = NULL; + ca->ai_next = NULL; + + ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo)); + memcpy(ca->ai_addr, ai->ai_addr, ss_size); + + if(namelen) { + size_t i; + ca->ai_canonname = (void *)((char *)ca->ai_addr + ss_size); + for(i = 0; i < namelen; ++i) /* convert wide string to ascii */ + ca->ai_canonname[i] = (char)ai->ai_canonname[i]; + ca->ai_canonname[namelen] = '\0'; + } + + /* if the return list is empty, this becomes the first element */ + if(!cafirst) + cafirst = ca; + + /* add this element last in the return list */ + if(calast) + calast->ai_next = ca; + calast = ca; + } + + /* if we failed, also destroy the Curl_addrinfo list */ + if(error) { + Curl_freeaddrinfo(cafirst); + cafirst = NULL; + } + else if(!cafirst) { +#ifdef EAI_NONAME + /* rfc3493 conformant */ + error = EAI_NONAME; +#else + /* rfc3493 obsoleted */ + error = EAI_NODATA; +#endif +#ifdef USE_WINSOCK + SET_SOCKERRNO(error); +#endif + } + tsd->res = cafirst; + } + + if(tsd->w8.res) { + Curl_FreeAddrInfoExW(tsd->w8.res); + tsd->w8.res = NULL; + } + + if(error) { + tsd->sock_error = SOCKERRNO?SOCKERRNO:error; + if(tsd->sock_error == 0) + tsd->sock_error = RESOLVER_ENOMEM; + } + else { + Curl_addrinfo_set_port(tsd->res, tsd->port); + } + + Curl_mutex_acquire(tsd->mtx); + if(tsd->done) { + /* too late, gotta clean up the mess */ + Curl_mutex_release(tsd->mtx); + destroy_thread_sync_data(tsd); + free(td); + } + else { +#ifndef CURL_DISABLE_SOCKETPAIR + char buf[1]; + if(tsd->sock_pair[1] != CURL_SOCKET_BAD) { + /* DNS has been resolved, signal client task */ + buf[0] = 1; + if(swrite(tsd->sock_pair[1], buf, sizeof(buf)) < 0) { + /* update sock_erro to errno */ + tsd->sock_error = SOCKERRNO; + } + } +#endif + tsd->done = 1; + Curl_mutex_release(tsd->mtx); + if(td->complete_ev) + SetEvent(td->complete_ev); /* Notify caller that the query completed */ + } +} +#endif #ifdef HAVE_GETADDRINFO @@ -391,9 +553,21 @@ static void destroy_async_data(struct Curl_async *async) Curl_mutex_release(td->tsd.mtx); if(!done) { +#ifdef _WIN32 + if(td->complete_ev) + CloseHandle(td->complete_ev); + else +#endif Curl_thread_destroy(td->thread_hnd); } else { +#ifdef _WIN32 + if(td->complete_ev) { + Curl_GetAddrInfoExCancel(&td->tsd.w8.cancel_ev); + WaitForSingleObject(td->complete_ev, INFINITE); + CloseHandle(td->complete_ev); + } +#endif if(td->thread_hnd != curl_thread_t_null) Curl_thread_join(&td->thread_hnd); @@ -428,9 +602,9 @@ static bool init_resolve_thread(struct Curl_easy *data, { struct thread_data *td = calloc(1, sizeof(struct thread_data)); int err = ENOMEM; - struct Curl_async *asp = &data->conn->resolve_async; + struct Curl_async *asp = &data->state.async; - data->conn->resolve_async.tdata = td; + data->state.async.tdata = td; if(!td) goto errno_exit; @@ -439,6 +613,9 @@ static bool init_resolve_thread(struct Curl_easy *data, asp->status = 0; asp->dns = NULL; td->thread_hnd = curl_thread_t_null; +#ifdef _WIN32 + td->complete_ev = NULL; +#endif if(!init_thread_sync_data(td, hostname, port, hints)) { asp->tdata = NULL; @@ -454,6 +631,41 @@ static bool init_resolve_thread(struct Curl_easy *data, /* The thread will set this to 1 when complete. */ td->tsd.done = 0; +#ifdef _WIN32 + if(Curl_isWindows8OrGreater && Curl_FreeAddrInfoExW && + Curl_GetAddrInfoExCancel && Curl_GetAddrInfoExW) { +#define MAX_NAME_LEN 256 /* max domain name is 253 chars */ +#define MAX_PORT_LEN 8 + WCHAR namebuf[MAX_NAME_LEN]; + WCHAR portbuf[MAX_PORT_LEN]; + /* calculate required length */ + int w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, hostname, + -1, NULL, 0); + if((w_len > 0) && (w_len < MAX_NAME_LEN)) { + /* do utf8 conversion */ + w_len = MultiByteToWideChar(CP_UTF8, 0, hostname, -1, namebuf, w_len); + if((w_len > 0) && (w_len < MAX_NAME_LEN)) { + swprintf(portbuf, MAX_PORT_LEN, L"%d", port); + td->tsd.w8.hints.ai_family = hints->ai_family; + td->tsd.w8.hints.ai_socktype = hints->ai_socktype; + td->complete_ev = CreateEvent(NULL, TRUE, FALSE, NULL); + if(!td->complete_ev) { + /* failed to start, mark it as done here for proper cleanup. */ + td->tsd.done = 1; + goto err_exit; + } + err = Curl_GetAddrInfoExW(namebuf, portbuf, NS_DNS, + NULL, &td->tsd.w8.hints, &td->tsd.w8.res, + NULL, &td->tsd.w8.overlapped, + &query_complete, &td->tsd.w8.cancel_ev); + if(err != WSA_IO_PENDING) + query_complete(err, 0, &td->tsd.w8.overlapped); + return TRUE; + } + } + } +#endif + #ifdef HAVE_GETADDRINFO td->thread_hnd = Curl_thread_create(getaddrinfo_thread, &td->tsd); #else @@ -488,11 +700,24 @@ static CURLcode thread_wait_resolv(struct Curl_easy *data, CURLcode result = CURLE_OK; DEBUGASSERT(data); - td = data->conn->resolve_async.tdata; + td = data->state.async.tdata; DEBUGASSERT(td); +#ifdef _WIN32 + DEBUGASSERT(td->complete_ev || td->thread_hnd != curl_thread_t_null); +#else DEBUGASSERT(td->thread_hnd != curl_thread_t_null); +#endif /* wait for the thread to resolve the name */ +#ifdef _WIN32 + if(td->complete_ev) { + WaitForSingleObject(td->complete_ev, INFINITE); + CloseHandle(td->complete_ev); + if(entry) + result = getaddrinfo_complete(data); + } + else +#endif if(Curl_thread_join(&td->thread_hnd)) { if(entry) result = getaddrinfo_complete(data); @@ -500,18 +725,18 @@ static CURLcode thread_wait_resolv(struct Curl_easy *data, else DEBUGASSERT(0); - data->conn->resolve_async.done = TRUE; + data->state.async.done = TRUE; if(entry) - *entry = data->conn->resolve_async.dns; + *entry = data->state.async.dns; - if(!data->conn->resolve_async.dns && report) + if(!data->state.async.dns && report) /* a name was not resolved, report error */ result = Curl_resolver_error(data); - destroy_async_data(&data->conn->resolve_async); + destroy_async_data(&data->state.async); - if(!data->conn->resolve_async.dns && report) + if(!data->state.async.dns && report) connclose(data->conn, "asynch resolve failed"); return result; @@ -524,7 +749,7 @@ static CURLcode thread_wait_resolv(struct Curl_easy *data, */ void Curl_resolver_kill(struct Curl_easy *data) { - struct thread_data *td = data->conn->resolve_async.tdata; + struct thread_data *td = data->state.async.tdata; /* If we're still resolving, we must wait for the threads to fully clean up, unfortunately. Otherwise, we can simply cancel to clean up any resolver @@ -563,7 +788,7 @@ CURLcode Curl_resolver_wait_resolv(struct Curl_easy *data, CURLcode Curl_resolver_is_resolved(struct Curl_easy *data, struct Curl_dns_entry **entry) { - struct thread_data *td = data->conn->resolve_async.tdata; + struct thread_data *td = data->state.async.tdata; int done = 0; DEBUGASSERT(entry); @@ -581,13 +806,13 @@ CURLcode Curl_resolver_is_resolved(struct Curl_easy *data, if(done) { getaddrinfo_complete(data); - if(!data->conn->resolve_async.dns) { + if(!data->state.async.dns) { CURLcode result = Curl_resolver_error(data); - destroy_async_data(&data->conn->resolve_async); + destroy_async_data(&data->state.async); return result; } - destroy_async_data(&data->conn->resolve_async); - *entry = data->conn->resolve_async.dns; + destroy_async_data(&data->state.async); + *entry = data->state.async.dns; } else { /* poll for name lookup done with exponential backoff up to 250ms */ @@ -619,9 +844,9 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks) int ret_val = 0; timediff_t milli; timediff_t ms; - struct resdata *reslv = (struct resdata *)data->conn->resolve_async.resolver; + struct resdata *reslv = (struct resdata *)data->state.async.resolver; #ifndef CURL_DISABLE_SOCKETPAIR - struct thread_data *td = data->conn->resolve_async.tdata; + struct thread_data *td = data->state.async.tdata; #else (void)socks; #endif @@ -662,7 +887,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, int port, int *waitp) { - struct resdata *reslv = (struct resdata *)data->conn->resolve_async.resolver; + struct resdata *reslv = (struct resdata *)data->state.async.resolver; *waitp = 0; /* default to synchronous response */ @@ -691,7 +916,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, { struct addrinfo hints; int pf = PF_INET; - struct resdata *reslv = (struct resdata *)data->conn->resolve_async.resolver; + struct resdata *reslv = (struct resdata *)data->state.async.resolver; *waitp = 0; /* default to synchronous response */ diff --git a/lib/bufref.c b/lib/bufref.c index ce686b6f3..f0a0e2a7d 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -25,6 +25,7 @@ #include "curl_setup.h" #include "urldata.h" #include "bufref.h" +#include "strdup.h" #include "curl_memory.h" #include "memdebug.h" @@ -116,12 +117,9 @@ CURLcode Curl_bufref_memdup(struct bufref *br, const void *ptr, size_t len) DEBUGASSERT(len <= CURL_MAX_INPUT_LENGTH); if(ptr) { - cpy = malloc(len + 1); + cpy = Curl_memdup0(ptr, len); if(!cpy) return CURLE_OUT_OF_MEMORY; - if(len) - memcpy(cpy, ptr, len); - cpy[len] = '\0'; } Curl_bufref_set(br, cpy, len, curl_free); diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 787d6bbdb..d02ecd73a 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -148,7 +148,7 @@ static int hyper_each_header(void *userdata, if(name_len + value_len + 2 > CURL_MAX_HTTP_HEADER) { failf(data, "Too long response header"); - data->state.hresult = CURLE_OUT_OF_MEMORY; + data->state.hresult = CURLE_TOO_LARGE; return HYPER_ITER_BREAK; } @@ -325,6 +325,9 @@ static CURLcode empty_header(struct Curl_easy *data) CURLE_WRITE_ERROR : CURLE_OK; if(result) failf(data, "hyperstream: couldn't pass blank header"); + /* Hyper does chunked decoding itself. If it was added during + * response header processing, remove it again. */ + Curl_cwriter_remove_by_name(data, "chunked"); } return result; } diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 2e23b0b9f..167e5315a 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -70,6 +70,7 @@ struct h1_tunnel_state { struct dynbuf request_data; size_t nsent; size_t headerlines; + struct Curl_chunker ch; enum keeponval { KEEPON_DONE, KEEPON_CONNECT, @@ -133,6 +134,7 @@ static CURLcode tunnel_init(struct Curl_cfilter *cf, Curl_dyn_init(&ts->rcvbuf, DYN_PROXY_CONNECT_HEADERS); Curl_dyn_init(&ts->request_data, DYN_HTTP_REQUEST); + Curl_httpchunk_init(data, &ts->ch, TRUE); *pts = ts; connkeep(cf->conn, "HTTP proxy CONNECT"); @@ -146,14 +148,6 @@ static void h1_tunnel_go_state(struct Curl_cfilter *cf, { if(ts->tunnel_state == new_state) return; - /* leaving this one */ - switch(ts->tunnel_state) { - case H1_TUNNEL_CONNECT: - data->req.ignorebody = FALSE; - break; - default: - break; - } /* entering this one */ switch(new_state) { case H1_TUNNEL_INIT: @@ -183,7 +177,7 @@ static void h1_tunnel_go_state(struct Curl_cfilter *cf, infof(data, "CONNECT phase completed"); data->state.authproxy.done = TRUE; data->state.authproxy.multipass = FALSE; - /* FALLTHROUGH */ + FALLTHROUGH(); case H1_TUNNEL_FAILED: if(new_state == H1_TUNNEL_FAILED) CURL_TRC_CF(data, cf, "new tunnel state 'failed'"); @@ -212,6 +206,7 @@ static void tunnel_free(struct Curl_cfilter *cf, h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); Curl_dyn_free(&ts->rcvbuf); Curl_dyn_free(&ts->request_data); + Curl_httpchunk_free(data, &ts->ch); free(ts); cf->ctx = NULL; } @@ -344,8 +339,8 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, STRCONST("chunked"))) { infof(data, "CONNECT responded chunked"); ts->chunked_encoding = TRUE; - /* init our chunky engine */ - Curl_httpchunk_init(data); + /* reset our chunky engine */ + Curl_httpchunk_reset(data, &ts->ch, TRUE); } } else if(Curl_compareheader(header, @@ -373,7 +368,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, struct SingleRequest *k = &data->req; curl_socket_t tunnelsocket = Curl_conn_cf_get_socket(cf, data); char *linep; - size_t perline; + size_t line_len; int error, writetype; #define SELECT_OK 0 @@ -432,17 +427,17 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, break; } } - else { + else if(ts->chunked_encoding) { /* chunked-encoded body, so we need to do the chunked dance properly to know when the end of the body is reached */ - CHUNKcode r; - CURLcode extra; size_t consumed = 0; /* now parse the chunked piece of data so that we can properly tell when the stream ends */ - r = Curl_httpchunk_read(data, &byte, 1, &consumed, &extra); - if(r == CHUNKE_STOP) { + result = Curl_httpchunk_read(data, &ts->ch, &byte, 1, &consumed); + if(result) + return result; + if(Curl_httpchunk_is_done(data, &ts->ch)) { /* we're done reading chunks! */ infof(data, "chunk reading DONE"); ts->keepon = KEEPON_DONE; @@ -462,19 +457,19 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, ts->headerlines++; linep = Curl_dyn_ptr(&ts->rcvbuf); - perline = Curl_dyn_len(&ts->rcvbuf); /* amount of bytes in this line */ + line_len = Curl_dyn_len(&ts->rcvbuf); /* amount of bytes in this line */ /* output debug if that is requested */ - Curl_debug(data, CURLINFO_HEADER_IN, linep, perline); + Curl_debug(data, CURLINFO_HEADER_IN, linep, line_len); /* send the header to the callback */ writetype = CLIENTWRITE_HEADER | CLIENTWRITE_CONNECT | (ts->headerlines == 1 ? CLIENTWRITE_STATUS : 0); - result = Curl_client_write(data, writetype, linep, perline); + result = Curl_client_write(data, writetype, linep, line_len); if(result) return result; - result = Curl_bump_headersize(data, perline, TRUE); + result = Curl_bump_headersize(data, line_len, TRUE); if(result) return result; @@ -497,29 +492,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, " bytes of response-body", ts->cl); } else if(ts->chunked_encoding) { - CHUNKcode r; - CURLcode extra; - size_t consumed = 0; - infof(data, "Ignore chunked response-body"); - - /* We set ignorebody true here since the chunked decoder - function will acknowledge that. Pay attention so that this is - cleared again when this function returns! */ - k->ignorebody = TRUE; - - if(linep[1] == '\n') - /* this can only be a LF if the letter at index 0 was a CR */ - linep++; - - /* now parse the chunked piece of data so that we can properly - tell when the stream ends */ - r = Curl_httpchunk_read(data, linep + 1, 1, &consumed, &extra); - if(r == CHUNKE_STOP) { - /* we're done reading chunks! */ - infof(data, "chunk reading DONE"); - ts->keepon = KEEPON_DONE; - } } else { /* without content-length or chunked encoding, we @@ -752,7 +725,7 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf, } if(!Curl_checkProxyheaders(data, conn, STRCONST("User-Agent")) && - data->set.str[STRING_USERAGENT]) { + data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT]) { struct dynbuf ua; Curl_dyn_init(&ua, DYN_HTTP_REQUEST); result = Curl_dyn_addf(&ua, "User-Agent: %s\r\n", @@ -912,7 +885,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, if(result) goto out; h1_tunnel_go_state(cf, ts, H1_TUNNEL_CONNECT, data); - /* FALLTHROUGH */ + FALLTHROUGH(); case H1_TUNNEL_CONNECT: /* see that the request is completely sent */ @@ -921,7 +894,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, if(result || !done) goto out; h1_tunnel_go_state(cf, ts, H1_TUNNEL_RECEIVE, data); - /* FALLTHROUGH */ + FALLTHROUGH(); case H1_TUNNEL_RECEIVE: /* read what is there */ @@ -936,7 +909,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, goto out; /* got it */ h1_tunnel_go_state(cf, ts, H1_TUNNEL_RESPONSE, data); - /* FALLTHROUGH */ + FALLTHROUGH(); case H1_TUNNEL_RESPONSE: CURL_TRC_CF(data, cf, "CONNECT response"); @@ -1030,6 +1003,14 @@ static CURLcode cf_h1_proxy_connect(struct Curl_cfilter *cf, *done = (result == CURLE_OK) && tunnel_is_established(cf->ctx); if(*done) { cf->connected = TRUE; + /* Restore `data->req` fields that may habe been touched */ + data->req.header = TRUE; /* assume header */ + data->req.bytecount = 0; + data->req.ignorebody = FALSE; + Curl_client_cleanup(data); + Curl_pgrsSetUploadCounter(data, 0); + Curl_pgrsSetDownloadCounter(data, 0); + tunnel_free(cf, data); } return result; diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index 147acdc86..f8f2f3c41 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -155,7 +155,7 @@ static void h2_tunnel_go_state(struct Curl_cfilter *cf, infof(data, "CONNECT phase completed"); data->state.authproxy.done = TRUE; data->state.authproxy.multipass = FALSE; - /* FALLTHROUGH */ + FALLTHROUGH(); case H2_TUNNEL_FAILED: if(new_state == H2_TUNNEL_FAILED) CURL_TRC_CF(data, cf, "[%d] new tunnel state 'failed'", ts->stream_id); @@ -221,10 +221,10 @@ static void drain_tunnel(struct Curl_cfilter *cf, bits = CURL_CSELECT_IN; if(!tunnel->closed && !tunnel->reset && tunnel->upload_blocked_len) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - CURL_TRC_CF(data, cf, "[%d] DRAIN dselect_bits=%x", + if(data->state.select_bits != bits) { + CURL_TRC_CF(data, cf, "[%d] DRAIN select_bits=%x", tunnel->stream_id, bits); - data->state.dselect_bits = bits; + data->state.select_bits = bits; Curl_expire(data, 0, EXPIRE_RUN_NOW); } } @@ -1033,7 +1033,7 @@ static CURLcode H2_CONNECT(struct Curl_cfilter *cf, if(result) goto out; h2_tunnel_go_state(cf, ts, H2_TUNNEL_CONNECT, data); - /* FALLTHROUGH */ + FALLTHROUGH(); case H2_TUNNEL_CONNECT: /* see that the request is completely sent */ @@ -1052,7 +1052,7 @@ static CURLcode H2_CONNECT(struct Curl_cfilter *cf, result = CURLE_OK; goto out; } - /* FALLTHROUGH */ + FALLTHROUGH(); case H2_TUNNEL_RESPONSE: DEBUGASSERT(ts->has_final_response); diff --git a/lib/cf-haproxy.c b/lib/cf-haproxy.c index 1ca43937b..c062887bf 100644 --- a/lib/cf-haproxy.c +++ b/lib/cf-haproxy.c @@ -125,7 +125,7 @@ static CURLcode cf_haproxy_connect(struct Curl_cfilter *cf, if(result) goto out; ctx->state = HAPROXY_SEND; - /* FALLTHROUGH */ + FALLTHROUGH(); case HAPROXY_SEND: len = Curl_dyn_len(&ctx->data_out); if(len > 0) { @@ -141,7 +141,7 @@ static CURLcode cf_haproxy_connect(struct Curl_cfilter *cf, } } ctx->state = HAPROXY_DONE; - /* FALLTHROUGH */ + FALLTHROUGH(); default: Curl_dyn_free(&ctx->data_out); break; diff --git a/lib/cf-https-connect.c b/lib/cf-https-connect.c index b4f33c8e0..b23fa056f 100644 --- a/lib/cf-https-connect.c +++ b/lib/cf-https-connect.c @@ -266,7 +266,7 @@ static CURLcode cf_hc_connect(struct Curl_cfilter *cf, cf_hc_baller_init(&ctx->h21_baller, cf, data, "h21", cf->conn->transport); ctx->state = CF_HC_CONNECT; - /* FALLTHROUGH */ + FALLTHROUGH(); case CF_HC_CONNECT: if(cf_hc_baller_is_active(&ctx->h3_baller)) { diff --git a/lib/cf-socket.c b/lib/cf-socket.c index e42b4a87b..742902f1b 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -137,14 +137,14 @@ static void nosigpipe(struct Curl_easy *data, #define nosigpipe(x,y) Curl_nop_stmt #endif -#if defined(__DragonFly__) || defined(HAVE_WINSOCK2_H) +#if defined(__DragonFly__) || defined(USE_WINSOCK) /* DragonFlyBSD and Windows use millisecond units */ #define KEEPALIVE_FACTOR(x) (x *= 1000) #else #define KEEPALIVE_FACTOR(x) #endif -#if defined(HAVE_WINSOCK2_H) && !defined(SIO_KEEPALIVE_VALS) +#if defined(USE_WINSOCK) && !defined(SIO_KEEPALIVE_VALS) #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) struct tcp_keepalive { @@ -163,7 +163,9 @@ tcpkeepalive(struct Curl_easy *data, /* only set IDLE and INTVL if setting KEEPALIVE is successful */ if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval, sizeof(optval)) < 0) { - infof(data, "Failed to set SO_KEEPALIVE on fd %d", sockfd); + infof(data, "Failed to set SO_KEEPALIVE on fd " + "%" CURL_FORMAT_SOCKET_T ": errno %d", + sockfd, SOCKERRNO); } else { #if defined(SIO_KEEPALIVE_VALS) @@ -178,8 +180,9 @@ tcpkeepalive(struct Curl_easy *data, vals.keepaliveinterval = optval; if(WSAIoctl(sockfd, SIO_KEEPALIVE_VALS, (LPVOID) &vals, sizeof(vals), NULL, 0, &dummy, NULL, NULL) != 0) { - infof(data, "Failed to set SIO_KEEPALIVE_VALS on fd %d: %d", - (int)sockfd, WSAGetLastError()); + infof(data, "Failed to set SIO_KEEPALIVE_VALS on fd " + "%" CURL_FORMAT_SOCKET_T ": errno %d", + sockfd, SOCKERRNO); } #else #ifdef TCP_KEEPIDLE @@ -187,7 +190,9 @@ tcpkeepalive(struct Curl_easy *data, KEEPALIVE_FACTOR(optval); if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval, sizeof(optval)) < 0) { - infof(data, "Failed to set TCP_KEEPIDLE on fd %d", sockfd); + infof(data, "Failed to set TCP_KEEPIDLE on fd " + "%" CURL_FORMAT_SOCKET_T ": errno %d", + sockfd, SOCKERRNO); } #elif defined(TCP_KEEPALIVE) /* Mac OS X style */ @@ -195,7 +200,9 @@ tcpkeepalive(struct Curl_easy *data, KEEPALIVE_FACTOR(optval); if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE, (void *)&optval, sizeof(optval)) < 0) { - infof(data, "Failed to set TCP_KEEPALIVE on fd %d", sockfd); + infof(data, "Failed to set TCP_KEEPALIVE on fd " + "%" CURL_FORMAT_SOCKET_T ": errno %d", + sockfd, SOCKERRNO); } #endif #ifdef TCP_KEEPINTVL @@ -203,7 +210,9 @@ tcpkeepalive(struct Curl_easy *data, KEEPALIVE_FACTOR(optval); if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&optval, sizeof(optval)) < 0) { - infof(data, "Failed to set TCP_KEEPINTVL on fd %d", sockfd); + infof(data, "Failed to set TCP_KEEPINTVL on fd " + "%" CURL_FORMAT_SOCKET_T ": errno %d", + sockfd, SOCKERRNO); } #endif #endif @@ -783,6 +792,7 @@ struct cf_socket_ctx { #endif BIT(got_first_byte); /* if first byte was received */ BIT(accepted); /* socket was accepted, not connected */ + BIT(sock_connected); /* socket is "connected", e.g. in UDP */ BIT(active); BIT(buffer_recv); }; @@ -983,20 +993,14 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf, if(result) goto out; -#ifndef CURL_DISABLE_VERBOSE_STRINGS - { - const char *ipmsg; #ifdef ENABLE_IPV6 - if(ctx->addr.family == AF_INET6) { - set_ipv6_v6only(ctx->sock, 0); - ipmsg = " Trying [%s]:%d..."; - } - else -#endif - ipmsg = " Trying %s:%d..."; - infof(data, ipmsg, ctx->r_ip, ctx->r_port); + if(ctx->addr.family == AF_INET6) { + set_ipv6_v6only(ctx->sock, 0); + infof(data, " Trying [%s]:%d...", ctx->r_ip, ctx->r_port); } + else #endif + infof(data, " Trying %s:%d...", ctx->r_ip, ctx->r_port); #ifdef ENABLE_IPV6 is_tcp = (ctx->addr.family == AF_INET @@ -1054,7 +1058,7 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf, /* set socket non-blocking */ (void)curlx_nonblock(ctx->sock, TRUE); - + ctx->sock_connected = (ctx->addr.socktype != SOCK_DGRAM); out: if(result) { if(ctx->sock != CURL_SOCKET_BAD) { @@ -1242,11 +1246,14 @@ static void cf_socket_adjust_pollset(struct Curl_cfilter *cf, struct cf_socket_ctx *ctx = cf->ctx; if(ctx->sock != CURL_SOCKET_BAD) { - if(!cf->connected) + if(!cf->connected) { Curl_pollset_set_out_only(data, ps, ctx->sock); - else + CURL_TRC_CF(data, cf, "adjust_pollset(!connected) -> %d socks", ps->num); + } + else if(!ctx->active) { Curl_pollset_add_in(data, ps, ctx->sock); - CURL_TRC_CF(data, cf, "adjust_pollset -> %d socks", ps->num); + CURL_TRC_CF(data, cf, "adjust_pollset(!active) -> %d socks", ps->num); + } } } @@ -1429,36 +1436,11 @@ static ssize_t cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data, static void conn_set_primary_ip(struct Curl_cfilter *cf, struct Curl_easy *data) { -#ifdef HAVE_GETPEERNAME struct cf_socket_ctx *ctx = cf->ctx; - if(!(data->conn->handler->protocol & CURLPROTO_TFTP)) { - /* TFTP does not connect the endpoint: getpeername() failed with errno - 107: Transport endpoint is not connected */ - - char buffer[STRERROR_LEN]; - struct Curl_sockaddr_storage ssrem; - curl_socklen_t plen; - int port; - plen = sizeof(ssrem); - memset(&ssrem, 0, plen); - if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) { - int error = SOCKERRNO; - failf(data, "getpeername() failed with errno %d: %s", - error, Curl_strerror(error, buffer, sizeof(buffer))); - return; - } - if(!Curl_addr2string((struct sockaddr*)&ssrem, plen, - cf->conn->primary_ip, &port)) { - failf(data, "ssrem inet_ntop() failed with errno %d: %s", - errno, Curl_strerror(errno, buffer, sizeof(buffer))); - return; - } - } -#else - cf->conn->primary_ip[0] = 0; (void)data; -#endif + DEBUGASSERT(sizeof(ctx->r_ip) == sizeof(cf->conn->primary_ip)); + memcpy(cf->conn->primary_ip, ctx->r_ip, sizeof(cf->conn->primary_ip)); } static void cf_socket_active(struct Curl_cfilter *cf, struct Curl_easy *data) @@ -1574,7 +1556,7 @@ static CURLcode cf_socket_query(struct Curl_cfilter *cf, *when = ctx->first_byte_at; break; } - /* FALLTHROUGH */ + FALLTHROUGH(); default: *when = ctx->connected_at; break; @@ -1648,10 +1630,17 @@ static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf, /* QUIC needs a connected socket, nonblocking */ DEBUGASSERT(ctx->sock != CURL_SOCKET_BAD); +#if defined(__APPLE__) && defined(USE_OPENSSL_QUIC) + (void)rc; + /* On macOS OpenSSL QUIC fails on connected sockets. + * see: */ +#else rc = connect(ctx->sock, &ctx->addr.sa_addr, ctx->addr.addrlen); if(-1 == rc) { return socket_connect_result(data, ctx->r_ip, SOCKERRNO); } + ctx->sock_connected = TRUE; +#endif set_local_ip(cf, data); CURL_TRC_CF(data, cf, "%s socket %" CURL_FORMAT_SOCKET_T " connected: [%s:%d] -> [%s:%d]", diff --git a/lib/cf-socket.h b/lib/cf-socket.h index 1d40df737..87e0f30a2 100644 --- a/lib/cf-socket.h +++ b/lib/cf-socket.h @@ -34,23 +34,6 @@ struct Curl_easy; struct connectdata; struct Curl_sockaddr_ex; -#ifndef SIZEOF_CURL_SOCKET_T -/* configure and cmake check and set the define */ -# ifdef _WIN64 -# define SIZEOF_CURL_SOCKET_T 8 -# else -/* default guess */ -# define SIZEOF_CURL_SOCKET_T 4 -# endif -#endif - -#if SIZEOF_CURL_SOCKET_T < 8 -# define CURL_FORMAT_SOCKET_T "d" -#else -# define CURL_FORMAT_SOCKET_T "qd" -#endif - - /* * The Curl_sockaddr_ex structure is basically libcurl's external API * curl_sockaddr structure with enough space available to directly hold any diff --git a/lib/cfilters.c b/lib/cfilters.c index e78ecd71d..823e90c3f 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -760,25 +760,11 @@ static void ps_add(struct Curl_easy *data, struct easy_pollset *ps, void Curl_pollset_add_socks(struct Curl_easy *data, struct easy_pollset *ps, int (*get_socks_cb)(struct Curl_easy *data, - struct connectdata *conn, curl_socket_t *socks)) { curl_socket_t socks[MAX_SOCKSPEREASYHANDLE]; int bitmap; - DEBUGASSERT(data->conn); - bitmap = get_socks_cb(data, data->conn, socks); - ps_add(data, ps, bitmap, socks); -} - -void Curl_pollset_add_socks2(struct Curl_easy *data, - struct easy_pollset *ps, - int (*get_socks_cb)(struct Curl_easy *data, - curl_socket_t *socks)) -{ - curl_socket_t socks[MAX_SOCKSPEREASYHANDLE]; - int bitmap; - bitmap = get_socks_cb(data, socks); ps_add(data, ps, bitmap, socks); } diff --git a/lib/cfilters.h b/lib/cfilters.h index 09a3f162a..f83842920 100644 --- a/lib/cfilters.h +++ b/lib/cfilters.h @@ -530,12 +530,7 @@ void Curl_pollset_set(struct Curl_easy *data, void Curl_pollset_add_socks(struct Curl_easy *data, struct easy_pollset *ps, int (*get_socks_cb)(struct Curl_easy *data, - struct connectdata *conn, curl_socket_t *socks)); -void Curl_pollset_add_socks2(struct Curl_easy *data, - struct easy_pollset *ps, - int (*get_socks_cb)(struct Curl_easy *data, - curl_socket_t *socks)); /** * Check if the pollset, as is, wants to read and/or write regarding diff --git a/lib/config-os400.h b/lib/config-os400.h index 357a36458..32852bb37 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -116,12 +116,6 @@ /* Define if you have the GNU gssapi libraries */ #undef HAVE_GSSGNU -/* Define if you have the Heimdal gssapi libraries */ -#define HAVE_GSSHEIMDAL - -/* Define if you have the MIT gssapi libraries */ -#undef HAVE_GSSMIT - /* Define if you need the malloc.h header file even with stdlib.h */ /* #define NEED_MALLOC_H 1 */ diff --git a/lib/config-win32.h b/lib/config-win32.h index 7b8a289bc..89ed1a0f1 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -97,15 +97,6 @@ #define HAVE_UNISTD_H 1 #endif -/* Define if you have the header file. */ -#define HAVE_WINDOWS_H 1 - -/* Define if you have the header file. */ -#define HAVE_WINSOCK2_H 1 - -/* Define if you have the header file. */ -#define HAVE_WS2TCPIP_H 1 - /* Define to 1 if you have the header file. */ #if defined(__MINGW32__) #define HAVE_LIBGEN_H 1 @@ -292,52 +283,6 @@ /* Define to the size of `curl_off_t', as computed by sizeof. */ #define SIZEOF_CURL_OFF_T 8 -/* ---------------------------------------------------------------- */ -/* BSD-style lwIP TCP/IP stack SPECIFIC */ -/* ---------------------------------------------------------------- */ - -/* Define to use BSD-style lwIP TCP/IP stack. */ -/* #define USE_LWIPSOCK 1 */ - -#ifdef USE_LWIPSOCK -# undef USE_WINSOCK -# undef HAVE_WINSOCK2_H -# undef HAVE_WS2TCPIP_H -# undef HAVE_GETHOSTNAME -# undef LWIP_POSIX_SOCKETS_IO_NAMES -# undef RECV_TYPE_ARG1 -# undef RECV_TYPE_ARG3 -# undef SEND_TYPE_ARG1 -# undef SEND_TYPE_ARG3 -# define HAVE_GETHOSTBYNAME_R -# define HAVE_GETHOSTBYNAME_R_6 -# define LWIP_POSIX_SOCKETS_IO_NAMES 0 -# define RECV_TYPE_ARG1 int -# define RECV_TYPE_ARG3 size_t -# define SEND_TYPE_ARG1 int -# define SEND_TYPE_ARG3 size_t -#endif - -/* ---------------------------------------------------------------- */ -/* Watt-32 tcp/ip SPECIFIC */ -/* ---------------------------------------------------------------- */ - -#ifdef USE_WATT32 - #include - #undef byte - #undef word - #undef USE_WINSOCK - #undef HAVE_WINSOCK2_H - #undef HAVE_WS2TCPIP_H - #define HAVE_SYS_IOCTL_H - #define HAVE_SYS_SOCKET_H - #define HAVE_NETINET_IN_H - #define HAVE_NETDB_H - #define HAVE_ARPA_INET_H - #define SOCKET int -#endif - - /* ---------------------------------------------------------------- */ /* COMPILER SPECIFIC */ /* ---------------------------------------------------------------- */ diff --git a/lib/config-win32ce.h b/lib/config-win32ce.h index e0db57fd0..ae3ca290c 100644 --- a/lib/config-win32ce.h +++ b/lib/config-win32ce.h @@ -85,15 +85,6 @@ #define HAVE_UNISTD_H 1 #endif -/* Define if you have the header file. */ -#define HAVE_WINDOWS_H 1 - -/* Define if you have the header file. */ -#define HAVE_WINSOCK2_H 1 - -/* Define if you have the header file. */ -#define HAVE_WS2TCPIP_H 1 - /* ---------------------------------------------------------------- */ /* OTHER HEADER INFO */ /* ---------------------------------------------------------------- */ diff --git a/lib/connect.c b/lib/connect.c index ec5ab71d4..45743e98b 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -93,25 +93,17 @@ * transfer/connection. If the value is 0, there's no timeout (ie there's * infinite time left). If the value is negative, the timeout time has already * elapsed. - * - * If 'nowp' is non-NULL, it points to the current time. - * 'duringconnect' is FALSE if not during a connect, as then of course the - * connect timeout is not taken into account! - * + * @param data the transfer to check on + * @param nowp timestamp to use for calculdation, NULL to use Curl_now() + * @param duringconnect TRUE iff connect timeout is also taken into account. * @unittest: 1303 */ - -#define TIMEOUT_CONNECT 1 -#define TIMEOUT_MAXTIME 2 - timediff_t Curl_timeleft(struct Curl_easy *data, struct curltime *nowp, bool duringconnect) { - unsigned int timeout_set = 0; - timediff_t connect_timeout_ms = 0; - timediff_t maxtime_timeout_ms = 0; - timediff_t timeout_ms = 0; + timediff_t timeleft_ms = 0; + timediff_t ctimeleft_ms = 0; struct curltime now; /* The duration of a connect and the total transfer are calculated from two @@ -119,43 +111,35 @@ timediff_t Curl_timeleft(struct Curl_easy *data, before the connect timeout expires and we must acknowledge whichever timeout that is reached first. The total timeout is set per entire operation, while the connect timeout is set per connect. */ - - if(data->set.timeout > 0) { - timeout_set = TIMEOUT_MAXTIME; - maxtime_timeout_ms = data->set.timeout; - } - if(duringconnect) { - timeout_set |= TIMEOUT_CONNECT; - connect_timeout_ms = (data->set.connecttimeout > 0) ? - data->set.connecttimeout : DEFAULT_CONNECT_TIMEOUT; - } - if(!timeout_set) - /* no timeout */ - return 0; + if(data->set.timeout <= 0 && !duringconnect) + return 0; /* no timeout in place or checked, return "no limit" */ if(!nowp) { now = Curl_now(); nowp = &now; } - if(timeout_set & TIMEOUT_MAXTIME) { - maxtime_timeout_ms -= Curl_timediff(*nowp, data->progress.t_startop); - timeout_ms = maxtime_timeout_ms; + if(data->set.timeout > 0) { + timeleft_ms = data->set.timeout - + Curl_timediff(*nowp, data->progress.t_startop); + if(!timeleft_ms) + timeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */ + if(!duringconnect) + return timeleft_ms; /* no connect check, this is it */ } - if(timeout_set & TIMEOUT_CONNECT) { - connect_timeout_ms -= Curl_timediff(*nowp, data->progress.t_startsingle); - - if(!(timeout_set & TIMEOUT_MAXTIME) || - (connect_timeout_ms < maxtime_timeout_ms)) - timeout_ms = connect_timeout_ms; + if(duringconnect) { + timediff_t ctimeout_ms = (data->set.connecttimeout > 0) ? + data->set.connecttimeout : DEFAULT_CONNECT_TIMEOUT; + ctimeleft_ms = ctimeout_ms - + Curl_timediff(*nowp, data->progress.t_startsingle); + if(!ctimeleft_ms) + ctimeleft_ms = -1; /* 0 is "no limit", fake 1 ms expiry */ + if(!timeleft_ms) + return ctimeleft_ms; /* no general timeout, this is it */ } - - if(!timeout_ms) - /* avoid returning 0 as that means no timeout! */ - return -1; - - return timeout_ms; + /* return minimal time left or max amount already expired */ + return (ctimeleft_ms < timeleft_ms)? ctimeleft_ms : timeleft_ms; } /* Copies connection info into the transfer handle to make it available when @@ -405,7 +389,7 @@ static CURLcode eyeballer_new(struct eyeballer **pballer, struct eyeballer *baller; *pballer = NULL; - baller = calloc(1, sizeof(*baller) + 1000); + baller = calloc(1, sizeof(*baller)); if(!baller) return CURLE_OUT_OF_MEMORY; @@ -908,7 +892,7 @@ static CURLcode cf_he_connect(struct Curl_cfilter *cf, if(result) return result; ctx->state = SCFST_WAITING; - /* FALLTHROUGH */ + FALLTHROUGH(); case SCFST_WAITING: result = is_connected(cf, data, done); if(!result && *done) { diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 4167d4d68..c1abf24e8 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -365,11 +365,14 @@ static CURLcode gzip_do_init(struct Curl_easy *data, #ifdef OLD_ZLIB_SUPPORT /* Skip over the gzip header */ -static enum { +typedef enum { GZIP_OK, GZIP_BAD, GZIP_UNDERFLOW -} check_gzip_header(unsigned char const *data, ssize_t len, ssize_t *headerlen) +} gzip_status; + +static gzip_status check_gzip_header(unsigned char const *data, ssize_t len, + ssize_t *headerlen) { int method, flags; const ssize_t totallen = len; @@ -832,8 +835,8 @@ static const struct Curl_cwtype identity_encoding = { }; -/* supported content encodings table. */ -static const struct Curl_cwtype * const encodings[] = { +/* supported general content decoders. */ +static const struct Curl_cwtype * const general_unencoders[] = { &identity_encoding, #ifdef HAVE_LIBZ &deflate_encoding, @@ -848,6 +851,13 @@ static const struct Curl_cwtype * const encodings[] = { NULL }; +/* supported content decoders only for transfer encodings */ +static const struct Curl_cwtype * const transfer_unencoders[] = { +#ifndef CURL_DISABLE_HTTP + &Curl_httpchunk_unencoder, +#endif + NULL +}; /* Provide a list of comma-separated names of supported encodings. */ @@ -861,7 +871,7 @@ void Curl_all_content_encodings(char *buf, size_t blen) DEBUGASSERT(blen); buf[0] = 0; - for(cep = encodings; *cep; cep++) { + for(cep = general_unencoders; *cep; cep++) { ce = *cep; if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) len += strlen(ce->name) + 2; @@ -873,7 +883,7 @@ void Curl_all_content_encodings(char *buf, size_t blen) } else if(blen > len) { char *p = buf; - for(cep = encodings; *cep; cep++) { + for(cep = general_unencoders; *cep; cep++) { ce = *cep; if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) { strcpy(p, ce->name); @@ -931,12 +941,23 @@ static const struct Curl_cwtype error_writer = { }; /* Find the content encoding by name. */ -static const struct Curl_cwtype *find_encoding(const char *name, - size_t len) +static const struct Curl_cwtype *find_unencode_writer(const char *name, + size_t len, + Curl_cwriter_phase phase) { const struct Curl_cwtype * const *cep; - for(cep = encodings; *cep; cep++) { + if(phase == CURL_CW_TRANSFER_DECODE) { + for(cep = transfer_unencoders; *cep; cep++) { + const struct Curl_cwtype *ce = *cep; + if((strncasecompare(name, ce->name, len) && !ce->name[len]) || + (ce->alias && strncasecompare(name, ce->alias, len) + && !ce->alias[len])) + return ce; + } + } + /* look among the general decoders */ + for(cep = general_unencoders; *cep; cep++) { const struct Curl_cwtype *ce = *cep; if((strncasecompare(name, ce->name, len) && !ce->name[len]) || (ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len])) @@ -950,7 +971,6 @@ static const struct Curl_cwtype *find_encoding(const char *name, CURLcode Curl_build_unencoding_stack(struct Curl_easy *data, const char *enclist, int is_transfer) { - struct SingleRequest *k = &data->req; Curl_cwriter_phase phase = is_transfer? CURL_CW_TRANSFER_DECODE:CURL_CW_CONTENT_DECODE; CURLcode result; @@ -969,16 +989,14 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data, if(!ISSPACE(*enclist)) namelen = enclist - name + 1; - /* Special case: chunked encoding is handled at the reader level. */ - if(is_transfer && namelen == 7 && strncasecompare(name, "chunked", 7)) { - k->chunk = TRUE; /* chunks coming our way. */ - Curl_httpchunk_init(data); /* init our chunky engine. */ - } - else if(namelen) { + if(namelen) { const struct Curl_cwtype *cwt; struct Curl_cwriter *writer; - if((is_transfer && !data->set.http_transfer_encoding) || + /* if we skip the decoding in this phase, do not look further. + * Exception is "chunked" transfer-encoding which always must happen */ + if((is_transfer && !data->set.http_transfer_encoding && + (namelen != 7 || !strncasecompare(name, "chunked", 7))) || (!is_transfer && data->set.http_ce_skip)) { /* not requested, ignore */ return CURLE_OK; @@ -990,7 +1008,7 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data, return CURLE_BAD_CONTENT_ENCODING; } - cwt = find_encoding(name, namelen); + cwt = find_unencode_writer(name, namelen, phase); if(!cwt) cwt = &error_writer; /* Defer error at use. */ diff --git a/lib/cookie.c b/lib/cookie.c index 9095cea3e..dc319b611 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -365,7 +365,7 @@ static void strstore(char **str, const char *newstr, size_t len) DEBUGASSERT(newstr); DEBUGASSERT(str); free(*str); - *str = Curl_strndup(newstr, len); + *str = Curl_memdup0(newstr, len); } /* @@ -821,10 +821,8 @@ Curl_cookie_add(struct Curl_easy *data, endslash = memrchr(path, '/', (queryp - path)); if(endslash) { size_t pathlen = (endslash-path + 1); /* include end slash */ - co->path = malloc(pathlen + 1); /* one extra for the zero byte */ + co->path = Curl_memdup0(path, pathlen); if(co->path) { - memcpy(co->path, path, pathlen); - co->path[pathlen] = 0; /* null-terminate */ co->spath = sanitize_cookie_path(co->path); if(!co->spath) badcookie = TRUE; /* out of memory bad */ @@ -927,7 +925,7 @@ Curl_cookie_add(struct Curl_easy *data, if(!co->spath) badcookie = TRUE; fields++; /* add a field and fall down to secure */ - /* FALLTHROUGH */ + FALLTHROUGH(); case 3: co->secure = FALSE; if(strcasecompare(ptr, "TRUE")) { @@ -1229,7 +1227,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data, if(data) { FILE *fp = NULL; - if(file) { + if(file && *file) { if(!strcmp(file, "-")) fp = stdin; else { diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 339358ea3..937b93edb 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -298,12 +298,6 @@ /* if you have the GNU gssapi libraries */ #cmakedefine HAVE_GSSGNU 1 -/* if you have the Heimdal gssapi libraries */ -#cmakedefine HAVE_GSSHEIMDAL 1 - -/* if you have the MIT gssapi libraries */ -#cmakedefine HAVE_GSSMIT 1 - /* Define to 1 if you have the `idna_strerror' function. */ #cmakedefine HAVE_IDNA_STRERROR 1 @@ -599,18 +593,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UTIME_H 1 -/* Define to 1 if you have the windows.h header file. */ -#cmakedefine HAVE_WINDOWS_H 1 - -/* Define to 1 if you have the winsock2.h header file. */ -#cmakedefine HAVE_WINSOCK2_H 1 - /* Define this symbol if your OS supports changing the contents of argv */ #cmakedefine HAVE_WRITABLE_ARGV 1 -/* Define to 1 if you have the ws2tcpip.h header file. */ -#cmakedefine HAVE_WS2TCPIP_H 1 - /* Define to 1 if you need the lber.h header file even with ldap.h */ #cmakedefine NEED_LBER_H 1 @@ -713,9 +698,6 @@ ${SIZEOF_TIME_T_CODE} /* if libPSL is in use */ #cmakedefine USE_LIBPSL 1 -/* If you want to build curl with the built-in manual */ -#cmakedefine USE_MANUAL 1 - /* if you want to use OpenLDAP code instead of legacy ldap implementation */ #cmakedefine USE_OPENLDAP 1 diff --git a/lib/curl_ntlm_wb.c b/lib/curl_ntlm_wb.c index b087a37a3..0c7892ab7 100644 --- a/lib/curl_ntlm_wb.c +++ b/lib/curl_ntlm_wb.c @@ -266,7 +266,7 @@ static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm, size_t len_in = strlen(input), len_out = 0; struct dynbuf b; char *ptr = NULL; - unsigned char *buf = (unsigned char *)data->state.buffer; + usigned char buf[1024] Curl_dyn_init(&b, MAX_NTLM_WB_RESPONSE); while(len_in > 0) { @@ -284,7 +284,7 @@ static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm, /* Read one line */ while(1) { ssize_t size = - wakeup_read(ntlm->ntlm_auth_hlpr_socket, buf, data->set.buffer_size); + wakeup_read(ntlm->ntlm_auth_hlpr_socket, buf, sizeof(buf)); if(size == -1) { if(errno == EINTR) continue; @@ -481,7 +481,7 @@ CURLcode Curl_output_ntlm_wb(struct Curl_easy *data, struct connectdata *conn, /* connection is already authenticated, * don't send a header in future requests */ *state = NTLMSTATE_LAST; - /* FALLTHROUGH */ + FALLTHROUGH(); case NTLMSTATE_LAST: Curl_safefree(*allocuserpwd); authp->done = TRUE; diff --git a/lib/curl_printf.h b/lib/curl_printf.h index 46ef344f7..c2457d2a6 100644 --- a/lib/curl_printf.h +++ b/lib/curl_printf.h @@ -31,6 +31,10 @@ #include +#define MERR_OK 0 +#define MERR_MEM 1 +#define MERR_TOO_LARGE 2 + # undef printf # undef fprintf # undef msnprintf diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index f7cf54e88..147b12a3f 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -79,7 +79,7 @@ const struct Curl_handler Curl_handler_rtmp = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMP, /* defport */ @@ -102,7 +102,7 @@ const struct Curl_handler Curl_handler_rtmpt = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMPT, /* defport */ @@ -125,7 +125,7 @@ const struct Curl_handler Curl_handler_rtmpe = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMP, /* defport */ @@ -148,7 +148,7 @@ const struct Curl_handler Curl_handler_rtmpte = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMPT, /* defport */ @@ -171,7 +171,7 @@ const struct Curl_handler Curl_handler_rtmps = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMPS, /* defport */ @@ -194,7 +194,7 @@ const struct Curl_handler Curl_handler_rtmpts = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtmp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTMPS, /* defport */ diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index 78ad298f2..66639cbac 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -205,18 +205,23 @@ void Curl_sasl_init(struct SASL *sasl, struct Curl_easy *data, sasl->force_ir = FALSE; /* Respect external option */ if(auth != CURLAUTH_BASIC) { - sasl->resetprefs = FALSE; - sasl->prefmech = SASL_AUTH_NONE; + unsigned short mechs = SASL_AUTH_NONE; + + /* If some usable http authentication options have been set, determine + new defaults from them. */ if(auth & CURLAUTH_BASIC) - sasl->prefmech |= SASL_MECH_PLAIN | SASL_MECH_LOGIN; + mechs |= SASL_MECH_PLAIN | SASL_MECH_LOGIN; if(auth & CURLAUTH_DIGEST) - sasl->prefmech |= SASL_MECH_DIGEST_MD5; + mechs |= SASL_MECH_DIGEST_MD5; if(auth & CURLAUTH_NTLM) - sasl->prefmech |= SASL_MECH_NTLM; + mechs |= SASL_MECH_NTLM; if(auth & CURLAUTH_BEARER) - sasl->prefmech |= SASL_MECH_OAUTHBEARER | SASL_MECH_XOAUTH2; + mechs |= SASL_MECH_OAUTHBEARER | SASL_MECH_XOAUTH2; if(auth & CURLAUTH_GSSAPI) - sasl->prefmech |= SASL_MECH_GSSAPI; + mechs |= SASL_MECH_GSSAPI; + + if(mechs != SASL_AUTH_NONE) + sasl->prefmech = mechs; } } diff --git a/lib/curl_setup.h b/lib/curl_setup.h index a08784140..703e903fa 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -28,6 +28,13 @@ #define CURL_NO_OLDIES #endif +/* FIXME: Delete this once the warnings have been fixed. */ +#if !defined(CURL_WARN_SIGN_CONVERSION) +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +#endif + /* Set default _WIN32_WINNT */ #ifdef __MINGW32__ #include <_mingw.h> @@ -253,12 +260,39 @@ * Windows setup file includes some system headers. */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # include "setup-win32.h" #endif #include +/* curl uses its own printf() function internally. It understands the GNU + * format. Use this format, so that is matches the GNU format attribute we + * use with the mingw compiler, allowing it to verify them at compile-time. + */ +#ifdef __MINGW32__ +# undef CURL_FORMAT_CURL_OFF_T +# undef CURL_FORMAT_CURL_OFF_TU +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +#endif + +/* based on logic in "curl/mprintf.h" */ + +#if (defined(__GNUC__) || defined(__clang__)) && \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(CURL_NO_FMT_CHECKS) +#if defined(__MINGW32__) && !defined(__clang__) +#define CURL_PRINTF(fmt, arg) \ + __attribute__((format(gnu_printf, fmt, arg))) +#else +#define CURL_PRINTF(fmt, arg) \ + __attribute__((format(__printf__, fmt, arg))) +#endif +#else +#define CURL_PRINTF(fmt, arg) +#endif + /* * Use getaddrinfo to resolve the IPv4 address literal. If the current network * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64, @@ -408,6 +442,24 @@ #define SIZEOF_TIME_T 4 #endif +#ifndef SIZEOF_CURL_SOCKET_T +/* configure and cmake check and set the define */ +# ifdef _WIN64 +# define SIZEOF_CURL_SOCKET_T 8 +# else +/* default guess */ +# define SIZEOF_CURL_SOCKET_T 4 +# endif +#endif + +#if SIZEOF_CURL_SOCKET_T < 8 +# define CURL_FORMAT_SOCKET_T "d" +#elif defined(__MINGW32__) +# define CURL_FORMAT_SOCKET_T "zd" +#else +# define CURL_FORMAT_SOCKET_T "qd" +#endif + /* * Default sizeof(off_t) in case it hasn't been defined in config file. */ @@ -648,6 +700,17 @@ #endif #endif +/* fallthrough attribute */ + +#if !defined(FALLTHROUGH) +#if (defined(__GNUC__) && __GNUC__ >= 7) || \ + (defined(__clang__) && __clang_major__ >= 10) +# define FALLTHROUGH() __attribute__((fallthrough)) +#else +# define FALLTHROUGH() do {} while (0) +#endif +#endif + /* * Include macros and defines that should only be processed once. */ @@ -669,10 +732,7 @@ */ #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H) -# if defined(SOCKET) || \ - defined(USE_WINSOCK) || \ - defined(HAVE_WINSOCK2_H) || \ - defined(HAVE_WS2TCPIP_H) +# if defined(SOCKET) || defined(USE_WINSOCK) # error "WinSock and lwIP TCP/IP stack definitions shall not coexist!" # endif #endif @@ -767,7 +827,13 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, #endif #if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \ + (defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \ defined(USE_QUICHE) || defined(USE_MSH3) + +#ifdef CURL_WITH_MULTI_SSL +#error "Multi-SSL combined with QUIC is not supported" +#endif + #define ENABLE_QUIC #define USE_HTTP3 #endif diff --git a/lib/curl_trc.c b/lib/curl_trc.c index 0ebe40b8f..b8dccc419 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -157,8 +157,10 @@ static struct Curl_cftype *cf_types[] = { #endif #ifdef USE_SSL &Curl_cft_ssl, +#ifndef CURL_DISABLE_PROXY &Curl_cft_ssl_proxy, #endif +#endif #if !defined(CURL_DISABLE_PROXY) #if !defined(CURL_DISABLE_HTTP) &Curl_cft_h1_proxy, diff --git a/lib/curl_trc.h b/lib/curl_trc.h index ade9108ac..3a5387a27 100644 --- a/lib/curl_trc.h +++ b/lib/curl_trc.h @@ -58,14 +58,7 @@ void Curl_debug(struct Curl_easy *data, curl_infotype type, * Output a failure message on registered callbacks for transfer. */ void Curl_failf(struct Curl_easy *data, -#if defined(__GNUC__) && !defined(printf) && \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__MINGW32__) - const char *fmt, ...) - __attribute__((format(printf, 2, 3))); -#else - const char *fmt, ...); -#endif + const char *fmt, ...) CURL_PRINTF(2, 3); #define failf Curl_failf @@ -102,26 +95,14 @@ void Curl_failf(struct Curl_easy *data, * Output an informational message when transfer's verbose logging is enabled. */ void Curl_infof(struct Curl_easy *data, -#if defined(__GNUC__) && !defined(printf) && defined(CURL_HAVE_C99) && \ - !defined(__MINGW32__) - const char *fmt, ...) - __attribute__((format(printf, 2, 3))); -#else - const char *fmt, ...); -#endif + const char *fmt, ...) CURL_PRINTF(2, 3); /** * Output an informational message when both transfer's verbose logging * and connection filters verbose logging are enabled. */ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf, -#if defined(__GNUC__) && !defined(printf) && defined(CURL_HAVE_C99) && \ - !defined(__MINGW32__) - const char *fmt, ...) - __attribute__((format(printf, 3, 4))); -#else - const char *fmt, ...); -#endif + const char *fmt, ...) CURL_PRINTF(3, 4); #else /* defined(CURL_DISABLE_VERBOSE_STRINGS) */ /* All informational messages are not compiled in for size savings */ diff --git a/lib/dict.c b/lib/dict.c index 3172b3829..323984822 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -89,7 +89,7 @@ const struct Curl_handler Curl_handler_dict = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_DICT, /* defport */ @@ -122,6 +122,9 @@ static char *unescape_word(const char *input) } /* sendf() sends formatted data to the server */ +static CURLcode sendf(curl_socket_t sockfd, struct Curl_easy *data, + const char *fmt, ...) CURL_PRINTF(3, 4); + static CURLcode sendf(curl_socket_t sockfd, struct Curl_easy *data, const char *fmt, ...) { diff --git a/lib/doh.c b/lib/doh.c index 1d928e92c..ef32d507d 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -218,7 +218,6 @@ static CURLcode dohprobe(struct Curl_easy *data, struct curl_slist *headers) { struct Curl_easy *doh = NULL; - char *nurl = NULL; CURLcode result = CURLE_OK; timediff_t timeout_ms; DOHcode d = doh_encode(host, dnstype, p->dohbuffer, sizeof(p->dohbuffer), @@ -351,11 +350,9 @@ static CURLcode dohprobe(struct Curl_easy *data, } else goto error; - free(nurl); return CURLE_OK; error: - free(nurl); Curl_close(&doh); return result; } @@ -447,7 +444,7 @@ static DOHcode skipqname(const unsigned char *doh, size_t dohlen, return DOH_DNS_BAD_LABEL; if(dohlen < (*indexp + 1 + length)) return DOH_DNS_OUT_OF_RANGE; - *indexp += 1 + length; + *indexp += (unsigned int)(1 + length); } while(length); return DOH_OK; } @@ -459,14 +456,15 @@ static unsigned short get16bit(const unsigned char *doh, int index) static unsigned int get32bit(const unsigned char *doh, int index) { - /* make clang and gcc optimize this to bswap by incrementing - the pointer first. */ - doh += index; - - /* avoid undefined behavior by casting to unsigned before shifting - 24 bits, possibly into the sign bit. codegen is same, but - ub sanitizer won't be upset */ - return ( (unsigned)doh[0] << 24) | (doh[1] << 16) |(doh[2] << 8) | doh[3]; + /* make clang and gcc optimize this to bswap by incrementing + the pointer first. */ + doh += index; + + /* avoid undefined behavior by casting to unsigned before shifting + 24 bits, possibly into the sign bit. codegen is same, but + ub sanitizer won't be upset */ + return ((unsigned)doh[0] << 24) | ((unsigned)doh[1] << 16) | + ((unsigned)doh[2] << 8) | doh[3]; } static DOHcode store_a(const unsigned char *doh, int index, struct dohentry *d) @@ -904,7 +902,6 @@ UNITTEST void de_cleanup(struct dohentry *d) CURLcode Curl_doh_is_resolved(struct Curl_easy *data, struct Curl_dns_entry **dnsp) { - struct connectdata *conn = data->conn; CURLcode result; struct dohdata *dohp = data->req.doh; *dnsp = NULL; /* defaults to no response */ @@ -913,7 +910,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, if(!dohp->probe[DOH_PROBE_SLOT_IPADDR_V4].easy && !dohp->probe[DOH_PROBE_SLOT_IPADDR_V6].easy) { - failf(data, "Could not DoH-resolve: %s", conn->resolve_async.hostname); + failf(data, "Could not DoH-resolve: %s", data->state.async.hostname); return CONN_IS_PROXIED(data->conn)?CURLE_COULDNT_RESOLVE_PROXY: CURLE_COULDNT_RESOLVE_HOST; } @@ -976,7 +973,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, Curl_freeaddrinfo(ai); } else { - conn->resolve_async.dns = dns; + data->state.async.dns = dns; *dnsp = dns; result = CURLE_OK; /* address resolution OK */ } diff --git a/lib/dynbuf.c b/lib/dynbuf.c index 2973d8da2..a4c599d10 100644 --- a/lib/dynbuf.c +++ b/lib/dynbuf.c @@ -81,7 +81,7 @@ static CURLcode dyn_nappend(struct dynbuf *s, if(fit > s->toobig) { Curl_dyn_free(s); - return CURLE_OUT_OF_MEMORY; + return CURLE_TOO_LARGE; } else if(!a) { DEBUGASSERT(!indx); @@ -199,6 +199,9 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) if(!rc) return CURLE_OK; + else if(rc == MERR_TOO_LARGE) + return CURLE_TOO_LARGE; + return CURLE_OUT_OF_MEMORY; #else char *str; str = vaprintf(fmt, ap); /* this allocs a new string to append */ @@ -210,8 +213,8 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) } /* If we failed, we cleanup the whole buffer and return error */ Curl_dyn_free(s); + return CURLE_OK; #endif - return CURLE_OUT_OF_MEMORY; } /* diff --git a/lib/dynbuf.h b/lib/dynbuf.h index 31a913019..7dbaab886 100644 --- a/lib/dynbuf.h +++ b/lib/dynbuf.h @@ -61,9 +61,9 @@ CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len) CURLcode Curl_dyn_add(struct dynbuf *s, const char *str) WARN_UNUSED_RESULT; CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...) - WARN_UNUSED_RESULT; + WARN_UNUSED_RESULT CURL_PRINTF(2, 3); CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) - WARN_UNUSED_RESULT; + WARN_UNUSED_RESULT CURL_PRINTF(2, 0); void Curl_dyn_reset(struct dynbuf *s); CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail); CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t set); diff --git a/lib/easy.c b/lib/easy.c index 322d1a41b..067b6d7b6 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -480,13 +480,15 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */ ev->list = nxt; free(m); m = nxt; - infof(easy, "socket cb: socket %d REMOVED", s); + infof(easy, "socket cb: socket %" CURL_FORMAT_SOCKET_T + " REMOVED", s); } else { /* The socket 's' is already being monitored, update the activity mask. Convert from libcurl bitmask to the poll one. */ m->socket.events = socketcb2poll(what); - infof(easy, "socket cb: socket %d UPDATED as %s%s", s, + infof(easy, "socket cb: socket %" CURL_FORMAT_SOCKET_T + " UPDATED as %s%s", s, (what&CURL_POLL_IN)?"IN":"", (what&CURL_POLL_OUT)?"OUT":""); } @@ -510,7 +512,8 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */ m->socket.events = socketcb2poll(what); m->socket.revents = 0; ev->list = m; - infof(easy, "socket cb: socket %d ADDED as %s%s", s, + infof(easy, "socket cb: socket %" CURL_FORMAT_SOCKET_T + " ADDED as %s%s", s, (what&CURL_POLL_IN)?"IN":"", (what&CURL_POLL_OUT)?"OUT":""); } @@ -599,8 +602,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) if(fds[i].revents) { /* socket activity, tell libcurl */ int act = poll2cselect(fds[i].revents); /* convert */ - infof(multi->easyp, "call curl_multi_socket_action(socket %d)", - fds[i].fd); + infof(multi->easyp, + "call curl_multi_socket_action(socket " + "%" CURL_FORMAT_SOCKET_T ")", fds[i].fd); mcode = curl_multi_socket_action(multi, fds[i].fd, act, &ev->running_handles); } @@ -684,9 +688,9 @@ static CURLcode easy_transfer(struct Curl_multi *multi) /* Make sure to return some kind of error if there was a multi problem */ if(mcode) { result = (mcode == CURLM_OUT_OF_MEMORY) ? CURLE_OUT_OF_MEMORY : - /* The other multi errors should never happen, so return - something suitably generic */ - CURLE_BAD_FUNCTION_ARGUMENT; + /* The other multi errors should never happen, so return + something suitably generic */ + CURLE_BAD_FUNCTION_ARGUMENT; } return result; @@ -973,6 +977,36 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) } #endif +#ifdef CURLRES_ASYNCH + /* Clone the resolver handle, if present, for the new handle */ + if(Curl_resolver_duphandle(outcurl, + &outcurl->state.async.resolver, + data->state.async.resolver)) + goto fail; +#endif + +#ifdef USE_ARES + { + CURLcode rc; + + rc = Curl_set_dns_servers(outcurl, data->set.str[STRING_DNS_SERVERS]); + if(rc && rc != CURLE_NOT_BUILT_IN) + goto fail; + + rc = Curl_set_dns_interface(outcurl, data->set.str[STRING_DNS_INTERFACE]); + if(rc && rc != CURLE_NOT_BUILT_IN) + goto fail; + + rc = Curl_set_dns_local_ip4(outcurl, data->set.str[STRING_DNS_LOCAL_IP4]); + if(rc && rc != CURLE_NOT_BUILT_IN) + goto fail; + + rc = Curl_set_dns_local_ip6(outcurl, data->set.str[STRING_DNS_LOCAL_IP6]); + if(rc && rc != CURLE_NOT_BUILT_IN) + goto fail; + } +#endif /* USE_ARES */ + Curl_initinfo(outcurl); outcurl->magic = CURLEASY_MAGIC_NUMBER; @@ -1111,7 +1145,7 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action) if(!data->state.tempcount) /* if not pausing again, force a recv/send check of this connection as the data might've been read off the socket already */ - data->conn->cselect_bits = CURL_CSELECT_IN | CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_IN | CURL_CSELECT_OUT; if(data->multi) { if(Curl_update_timer(data->multi)) return CURLE_ABORTED_BY_CALLBACK; diff --git a/lib/easyoptions.c b/lib/easyoptions.c index e69c658b0..da4c6111a 100644 --- a/lib/easyoptions.c +++ b/lib/easyoptions.c @@ -274,6 +274,8 @@ struct curl_easyoption Curl_easyopts[] = { {"SEEKFUNCTION", CURLOPT_SEEKFUNCTION, CURLOT_FUNCTION, 0}, {"SERVER_RESPONSE_TIMEOUT", CURLOPT_SERVER_RESPONSE_TIMEOUT, CURLOT_LONG, 0}, + {"SERVER_RESPONSE_TIMEOUT_MS", CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, + CURLOT_LONG, 0}, {"SERVICE_NAME", CURLOPT_SERVICE_NAME, CURLOT_STRING, 0}, {"SHARE", CURLOPT_SHARE, CURLOT_OBJECT, 0}, {"SOCKOPTDATA", CURLOPT_SOCKOPTDATA, CURLOT_CBPTR, 0}, @@ -373,6 +375,6 @@ struct curl_easyoption Curl_easyopts[] = { */ int Curl_easyopts_check(void) { - return ((CURLOPT_LASTENTRY%10000) != (323 + 1)); + return ((CURLOPT_LASTENTRY%10000) != (324 + 1)); } #endif diff --git a/lib/file.c b/lib/file.c index c98507137..b7ce3a8ed 100644 --- a/lib/file.c +++ b/lib/file.c @@ -113,7 +113,7 @@ const struct Curl_handler Curl_handler_file = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ file_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ 0, /* defport */ @@ -290,16 +290,15 @@ static CURLcode file_upload(struct Curl_easy *data) int fd; int mode; CURLcode result = CURLE_OK; - char *buf = data->state.buffer; + char buffer[8*1024], *uphere_save; curl_off_t bytecount = 0; struct_stat file_stat; - const char *buf2; + const char *sendbuf; /* * Since FILE: doesn't do the full init, we need to provide some extra * assignments here. */ - data->req.upload_fromhere = buf; if(!dir) return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ @@ -338,11 +337,15 @@ static CURLcode file_upload(struct Curl_easy *data) data->state.resume_from = (curl_off_t)file_stat.st_size; } + /* Yikes! Curl_fillreadbuffer uses data->req.upload_fromhere to READ + * client data to! Please, someone fix... */ + uphere_save = data->req.upload_fromhere; while(!result) { size_t nread; ssize_t nwrite; size_t readcount; - result = Curl_fillreadbuffer(data, data->set.buffer_size, &readcount); + data->req.upload_fromhere = buffer; + result = Curl_fillreadbuffer(data, sizeof(buffer), &readcount); if(result) break; @@ -356,19 +359,19 @@ static CURLcode file_upload(struct Curl_easy *data) if((curl_off_t)nread <= data->state.resume_from) { data->state.resume_from -= nread; nread = 0; - buf2 = buf; + sendbuf = buffer; } else { - buf2 = buf + data->state.resume_from; + sendbuf = buffer + data->state.resume_from; nread -= (size_t)data->state.resume_from; data->state.resume_from = 0; } } else - buf2 = buf; + sendbuf = buffer; /* write the data to the target */ - nwrite = write(fd, buf2, nread); + nwrite = write(fd, sendbuf, nread); if((size_t)nwrite != nread) { result = CURLE_SEND_ERROR; break; @@ -387,6 +390,7 @@ static CURLcode file_upload(struct Curl_easy *data) result = CURLE_ABORTED_BY_CALLBACK; close(fd); + data->req.upload_fromhere = uphere_save; return result; } @@ -413,14 +417,11 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) curl_off_t expected_size = -1; bool size_known; bool fstated = FALSE; - char *buf = data->state.buffer; int fd; struct FILEPROTO *file; *done = TRUE; /* unconditionally */ - Curl_pgrsStartNow(data); - if(data->state.upload) return file_upload(data); @@ -543,21 +544,22 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) Curl_pgrsTime(data, TIMER_STARTTRANSFER); while(!result) { + char tmpbuf[8*1024]; ssize_t nread; /* Don't fill a whole buffer if we want less than all data */ size_t bytestoread; if(size_known) { - bytestoread = (expected_size < data->set.buffer_size) ? - curlx_sotouz(expected_size) : (size_t)data->set.buffer_size; + bytestoread = (expected_size < (curl_off_t)(sizeof(tmpbuf)-1)) ? + curlx_sotouz(expected_size) : (sizeof(tmpbuf)-1); } else - bytestoread = data->set.buffer_size-1; + bytestoread = sizeof(tmpbuf)-1; - nread = read(fd, buf, bytestoread); + nread = read(fd, tmpbuf, bytestoread); if(nread > 0) - buf[nread] = 0; + tmpbuf[nread] = 0; if(nread <= 0 || (size_known && (expected_size == 0))) break; @@ -565,7 +567,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) if(size_known) expected_size -= nread; - result = Curl_client_write(data, CLIENTWRITE_BODY, buf, nread); + result = Curl_client_write(data, CLIENTWRITE_BODY, tmpbuf, nread); if(result) return result; diff --git a/lib/formdata.c b/lib/formdata.c index 05dc9b53d..d6a1697aa 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -277,7 +277,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, case CURLFORM_PTRNAME: current_form->flags |= HTTPPOST_PTRNAME; /* fall through */ - /* FALLTHROUGH */ + FALLTHROUGH(); case CURLFORM_COPYNAME: if(current_form->name) return_value = CURL_FORMADD_OPTION_TWICE; @@ -303,7 +303,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, */ case CURLFORM_PTRCONTENTS: current_form->flags |= HTTPPOST_PTRCONTENTS; - /* FALLTHROUGH */ + FALLTHROUGH(); case CURLFORM_COPYCONTENTS: if(current_form->value) return_value = CURL_FORMADD_OPTION_TWICE; @@ -603,7 +603,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, app passed in a bad combo, so we better check for that first. */ if(form->name) { /* copy name (without strdup; possibly not null-terminated) */ - form->name = Curl_strndup(form->name, form->namelength? + form->name = Curl_memdup0(form->name, form->namelength? form->namelength: strlen(form->name)); } @@ -779,11 +779,9 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len) if(!name || !len) return curl_mime_name(part, name); - zname = malloc(len + 1); + zname = Curl_memdup0(name, len); if(!zname) return CURLE_OUT_OF_MEMORY; - memcpy(zname, name, len); - zname[len] = '\0'; res = curl_mime_name(part, zname); free(zname); return res; diff --git a/lib/ftp.c b/lib/ftp.c index a8dcedf53..f62108234 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -72,6 +72,7 @@ #include "warnless.h" #include "http_proxy.h" #include "socks.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" @@ -167,7 +168,7 @@ const struct Curl_handler Curl_handler_ftp = { ftp_domore_getsock, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_FTP, /* defport */ @@ -198,7 +199,7 @@ const struct Curl_handler Curl_handler_ftps = { ftp_domore_getsock, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_FTPS, /* defport */ @@ -362,10 +363,11 @@ static CURLcode ReceivedServerConnect(struct Curl_easy *data, bool *received) curl_socket_t data_sock = conn->sock[SECONDARYSOCKET]; struct ftp_conn *ftpc = &conn->proto.ftpc; struct pingpong *pp = &ftpc->pp; - int result; + int socketstate = 0; timediff_t timeout_ms; ssize_t nread; int ftpcode; + bool response = FALSE; *received = FALSE; @@ -378,17 +380,21 @@ static CURLcode ReceivedServerConnect(struct Curl_easy *data, bool *received) } /* First check whether there is a cached response from server */ - if(pp->cache_size && pp->cache && pp->cache[0] > '3') { + if(Curl_dyn_len(&pp->recvbuf) && (*Curl_dyn_ptr(&pp->recvbuf) > '3')) { /* Data connection could not be established, let's return */ infof(data, "There is negative response in cache while serv connect"); (void)Curl_GetFTPResponse(data, &nread, &ftpcode); return CURLE_FTP_ACCEPT_FAILED; } - result = Curl_socket_check(ctrl_sock, data_sock, CURL_SOCKET_BAD, 0); + if(pp->overflow) + /* there is pending control data still in the buffer to read */ + response = TRUE; + else + socketstate = Curl_socket_check(ctrl_sock, data_sock, CURL_SOCKET_BAD, 0); /* see if the connection request is already here */ - switch(result) { + switch(socketstate) { case -1: /* error */ /* let's die here */ failf(data, "Error while waiting for server connect"); @@ -396,23 +402,23 @@ static CURLcode ReceivedServerConnect(struct Curl_easy *data, bool *received) case 0: /* Server connect is not received yet */ break; /* loop */ default: - - if(result & CURL_CSELECT_IN2) { + if(socketstate & CURL_CSELECT_IN2) { infof(data, "Ready to accept data connection from server"); *received = TRUE; } - else if(result & CURL_CSELECT_IN) { - infof(data, "Ctrl conn has data while waiting for data conn"); - (void)Curl_GetFTPResponse(data, &nread, &ftpcode); - - if(ftpcode/100 > 3) - return CURLE_FTP_ACCEPT_FAILED; + else if(socketstate & CURL_CSELECT_IN) + response = TRUE; + break; + } + if(response) { + infof(data, "Ctrl conn has data while waiting for data conn"); + (void)Curl_GetFTPResponse(data, &nread, &ftpcode); - return CURLE_WEIRD_SERVER_REPLY; - } + if(ftpcode/100 > 3) + return CURLE_FTP_ACCEPT_FAILED; - break; - } /* switch() */ + return CURLE_WEIRD_SERVER_REPLY; + } return CURLE_OK; } @@ -553,7 +559,7 @@ static CURLcode ftp_readresp(struct Curl_easy *data, #ifdef HAVE_GSSAPI { struct connectdata *conn = data->conn; - char * const buf = data->state.buffer; + char * const buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf); /* handle the security-oriented responses 6xx ***/ switch(code) { @@ -659,7 +665,7 @@ CURLcode Curl_GetFTPResponse(struct Curl_easy *data, * */ - if(pp->cache && (cache_skip < 2)) { + if(Curl_dyn_len(&pp->recvbuf) && (cache_skip < 2)) { /* * There's a cache left since before. We then skipping the wait for * socket action, unless this is the same cache like the previous round @@ -687,7 +693,7 @@ CURLcode Curl_GetFTPResponse(struct Curl_easy *data, if(result) break; - if(!nread && pp->cache) + if(!nread && Curl_dyn_len(&pp->recvbuf)) /* bump cache skip counter as on repeated skips we must wait for more data */ cache_skip++; @@ -926,6 +932,8 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, bool possibly_non_local = TRUE; char buffer[STRERROR_LEN]; char *addr = NULL; + size_t addrlen = 0; + char ipstr[50]; /* Step 1, figure out what is requested, * accepted format : @@ -934,32 +942,17 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, if(data->set.str[STRING_FTPPORT] && (strlen(data->set.str[STRING_FTPPORT]) > 1)) { - -#ifdef ENABLE_IPV6 - size_t addrlen = INET6_ADDRSTRLEN > strlen(string_ftpport) ? - INET6_ADDRSTRLEN : strlen(string_ftpport); -#else - size_t addrlen = INET_ADDRSTRLEN > strlen(string_ftpport) ? - INET_ADDRSTRLEN : strlen(string_ftpport); -#endif - char *ip_start = string_ftpport; char *ip_end = NULL; - char *port_start = NULL; - char *port_sep = NULL; - - addr = calloc(1, addrlen + 1); - if(!addr) { - result = CURLE_OUT_OF_MEMORY; - goto out; - } #ifdef ENABLE_IPV6 if(*string_ftpport == '[') { /* [ipv6]:port(-range) */ - ip_start = string_ftpport + 1; - ip_end = strchr(string_ftpport, ']'); - if(ip_end) - strncpy(addr, ip_start, ip_end - ip_start); + char *ip_start = string_ftpport + 1; + ip_end = strchr(ip_start, ']'); + if(ip_end) { + addrlen = ip_end - ip_start; + addr = ip_start; + } } else #endif @@ -969,28 +962,27 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, } else { ip_end = strchr(string_ftpport, ':'); + addr = string_ftpport; if(ip_end) { /* either ipv6 or (ipv4|domain|interface):port(-range) */ + addrlen = ip_end - string_ftpport; #ifdef ENABLE_IPV6 if(Curl_inet_pton(AF_INET6, string_ftpport, &sa6->sin6_addr) == 1) { /* ipv6 */ port_min = port_max = 0; - strcpy(addr, string_ftpport); ip_end = NULL; /* this got no port ! */ } - else #endif - /* (ipv4|domain|interface):port(-range) */ - strncpy(addr, string_ftpport, ip_end - ip_start); } else /* ipv4|interface */ - strcpy(addr, string_ftpport); + addrlen = strlen(string_ftpport); } /* parse the port */ if(ip_end) { - port_start = strchr(ip_end, ':'); + char *port_sep = NULL; + char *port_start = strchr(ip_end, ':'); if(port_start) { port_min = curlx_ultous(strtoul(port_start + 1, NULL, 10)); port_sep = strchr(port_start, '-'); @@ -1011,22 +1003,29 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, if(port_min > port_max) port_min = port_max = 0; - if(*addr != '\0') { + if(addrlen) { + DEBUGASSERT(addr); + if(addrlen >= sizeof(ipstr)) + goto out; + memcpy(ipstr, addr, addrlen); + ipstr[addrlen] = 0; + /* attempt to get the address of the given interface name */ switch(Curl_if2ip(conn->remote_addr->family, #ifdef ENABLE_IPV6 Curl_ipv6_scope(&conn->remote_addr->sa_addr), conn->scope_id, #endif - addr, hbuf, sizeof(hbuf))) { + ipstr, hbuf, sizeof(hbuf))) { case IF2IP_NOT_FOUND: /* not an interface, use the given string as host name instead */ - host = addr; + host = ipstr; break; case IF2IP_AF_NOT_SUPPORTED: goto out; case IF2IP_FOUND: host = hbuf; /* use the hbuf for host name */ + break; } } else @@ -1266,7 +1265,6 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, } if(portsock != CURL_SOCKET_BAD) Curl_socket_close(data, conn, portsock); - free(addr); return result; } @@ -1589,13 +1587,14 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data, } /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ do { + char scratch[4*1024]; size_t readthisamountnow = - (data->state.resume_from - passed > data->set.buffer_size) ? - (size_t)data->set.buffer_size : + (data->state.resume_from - passed > (curl_off_t)sizeof(scratch)) ? + sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread = - data->state.fread_func(data->state.buffer, 1, readthisamountnow, + data->state.fread_func(scratch, 1, readthisamountnow, data->state.in); passed += actuallyread; @@ -1828,7 +1827,9 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, struct Curl_dns_entry *addr = NULL; enum resolve_t rc; unsigned short connectport; /* the local port connect() should use! */ - char *str = &data->state.buffer[4]; /* start on the first letter */ + struct pingpong *pp = &ftpc->pp; + char *str = + Curl_dyn_ptr(&pp->recvbuf) + 4; /* start on the first letter */ /* if we come here again, make sure the former name is cleared */ Curl_safefree(ftpc->newhost); @@ -2106,8 +2107,9 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data, /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the last .sss part is optional and means fractions of a second */ int year, month, day, hour, minute, second; - if(ftp_213_date(&data->state.buffer[4], - &year, &month, &day, &hour, &minute, &second)) { + struct pingpong *pp = &ftpc->pp; + char *resp = Curl_dyn_ptr(&pp->recvbuf) + 4; + if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) { /* we have a time, reformat it */ char timebuf[24]; msnprintf(timebuf, sizeof(timebuf), @@ -2318,7 +2320,8 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data, { CURLcode result = CURLE_OK; curl_off_t filesize = -1; - char *buf = data->state.buffer; + char *buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf); + size_t len = data->conn->proto.ftpc.pp.nfinal; /* get the size from the ascii string: */ if(ftpcode == 213) { @@ -2326,13 +2329,13 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data, for all the digits at the end of the response and parse only those as a number. */ char *start = &buf[4]; - char *fdigit = strchr(start, '\r'); + char *fdigit = memchr(start, '\r', len); if(fdigit) { - do + fdigit--; + if(*fdigit == '\n') + fdigit--; + while(ISDIGIT(fdigit[-1]) && (fdigit > start)) fdigit--; - while(ISDIGIT(*fdigit) && (fdigit > start)); - if(!ISDIGIT(*fdigit)) - fdigit++; } else fdigit = start; @@ -2501,7 +2504,7 @@ static CURLcode ftp_state_get_resp(struct Curl_easy *data, * * Example D above makes this parsing a little tricky */ char *bytes; - char *buf = data->state.buffer; + char *buf = Curl_dyn_ptr(&conn->proto.ftpc.pp.recvbuf); bytes = strstr(buf, " bytes"); if(bytes) { long in = (long)(--bytes-buf); @@ -2770,7 +2773,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, case FTP_AUTH: /* we have gotten the response to a previous AUTH command */ - if(pp->cache_size) + if(pp->overflow) return CURLE_WEIRD_SERVER_REPLY; /* Forbid pipelining in response. */ /* RFC2228 (page 5) says: @@ -2868,14 +2871,11 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, case FTP_PWD: if(ftpcode == 257) { - char *ptr = &data->state.buffer[4]; /* start on the first letter */ - const size_t buf_size = data->set.buffer_size; - char *dir; + char *ptr = Curl_dyn_ptr(&pp->recvbuf) + 4; /* start on the first + letter */ bool entry_extracted = FALSE; - - dir = malloc(nread + 1); - if(!dir) - return CURLE_OUT_OF_MEMORY; + struct dynbuf out; + Curl_dyn_init(&out, 1000); /* Reply format is like 257[rubbish]"" and the @@ -2887,33 +2887,30 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, */ /* scan for the first double-quote for non-standard responses */ - while(ptr < &data->state.buffer[buf_size] - && *ptr != '\n' && *ptr != '\0' && *ptr != '"') + while(*ptr != '\n' && *ptr != '\0' && *ptr != '"') ptr++; if('\"' == *ptr) { /* it started good */ - char *store; - ptr++; - for(store = dir; *ptr;) { + for(ptr++; *ptr; ptr++) { if('\"' == *ptr) { if('\"' == ptr[1]) { /* "quote-doubling" */ - *store = ptr[1]; + result = Curl_dyn_addn(&out, &ptr[1], 1); ptr++; } else { /* end of path */ - entry_extracted = TRUE; + if(Curl_dyn_len(&out)) + entry_extracted = TRUE; break; /* get out of this loop */ } } else - *store = *ptr; - store++; - ptr++; + result = Curl_dyn_addn(&out, ptr, 1); + if(result) + return result; } - *store = '\0'; /* null-terminate */ } if(entry_extracted) { /* If the path name does not look like an absolute path (i.e.: it @@ -2927,6 +2924,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, The method used here is to check the server OS: we do it only if the path name looks strange to minimize overhead on other systems. */ + char *dir = Curl_dyn_ptr(&out); if(!ftpc->server_os && dir[0] != '/') { result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SYST"); @@ -2951,7 +2949,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, } else { /* couldn't get the path */ - free(dir); + Curl_dyn_free(&out); infof(data, "Failed to figure out path"); } } @@ -2961,25 +2959,23 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, case FTP_SYST: if(ftpcode == 215) { - char *ptr = &data->state.buffer[4]; /* start on the first letter */ + char *ptr = Curl_dyn_ptr(&pp->recvbuf) + 4; /* start on the first + letter */ char *os; - char *store; - - os = malloc(nread + 1); - if(!os) - return CURLE_OUT_OF_MEMORY; + char *start; /* Reply format is like 215 */ while(*ptr == ' ') ptr++; - for(store = os; *ptr && *ptr != ' ';) - *store++ = *ptr++; - *store = '\0'; /* null-terminate */ + for(start = ptr; *ptr && *ptr != ' '; ptr++) + ; + os = Curl_memdup0(start, ptr - start); + if(!os) + return CURLE_OUT_OF_MEMORY; /* Check for special servers here. */ - if(strcasecompare(os, "OS/400")) { /* Force OS400 name format 1. */ result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SITE NAMEFMT 1"); @@ -3131,7 +3127,6 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, break; case FTP_QUIT: - /* fallthrough, just stop! */ default: /* internal error */ ftp_state(data, FTP_STOP); @@ -3206,8 +3201,7 @@ static CURLcode ftp_connect(struct Curl_easy *data, conn->bits.ftp_use_control_ssl = TRUE; } - Curl_pp_setup(pp); /* once per transfer */ - Curl_pp_init(data, pp); /* init the generic pingpong data */ + Curl_pp_init(pp); /* once per transfer */ /* When we connect, we start in the state where we await the 220 response */ @@ -3258,14 +3252,13 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status, case CURLE_REMOTE_FILE_NOT_FOUND: case CURLE_WRITE_ERROR: /* the connection stays alive fine even though this happened */ - /* fall-through */ case CURLE_OK: /* doesn't affect the control connection's status */ if(!premature) break; /* until we cope better with prematurely ended requests, let them * fallback as if in complete failure */ - /* FALLTHROUGH */ + FALLTHROUGH(); default: /* by default, an error means the control connection is wedged and should not be used anymore */ ftpc->ctl_valid = FALSE; @@ -4177,13 +4170,12 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data) return CURLE_OUT_OF_MEMORY; } - ftpc->dirs[0] = calloc(1, dirlen + 1); + ftpc->dirs[0] = Curl_memdup0(rawPath, dirlen); if(!ftpc->dirs[0]) { free(rawPath); return CURLE_OUT_OF_MEMORY; } - strncpy(ftpc->dirs[0], rawPath, dirlen); ftpc->dirdepth = 1; /* we consider it to be a single dir */ fileName = slashPos + 1; /* rest is file name */ } @@ -4222,12 +4214,11 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data) CWD requires a parameter and a non-existent parameter a) doesn't work on many servers and b) has no effect on the others. */ if(compLen > 0) { - char *comp = calloc(1, compLen + 1); + char *comp = Curl_memdup0(curPos, compLen); if(!comp) { free(rawPath); return CURLE_OUT_OF_MEMORY; } - strncpy(comp, curPos, compLen); ftpc->dirs[ftpc->dirdepth++] = comp; } curPos = slashPos + 1; diff --git a/lib/getinfo.c b/lib/getinfo.c index f1574e097..2f74629e1 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -409,6 +409,9 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, case CURLINFO_STARTTRANSFER_TIME_T: *param_offt = data->progress.t_starttransfer; break; + case CURLINFO_QUEUE_TIME_T: + *param_offt = data->progress.t_postqueue; + break; case CURLINFO_REDIRECT_TIME_T: *param_offt = data->progress.t_redirect; break; @@ -420,7 +423,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, break; case CURLINFO_CONN_ID: *param_offt = data->conn? - data->conn->connection_id : data->state.recent_conn_id; + data->conn->connection_id : data->state.recent_conn_id; break; default: return CURLE_UNKNOWN_OPTION; diff --git a/lib/gopher.c b/lib/gopher.c index 61e41b7e4..9ca08289e 100644 --- a/lib/gopher.c +++ b/lib/gopher.c @@ -75,7 +75,7 @@ const struct Curl_handler Curl_handler_gopher = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_GOPHER, /* defport */ @@ -99,7 +99,7 @@ const struct Curl_handler Curl_handler_gophers = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_GOPHER, /* defport */ diff --git a/lib/headers.c b/lib/headers.c index 3ff4d5eb0..8a3264ab5 100644 --- a/lib/headers.c +++ b/lib/headers.c @@ -185,7 +185,7 @@ struct curl_header *curl_easy_nextheader(CURL *easy, } static CURLcode namevalue(char *header, size_t hlen, unsigned int type, - char **name, char **value) + char **name, char **value) { char *end = header + hlen - 1; /* point to the last byte */ DEBUGASSERT(hlen); @@ -292,9 +292,10 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, if(!end) { end = strchr(header, '\n'); if(!end) - return CURLE_BAD_FUNCTION_ARGUMENT; + /* neither CR nor LF as terminator is not a valid header */ + return CURLE_WEIRD_SERVER_REPLY; } - hlen = end - header + 1; + hlen = end - header; if((header[0] == ' ') || (header[0] == '\t')) { if(data->state.prevhead) @@ -319,21 +320,19 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, hs->buffer[hlen] = 0; /* nul terminate */ result = namevalue(hs->buffer, hlen, type, &name, &value); - if(result) - goto fail; - - hs->name = name; - hs->value = value; - hs->type = type; - hs->request = data->state.requests; - - /* insert this node into the list of headers */ - Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail, - hs, &hs->node); - data->state.prevhead = hs; - return CURLE_OK; -fail: - free(hs); + if(!result) { + hs->name = name; + hs->value = value; + hs->type = type; + hs->request = data->state.requests; + + /* insert this node into the list of headers */ + Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail, + hs, &hs->node); + data->state.prevhead = hs; + } + else + free(hs); return result; } diff --git a/lib/hostasyn.c b/lib/hostasyn.c index faf01c5f4..2f6762ca4 100644 --- a/lib/hostasyn.c +++ b/lib/hostasyn.c @@ -67,11 +67,10 @@ CURLcode Curl_addrinfo_callback(struct Curl_easy *data, int status, struct Curl_addrinfo *ai) { - struct connectdata *conn = data->conn; struct Curl_dns_entry *dns = NULL; CURLcode result = CURLE_OK; - conn->resolve_async.status = status; + data->state.async.status = status; if(CURL_ASYNC_SUCCESS == status) { if(ai) { @@ -79,8 +78,8 @@ CURLcode Curl_addrinfo_callback(struct Curl_easy *data, Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); dns = Curl_cache_addr(data, ai, - conn->resolve_async.hostname, 0, - conn->resolve_async.port); + data->state.async.hostname, 0, + data->state.async.port); if(data->share) Curl_share_unlock(data, CURL_LOCK_DATA_DNS); @@ -95,12 +94,12 @@ CURLcode Curl_addrinfo_callback(struct Curl_easy *data, } } - conn->resolve_async.dns = dns; + data->state.async.dns = dns; /* Set async.done TRUE last in this function since it may be used multi- threaded and once this is TRUE the other thread may read fields from the async struct */ - conn->resolve_async.done = TRUE; + data->state.async.done = TRUE; /* IPv4: The input hostent struct will be freed by ares when we return from this function */ diff --git a/lib/hostip.c b/lib/hostip.c index e7c318af7..4f44d348f 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -741,7 +741,7 @@ enum resolve_t Curl_resolv(struct Curl_easy *data, Curl_set_in_callback(data, true); st = data->set.resolver_start( #ifdef USE_CURL_ASYNC - conn->resolve_async.resolver, + data->state.async.resolver, #else NULL, #endif @@ -754,16 +754,22 @@ enum resolve_t Curl_resolv(struct Curl_easy *data, #ifndef USE_RESOLVE_ON_IPS /* First check if this is an IPv4 address string */ - if(Curl_inet_pton(AF_INET, hostname, &in) > 0) + if(Curl_inet_pton(AF_INET, hostname, &in) > 0) { /* This is a dotted IP address 123.123.123.123-style */ addr = Curl_ip2addr(AF_INET, &in, hostname, port); + if(!addr) + return CURLRESOLV_ERROR; + } #ifdef ENABLE_IPV6 - if(!addr) { + else { struct in6_addr in6; /* check if this is an IPv6 address string */ - if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0) + if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0) { /* This is an IPv6 address literal */ addr = Curl_ip2addr(AF_INET6, &in6, hostname, port); + if(!addr) + return CURLRESOLV_ERROR; + } } #endif /* ENABLE_IPV6 */ @@ -1415,9 +1421,9 @@ CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_done) struct connectdata *conn = data->conn; #ifdef USE_CURL_ASYNC - if(conn->resolve_async.dns) { - conn->dns_entry = conn->resolve_async.dns; - conn->resolve_async.dns = NULL; + if(data->state.async.dns) { + conn->dns_entry = data->state.async.dns; + data->state.async.dns = NULL; } #endif @@ -1439,11 +1445,11 @@ CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_done) #ifdef USE_CURL_ASYNC CURLcode Curl_resolver_error(struct Curl_easy *data) { - struct connectdata *conn = data->conn; const char *host_or_proxy; CURLcode result; #ifndef CURL_DISABLE_PROXY + struct connectdata *conn = data->conn; if(conn->bits.httpproxy) { host_or_proxy = "proxy"; result = CURLE_COULDNT_RESOLVE_PROXY; @@ -1456,7 +1462,7 @@ CURLcode Curl_resolver_error(struct Curl_easy *data) } failf(data, "Could not resolve %s: %s", host_or_proxy, - conn->resolve_async.hostname); + data->state.async.hostname); return result; } diff --git a/lib/hsts.c b/lib/hsts.c index 9314be294..8725a35c1 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -117,8 +117,6 @@ static CURLcode hsts_create(struct hsts *h, bool subdomains, curl_off_t expires) { - struct stsentry *sts; - char *duphost; size_t hlen; DEBUGASSERT(h); DEBUGASSERT(hostname); @@ -127,24 +125,23 @@ static CURLcode hsts_create(struct hsts *h, if(hlen && (hostname[hlen - 1] == '.')) /* strip off any trailing dot */ --hlen; - if(!hlen) - /* no host name left */ - return CURLE_BAD_FUNCTION_ARGUMENT; - - sts = hsts_entry(); - if(!sts) - return CURLE_OUT_OF_MEMORY; + if(hlen) { + char *duphost; + struct stsentry *sts = hsts_entry(); + if(!sts) + return CURLE_OUT_OF_MEMORY; + + duphost = Curl_memdup0(hostname, hlen); + if(!duphost) { + free(sts); + return CURLE_OUT_OF_MEMORY; + } - duphost = Curl_strndup(hostname, hlen); - if(!duphost) { - free(sts); - return CURLE_OUT_OF_MEMORY; + sts->host = duphost; + sts->expires = expires; + sts->includeSubDomains = subdomains; + Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node); } - - sts->host = duphost; - sts->expires = expires; - sts->includeSubDomains = subdomains; - Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node); return CURLE_OK; } @@ -481,6 +478,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h) if(sc == CURLSTS_OK) { time_t expires; CURLcode result; + DEBUGASSERT(e.name[0]); if(!e.name[0]) /* bail out if no name was stored */ return CURLE_BAD_FUNCTION_ARGUMENT; diff --git a/lib/http.c b/lib/http.c index be6d442e8..679931e4b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -100,24 +100,14 @@ * Forward declarations. */ -static int http_getsock_do(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *socks); static bool http_should_fail(struct Curl_easy *data); -static CURLcode http_setup_conn(struct Curl_easy *data, - struct connectdata *conn); -#ifdef USE_WEBSOCKETS -static CURLcode ws_setup_conn(struct Curl_easy *data, - struct connectdata *conn); -#endif - /* * HTTP handler interface. */ const struct Curl_handler Curl_handler_http = { "HTTP", /* scheme */ - http_setup_conn, /* setup_connection */ + Curl_http_setup_conn, /* setup_connection */ Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ @@ -125,11 +115,11 @@ const struct Curl_handler Curl_handler_http = { ZERO_NULL, /* connecting */ ZERO_NULL, /* doing */ ZERO_NULL, /* proto_getsock */ - http_getsock_do, /* doing_getsock */ + Curl_http_getsock_do, /* doing_getsock */ ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + Curl_http_write_resp, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_HTTP, /* defport */ @@ -139,39 +129,13 @@ const struct Curl_handler Curl_handler_http = { PROTOPT_USERPWDCTRL }; -#ifdef USE_WEBSOCKETS -const struct Curl_handler Curl_handler_ws = { - "WS", /* scheme */ - ws_setup_conn, /* setup_connection */ - Curl_http, /* do_it */ - Curl_http_done, /* done */ - ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ - ZERO_NULL, /* connecting */ - ZERO_NULL, /* doing */ - ZERO_NULL, /* proto_getsock */ - http_getsock_do, /* doing_getsock */ - ZERO_NULL, /* domore_getsock */ - ZERO_NULL, /* perform_getsock */ - Curl_ws_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ - ZERO_NULL, /* connection_check */ - ZERO_NULL, /* attach connection */ - PORT_HTTP, /* defport */ - CURLPROTO_WS, /* protocol */ - CURLPROTO_HTTP, /* family */ - PROTOPT_CREDSPERREQUEST | /* flags */ - PROTOPT_USERPWDCTRL -}; -#endif - #ifdef USE_SSL /* * HTTPS handler interface. */ const struct Curl_handler Curl_handler_https = { "HTTPS", /* scheme */ - http_setup_conn, /* setup_connection */ + Curl_http_setup_conn, /* setup_connection */ Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ @@ -179,11 +143,11 @@ const struct Curl_handler Curl_handler_https = { NULL, /* connecting */ ZERO_NULL, /* doing */ NULL, /* proto_getsock */ - http_getsock_do, /* doing_getsock */ + Curl_http_getsock_do, /* doing_getsock */ ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + Curl_http_write_resp, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_HTTPS, /* defport */ @@ -193,36 +157,10 @@ const struct Curl_handler Curl_handler_https = { PROTOPT_USERPWDCTRL }; -#ifdef USE_WEBSOCKETS -const struct Curl_handler Curl_handler_wss = { - "WSS", /* scheme */ - ws_setup_conn, /* setup_connection */ - Curl_http, /* do_it */ - Curl_http_done, /* done */ - ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ - NULL, /* connecting */ - ZERO_NULL, /* doing */ - NULL, /* proto_getsock */ - http_getsock_do, /* doing_getsock */ - ZERO_NULL, /* domore_getsock */ - ZERO_NULL, /* perform_getsock */ - Curl_ws_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ - ZERO_NULL, /* connection_check */ - ZERO_NULL, /* attach connection */ - PORT_HTTPS, /* defport */ - CURLPROTO_WSS, /* protocol */ - CURLPROTO_HTTP, /* family */ - PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */ - PROTOPT_USERPWDCTRL -}; -#endif - #endif -static CURLcode http_setup_conn(struct Curl_easy *data, - struct connectdata *conn) +CURLcode Curl_http_setup_conn(struct Curl_easy *data, + struct connectdata *conn) { /* allocate the HTTP-specific struct for the Curl_easy, only to survive during this request */ @@ -245,16 +183,6 @@ static CURLcode http_setup_conn(struct Curl_easy *data, return CURLE_OK; } -#ifdef USE_WEBSOCKETS -static CURLcode ws_setup_conn(struct Curl_easy *data, - struct connectdata *conn) -{ - /* websockets is 1.1 only (for now) */ - data->state.httpwant = CURL_HTTP_VERSION_1_1; - return http_setup_conn(data, conn); -} -#endif - #ifndef CURL_DISABLE_PROXY /* * checkProxyHeaders() checks the linked list of custom proxy headers @@ -297,7 +225,6 @@ char *Curl_copy_header_value(const char *header) { const char *start; const char *end; - char *value; size_t len; /* Find the end of the header name */ @@ -330,14 +257,7 @@ char *Curl_copy_header_value(const char *header) /* get length of the type */ len = end - start + 1; - value = malloc(len + 1); - if(!value) - return NULL; - - memcpy(value, start, len); - value[len] = 0; /* null-terminate */ - - return value; + return Curl_memdup0(start, len); } #ifndef CURL_DISABLE_HTTP_AUTH @@ -1597,9 +1517,9 @@ CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) /* this returns the socket to wait for in the DO and DOING state for the multi interface and then we're always _sending_ a request and thus we wait for the single socket to become writable only */ -static int http_getsock_do(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *socks) +int Curl_http_getsock_do(struct Curl_easy *data, + struct connectdata *conn, + curl_socket_t *socks) { /* write mode */ (void)conn; @@ -2103,6 +2023,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data, switch(data->set.timecondition) { default: + DEBUGF(infof(data, "invalid time condition")); return CURLE_BAD_FUNCTION_ARGUMENT; case CURL_TIMECOND_IFMODSINCE: @@ -2271,7 +2192,7 @@ CURLcode Curl_http_host(struct Curl_easy *data, struct connectdata *conn) } #endif - if(strcmp("Host:", ptr)) { + if(!strcasecompare("Host:", ptr)) { aptr->host = aprintf("Host:%s\r\n", &ptr[5]); if(!aptr->host) return CURLE_OUT_OF_MEMORY; @@ -2359,9 +2280,7 @@ CURLcode Curl_http_target(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; } } - /* Extract the URL to use in the request. Store in STRING_TEMP_URL for - clean-up reasons if the function returns before the free() further - down. */ + /* Extract the URL to use in the request. */ uc = curl_url_get(h, CURLUPART_URL, &url, CURLU_NO_DEFAULT_PORT); if(uc) { curl_url_cleanup(h); @@ -3021,13 +2940,14 @@ CURLcode Curl_http_resume(struct Curl_easy *data, } /* when seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ do { + char scratch[4*1024]; size_t readthisamountnow = - (data->state.resume_from - passed > data->set.buffer_size) ? - (size_t)data->set.buffer_size : + (data->state.resume_from - passed > (curl_off_t)sizeof(scratch)) ? + sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread = - data->state.fread_func(data->state.buffer, 1, readthisamountnow, + data->state.fread_func(scratch, 1, readthisamountnow, data->state.in); passed += actuallyread; @@ -3062,6 +2982,7 @@ CURLcode Curl_http_firstwrite(struct Curl_easy *data, { struct SingleRequest *k = &data->req; + *done = FALSE; if(data->req.newurl) { if(conn->bits.close) { /* Abort after the headers if "follow Location" is set @@ -3187,7 +3108,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) ) { result = Curl_http2_switch(data, conn, FIRSTSOCKET); if(result) - return result; + goto fail; } else #endif @@ -3202,7 +3123,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) DEBUGF(infof(data, "HTTP/2 over clean TCP")); result = Curl_http2_switch(data, conn, FIRSTSOCKET); if(result) - return result; + goto fail; } break; } @@ -3212,11 +3133,11 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) result = Curl_http_host(data, conn); if(result) - return result; + goto fail; result = Curl_http_useragent(data); if(result) - return result; + goto fail; Curl_http_method(data, conn, &request, &httpreq); @@ -3232,7 +3153,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) (pq ? pq : data->state.up.path), FALSE); free(pq); if(result) - return result; + goto fail; } Curl_safefree(data->state.aptr.ref); @@ -3257,23 +3178,23 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) /* we only consider transfer-encoding magic if libz support is built-in */ result = Curl_transferencode(data); if(result) - return result; + goto fail; #endif result = Curl_http_body(data, conn, httpreq, &te); if(result) - return result; + goto fail; p_accept = Curl_checkheaders(data, STRCONST("Accept"))?NULL:"Accept: */*\r\n"; result = Curl_http_resume(data, conn, httpreq); if(result) - return result; + goto fail; result = Curl_http_range(data, httpreq); if(result) - return result; + goto fail; httpstring = get_http_string(data, conn); @@ -3291,7 +3212,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) result = Curl_http_target(data, conn, &req); if(result) { Curl_dyn_free(&req); - return result; + goto fail; } #ifndef CURL_DISABLE_ALTSVC @@ -3362,7 +3283,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) if(result) { Curl_dyn_free(&req); - return result; + goto fail; } if(!(conn->handler->flags&PROTOPT_SSL) && @@ -3398,7 +3319,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) } if(result) { Curl_dyn_free(&req); - return result; + goto fail; } if((http->postsize > -1) && @@ -3434,6 +3355,9 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) but is disabled here again to avoid that the chunked encoded version is actually used when sending the request body over h2 */ data->req.upload_chunky = FALSE; +fail: + if(CURLE_TOO_LARGE == result) + failf(data, "HTTP request too large"); return result; } @@ -3896,7 +3820,7 @@ CURLcode Curl_http_statusline(struct Curl_easy *data, * fields. */ if(data->set.timecondition) data->info.timecond = TRUE; - /* FALLTHROUGH */ + FALLTHROUGH(); case 204: /* (quote from RFC2616, section 10.2.5): The server has * fulfilled the request but does not need to return an @@ -3995,15 +3919,16 @@ CURLcode Curl_bump_headersize(struct Curl_easy *data, /* * Read any HTTP header lines from the server and pass them to the client app. */ -CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, - struct connectdata *conn, - const char *buf, size_t blen, - size_t *pconsumed) +static CURLcode http_rw_headers(struct Curl_easy *data, + const char *buf, size_t blen, + size_t *pconsumed) { - CURLcode result; + struct connectdata *conn = data->conn; + CURLcode result = CURLE_OK; struct SingleRequest *k = &data->req; char *headp; char *end_ptr; + bool leftover_body = FALSE; /* header line within buffer loop */ *pconsumed = 0; @@ -4032,12 +3957,12 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, if(st == STATUS_BAD) { /* this is not the beginning of a protocol first header line */ k->header = FALSE; - k->badheader = TRUE; streamclose(conn, "bad HTTP: No end-of-message indicator"); if(!data->set.http09_allowed) { failf(data, "Received HTTP/0.9 when not allowed"); return CURLE_UNSUPPORTED_PROTOCOL; } + leftover_body = TRUE; goto out; } } @@ -4071,15 +3996,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, return CURLE_UNSUPPORTED_PROTOCOL; } k->header = FALSE; - if(blen) - /* since there's more, this is a partial bad header */ - k->badheader = TRUE; - else { - /* this was all we read so it's all a bad header */ - k->badheader = TRUE; - return CURLE_OK; - } - break; + leftover_body = TRUE; + goto out; } } @@ -4088,6 +4006,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, headp = Curl_dyn_ptr(&data->state.headerb); if((0x0a == *headp) || (0x0d == *headp)) { size_t headerlen; + bool switch_to_h2 = FALSE; /* Zero-length header line means end of headers! */ if('\r' == *headp) @@ -4117,42 +4036,40 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, } break; case 101: - /* Switching Protocols */ - if(k->upgr101 == UPGR101_H2) { - /* Switching to HTTP/2 */ - DEBUGASSERT(conn->httpversion < 20); - infof(data, "Received 101, Switching to HTTP/2"); - k->upgr101 = UPGR101_RECEIVED; - - /* we'll get more headers (HTTP/2 response) */ - k->header = TRUE; - k->headerline = 0; /* restart the header line counter */ - - /* switch to http2 now. The bytes after response headers - are also processed here, otherwise they are lost. */ - result = Curl_http2_upgrade(data, conn, FIRSTSOCKET, buf, blen); - if(result) - return result; - *pconsumed += blen; - blen = 0; - } + if(conn->httpversion == 11) { + /* Switching Protocols only allowed from HTTP/1.1 */ + if(k->upgr101 == UPGR101_H2) { + /* Switching to HTTP/2 */ + infof(data, "Received 101, Switching to HTTP/2"); + k->upgr101 = UPGR101_RECEIVED; + + /* we'll get more headers (HTTP/2 response) */ + k->header = TRUE; + k->headerline = 0; /* restart the header line counter */ + switch_to_h2 = TRUE; + } #ifdef USE_WEBSOCKETS - else if(k->upgr101 == UPGR101_WS) { - /* verify the response */ - result = Curl_ws_accept(data, buf, blen); - if(result) - return result; - k->header = FALSE; /* no more header to parse! */ - if(data->set.connect_only) { - k->keepon &= ~KEEP_RECV; /* read no more content */ - *pconsumed += blen; + else if(k->upgr101 == UPGR101_WS) { + /* verify the response */ + result = Curl_ws_accept(data, buf, blen); + if(result) + return result; + k->header = FALSE; /* no more header to parse! */ + *pconsumed += blen; /* ws accept handled the data */ blen = 0; + if(data->set.connect_only) + k->keepon &= ~KEEP_RECV; /* read no more content */ } - } #endif + else { + /* Not switching to another protocol */ + k->header = FALSE; /* no more header to parse! */ + } + } else { - /* Not switching to another protocol */ - k->header = FALSE; /* no more header to parse! */ + /* invalid for other HTTP versions */ + failf(data, "unexpected 101 response code"); + return CURLE_WEIRD_SERVER_REPLY; } break; default: @@ -4359,16 +4276,6 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, */ if(data->req.no_body) k->download_done = TRUE; -#ifndef CURL_DISABLE_RTSP - else if((conn->handler->protocol & CURLPROTO_RTSP) && - (data->set.rtspreq == RTSPREQ_DESCRIBE) && - (k->size <= -1)) - /* Respect section 4.4 of rfc2326: If the Content-Length header is - absent, a length 0 must be assumed. It will prevent libcurl from - hanging on DESCRIBE request that got refused for whatever - reason */ - k->download_done = TRUE; -#endif /* If max download size is *zero* (nothing) we already have nothing and can safely return ok now! But for HTTP/2, we'd @@ -4388,6 +4295,17 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, /* We continue reading headers, reset the line-based header */ Curl_dyn_reset(&data->state.headerb); + if(switch_to_h2) { + /* Having handled the headers, we can do the HTTP/2 switch. + * Any remaining `buf` bytes are already HTTP/2 and passed to + * be processed. */ + result = Curl_http2_upgrade(data, conn, FIRSTSOCKET, buf, blen); + if(result) + return result; + *pconsumed += blen; + blen = 0; + } + continue; } @@ -4578,9 +4496,78 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, there might be a non-header part left in the end of the read buffer. */ out: + if(!k->header && !leftover_body) { + Curl_dyn_free(&data->state.headerb); + } return CURLE_OK; } +/* + * HTTP protocol `write_resp` implementation. Will parse headers + * when not done yet and otherwise return without consuming data. + */ +CURLcode Curl_http_write_resp_hds(struct Curl_easy *data, + const char *buf, size_t blen, + size_t *pconsumed, + bool *done) +{ + *done = FALSE; + if(!data->req.header) { + *pconsumed = 0; + return CURLE_OK; + } + else { + CURLcode result; + + result = http_rw_headers(data, buf, blen, pconsumed); + if(!result && !data->req.header) { + /* we have successfully finished parsing the HEADERs */ + result = Curl_http_firstwrite(data, data->conn, done); + + if(!data->req.no_body && Curl_dyn_len(&data->state.headerb)) { + /* leftover from parsing something that turned out not + * to be a header, only happens if we allow for + * HTTP/0.9 like responses */ + result = Curl_client_write(data, CLIENTWRITE_BODY, + Curl_dyn_ptr(&data->state.headerb), + Curl_dyn_len(&data->state.headerb)); + } + Curl_dyn_free(&data->state.headerb); + } + return result; + } +} + +CURLcode Curl_http_write_resp(struct Curl_easy *data, + const char *buf, size_t blen, + bool is_eos, + bool *done) +{ + CURLcode result; + size_t consumed; + int flags; + + *done = FALSE; + result = Curl_http_write_resp_hds(data, buf, blen, &consumed, done); + if(result || *done) + goto out; + + DEBUGASSERT(consumed <= blen); + blen -= consumed; + buf += consumed; + /* either all was consumed in header parsing, or we have data left + * and are done with heders, e.g. it is BODY data */ + DEBUGASSERT(!blen || !data->req.header); + if(!data->req.header && (blen || is_eos)) { + /* BODY data after header been parsed, write and consume */ + flags = CLIENTWRITE_BODY; + if(is_eos) + flags |= CLIENTWRITE_EOS; + result = Curl_client_write(data, flags, (char *)buf, blen); + } +out: + return result; +} /* Decode HTTP status code string. */ CURLcode Curl_http_decode_status(int *pstatus, const char *s, size_t len) @@ -4617,7 +4604,7 @@ CURLcode Curl_http_req_make(struct httpreq **preq, CURLcode result = CURLE_OUT_OF_MEMORY; DEBUGASSERT(method); - if(m_len + 1 >= sizeof(req->method)) + if(m_len + 1 > sizeof(req->method)) return CURLE_BAD_FUNCTION_ARGUMENT; req = calloc(1, sizeof(*req)); @@ -4625,17 +4612,17 @@ CURLcode Curl_http_req_make(struct httpreq **preq, goto out; memcpy(req->method, method, m_len); if(scheme) { - req->scheme = Curl_strndup(scheme, s_len); + req->scheme = Curl_memdup0(scheme, s_len); if(!req->scheme) goto out; } if(authority) { - req->authority = Curl_strndup(authority, a_len); + req->authority = Curl_memdup0(authority, a_len); if(!req->authority) goto out; } if(path) { - req->path = Curl_strndup(path, p_len); + req->path = Curl_memdup0(path, p_len); if(!req->path) goto out; } @@ -4773,7 +4760,7 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, CURLUcode uc; DEBUGASSERT(method); - if(m_len + 1 >= sizeof(req->method)) + if(m_len + 1 > sizeof(req->method)) return CURLE_BAD_FUNCTION_ARGUMENT; req = calloc(1, sizeof(*req)); diff --git a/lib/http.h b/lib/http.h index 56b091301..ad2697c9e 100644 --- a/lib/http.h +++ b/lib/http.h @@ -54,14 +54,6 @@ extern const struct Curl_handler Curl_handler_http; extern const struct Curl_handler Curl_handler_https; #endif -#ifdef USE_WEBSOCKETS -extern const struct Curl_handler Curl_handler_ws; - -#ifdef USE_SSL -extern const struct Curl_handler Curl_handler_wss; -#endif -#endif /* websockets */ - struct dynhds; CURLcode Curl_bump_headersize(struct Curl_easy *data, @@ -147,9 +139,17 @@ CURLcode Curl_http_firstwrite(struct Curl_easy *data, bool *done); /* protocol-specific functions set up to be called by the main engine */ +CURLcode Curl_http_setup_conn(struct Curl_easy *data, + struct connectdata *conn); CURLcode Curl_http(struct Curl_easy *data, bool *done); CURLcode Curl_http_done(struct Curl_easy *data, CURLcode, bool premature); CURLcode Curl_http_connect(struct Curl_easy *data, bool *done); +int Curl_http_getsock_do(struct Curl_easy *data, struct connectdata *conn, + curl_socket_t *socks); +CURLcode Curl_http_write_resp(struct Curl_easy *data, + const char *buf, size_t blen, + bool is_eos, + bool *done); /* These functions are in http.c */ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy, @@ -225,10 +225,10 @@ struct HTTP { CURLcode Curl_http_size(struct Curl_easy *data); -CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, - struct connectdata *conn, - const char *buf, size_t blen, - size_t *pconsumed); +CURLcode Curl_http_write_resp_hds(struct Curl_easy *data, + const char *buf, size_t blen, + size_t *pconsumed, + bool *done); /** * Curl_http_output_auth() setups the authentication headers for the diff --git a/lib/http2.c b/lib/http2.c index 973848484..c3157d1ef 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -219,10 +219,10 @@ static void drain_stream(struct Curl_cfilter *cf, if(!stream->send_closed && (stream->upload_left || stream->upload_blocked_len)) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - CURL_TRC_CF(data, cf, "[%d] DRAIN dselect_bits=%x", + if(data->state.select_bits != bits) { + CURL_TRC_CF(data, cf, "[%d] DRAIN select_bits=%x", stream->id, bits); - data->state.dselect_bits = bits; + data->state.select_bits = bits; Curl_expire(data, 0, EXPIRE_RUN_NOW); } } @@ -283,13 +283,20 @@ static void http2_data_done(struct Curl_cfilter *cf, return; if(ctx->h2) { + bool flush_egress = FALSE; + /* returns error if stream not known, which is fine here */ + (void)nghttp2_session_set_stream_user_data(ctx->h2, stream->id, NULL); + if(!stream->closed && stream->id > 0) { /* RST_STREAM */ CURL_TRC_CF(data, cf, "[%d] premature DATA_DONE, RST stream", stream->id); - if(!nghttp2_submit_rst_stream(ctx->h2, NGHTTP2_FLAG_NONE, - stream->id, NGHTTP2_STREAM_CLOSED)) - (void)nghttp2_session_send(ctx->h2); + stream->closed = TRUE; + stream->reset = TRUE; + stream->send_closed = TRUE; + nghttp2_submit_rst_stream(ctx->h2, NGHTTP2_FLAG_NONE, + stream->id, NGHTTP2_STREAM_CLOSED); + flush_egress = TRUE; } if(!Curl_bufq_is_empty(&stream->recvbuf)) { /* Anything in the recvbuf is still being counted @@ -299,19 +306,11 @@ static void http2_data_done(struct Curl_cfilter *cf, nghttp2_session_consume(ctx->h2, stream->id, Curl_bufq_len(&stream->recvbuf)); /* give WINDOW_UPATE a chance to be sent, but ignore any error */ - (void)h2_progress_egress(cf, data); + flush_egress = TRUE; } - /* -1 means unassigned and 0 means cleared */ - if(nghttp2_session_get_stream_user_data(ctx->h2, stream->id)) { - int rv = nghttp2_session_set_stream_user_data(ctx->h2, - stream->id, 0); - if(rv) { - infof(data, "http/2: failed to clear user_data for stream %u", - stream->id); - DEBUGASSERT(0); - } - } + if(flush_egress) + nghttp2_session_send(ctx->h2); } Curl_bufq_free(&stream->sendbuf); @@ -1316,26 +1315,43 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *userp) { struct Curl_cfilter *cf = userp; - struct Curl_easy *data_s; + struct Curl_easy *data_s, *call_data = CF_DATA_CURRENT(cf); struct stream_ctx *stream; int rv; (void)session; + DEBUGASSERT(call_data); /* get the stream from the hash based on Stream ID, stream ID zero is for connection-oriented stuff */ data_s = stream_id? nghttp2_session_get_stream_user_data(session, stream_id) : NULL; if(!data_s) { + CURL_TRC_CF(call_data, cf, + "[%d] on_stream_close, no easy set on stream", stream_id); return 0; } + if(!GOOD_EASY_HANDLE(data_s)) { + /* nghttp2 still has an easy registered for the stream which has + * been freed be libcurl. This points to a code path that does not + * trigger DONE or DETACH events as it must. */ + CURL_TRC_CF(call_data, cf, + "[%d] on_stream_close, not a GOOD easy on stream", stream_id); + (void)nghttp2_session_set_stream_user_data(session, stream_id, 0); + return NGHTTP2_ERR_CALLBACK_FAILURE; + } stream = H2_STREAM_CTX(data_s); - if(!stream) + if(!stream) { + CURL_TRC_CF(data_s, cf, + "[%d] on_stream_close, GOOD easy but no stream", stream_id); return NGHTTP2_ERR_CALLBACK_FAILURE; + } stream->closed = TRUE; stream->error = error_code; - if(stream->error) + if(stream->error) { stream->reset = TRUE; + stream->send_closed = TRUE; + } if(stream->error) CURL_TRC_CF(data_s, cf, "[%d] RESET: %s (err %d)", @@ -2315,18 +2331,22 @@ static void cf_h2_adjust_pollset(struct Curl_cfilter *cf, struct easy_pollset *ps) { struct cf_h2_ctx *ctx = cf->ctx; - bool want_recv = CURL_WANT_RECV(data); - bool want_send = CURL_WANT_SEND(data); + curl_socket_t sock; + bool want_recv, want_send; + + if(!ctx->h2) + return; - if(ctx->h2 && (want_recv || want_send)) { + sock = Curl_conn_cf_get_socket(cf, data); + Curl_pollset_check(data, ps, sock, &want_recv, &want_send); + if(want_recv || want_send) { struct stream_ctx *stream = H2_STREAM_CTX(data); - curl_socket_t sock = Curl_conn_cf_get_socket(cf, data); struct cf_call_data save; bool c_exhaust, s_exhaust; CF_DATA_SAVE(save, cf, data); - c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2); - s_exhaust = stream && stream->id >= 0 && + c_exhaust = want_send && !nghttp2_session_get_remote_window_size(ctx->h2); + s_exhaust = want_send && stream && stream->id >= 0 && !nghttp2_session_get_stream_remote_window_size(ctx->h2, stream->id); want_recv = (want_recv || c_exhaust || s_exhaust); diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index b673055f3..c9382918e 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -247,7 +247,7 @@ static CURLcode make_headers(struct Curl_easy *data, } else { char *value; - + char *endp; value = strchr(*date_header, ':'); if(!value) { *date_header = NULL; @@ -256,8 +256,17 @@ static CURLcode make_headers(struct Curl_easy *data, ++value; while(ISBLANK(*value)) ++value; - strncpy(timestamp, value, TIMESTAMP_SIZE - 1); - timestamp[TIMESTAMP_SIZE - 1] = 0; + endp = value; + while(*endp && ISALNUM(*endp)) + ++endp; + /* 16 bytes => "19700101T000000Z" */ + if((endp - value) == TIMESTAMP_SIZE - 1) { + memcpy(timestamp, value, TIMESTAMP_SIZE - 1); + timestamp[TIMESTAMP_SIZE - 1] = 0; + } + else + /* bad timestamp length */ + timestamp[0] = 0; *date_header = NULL; } @@ -605,7 +614,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy) result = CURLE_URL_MALFORMAT; goto fail; } - strncpy(service, hostname, len); + memcpy(service, hostname, len); service[len] = '\0'; infof(data, "aws_sigv4: picked service %s from host", service); @@ -624,7 +633,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy) result = CURLE_URL_MALFORMAT; goto fail; } - strncpy(region, reg, len); + memcpy(region, reg, len); region[len] = '\0'; infof(data, "aws_sigv4: picked region %s from host", region); } diff --git a/lib/http_chunks.c b/lib/http_chunks.c index acdb10863..039c179c4 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -75,47 +75,67 @@ */ -void Curl_httpchunk_init(struct Curl_easy *data) +void Curl_httpchunk_init(struct Curl_easy *data, struct Curl_chunker *ch, + bool ignore_body) { - struct connectdata *conn = data->conn; - struct Curl_chunker *chunk = &conn->chunk; - chunk->hexindex = 0; /* start at 0 */ - chunk->state = CHUNK_HEX; /* we get hex first! */ - Curl_dyn_init(&conn->trailer, DYN_H1_TRAILER); + (void)data; + ch->hexindex = 0; /* start at 0 */ + ch->state = CHUNK_HEX; /* we get hex first! */ + ch->last_code = CHUNKE_OK; + Curl_dyn_init(&ch->trailer, DYN_H1_TRAILER); + ch->ignore_body = ignore_body; } -/* - * chunk_read() returns a OK for normal operations, or a positive return code - * for errors. STOP means this sequence of chunks is complete. The 'wrote' - * argument is set to tell the caller how many bytes we actually passed to the - * client (for byte-counting and whatever). - * - * The states and the state-machine is further explained in the header file. - * - * This function always uses ASCII hex values to accommodate non-ASCII hosts. - * For example, 0x0d and 0x0a are used instead of '\r' and '\n'. - */ -CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, - char *buf, - size_t blen, - size_t *pconsumed, - CURLcode *extrap) +void Curl_httpchunk_reset(struct Curl_easy *data, struct Curl_chunker *ch, + bool ignore_body) +{ + (void)data; + ch->hexindex = 0; /* start at 0 */ + ch->state = CHUNK_HEX; /* we get hex first! */ + ch->last_code = CHUNKE_OK; + Curl_dyn_reset(&ch->trailer); + ch->ignore_body = ignore_body; +} + +void Curl_httpchunk_free(struct Curl_easy *data, struct Curl_chunker *ch) +{ + (void)data; + Curl_dyn_free(&ch->trailer); +} + +bool Curl_httpchunk_is_done(struct Curl_easy *data, struct Curl_chunker *ch) +{ + (void)data; + return ch->state == CHUNK_DONE; +} + +static CURLcode httpchunk_readwrite(struct Curl_easy *data, + struct Curl_chunker *ch, + struct Curl_cwriter *cw_next, + const char *buf, size_t blen, + size_t *pconsumed) { CURLcode result = CURLE_OK; - struct connectdata *conn = data->conn; - struct Curl_chunker *ch = &conn->chunk; - struct SingleRequest *k = &data->req; size_t piece; *pconsumed = 0; /* nothing's written yet */ + /* first check terminal states that will not progress anywhere */ + if(ch->state == CHUNK_DONE) + return CURLE_OK; + if(ch->state == CHUNK_FAILED) + return CURLE_RECV_ERROR; /* the original data is written to the client, but we go on with the chunk read process, to properly calculate the content length */ - if(data->set.http_te_skip && !k->ignorebody) { - result = Curl_client_write(data, CLIENTWRITE_BODY, buf, blen); + if(data->set.http_te_skip && !ch->ignore_body) { + if(cw_next) + result = Curl_cwriter_write(data, cw_next, CLIENTWRITE_BODY, buf, blen); + else + result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)buf, blen); if(result) { - *extrap = result; - return CHUNKE_PASSTHRU_ERROR; + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_PASSTHRU_ERROR; + return result; } } @@ -123,28 +143,35 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, switch(ch->state) { case CHUNK_HEX: if(ISXDIGIT(*buf)) { - if(ch->hexindex < CHUNK_MAXNUM_LEN) { - ch->hexbuffer[ch->hexindex] = *buf; - buf++; - blen--; - ch->hexindex++; - } - else { - return CHUNKE_TOO_LONG_HEX; /* longer hex than we support */ + if(ch->hexindex >= CHUNK_MAXNUM_LEN) { + failf(data, "chunk hex-length longer than %d", CHUNK_MAXNUM_LEN); + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_TOO_LONG_HEX; /* longer than we support */ + return CURLE_RECV_ERROR; } + ch->hexbuffer[ch->hexindex++] = *buf; + buf++; + blen--; } else { char *endptr; - if(0 == ch->hexindex) + if(0 == ch->hexindex) { /* This is illegal data, we received junk where we expected a hexadecimal digit. */ - return CHUNKE_ILLEGAL_HEX; + failf(data, "chunk hex-length char not a hex digit: 0x%x", *buf); + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_ILLEGAL_HEX; + return CURLE_RECV_ERROR; + } /* blen and buf are unmodified */ ch->hexbuffer[ch->hexindex] = 0; - - if(curlx_strtoofft(ch->hexbuffer, &endptr, 16, &ch->datasize)) - return CHUNKE_ILLEGAL_HEX; + if(curlx_strtoofft(ch->hexbuffer, &endptr, 16, &ch->datasize)) { + failf(data, "chunk hex-length not valid: '%s'", ch->hexbuffer); + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_ILLEGAL_HEX; + return CURLE_RECV_ERROR; + } ch->state = CHUNK_LF; /* now wait for the CRLF */ } break; @@ -173,12 +200,17 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, piece = curlx_sotouz(ch->datasize); /* Write the data portion available */ - if(!data->set.http_te_skip && !k->ignorebody) { - result = Curl_client_write(data, CLIENTWRITE_BODY, buf, piece); - + if(!data->set.http_te_skip && !ch->ignore_body) { + if(cw_next) + result = Curl_cwriter_write(data, cw_next, CLIENTWRITE_BODY, + buf, piece); + else + result = Curl_client_write(data, CLIENTWRITE_BODY, + (char *)buf, piece); if(result) { - *extrap = result; - return CHUNKE_PASSTHRU_ERROR; + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_PASSTHRU_ERROR; + return result; } } @@ -195,38 +227,51 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, case CHUNK_POSTLF: if(*buf == 0x0a) { /* The last one before we go back to hex state and start all over. */ - Curl_httpchunk_init(data); /* sets state back to CHUNK_HEX */ + Curl_httpchunk_reset(data, ch, ch->ignore_body); + } + else if(*buf != 0x0d) { + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_BAD_CHUNK; + return CURLE_RECV_ERROR; } - else if(*buf != 0x0d) - return CHUNKE_BAD_CHUNK; buf++; blen--; break; case CHUNK_TRAILER: if((*buf == 0x0d) || (*buf == 0x0a)) { - char *tr = Curl_dyn_ptr(&conn->trailer); + char *tr = Curl_dyn_ptr(&ch->trailer); /* this is the end of a trailer, but if the trailer was zero bytes there was no trailer and we move on */ if(tr) { size_t trlen; - result = Curl_dyn_addn(&conn->trailer, (char *)STRCONST("\x0d\x0a")); - if(result) - return CHUNKE_OUT_OF_MEMORY; - - tr = Curl_dyn_ptr(&conn->trailer); - trlen = Curl_dyn_len(&conn->trailer); + result = Curl_dyn_addn(&ch->trailer, (char *)STRCONST("\x0d\x0a")); + if(result) { + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_OUT_OF_MEMORY; + return result; + } + tr = Curl_dyn_ptr(&ch->trailer); + trlen = Curl_dyn_len(&ch->trailer); if(!data->set.http_te_skip) { - result = Curl_client_write(data, - CLIENTWRITE_HEADER|CLIENTWRITE_TRAILER, - tr, trlen); + if(cw_next) + result = Curl_cwriter_write(data, cw_next, + CLIENTWRITE_HEADER| + CLIENTWRITE_TRAILER, + tr, trlen); + else + result = Curl_client_write(data, + CLIENTWRITE_HEADER| + CLIENTWRITE_TRAILER, + tr, trlen); if(result) { - *extrap = result; - return CHUNKE_PASSTHRU_ERROR; + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_PASSTHRU_ERROR; + return result; } } - Curl_dyn_reset(&conn->trailer); + Curl_dyn_reset(&ch->trailer); ch->state = CHUNK_TRAILER_CR; if(*buf == 0x0a) /* already on the LF */ @@ -239,9 +284,12 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, } } else { - result = Curl_dyn_addn(&conn->trailer, buf, 1); - if(result) - return CHUNKE_OUT_OF_MEMORY; + result = Curl_dyn_addn(&ch->trailer, buf, 1); + if(result) { + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_OUT_OF_MEMORY; + return result; + } } buf++; blen--; @@ -253,8 +301,11 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, buf++; blen--; } - else - return CHUNKE_BAD_CHUNK; + else { + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_BAD_CHUNK; + return CURLE_RECV_ERROR; + } break; case CHUNK_TRAILER_POSTCR: @@ -277,21 +328,29 @@ CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, case CHUNK_STOP: if(*buf == 0x0a) { blen--; - /* Record the length of any data left in the end of the buffer even if there's no more chunks to read */ ch->datasize = blen; - - return CHUNKE_STOP; /* return stop */ + ch->state = CHUNK_DONE; + return CURLE_OK; } - else - return CHUNKE_BAD_CHUNK; + else { + ch->state = CHUNK_FAILED; + ch->last_code = CHUNKE_BAD_CHUNK; + return CURLE_RECV_ERROR; + } + case CHUNK_DONE: + return CURLE_OK; + + case CHUNK_FAILED: + return CURLE_RECV_ERROR; } + } - return CHUNKE_OK; + return CURLE_OK; } -const char *Curl_chunked_strerror(CHUNKcode code) +static const char *Curl_chunked_strerror(CHUNKcode code) { switch(code) { default: @@ -303,8 +362,7 @@ const char *Curl_chunked_strerror(CHUNKcode code) case CHUNKE_BAD_CHUNK: return "Malformed encoding found"; case CHUNKE_PASSTHRU_ERROR: - DEBUGASSERT(0); /* never used */ - return ""; + return "Error writing data to client"; case CHUNKE_BAD_ENCODING: return "Bad content-encoding found"; case CHUNKE_OUT_OF_MEMORY: @@ -312,4 +370,86 @@ const char *Curl_chunked_strerror(CHUNKcode code) } } +CURLcode Curl_httpchunk_read(struct Curl_easy *data, + struct Curl_chunker *ch, + char *buf, size_t blen, + size_t *pconsumed) +{ + return httpchunk_readwrite(data, ch, NULL, buf, blen, pconsumed); +} + +struct chunked_writer { + struct Curl_cwriter super; + struct Curl_chunker ch; +}; + +static CURLcode cw_chunked_init(struct Curl_easy *data, + struct Curl_cwriter *writer) +{ + struct chunked_writer *ctx = (struct chunked_writer *)writer; + + data->req.chunk = TRUE; /* chunks coming our way. */ + Curl_httpchunk_init(data, &ctx->ch, FALSE); + return CURLE_OK; +} + +static void cw_chunked_close(struct Curl_easy *data, + struct Curl_cwriter *writer) +{ + struct chunked_writer *ctx = (struct chunked_writer *)writer; + Curl_httpchunk_free(data, &ctx->ch); +} + +static CURLcode cw_chunked_write(struct Curl_easy *data, + struct Curl_cwriter *writer, int type, + const char *buf, size_t blen) +{ + struct chunked_writer *ctx = (struct chunked_writer *)writer; + CURLcode result; + size_t consumed; + + if(!(type & CLIENTWRITE_BODY)) + return Curl_cwriter_write(data, writer->next, type, buf, blen); + + consumed = 0; + result = httpchunk_readwrite(data, &ctx->ch, writer->next, buf, blen, + &consumed); + + if(result) { + if(CHUNKE_PASSTHRU_ERROR == ctx->ch.last_code) { + failf(data, "Failed reading the chunked-encoded stream"); + } + else { + failf(data, "%s in chunked-encoding", + Curl_chunked_strerror(ctx->ch.last_code)); + } + return result; + } + + blen -= consumed; + if(CHUNK_DONE == ctx->ch.state) { + /* chunks read successfully, download is complete */ + data->req.download_done = TRUE; + if(blen) { + infof(data, "Leftovers after chunking: %zu bytes", blen); + } + } + else if((type & CLIENTWRITE_EOS) && !data->req.no_body) { + failf(data, "transfer closed with outstanding read data remaining"); + return CURLE_PARTIAL_FILE; + } + + return CURLE_OK; +} + +/* HTTP chunked Transfer-Encoding decoder */ +const struct Curl_cwtype Curl_httpchunk_unencoder = { + "chunked", + NULL, + cw_chunked_init, + cw_chunked_write, + cw_chunked_close, + sizeof(struct chunked_writer) +}; + #endif /* CURL_DISABLE_HTTP */ diff --git a/lib/http_chunks.h b/lib/http_chunks.h index 0a36f379b..07f2984c3 100644 --- a/lib/http_chunks.h +++ b/lib/http_chunks.h @@ -24,6 +24,10 @@ * ***************************************************************************/ +#ifndef CURL_DISABLE_HTTP + +#include "dynbuf.h" + struct connectdata; /* @@ -67,34 +71,68 @@ typedef enum { signalled If this is an empty trailer CHUNKE_STOP will be signalled. Otherwise the trailer will be broadcasted via Curl_client_write() and the next state will be CHUNK_TRAILER */ - CHUNK_TRAILER_POSTCR + CHUNK_TRAILER_POSTCR, + + /* Successfully de-chunked everything */ + CHUNK_DONE, + + /* Failed on seeing a bad or not correctly terminated chunk */ + CHUNK_FAILED } ChunkyState; typedef enum { - CHUNKE_STOP = -1, CHUNKE_OK = 0, CHUNKE_TOO_LONG_HEX = 1, CHUNKE_ILLEGAL_HEX, CHUNKE_BAD_CHUNK, CHUNKE_BAD_ENCODING, CHUNKE_OUT_OF_MEMORY, - CHUNKE_PASSTHRU_ERROR, /* Curl_httpchunk_read() returns a CURLcode to use */ - CHUNKE_LAST + CHUNKE_PASSTHRU_ERROR /* Curl_httpchunk_read() returns a CURLcode to use */ } CHUNKcode; -const char *Curl_chunked_strerror(CHUNKcode code); - struct Curl_chunker { curl_off_t datasize; ChunkyState state; + CHUNKcode last_code; + struct dynbuf trailer; /* for chunked-encoded trailer */ unsigned char hexindex; - char hexbuffer[ CHUNK_MAXNUM_LEN + 1]; /* +1 for null-terminator */ + char hexbuffer[CHUNK_MAXNUM_LEN + 1]; /* +1 for null-terminator */ + BIT(ignore_body); /* never write response body data */ }; /* The following functions are defined in http_chunks.c */ -void Curl_httpchunk_init(struct Curl_easy *data); -CHUNKcode Curl_httpchunk_read(struct Curl_easy *data, char *buf, - size_t blen, size_t *pconsumed, - CURLcode *passthru); +void Curl_httpchunk_init(struct Curl_easy *data, struct Curl_chunker *ch, + bool ignore_body); +void Curl_httpchunk_free(struct Curl_easy *data, struct Curl_chunker *ch); +void Curl_httpchunk_reset(struct Curl_easy *data, struct Curl_chunker *ch, + bool ignore_body); + +/* + * Read BODY bytes in HTTP/1.1 chunked encoding from `buf` and return + * the amount of bytes consumed. The actual response bytes and trailer + * headers are written out to the client. + * On success, this will consume all bytes up to the end of the response, + * e.g. the last chunk, has been processed. + * @param data the transfer involved + * @param ch the chunker instance keeping state across calls + * @param buf the response data + * @param blen amount of bytes in `buf` + * @param pconsumed on successful return, the number of bytes in `buf` + * consumed + * + * This function always uses ASCII hex values to accommodate non-ASCII hosts. + * For example, 0x0d and 0x0a are used instead of '\r' and '\n'. + */ +CURLcode Curl_httpchunk_read(struct Curl_easy *data, struct Curl_chunker *ch, + char *buf, size_t blen, size_t *pconsumed); + +/** + * @return TRUE iff chunked decoded has finished successfully. + */ +bool Curl_httpchunk_is_done(struct Curl_easy *data, struct Curl_chunker *ch); + +extern const struct Curl_cwtype Curl_httpchunk_unencoder; + +#endif /* !CURL_DISABLE_HTTP */ #endif /* HEADER_CURL_HTTP_CHUNKS_H */ diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 8e1832581..113c43a41 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -131,8 +131,8 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, goto out; } - if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) - && data->set.str[STRING_USERAGENT]) { + if(!Curl_checkProxyheaders(data, cf->conn, STRCONST("User-Agent")) && + data->set.str[STRING_USERAGENT] && *data->set.str[STRING_USERAGENT]) { result = Curl_dynhds_cadd(&req->headers, "User-Agent", data->set.str[STRING_USERAGENT]); if(result) diff --git a/lib/imap.c b/lib/imap.c index 47cff4897..f9211d966 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -97,7 +97,8 @@ static CURLcode imap_doing(struct Curl_easy *data, bool *dophase_done); static CURLcode imap_setup_connection(struct Curl_easy *data, struct connectdata *conn); static char *imap_atom(const char *str, bool escape_only); -static CURLcode imap_sendf(struct Curl_easy *data, const char *fmt, ...); +static CURLcode imap_sendf(struct Curl_easy *data, const char *fmt, ...) + CURL_PRINTF(2, 3); static CURLcode imap_parse_url_options(struct connectdata *conn); static CURLcode imap_parse_url_path(struct Curl_easy *data); static CURLcode imap_parse_custom_request(struct Curl_easy *data); @@ -129,7 +130,7 @@ const struct Curl_handler Curl_handler_imap = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ imap_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_IMAP, /* defport */ @@ -158,7 +159,7 @@ const struct Curl_handler Curl_handler_imaps = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ imap_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_IMAPS, /* defport */ @@ -354,8 +355,8 @@ static bool imap_endofresp(struct Curl_easy *data, struct connectdata *conn, */ static CURLcode imap_get_message(struct Curl_easy *data, struct bufref *out) { - char *message = data->state.buffer; - size_t len = strlen(message); + char *message = Curl_dyn_ptr(&data->conn->proto.imapc.pp.recvbuf); + size_t len = data->conn->proto.imapc.pp.nfinal; if(len > 2) { /* Find the start of the message */ @@ -895,7 +896,7 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; struct connectdata *conn = data->conn; struct imap_conn *imapc = &conn->proto.imapc; - const char *line = data->state.buffer; + const char *line = Curl_dyn_ptr(&imapc->pp.recvbuf); (void)instate; /* no use for this yet */ @@ -981,7 +982,7 @@ static CURLcode imap_state_starttls_resp(struct Curl_easy *data, (void)instate; /* no use for this yet */ /* Pipelining in response is forbidden. */ - if(data->conn->proto.imapc.pp.cache_size) + if(data->conn->proto.imapc.pp.overflow) return CURLE_WEIRD_SERVER_REPLY; if(imapcode != IMAP_RESP_OK) { @@ -1057,17 +1058,13 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data, imapstate instate) { CURLcode result = CURLE_OK; - char *line = data->state.buffer; - size_t len = strlen(line); + char *line = Curl_dyn_ptr(&data->conn->proto.imapc.pp.recvbuf); + size_t len = data->conn->proto.imapc.pp.nfinal; (void)instate; /* No use for this yet */ - if(imapcode == '*') { - /* Temporarily add the LF character back and send as body to the client */ - line[len] = '\n'; - result = Curl_client_write(data, CLIENTWRITE_BODY, line, len + 1); - line[len] = '\0'; - } + if(imapcode == '*') + result = Curl_client_write(data, CLIENTWRITE_BODY, line, len); else if(imapcode != IMAP_RESP_OK) result = CURLE_QUOTE_ERROR; else @@ -1085,7 +1082,7 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data, int imapcode, struct connectdata *conn = data->conn; struct IMAP *imap = data->req.p.imap; struct imap_conn *imapc = &conn->proto.imapc; - const char *line = data->state.buffer; + const char *line = Curl_dyn_ptr(&data->conn->proto.imapc.pp.recvbuf); (void)instate; /* no use for this yet */ @@ -1144,7 +1141,8 @@ static CURLcode imap_state_fetch_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; struct pingpong *pp = &imapc->pp; - const char *ptr = data->state.buffer; + const char *ptr = Curl_dyn_ptr(&data->conn->proto.imapc.pp.recvbuf); + size_t len = data->conn->proto.imapc.pp.nfinal; bool parsed = FALSE; curl_off_t size = 0; @@ -1158,16 +1156,12 @@ static CURLcode imap_state_fetch_resp(struct Curl_easy *data, /* Something like this is received "* 1 FETCH (BODY[TEXT] {2021}\r" so parse the continuation data contained within the curly brackets */ - while(*ptr && (*ptr != '{')) - ptr++; - - if(*ptr == '{') { + ptr = memchr(ptr, '{', len); + if(ptr) { char *endptr; - if(!curlx_strtoofft(ptr + 1, &endptr, 10, &size)) { - if(endptr - ptr > 1 && endptr[0] == '}' && - endptr[1] == '\r' && endptr[2] == '\0') - parsed = TRUE; - } + if(!curlx_strtoofft(ptr + 1, &endptr, 10, &size) && + (endptr - ptr > 1 && *endptr == '}')) + parsed = TRUE; } if(parsed) { @@ -1175,11 +1169,15 @@ static CURLcode imap_state_fetch_resp(struct Curl_easy *data, size); Curl_pgrsSetDownloadSize(data, size); - if(pp->cache) { - /* At this point there is a bunch of data in the header "cache" that is - actually body content, send it as body and then skip it. Do note - that there may even be additional "headers" after the body. */ - size_t chunk = pp->cache_size; + if(pp->overflow) { + /* At this point there is a data in the receive buffer that is body + content, send it as body and then skip it. Do note that there may + even be additional "headers" after the body. */ + size_t chunk = pp->overflow; + + /* keep only the overflow */ + Curl_dyn_tail(&pp->recvbuf, chunk); + pp->nfinal = 0; /* done */ if(chunk > (size_t)size) /* The conversion from curl_off_t to size_t is always fine here */ @@ -1190,25 +1188,24 @@ static CURLcode imap_state_fetch_resp(struct Curl_easy *data, imap_state(data, IMAP_STOP); return CURLE_OK; } - result = Curl_client_write(data, CLIENTWRITE_BODY, pp->cache, chunk); + result = Curl_client_write(data, CLIENTWRITE_BODY, + Curl_dyn_ptr(&pp->recvbuf), chunk); if(result) return result; infof(data, "Written %zu bytes, %" CURL_FORMAT_CURL_OFF_TU " bytes are left for transfer", chunk, size - chunk); - /* Have we used the entire cache or just part of it?*/ - if(pp->cache_size > chunk) { - /* Only part of it so shrink the cache to fit the trailing data */ - memmove(pp->cache, pp->cache + chunk, pp->cache_size - chunk); - pp->cache_size -= chunk; + /* Have we used the entire overflow or just part of it?*/ + if(pp->overflow > chunk) { + /* remember the remaining trailing overflow data */ + pp->overflow -= chunk; + Curl_dyn_tail(&pp->recvbuf, pp->overflow); } else { + pp->overflow = 0; /* handled */ /* Free the cache */ - Curl_safefree(pp->cache); - - /* Reset the cache size */ - pp->cache_size = 0; + Curl_dyn_reset(&pp->recvbuf); } } @@ -1220,7 +1217,7 @@ static CURLcode imap_state_fetch_resp(struct Curl_easy *data, data->req.maxdownload = size; /* force a recv/send check of this connection, as the data might've been read off the socket already */ - data->conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; Curl_setup_transfer(data, FIRSTSOCKET, size, FALSE, -1); } } @@ -1376,7 +1373,6 @@ static CURLcode imap_statemachine(struct Curl_easy *data, break; case IMAP_LOGOUT: - /* fallthrough, just stop! */ default: /* internal error */ imap_state(data, IMAP_STOP); @@ -1472,9 +1468,7 @@ static CURLcode imap_connect(struct Curl_easy *data, bool *done) Curl_sasl_init(&imapc->sasl, data, &saslimap); Curl_dyn_init(&imapc->dyn, DYN_IMAP_CMD); - /* Initialise the pingpong layer */ - Curl_pp_setup(pp); - Curl_pp_init(data, pp); + Curl_pp_init(pp); /* Parse the URL options */ result = imap_parse_url_options(conn); @@ -1795,7 +1789,14 @@ static CURLcode imap_sendf(struct Curl_easy *data, const char *fmt, ...) if(!result) { va_list ap; va_start(ap, fmt); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif result = Curl_pp_vsendf(data, &imapc->pp, Curl_dyn_ptr(&imapc->dyn), ap); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif va_end(ap); } return result; diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 7d3c69879..176cc956f 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -112,7 +112,8 @@ inet_pton4(const char *src, unsigned char *dst) pch = strchr(digits, ch); if(pch) { - unsigned int val = *tp * 10 + (unsigned int)(pch - digits); + unsigned int val = (unsigned int)(*tp * 10) + + (unsigned int)(pch - digits); if(saw_digit && *tp == 0) return (0); diff --git a/lib/inet_pton.h b/lib/inet_pton.h index 82fde7e2e..f8562fa8a 100644 --- a/lib/inet_pton.h +++ b/lib/inet_pton.h @@ -31,9 +31,6 @@ int Curl_inet_pton(int, const char *, void *); #ifdef HAVE_INET_PTON #ifdef HAVE_ARPA_INET_H #include -#elif defined(HAVE_WS2TCPIP_H) -/* inet_pton() exists in Vista or later */ -#include #endif #define Curl_inet_pton(x,y,z) inet_pton(x,y,z) #endif diff --git a/lib/krb5.c b/lib/krb5.c index 18e73debb..4db19fb27 100644 --- a/lib/krb5.c +++ b/lib/krb5.c @@ -75,8 +75,7 @@ static CURLcode ftpsend(struct Curl_easy *data, struct connectdata *conn, unsigned char data_sec = conn->data_prot; #endif - if(!cmd) - return CURLE_BAD_FUNCTION_ARGUMENT; + DEBUGASSERT(cmd); write_len = strlen(cmd); if(!write_len || write_len > (sizeof(s) -3)) @@ -236,9 +235,12 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn) if(Curl_GetFTPResponse(data, &nread, NULL)) return -1; - - if(data->state.buffer[0] != '3') - return -1; + else { + struct pingpong *pp = &conn->proto.ftpc.pp; + char *line = Curl_dyn_ptr(&pp->recvbuf); + if(line[0] != '3') + return -1; + } } stringp = aprintf("%s@%s", service, host); @@ -322,15 +324,19 @@ krb5_auth(void *app_data, struct Curl_easy *data, struct connectdata *conn) ret = -1; break; } - - if(data->state.buffer[0] != '2' && data->state.buffer[0] != '3') { - infof(data, "Server didn't accept auth data"); - ret = AUTH_ERROR; - break; + else { + struct pingpong *pp = &conn->proto.ftpc.pp; + size_t len = Curl_dyn_len(&pp->recvbuf); + p = Curl_dyn_ptr(&pp->recvbuf); + if((len < 4) || (p[0] != '2' && p[0] != '3')) { + infof(data, "Server didn't accept auth data"); + ret = AUTH_ERROR; + break; + } } _gssresp.value = NULL; /* make sure it is initialized */ - p = data->state.buffer + 4; + p += 4; /* over '789 ' */ p = strstr(p, "ADAT="); if(p) { result = Curl_base64_decode(p + 5, @@ -417,7 +423,6 @@ static char level_to_char(int level) case PROT_PRIVATE: return 'P'; case PROT_CMD: - /* Fall through */ default: /* Those 2 cases should not be reached! */ break; @@ -429,6 +434,9 @@ static char level_to_char(int level) /* Send an FTP command defined by |message| and the optional arguments. The function returns the ftp_code. If an error occurs, -1 is returned. */ +static int ftp_send_command(struct Curl_easy *data, const char *message, ...) + CURL_PRINTF(2, 3); + static int ftp_send_command(struct Curl_easy *data, const char *message, ...) { int ftp_code; @@ -750,6 +758,8 @@ static int sec_set_protection_level(struct Curl_easy *data) if(level) { char *pbsz; unsigned int buffer_size = 1 << 20; /* 1048576 */ + struct pingpong *pp = &conn->proto.ftpc.pp; + char *line; code = ftp_send_command(data, "PBSZ %u", buffer_size); if(code < 0) @@ -761,10 +771,11 @@ static int sec_set_protection_level(struct Curl_easy *data) } conn->buffer_size = buffer_size; - pbsz = strstr(data->state.buffer, "PBSZ="); + line = Curl_dyn_ptr(&pp->recvbuf); + pbsz = strstr(line, "PBSZ="); if(pbsz) { /* stick to default value if the check fails */ - if(!strncmp(pbsz, "PBSZ=", 5) && ISDIGIT(pbsz[5])) + if(ISDIGIT(pbsz[5])) buffer_size = atoi(&pbsz[5]); if(buffer_size < conn->buffer_size) conn->buffer_size = buffer_size; diff --git a/lib/ldap.c b/lib/ldap.c index eb5fe795e..4c04647f4 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -137,7 +137,7 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp); _ldap_trace x; \ } while(0) - static void _ldap_trace(const char *fmt, ...); + static void _ldap_trace(const char *fmt, ...) CURL_PRINTF(1, 2); #else #define LDAP_TRACE(x) Curl_nop_stmt #endif @@ -177,7 +177,7 @@ const struct Curl_handler Curl_handler_ldap = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_LDAP, /* defport */ @@ -205,7 +205,7 @@ const struct Curl_handler Curl_handler_ldaps = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_LDAPS, /* defport */ diff --git a/lib/md4.c b/lib/md4.c index 486e5fa6a..067c211e4 100644 --- a/lib/md4.c +++ b/lib/md4.c @@ -194,11 +194,9 @@ static int MD4_Init(MD4_CTX *ctx) static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) { if(!ctx->data) { - ctx->data = malloc(size); - if(ctx->data) { - memcpy(ctx->data, data, size); + ctx->data = Curl_memdup(data, size); + if(ctx->data) ctx->size = size; - } } } diff --git a/lib/memdebug.c b/lib/memdebug.c index f6ced85cd..fce933a32 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -304,12 +304,6 @@ void curl_dbg_free(void *ptr, int line, const char *source) curl_socket_t curl_dbg_socket(int domain, int type, int protocol, int line, const char *source) { - const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socket() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socket() = %ld\n" : - "FD %s:%d socket() = %zd\n"; - curl_socket_t sockfd; if(countcheck("socket", line, source)) @@ -318,7 +312,8 @@ curl_socket_t curl_dbg_socket(int domain, int type, int protocol, sockfd = socket(domain, type, protocol); if(source && (sockfd != CURL_SOCKET_BAD)) - curl_dbg_log(fmt, source, line, sockfd); + curl_dbg_log("FD %s:%d socket() = %" CURL_FORMAT_SOCKET_T "\n", + source, line, sockfd); return sockfd; } @@ -357,16 +352,12 @@ int curl_dbg_socketpair(int domain, int type, int protocol, curl_socket_t socket_vector[2], int line, const char *source) { - const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d socketpair() = %d %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d socketpair() = %ld %ld\n" : - "FD %s:%d socketpair() = %zd %zd\n"; - int res = socketpair(domain, type, protocol, socket_vector); if(source && (0 == res)) - curl_dbg_log(fmt, source, line, socket_vector[0], socket_vector[1]); + curl_dbg_log("FD %s:%d socketpair() = " + "%" CURL_FORMAT_SOCKET_T " %" CURL_FORMAT_SOCKET_T "\n", + source, line, socket_vector[0], socket_vector[1]); return res; } @@ -375,19 +366,14 @@ int curl_dbg_socketpair(int domain, int type, int protocol, curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen, int line, const char *source) { - const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d accept() = %d\n" : - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d accept() = %ld\n" : - "FD %s:%d accept() = %zd\n"; - struct sockaddr *addr = (struct sockaddr *)saddr; curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen; curl_socket_t sockfd = accept(s, addr, addrlen); if(source && (sockfd != CURL_SOCKET_BAD)) - curl_dbg_log(fmt, source, line, sockfd); + curl_dbg_log("FD %s:%d accept() = %" CURL_FORMAT_SOCKET_T "\n", + source, line, sockfd); return sockfd; } @@ -395,14 +381,9 @@ curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen, /* separate function to allow libcurl to mark a "faked" close */ void curl_dbg_mark_sclose(curl_socket_t sockfd, int line, const char *source) { - const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ? - "FD %s:%d sclose(%d)\n": - (sizeof(curl_socket_t) == sizeof(long)) ? - "FD %s:%d sclose(%ld)\n": - "FD %s:%d sclose(%zd)\n"; - if(source) - curl_dbg_log(fmt, source, line, sockfd); + curl_dbg_log("FD %s:%d sclose(%" CURL_FORMAT_SOCKET_T ")\n", + source, line, sockfd); } /* this is our own defined way to close sockets on *ALL* platforms */ diff --git a/lib/memdebug.h b/lib/memdebug.h index 78a012580..51147cdcb 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -72,7 +72,7 @@ CURL_EXTERN ALLOC_FUNC wchar_t *curl_dbg_wcsdup(const wchar_t *str, CURL_EXTERN void curl_dbg_memdebug(const char *logname); CURL_EXTERN void curl_dbg_memlimit(long limit); -CURL_EXTERN void curl_dbg_log(const char *format, ...); +CURL_EXTERN void curl_dbg_log(const char *format, ...) CURL_PRINTF(1, 2); /* file descriptor manipulators */ CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol, diff --git a/lib/mime.c b/lib/mime.c index bb66130ad..d712331d0 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -30,6 +30,7 @@ #include "warnless.h" #include "urldata.h" #include "sendf.h" +#include "strdup.h" #if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \ !defined(CURL_DISABLE_SMTP) || \ @@ -817,7 +818,7 @@ static size_t read_part_content(curl_mimepart *part, case MIMEKIND_FILE: if(part->fp && feof(part->fp)) break; /* At EOF. */ - /* FALLTHROUGH */ + FALLTHROUGH(); default: if(part->readfunc) { if(!(part->flags & MIME_FAST_READ)) { @@ -936,7 +937,7 @@ static size_t readback_part(curl_mimepart *part, mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next); break; } - /* FALLTHROUGH */ + FALLTHROUGH(); case MIMESTATE_CURLHEADERS: if(!hdr) mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders); @@ -970,7 +971,7 @@ static size_t readback_part(curl_mimepart *part, fclose(part->fp); part->fp = NULL; } - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_READFUNC_ABORT: case CURL_READFUNC_PAUSE: case READ_ERROR: @@ -1235,6 +1236,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data, } break; default: /* Invalid kind: should not occur. */ + DEBUGF(infof(data, "invalid MIMEKIND* attempt")); res = CURLE_BAD_FUNCTION_ARGUMENT; /* Internal error? */ break; } @@ -1370,27 +1372,22 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) /* Set mime part content from memory data. */ CURLcode curl_mime_data(curl_mimepart *part, - const char *data, size_t datasize) + const char *ptr, size_t datasize) { if(!part) return CURLE_BAD_FUNCTION_ARGUMENT; cleanup_part_content(part); - if(data) { + if(ptr) { if(datasize == CURL_ZERO_TERMINATED) - datasize = strlen(data); + datasize = strlen(ptr); - part->data = malloc(datasize + 1); + part->data = Curl_memdup0(ptr, datasize); if(!part->data) return CURLE_OUT_OF_MEMORY; part->datasize = datasize; - - if(datasize) - memcpy(part->data, data, datasize); - part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */ - part->readfunc = mime_mem_read; part->seekfunc = mime_mem_seek; part->freefunc = mime_mem_free; diff --git a/lib/mime.h b/lib/mime.h index 0a05c2a5a..a64f41d4b 100644 --- a/lib/mime.h +++ b/lib/mime.h @@ -130,7 +130,8 @@ struct curl_mimepart { size_t lastreadstatus; /* Last read callback returned status. */ }; -CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...); +CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...) + CURL_PRINTF(2, 3); #if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \ !defined(CURL_DISABLE_SMTP) || \ diff --git a/lib/mprintf.c b/lib/mprintf.c index 6b5df5bdd..63f7f2409 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -20,25 +20,11 @@ * * SPDX-License-Identifier: curl * - * - * Purpose: - * A merge of Bjorn Reese's format() function and Daniel's dsprintf() - * 1.0. A full blooded printf() clone with full support for $ - * everywhere (parameters, widths and precisions) including variabled - * sized parameters (like doubles, long longs, long doubles and even - * void * in 64-bit architectures). - * - * Current restrictions: - * - Max 128 parameters - * - No 'long double' support. - * - * If you ever want truly portable and good *printf() clones, the project that - * took on from here is named 'Trio' and you find more details on the trio web - * page at https://daniel.haxx.se/projects/trio/ */ #include "curl_setup.h" #include "dynbuf.h" +#include "curl_printf.h" #include #include "curl_memory.h" @@ -86,7 +72,8 @@ #define BUFFSIZE 326 /* buffer for long-to-str and float-to-str calcs, should fit negative DBL_MAX (317 letters) */ -#define MAX_PARAMETERS 128 /* lame static limit */ +#define MAX_PARAMETERS 128 /* number of input arguments */ +#define MAX_SEGMENTS 128 /* number of output segments */ #ifdef __AMIGA__ # undef FORMAT_INT @@ -98,31 +85,33 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; /* Upper-case digits. */ static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#define OUTCHAR(x) \ - do { \ - if(stream((unsigned char)(x), (FILE *)data) != -1) \ - done++; \ - else \ - return done; /* return immediately on failure */ \ +#define OUTCHAR(x) \ + do { \ + if(!stream(x, userp)) \ + done++; \ + else \ + return done; /* return on failure */ \ } while(0) /* Data type to read from the arglist */ typedef enum { - FORMAT_UNKNOWN = 0, FORMAT_STRING, FORMAT_PTR, - FORMAT_INT, FORMAT_INTPTR, + FORMAT_INT, FORMAT_LONG, FORMAT_LONGLONG, + FORMAT_INTU, + FORMAT_LONGU, + FORMAT_LONGLONGU, FORMAT_DOUBLE, FORMAT_LONGDOUBLE, - FORMAT_WIDTH /* For internal use */ + FORMAT_WIDTH, + FORMAT_PRECISION } FormatType; /* conversion and display flags */ enum { - FLAGS_NEW = 0, FLAGS_SPACE = 1<<0, FLAGS_SHOWSIGN = 1<<1, FLAGS_LEFT = 1<<2, @@ -142,23 +131,40 @@ enum { FLAGS_PRECPARAM = 1<<16, /* precision PARAMETER was specified */ FLAGS_CHAR = 1<<17, /* %c story */ FLAGS_FLOATE = 1<<18, /* %e or %E */ - FLAGS_FLOATG = 1<<19 /* %g or %G */ + FLAGS_FLOATG = 1<<19, /* %g or %G */ + FLAGS_SUBSTR = 1<<20 /* no input, only substring */ }; -struct va_stack { - FormatType type; - int flags; - long width; /* width OR width parameter number */ - long precision; /* precision OR precision parameter number */ +enum { + DOLLAR_UNKNOWN, + DOLLAR_NOPE, + DOLLAR_USE +}; + +/* + * Describes an input va_arg type and hold its value. + */ +struct va_input { + FormatType type; /* FormatType */ union { char *str; void *ptr; - union { - mp_intmax_t as_signed; - mp_uintmax_t as_unsigned; - } num; + mp_intmax_t nums; /* signed */ + mp_uintmax_t numu; /* unsigned */ double dnum; - } data; + } val; +}; + +/* + * Describes an output segment. + */ +struct outsegment { + int width; /* width OR width parameter number */ + int precision; /* precision OR precision parameter number */ + unsigned int flags; + unsigned int input; /* input argument array index */ + char *start; /* format string start to output */ + size_t outlen; /* number of bytes from the format string to output */ }; struct nsprintf { @@ -169,118 +175,123 @@ struct nsprintf { struct asprintf { struct dynbuf *b; - bool fail; /* if an alloc has failed and thus the output is not the complete - data */ + char merr; }; -static long dprintf_DollarString(char *input, char **end) -{ - int number = 0; - while(ISDIGIT(*input)) { - if(number < MAX_PARAMETERS) { - number *= 10; - number += *input - '0'; - } - input++; - } - if(number <= MAX_PARAMETERS && ('$' == *input)) { - *end = ++input; - return number; - } - return 0; -} +/* the provided input number is 1-based but this returns the number 0-based. -static bool dprintf_IsQualifierNoDollar(const char *fmt) + returns -1 if no valid number was provided. +*/ +static int dollarstring(char *input, char **end) { -#if defined(MP_HAVE_INT_EXTENSIONS) - if(!strncmp(fmt, "I32", 3) || !strncmp(fmt, "I64", 3)) { - return TRUE; - } -#endif - - switch(*fmt) { - case '-': case '+': case ' ': case '#': case '.': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'h': case 'l': case 'L': case 'z': case 'q': - case '*': case 'O': -#if defined(MP_HAVE_INT_EXTENSIONS) - case 'I': -#endif - return TRUE; + if(ISDIGIT(*input)) { + int number = 0; + do { + if(number < MAX_PARAMETERS) { + number *= 10; + number += *input - '0'; + } + input++; + } while(ISDIGIT(*input)); - default: - return FALSE; + if(number && (number <= MAX_PARAMETERS) && ('$' == *input)) { + *end = ++input; + return number - 1; + } } + return -1; } -/****************************************************************** +/* + * Parse the format string. * - * Pass 1: - * Create an index with the type of each parameter entry and its - * value (may vary in size) + * Create two arrays. One describes the inputs, one describes the outputs. * * Returns zero on success. - * - ******************************************************************/ + */ -static int dprintf_Pass1(const char *format, struct va_stack *vto, - char **endpos, va_list arglist) +#define PFMT_OK 0 +#define PFMT_DOLLAR 1 /* bad dollar for main param */ +#define PFMT_DOLLARWIDTH 2 /* bad dollar use for width */ +#define PFMT_DOLLARPREC 3 /* bad dollar use for precision */ +#define PFMT_MANYARGS 4 /* too many input arguments used */ +#define PFMT_PREC 5 /* precision overflow */ +#define PFMT_PRECMIX 6 /* bad mix of precision specifiers */ +#define PFMT_WIDTH 7 /* width overflow */ +#define PFMT_INPUTGAP 8 /* gap in arguments */ +#define PFMT_WIDTHARG 9 /* attempted to use same arg twice, for width */ +#define PFMT_PRECARG 10 /* attempted to use same arg twice, for prec */ +#define PFMT_MANYSEGS 11 /* maxed out output segments */ + +static int parsefmt(const char *format, + struct outsegment *out, + struct va_input *in, + int *opieces, + int *ipieces, va_list arglist) { char *fmt = (char *)format; int param_num = 0; - long this_param; - long width; - long precision; - int flags; - long max_param = 0; - long i; + int param; + int width; + int precision; + unsigned int flags; + FormatType type; + int max_param = -1; + int i; + int ocount = 0; + unsigned char usedinput[MAX_PARAMETERS/8]; + size_t outlen = 0; + struct outsegment *optr; + int use_dollar = DOLLAR_UNKNOWN; + char *start = fmt; + + /* clear, set a bit for each used input */ + memset(usedinput, 0, sizeof(usedinput)); while(*fmt) { - if(*fmt++ == '%') { + if(*fmt == '%') { + struct va_input *iptr; + bool loopit = TRUE; + fmt++; + outlen = fmt - start - 1; if(*fmt == '%') { + /* this means a %% that should be output only as %. Create an output + segment. */ + if(outlen) { + optr = &out[ocount++]; + if(ocount > MAX_SEGMENTS) + return PFMT_MANYSEGS; + optr->input = 0; + optr->flags = FLAGS_SUBSTR; + optr->start = start; + optr->outlen = outlen; + } + start = fmt; fmt++; continue; /* while */ } - flags = FLAGS_NEW; - - /* Handle the positional case (N$) */ - - param_num++; - - this_param = dprintf_DollarString(fmt, &fmt); - if(0 == this_param) - /* we got no positional, get the next counter */ - this_param = param_num; - - if(this_param > max_param) - max_param = this_param; + flags = width = precision = 0; - /* - * The parameter with number 'i' should be used. Next, we need - * to get SIZE and TYPE of the parameter. Add the information - * to our array. - */ + if(use_dollar != DOLLAR_NOPE) { + param = dollarstring(fmt, &fmt); + if(param < 0) { + if(use_dollar == DOLLAR_USE) + /* illegal combo */ + return PFMT_DOLLAR; - width = 0; - precision = 0; - - /* Handle the flags */ - - while(dprintf_IsQualifierNoDollar(fmt)) { -#if defined(MP_HAVE_INT_EXTENSIONS) - if(!strncmp(fmt, "I32", 3)) { - flags |= FLAGS_LONG; - fmt += 3; - } - else if(!strncmp(fmt, "I64", 3)) { - flags |= FLAGS_LONGLONG; - fmt += 3; + /* we got no positional, just get the next arg */ + param = -1; + use_dollar = DOLLAR_NOPE; } else -#endif + use_dollar = DOLLAR_USE; + } + else + param = -1; + /* Handle the flags */ + while(loopit) { switch(*fmt++) { case ' ': flags |= FLAGS_SPACE; @@ -298,40 +309,63 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, case '.': if('*' == *fmt) { /* The precision is picked from a specified parameter */ - flags |= FLAGS_PRECPARAM; fmt++; - param_num++; - i = dprintf_DollarString(fmt, &fmt); - if(i) - precision = i; + if(use_dollar == DOLLAR_USE) { + precision = dollarstring(fmt, &fmt); + if(precision < 0) + /* illegal combo */ + return PFMT_DOLLARPREC; + } else - precision = param_num; - - if(precision > max_param) - max_param = precision; + /* get it from the next argument */ + precision = -1; } else { + bool is_neg = FALSE; flags |= FLAGS_PREC; - precision = strtol(fmt, &fmt, 10); + precision = 0; + if('-' == *fmt) { + is_neg = TRUE; + fmt++; + } + while(ISDIGIT(*fmt)) { + if(precision > INT_MAX/10) + return PFMT_PREC; + precision *= 10; + precision += *fmt - '0'; + fmt++; + } + if(is_neg) + precision = -precision; } if((flags & (FLAGS_PREC | FLAGS_PRECPARAM)) == (FLAGS_PREC | FLAGS_PRECPARAM)) /* it is not permitted to use both kinds of precision for the same argument */ - return 1; + return PFMT_PRECMIX; break; case 'h': flags |= FLAGS_SHORT; break; #if defined(MP_HAVE_INT_EXTENSIONS) case 'I': + if((fmt[0] == '3') && (fmt[1] == '2')) { + flags |= FLAGS_LONG; + fmt += 2; + } + else if((fmt[0] == '6') && (fmt[1] == '4')) { + flags |= FLAGS_LONGLONG; + fmt += 2; + } + else { #if (SIZEOF_CURL_OFF_T > SIZEOF_LONG) - flags |= FLAGS_LONGLONG; + flags |= FLAGS_LONGLONG; #else - flags |= FLAGS_LONG; + flags |= FLAGS_LONG; #endif + } break; #endif case 'l': @@ -365,401 +399,421 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto, case '0': if(!(flags & FLAGS_LEFT)) flags |= FLAGS_PAD_NIL; - /* FALLTHROUGH */ + FALLTHROUGH(); case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': flags |= FLAGS_WIDTH; - width = strtol(fmt-1, &fmt, 10); + width = 0; + fmt--; + do { + if(width > INT_MAX/10) + return PFMT_WIDTH; + width *= 10; + width += *fmt - '0'; + fmt++; + } while(ISDIGIT(*fmt)); break; - case '*': /* Special case */ + case '*': /* read width from argument list */ flags |= FLAGS_WIDTHPARAM; - param_num++; - - i = dprintf_DollarString(fmt, &fmt); - if(i) - width = i; + if(use_dollar == DOLLAR_USE) { + width = dollarstring(fmt, &fmt); + if(width < 0) + /* illegal combo */ + return PFMT_DOLLARWIDTH; + } else - width = param_num; - if(width > max_param) - max_param = width; + /* pick from the next argument */ + width = -1; break; - case '\0': - fmt--; default: + loopit = FALSE; + fmt--; break; - } - } /* switch */ - - /* Handle the specifier */ - - i = this_param - 1; - - if((i < 0) || (i >= MAX_PARAMETERS)) - /* out of allowed range */ - return 1; + } /* switch */ + } /* while */ switch(*fmt) { case 'S': flags |= FLAGS_ALT; - /* FALLTHROUGH */ + FALLTHROUGH(); case 's': - vto[i].type = FORMAT_STRING; + type = FORMAT_STRING; break; case 'n': - vto[i].type = FORMAT_INTPTR; + type = FORMAT_INTPTR; break; case 'p': - vto[i].type = FORMAT_PTR; + type = FORMAT_PTR; break; - case 'd': case 'i': - vto[i].type = FORMAT_INT; + case 'd': + case 'i': + if(flags & FLAGS_LONGLONG) + type = FORMAT_LONGLONG; + else if(flags & FLAGS_LONG) + type = FORMAT_LONG; + else + type = FORMAT_INT; break; case 'u': - vto[i].type = FORMAT_INT; + if(flags & FLAGS_LONGLONG) + type = FORMAT_LONGLONGU; + else if(flags & FLAGS_LONG) + type = FORMAT_LONGU; + else + type = FORMAT_INTU; flags |= FLAGS_UNSIGNED; break; case 'o': - vto[i].type = FORMAT_INT; + type = FORMAT_INT; flags |= FLAGS_OCTAL; break; case 'x': - vto[i].type = FORMAT_INT; + type = FORMAT_INTU; flags |= FLAGS_HEX|FLAGS_UNSIGNED; break; case 'X': - vto[i].type = FORMAT_INT; + type = FORMAT_INTU; flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED; break; case 'c': - vto[i].type = FORMAT_INT; + type = FORMAT_INT; flags |= FLAGS_CHAR; break; case 'f': - vto[i].type = FORMAT_DOUBLE; + type = FORMAT_DOUBLE; break; case 'e': - vto[i].type = FORMAT_DOUBLE; + type = FORMAT_DOUBLE; flags |= FLAGS_FLOATE; break; case 'E': - vto[i].type = FORMAT_DOUBLE; + type = FORMAT_DOUBLE; flags |= FLAGS_FLOATE|FLAGS_UPPER; break; case 'g': - vto[i].type = FORMAT_DOUBLE; + type = FORMAT_DOUBLE; flags |= FLAGS_FLOATG; break; case 'G': - vto[i].type = FORMAT_DOUBLE; + type = FORMAT_DOUBLE; flags |= FLAGS_FLOATG|FLAGS_UPPER; break; default: - vto[i].type = FORMAT_UNKNOWN; - break; + /* invalid instruction, disregard and continue */ + continue; } /* switch */ - vto[i].flags = flags; - vto[i].width = width; - vto[i].precision = precision; - if(flags & FLAGS_WIDTHPARAM) { - /* we have the width specified from a parameter, so we make that - parameter's info setup properly */ - long k = width - 1; - if((k < 0) || (k >= MAX_PARAMETERS)) - /* out of allowed range */ - return 1; - vto[i].width = k; - vto[k].type = FORMAT_WIDTH; - vto[k].flags = FLAGS_NEW; - /* can't use width or precision of width! */ - vto[k].width = 0; - vto[k].precision = 0; + if(width < 0) + width = param_num++; + else { + /* if this identifies a parameter already used, this + is illegal */ + if(usedinput[width/8] & (1 << (width&7))) + return PFMT_WIDTHARG; + } + if(width >= MAX_PARAMETERS) + return PFMT_MANYARGS; + if(width >= max_param) + max_param = width; + + in[width].type = FORMAT_WIDTH; + /* mark as used */ + usedinput[width/8] |= (unsigned char)(1 << (width&7)); } + if(flags & FLAGS_PRECPARAM) { - /* we have the precision specified from a parameter, so we make that - parameter's info setup properly */ - long k = precision - 1; - if((k < 0) || (k >= MAX_PARAMETERS)) - /* out of allowed range */ - return 1; - vto[i].precision = k; - vto[k].type = FORMAT_WIDTH; - vto[k].flags = FLAGS_NEW; - /* can't use width or precision of width! */ - vto[k].width = 0; - vto[k].precision = 0; + if(precision < 0) + precision = param_num++; + else { + /* if this identifies a parameter already used, this + is illegal */ + if(usedinput[precision/8] & (1 << (precision&7))) + return PFMT_PRECARG; + } + if(precision >= MAX_PARAMETERS) + return PFMT_MANYARGS; + if(precision >= max_param) + max_param = precision; + + in[precision].type = FORMAT_PRECISION; + usedinput[precision/8] |= (unsigned char)(1 << (precision&7)); } - *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */ + + /* Handle the specifier */ + if(param < 0) + param = param_num++; + if(param >= MAX_PARAMETERS) + return PFMT_MANYARGS; + if(param >= max_param) + max_param = param; + + iptr = &in[param]; + iptr->type = type; + + /* mark this input as used */ + usedinput[param/8] |= (unsigned char)(1 << (param&7)); + + fmt++; + optr = &out[ocount++]; + if(ocount > MAX_SEGMENTS) + return PFMT_MANYSEGS; + optr->input = param; + optr->flags = flags; + optr->width = width; + optr->precision = precision; + optr->start = start; + optr->outlen = outlen; + start = fmt; } + else + fmt++; } - /* Read the arg list parameters into our data list */ - for(i = 0; i MAX_SEGMENTS) + return PFMT_MANYSEGS; + optr->input = 0; + optr->flags = FLAGS_SUBSTR; + optr->start = start; + optr->outlen = outlen; + } - switch(vto[i].type) { + /* Read the arg list parameters into our data list */ + for(i = 0; i < max_param + 1; i++) { + struct va_input *iptr = &in[i]; + if(!(usedinput[i/8] & (1 << (i&7)))) + /* bad input */ + return PFMT_INPUTGAP; + + /* based on the type, read the correct argument */ + switch(iptr->type) { case FORMAT_STRING: - vto[i].data.str = va_arg(arglist, char *); + iptr->val.str = va_arg(arglist, char *); break; case FORMAT_INTPTR: - case FORMAT_UNKNOWN: case FORMAT_PTR: - vto[i].data.ptr = va_arg(arglist, void *); + iptr->val.ptr = va_arg(arglist, void *); break; - case FORMAT_INT: -#ifdef HAVE_LONG_LONG_TYPE - if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED)) - vto[i].data.num.as_unsigned = - (mp_uintmax_t)va_arg(arglist, mp_uintmax_t); - else if(vto[i].flags & FLAGS_LONGLONG) - vto[i].data.num.as_signed = - (mp_intmax_t)va_arg(arglist, mp_intmax_t); - else -#endif - { - if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED)) - vto[i].data.num.as_unsigned = - (mp_uintmax_t)va_arg(arglist, unsigned long); - else if(vto[i].flags & FLAGS_LONG) - vto[i].data.num.as_signed = - (mp_intmax_t)va_arg(arglist, long); - else if(vto[i].flags & FLAGS_UNSIGNED) - vto[i].data.num.as_unsigned = - (mp_uintmax_t)va_arg(arglist, unsigned int); - else - vto[i].data.num.as_signed = - (mp_intmax_t)va_arg(arglist, int); - } + case FORMAT_LONGLONGU: + iptr->val.numu = (mp_uintmax_t)va_arg(arglist, mp_uintmax_t); break; - case FORMAT_DOUBLE: - vto[i].data.dnum = va_arg(arglist, double); + case FORMAT_LONGLONG: + iptr->val.nums = (mp_intmax_t)va_arg(arglist, mp_intmax_t); + break; + + case FORMAT_LONGU: + iptr->val.numu = (mp_uintmax_t)va_arg(arglist, unsigned long); + break; + + case FORMAT_LONG: + iptr->val.nums = (mp_intmax_t)va_arg(arglist, long); + break; + + case FORMAT_INTU: + iptr->val.numu = (mp_uintmax_t)va_arg(arglist, unsigned int); break; + case FORMAT_INT: case FORMAT_WIDTH: - /* Argument has been read. Silently convert it into an integer - * for later use - */ - vto[i].type = FORMAT_INT; + case FORMAT_PRECISION: + iptr->val.nums = (mp_intmax_t)va_arg(arglist, int); + break; + + case FORMAT_DOUBLE: + iptr->val.dnum = va_arg(arglist, double); break; default: + DEBUGASSERT(NULL); /* unexpected */ break; } } + *ipieces = max_param + 1; + *opieces = ocount; - return 0; - + return PFMT_OK; } -static int dprintf_formatf( - void *data, /* untouched by format(), just sent to the stream() function in - the second argument */ +/* + * formatf() - the general printf function. + * + * It calls parsefmt() to parse the format string. It populates two arrays; + * one that describes the input arguments and one that describes a number of + * output segments. + * + * On success, the input array describes the type of all arguments and their + * values. + * + * The function then iterates over the output sengments and outputs them one + * by one until done. Using the appropriate input arguments (if any). + * + * All output is sent to the 'stream()' callback, one byte at a time. + */ + +static int formatf( + void *userp, /* untouched by format(), just sent to the stream() function in + the second argument */ /* function pointer called for each output character */ - int (*stream)(int, FILE *), + int (*stream)(unsigned char, void *), const char *format, /* %-formatted string */ va_list ap_save) /* list of parameters */ { - /* Base-36 digits for numbers. */ - const char *digits = lower_digits; - - /* Pointer into the format string. */ - char *f; - - /* Number of characters written. */ - int done = 0; - - long param; /* current parameter to read */ - long param_num = 0; /* parameter counter */ - - struct va_stack vto[MAX_PARAMETERS]; - char *endpos[MAX_PARAMETERS]; - char **end; + static const char nilstr[] = "(nil)"; + const char *digits = lower_digits; /* Base-36 digits for numbers. */ + int done = 0; /* number of characters written */ + int i; + int ocount = 0; /* number of output segments */ + int icount = 0; /* number of input arguments */ + + struct outsegment output[MAX_SEGMENTS]; + struct va_input input[MAX_PARAMETERS]; char work[BUFFSIZE]; - struct va_stack *p; /* 'workend' points to the final buffer byte position, but with an extra byte as margin to avoid the (false?) warning Coverity gives us otherwise */ char *workend = &work[sizeof(work) - 2]; - /* Do the actual %-code parsing */ - if(dprintf_Pass1(format, vto, endpos, ap_save)) + /* Parse the format string */ + if(parsefmt(format, output, input, &ocount, &icount, ap_save)) return 0; - end = &endpos[0]; /* the initial end-position from the list dprintf_Pass1() - created for us */ - - f = (char *)format; - while(*f != '\0') { - /* Format spec modifiers. */ - int is_alt; - - /* Width of a field. */ - long width; - - /* Precision of a field. */ - long prec; - - /* Decimal integer is negative. */ - int is_neg; - - /* Base of a number to be written. */ - unsigned long base; - - /* Integral values to be written. */ - mp_uintmax_t num; - - /* Used to convert negative in positive. */ - mp_intmax_t signed_num; - + for(i = 0; i < ocount; i++) { + struct outsegment *optr = &output[i]; + struct va_input *iptr; + bool is_alt; /* Format spec modifiers. */ + int width; /* Width of a field. */ + int prec; /* Precision of a field. */ + bool is_neg; /* Decimal integer is negative. */ + unsigned long base; /* Base of a number to be written. */ + mp_uintmax_t num; /* Integral values to be written. */ + mp_intmax_t signed_num; /* Used to convert negative in positive. */ char *w; - - if(*f != '%') { - /* This isn't a format spec, so write everything out until the next one - OR end of string is reached. */ - do { - OUTCHAR(*f); - } while(*++f && ('%' != *f)); - continue; + size_t outlen = optr->outlen; + int flags = optr->flags; + + if(outlen) { + char *str = optr->start; + for(; outlen && *str; outlen--) + OUTCHAR(*str++); + if(optr->flags & FLAGS_SUBSTR) + /* this is just a substring */ + continue; } - ++f; - - /* Check for "%%". Note that although the ANSI standard lists - '%' as a conversion specifier, it says "The complete format - specification shall be `%%'," so we can avoid all the width - and precision processing. */ - if(*f == '%') { - ++f; - OUTCHAR('%'); - continue; - } - - /* If this is a positional parameter, the position must follow immediately - after the %, thus create a %$ sequence */ - param = dprintf_DollarString(f, &f); - - if(!param) - param = param_num; - else - --param; - - param_num++; /* increase this always to allow "%2$s %1$s %s" and then the - third %s will pick the 3rd argument */ - - p = &vto[param]; - /* pick up the specified width */ - if(p->flags & FLAGS_WIDTHPARAM) { - width = (long)vto[p->width].data.num.as_signed; - param_num++; /* since the width is extracted from a parameter, we - must skip that to get to the next one properly */ + if(flags & FLAGS_WIDTHPARAM) { + width = (int)input[optr->width].val.nums; if(width < 0) { /* "A negative field width is taken as a '-' flag followed by a positive field width." */ - width = -width; - p->flags |= FLAGS_LEFT; - p->flags &= ~FLAGS_PAD_NIL; + if(width == INT_MIN) + width = INT_MAX; + else + width = -width; + flags |= FLAGS_LEFT; + flags &= ~FLAGS_PAD_NIL; } } else - width = p->width; + width = optr->width; /* pick up the specified precision */ - if(p->flags & FLAGS_PRECPARAM) { - prec = (long)vto[p->precision].data.num.as_signed; - param_num++; /* since the precision is extracted from a parameter, we - must skip that to get to the next one properly */ + if(flags & FLAGS_PRECPARAM) { + prec = (int)input[optr->precision].val.nums; if(prec < 0) /* "A negative precision is taken as if the precision were omitted." */ prec = -1; } - else if(p->flags & FLAGS_PREC) - prec = p->precision; + else if(flags & FLAGS_PREC) + prec = optr->precision; else prec = -1; - is_alt = (p->flags & FLAGS_ALT) ? 1 : 0; + is_alt = (flags & FLAGS_ALT) ? 1 : 0; + iptr = &input[optr->input]; - switch(p->type) { + switch(iptr->type) { + case FORMAT_INTU: + case FORMAT_LONGU: + case FORMAT_LONGLONGU: + flags |= FLAGS_UNSIGNED; + FALLTHROUGH(); case FORMAT_INT: - num = p->data.num.as_unsigned; - if(p->flags & FLAGS_CHAR) { + case FORMAT_LONG: + case FORMAT_LONGLONG: + num = iptr->val.numu; + if(flags & FLAGS_CHAR) { /* Character. */ - if(!(p->flags & FLAGS_LEFT)) + if(!(flags & FLAGS_LEFT)) while(--width > 0) OUTCHAR(' '); OUTCHAR((char) num); - if(p->flags & FLAGS_LEFT) + if(flags & FLAGS_LEFT) while(--width > 0) OUTCHAR(' '); break; } - if(p->flags & FLAGS_OCTAL) { - /* Octal unsigned integer. */ + if(flags & FLAGS_OCTAL) { + /* Octal unsigned integer */ base = 8; - goto unsigned_number; + is_neg = FALSE; } - else if(p->flags & FLAGS_HEX) { - /* Hexadecimal unsigned integer. */ - - digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits; + else if(flags & FLAGS_HEX) { + /* Hexadecimal unsigned integer */ + digits = (flags & FLAGS_UPPER)? upper_digits : lower_digits; base = 16; - goto unsigned_number; + is_neg = FALSE; } - else if(p->flags & FLAGS_UNSIGNED) { - /* Decimal unsigned integer. */ + else if(flags & FLAGS_UNSIGNED) { + /* Decimal unsigned integer */ base = 10; - goto unsigned_number; + is_neg = FALSE; } + else { + /* Decimal integer. */ + base = 10; - /* Decimal integer. */ - base = 10; - - is_neg = (p->data.num.as_signed < (mp_intmax_t)0) ? 1 : 0; - if(is_neg) { - /* signed_num might fail to hold absolute negative minimum by 1 */ - signed_num = p->data.num.as_signed + (mp_intmax_t)1; - signed_num = -signed_num; - num = (mp_uintmax_t)signed_num; - num += (mp_uintmax_t)1; + is_neg = (iptr->val.nums < (mp_intmax_t)0); + if(is_neg) { + /* signed_num might fail to hold absolute negative minimum by 1 */ + signed_num = iptr->val.nums + (mp_intmax_t)1; + signed_num = -signed_num; + num = (mp_uintmax_t)signed_num; + num += (mp_uintmax_t)1; + } } - - goto number; - -unsigned_number: - /* Unsigned number of base BASE. */ - is_neg = 0; - number: - /* Number of base BASE. */ - /* Supply a default precision if none was given. */ if(prec == -1) prec = 1; /* Put the number in WORK. */ w = workend; - while(num > 0) { - *w-- = digits[num % base]; - num /= base; + switch(base) { + case 10: + while(num > 0) { + *w-- = (char)('0' + (num % 10)); + num /= 10; + } + break; + default: + while(num > 0) { + *w-- = digits[num % base]; + num /= base; + } + break; } - width -= (long)(workend - w); - prec -= (long)(workend - w); + width -= (int)(workend - w); + prec -= (int)(workend - w); if(is_alt && base == 8 && prec <= 0) { *w-- = '0'; @@ -775,29 +829,29 @@ static int dprintf_formatf( if(is_alt && base == 16) width -= 2; - if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE)) + if(is_neg || (flags & FLAGS_SHOWSIGN) || (flags & FLAGS_SPACE)) --width; - if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL)) + if(!(flags & FLAGS_LEFT) && !(flags & FLAGS_PAD_NIL)) while(width-- > 0) OUTCHAR(' '); if(is_neg) OUTCHAR('-'); - else if(p->flags & FLAGS_SHOWSIGN) + else if(flags & FLAGS_SHOWSIGN) OUTCHAR('+'); - else if(p->flags & FLAGS_SPACE) + else if(flags & FLAGS_SPACE) OUTCHAR(' '); if(is_alt && base == 16) { OUTCHAR('0'); - if(p->flags & FLAGS_UPPER) + if(flags & FLAGS_UPPER) OUTCHAR('X'); else OUTCHAR('x'); } - if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL)) + if(!(flags & FLAGS_LEFT) && (flags & FLAGS_PAD_NIL)) while(width-- > 0) OUTCHAR('0'); @@ -806,219 +860,199 @@ static int dprintf_formatf( OUTCHAR(*w); } - if(p->flags & FLAGS_LEFT) + if(flags & FLAGS_LEFT) while(width-- > 0) OUTCHAR(' '); break; - case FORMAT_STRING: - /* String. */ - { - static const char null[] = "(nil)"; - const char *str; - size_t len; - - str = (char *) p->data.str; - if(!str) { - /* Write null[] if there's space. */ - if(prec == -1 || prec >= (long) sizeof(null) - 1) { - str = null; - len = sizeof(null) - 1; - /* Disable quotes around (nil) */ - p->flags &= (~FLAGS_ALT); - } - else { - str = ""; - len = 0; - } + case FORMAT_STRING: { + const char *str; + size_t len; + + str = (char *)iptr->val.str; + if(!str) { + /* Write null string if there's space. */ + if(prec == -1 || prec >= (int) sizeof(nilstr) - 1) { + str = nilstr; + len = sizeof(nilstr) - 1; + /* Disable quotes around (nil) */ + flags &= (~FLAGS_ALT); } - else if(prec != -1) - len = (size_t)prec; - else if(*str == '\0') + else { + str = ""; len = 0; - else - len = strlen(str); + } + } + else if(prec != -1) + len = (size_t)prec; + else if(*str == '\0') + len = 0; + else + len = strlen(str); - width -= (len > LONG_MAX) ? LONG_MAX : (long)len; + width -= (len > INT_MAX) ? INT_MAX : (int)len; - if(p->flags & FLAGS_ALT) - OUTCHAR('"'); + if(flags & FLAGS_ALT) + OUTCHAR('"'); - if(!(p->flags&FLAGS_LEFT)) - while(width-- > 0) - OUTCHAR(' '); + if(!(flags&FLAGS_LEFT)) + while(width-- > 0) + OUTCHAR(' '); - for(; len && *str; len--) - OUTCHAR(*str++); - if(p->flags&FLAGS_LEFT) - while(width-- > 0) - OUTCHAR(' '); + for(; len && *str; len--) + OUTCHAR(*str++); + if(flags&FLAGS_LEFT) + while(width-- > 0) + OUTCHAR(' '); - if(p->flags & FLAGS_ALT) - OUTCHAR('"'); - } + if(flags & FLAGS_ALT) + OUTCHAR('"'); break; + } case FORMAT_PTR: /* Generic pointer. */ - { - void *ptr; - ptr = (void *) p->data.ptr; - if(ptr) { - /* If the pointer is not NULL, write it as a %#x spec. */ - base = 16; - digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits; - is_alt = 1; - num = (size_t) ptr; - is_neg = 0; - goto number; - } - else { - /* Write "(nil)" for a nil pointer. */ - static const char strnil[] = "(nil)"; - const char *point; - - width -= (long)(sizeof(strnil) - 1); - if(p->flags & FLAGS_LEFT) - while(width-- > 0) - OUTCHAR(' '); - for(point = strnil; *point != '\0'; ++point) - OUTCHAR(*point); - if(!(p->flags & FLAGS_LEFT)) - while(width-- > 0) - OUTCHAR(' '); - } + if(iptr->val.ptr) { + /* If the pointer is not NULL, write it as a %#x spec. */ + base = 16; + digits = (flags & FLAGS_UPPER)? upper_digits : lower_digits; + is_alt = TRUE; + num = (size_t) iptr->val.ptr; + is_neg = FALSE; + goto number; } - break; + else { + /* Write "(nil)" for a nil pointer. */ + const char *point; - case FORMAT_DOUBLE: - { - char formatbuf[32]="%"; - char *fptr = &formatbuf[1]; - size_t left = sizeof(formatbuf)-strlen(formatbuf); - int len; - - width = -1; - if(p->flags & FLAGS_WIDTH) - width = p->width; - else if(p->flags & FLAGS_WIDTHPARAM) - width = (long)vto[p->width].data.num.as_signed; + width -= (int)(sizeof(nilstr) - 1); + if(flags & FLAGS_LEFT) + while(width-- > 0) + OUTCHAR(' '); + for(point = nilstr; *point != '\0'; ++point) + OUTCHAR(*point); + if(!(flags & FLAGS_LEFT)) + while(width-- > 0) + OUTCHAR(' '); + } + break; - prec = -1; - if(p->flags & FLAGS_PREC) - prec = p->precision; - else if(p->flags & FLAGS_PRECPARAM) - prec = (long)vto[p->precision].data.num.as_signed; - - if(p->flags & FLAGS_LEFT) - *fptr++ = '-'; - if(p->flags & FLAGS_SHOWSIGN) - *fptr++ = '+'; - if(p->flags & FLAGS_SPACE) - *fptr++ = ' '; - if(p->flags & FLAGS_ALT) - *fptr++ = '#'; - - *fptr = 0; - - if(width >= 0) { - if(width >= (long)sizeof(work)) - width = sizeof(work)-1; - /* RECURSIVE USAGE */ - len = curl_msnprintf(fptr, left, "%ld", width); - fptr += len; - left -= len; + case FORMAT_DOUBLE: { + char formatbuf[32]="%"; + char *fptr = &formatbuf[1]; + size_t left = sizeof(formatbuf)-strlen(formatbuf); + int len; + + if(flags & FLAGS_WIDTH) + width = optr->width; + + if(flags & FLAGS_PREC) + prec = optr->precision; + + if(flags & FLAGS_LEFT) + *fptr++ = '-'; + if(flags & FLAGS_SHOWSIGN) + *fptr++ = '+'; + if(flags & FLAGS_SPACE) + *fptr++ = ' '; + if(flags & FLAGS_ALT) + *fptr++ = '#'; + + *fptr = 0; + + if(width >= 0) { + if(width >= (int)sizeof(work)) + width = sizeof(work)-1; + /* RECURSIVE USAGE */ + len = curl_msnprintf(fptr, left, "%d", width); + fptr += len; + left -= len; + } + if(prec >= 0) { + /* for each digit in the integer part, we can have one less + precision */ + size_t maxprec = sizeof(work) - 2; + double val = iptr->val.dnum; + if(width > 0 && prec <= width) + maxprec -= width; + while(val >= 10.0) { + val /= 10; + maxprec--; } - if(prec >= 0) { - /* for each digit in the integer part, we can have one less - precision */ - size_t maxprec = sizeof(work) - 2; - double val = p->data.dnum; - if(width > 0 && prec <= width) - maxprec -= width; - while(val >= 10.0) { - val /= 10; - maxprec--; - } - if(prec > (long)maxprec) - prec = (long)maxprec-1; - if(prec < 0) - prec = 0; - /* RECURSIVE USAGE */ - len = curl_msnprintf(fptr, left, ".%ld", prec); - fptr += len; - } - if(p->flags & FLAGS_LONG) - *fptr++ = 'l'; + if(prec > (int)maxprec) + prec = (int)maxprec-1; + if(prec < 0) + prec = 0; + /* RECURSIVE USAGE */ + len = curl_msnprintf(fptr, left, ".%d", prec); + fptr += len; + } + if(flags & FLAGS_LONG) + *fptr++ = 'l'; - if(p->flags & FLAGS_FLOATE) - *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e'); - else if(p->flags & FLAGS_FLOATG) - *fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g'); - else - *fptr++ = 'f'; + if(flags & FLAGS_FLOATE) + *fptr++ = (char)((flags & FLAGS_UPPER) ? 'E':'e'); + else if(flags & FLAGS_FLOATG) + *fptr++ = (char)((flags & FLAGS_UPPER) ? 'G' : 'g'); + else + *fptr++ = 'f'; - *fptr = 0; /* and a final null-termination */ + *fptr = 0; /* and a final null-termination */ #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-nonliteral" #endif - /* NOTE NOTE NOTE!! Not all sprintf implementations return number of - output characters */ + /* NOTE NOTE NOTE!! Not all sprintf implementations return number of + output characters */ #ifdef HAVE_SNPRINTF - (snprintf)(work, sizeof(work), formatbuf, p->data.dnum); + (snprintf)(work, sizeof(work), formatbuf, iptr->val.dnum); #else - (sprintf)(work, formatbuf, p->data.dnum); + (sprintf)(work, formatbuf, iptr->val.dnum); #endif #ifdef __clang__ #pragma clang diagnostic pop #endif - DEBUGASSERT(strlen(work) <= sizeof(work)); - for(fptr = work; *fptr; fptr++) - OUTCHAR(*fptr); - } + DEBUGASSERT(strlen(work) <= sizeof(work)); + for(fptr = work; *fptr; fptr++) + OUTCHAR(*fptr); break; + } case FORMAT_INTPTR: /* Answer the count of characters written. */ #ifdef HAVE_LONG_LONG_TYPE - if(p->flags & FLAGS_LONGLONG) - *(LONG_LONG_TYPE *) p->data.ptr = (LONG_LONG_TYPE)done; + if(flags & FLAGS_LONGLONG) + *(LONG_LONG_TYPE *) iptr->val.ptr = (LONG_LONG_TYPE)done; else #endif - if(p->flags & FLAGS_LONG) - *(long *) p->data.ptr = (long)done; - else if(!(p->flags & FLAGS_SHORT)) - *(int *) p->data.ptr = (int)done; + if(flags & FLAGS_LONG) + *(long *) iptr->val.ptr = (long)done; + else if(!(flags & FLAGS_SHORT)) + *(int *) iptr->val.ptr = (int)done; else - *(short *) p->data.ptr = (short)done; + *(short *) iptr->val.ptr = (short)done; break; default: break; } - f = *end++; /* goto end of %-code */ - } return done; } /* fputc() look-alike */ -static int addbyter(int output, FILE *data) +static int addbyter(unsigned char outc, void *f) { - struct nsprintf *infop = (struct nsprintf *)data; - unsigned char outc = (unsigned char)output; - + struct nsprintf *infop = f; if(infop->length < infop->max) { /* only do this if we haven't reached max length yet */ - infop->buffer[0] = outc; /* store */ - infop->buffer++; /* increase pointer */ + *infop->buffer++ = outc; /* store */ infop->length++; /* we are now one byte larger */ - return outc; /* fputc() returns like this on success */ + return 0; /* fputc() returns like this on success */ } - return -1; + return 1; } int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, @@ -1031,7 +1065,7 @@ int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, info.length = 0; info.max = maxlength; - retcode = dprintf_formatf(&info, addbyter, format, ap_save); + retcode = formatf(&info, addbyter, format, ap_save); if(info.max) { /* we terminate this with a zero byte */ if(info.max == info.length) { @@ -1057,29 +1091,28 @@ int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...) } /* fputc() look-alike */ -static int alloc_addbyter(int output, FILE *data) +static int alloc_addbyter(unsigned char outc, void *f) { - struct asprintf *infop = (struct asprintf *)data; - unsigned char outc = (unsigned char)output; - - if(Curl_dyn_addn(infop->b, &outc, 1)) { - infop->fail = 1; - return -1; /* fail */ + struct asprintf *infop = f; + CURLcode result = Curl_dyn_addn(infop->b, &outc, 1); + if(result) { + infop->merr = result == CURLE_TOO_LARGE ? MERR_TOO_LARGE : MERR_MEM; + return 1 ; /* fail */ } - return outc; /* fputc() returns like this on success */ + return 0; } -/* appends the formatted string, returns 0 on success, 1 on error */ +/* appends the formatted string, returns MERR error code */ int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save) { struct asprintf info; info.b = dyn; - info.fail = 0; + info.merr = MERR_OK; - (void)dprintf_formatf(&info, alloc_addbyter, format, ap_save); - if(info.fail) { + (void)formatf(&info, alloc_addbyter, format, ap_save); + if(info.merr) { Curl_dyn_free(info.b); - return 1; + return info.merr; } return 0; } @@ -1090,10 +1123,10 @@ char *curl_mvaprintf(const char *format, va_list ap_save) struct dynbuf dyn; info.b = &dyn; Curl_dyn_init(info.b, DYN_APRINTF); - info.fail = 0; + info.merr = MERR_OK; - (void)dprintf_formatf(&info, alloc_addbyter, format, ap_save); - if(info.fail) { + (void)formatf(&info, alloc_addbyter, format, ap_save); + if(info.merr) { Curl_dyn_free(info.b); return NULL; } @@ -1112,13 +1145,12 @@ char *curl_maprintf(const char *format, ...) return s; } -static int storebuffer(int output, FILE *data) +static int storebuffer(unsigned char outc, void *f) { - char **buffer = (char **)data; - unsigned char outc = (unsigned char)output; + char **buffer = f; **buffer = outc; (*buffer)++; - return outc; /* act like fputc() ! */ + return 0; } int curl_msprintf(char *buffer, const char *format, ...) @@ -1126,19 +1158,29 @@ int curl_msprintf(char *buffer, const char *format, ...) va_list ap_save; /* argument pointer */ int retcode; va_start(ap_save, format); - retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); + retcode = formatf(&buffer, storebuffer, format, ap_save); va_end(ap_save); *buffer = 0; /* we terminate this with a zero byte */ return retcode; } +static int fputc_wrapper(unsigned char outc, void *f) +{ + int out = outc; + FILE *s = f; + int rc = fputc(out, s); + if(rc == out) + return 0; + return 1; +} + int curl_mprintf(const char *format, ...) { int retcode; va_list ap_save; /* argument pointer */ va_start(ap_save, format); - retcode = dprintf_formatf(stdout, fputc, format, ap_save); + retcode = formatf(stdout, fputc_wrapper, format, ap_save); va_end(ap_save); return retcode; } @@ -1148,25 +1190,24 @@ int curl_mfprintf(FILE *whereto, const char *format, ...) int retcode; va_list ap_save; /* argument pointer */ va_start(ap_save, format); - retcode = dprintf_formatf(whereto, fputc, format, ap_save); + retcode = formatf(whereto, fputc_wrapper, format, ap_save); va_end(ap_save); return retcode; } int curl_mvsprintf(char *buffer, const char *format, va_list ap_save) { - int retcode; - retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); + int retcode = formatf(&buffer, storebuffer, format, ap_save); *buffer = 0; /* we terminate this with a zero byte */ return retcode; } int curl_mvprintf(const char *format, va_list ap_save) { - return dprintf_formatf(stdout, fputc, format, ap_save); + return formatf(stdout, fputc_wrapper, format, ap_save); } int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save) { - return dprintf_formatf(whereto, fputc, format, ap_save); + return formatf(whereto, fputc_wrapper, format, ap_save); } diff --git a/lib/mqtt.c b/lib/mqtt.c index 366235c55..5a9d6d0f1 100644 --- a/lib/mqtt.c +++ b/lib/mqtt.c @@ -88,7 +88,7 @@ const struct Curl_handler Curl_handler_mqtt = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_MQTT, /* defport */ @@ -524,8 +524,10 @@ static CURLcode mqtt_publish(struct Curl_easy *data) char encodedbytes[4]; curl_off_t postfieldsize = data->set.postfieldsize; - if(!payload) + if(!payload) { + DEBUGF(infof(data, "mqtt_publish without payload, return bad arg")); return CURLE_BAD_FUNCTION_ARGUMENT; + } if(postfieldsize < 0) payloadlen = strlen(payload); else @@ -622,7 +624,6 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done) struct connectdata *conn = data->conn; curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; ssize_t nread; - unsigned char *pkt = (unsigned char *)data->state.buffer; size_t remlen; struct mqtt_conn *mqtt = &conn->proto.mqtt; struct MQTT *mq = data->req.p.mqtt; @@ -671,13 +672,14 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done) data->req.bytecount = 0; data->req.size = remlen; mq->npacket = remlen; /* get this many bytes */ - /* FALLTHROUGH */ + FALLTHROUGH(); case MQTT_PUB_REMAIN: { /* read rest of packet, but no more. Cap to buffer size */ + char buffer[4*1024]; size_t rest = mq->npacket; - if(rest > (size_t)data->set.buffer_size) - rest = (size_t)data->set.buffer_size; - result = Curl_read(data, sockfd, (char *)pkt, rest, &nread); + if(rest > sizeof(buffer)) + rest = sizeof(buffer); + result = Curl_read(data, sockfd, buffer, rest, &nread); if(result) { if(CURLE_AGAIN == result) { infof(data, "EEEE AAAAGAIN"); @@ -690,14 +692,12 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done) goto end; } - mq->npacket -= nread; - /* if QoS is set, message contains packet id */ - - result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)pkt, nread); + result = Curl_client_write(data, CLIENTWRITE_BODY, buffer, nread); if(result) goto end; + mq->npacket -= nread; if(!mq->npacket) /* no more PUBLISH payload, back to subscribe wait state */ mqstate(data, MQTT_FIRST, MQTT_PUBWAIT); @@ -745,7 +745,6 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done) struct MQTT *mq = data->req.p.mqtt; ssize_t nread; curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; - unsigned char *pkt = (unsigned char *)data->state.buffer; unsigned char byte; *done = FALSE; @@ -776,14 +775,14 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done) /* remember the first byte */ mq->npacket = 0; mqstate(data, MQTT_REMAINING_LENGTH, MQTT_NOSTATE); - /* FALLTHROUGH */ + FALLTHROUGH(); case MQTT_REMAINING_LENGTH: do { result = Curl_read(data, sockfd, (char *)&byte, 1, &nread); if(!nread) break; Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1); - pkt[mq->npacket++] = byte; + mq->pkt_hd[mq->npacket++] = byte; } while((byte & 0x80) && (mq->npacket < 4)); if(nread && (byte & 0x80)) /* MQTT supports up to 127 * 128^0 + 127 * 128^1 + 127 * 128^2 + @@ -791,7 +790,7 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done) result = CURLE_WEIRD_SERVER_REPLY; if(result) break; - mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL); + mq->remaining_length = mqtt_decode_len(mq->pkt_hd, mq->npacket, NULL); mq->npacket = 0; if(mq->remaining_length) { mqstate(data, mqtt->nextstate, MQTT_NOSTATE); diff --git a/lib/mqtt.h b/lib/mqtt.h index 84f177022..99ab12a98 100644 --- a/lib/mqtt.h +++ b/lib/mqtt.h @@ -57,6 +57,7 @@ struct MQTT { unsigned char firstbyte; size_t remaining_length; struct dynbuf recvbuf; + unsigned char pkt_hd[4]; /* for decoding the arriving packet length */ }; #endif /* HEADER_CURL_MQTT_H */ diff --git a/lib/multi.c b/lib/multi.c index 5456113be..0926b0d85 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -672,6 +672,7 @@ static CURLcode multi_done(struct Curl_easy *data, many callbacks and protocols work differently, we could potentially do this more fine-grained in the future. */ premature = TRUE; + FALLTHROUGH(); default: break; } @@ -993,31 +994,92 @@ void Curl_attach_connection(struct Curl_easy *data, Curl_conn_ev_data_attach(conn, data); } -static int domore_getsock(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *socks) +static int connecting_getsock(struct Curl_easy *data, curl_socket_t *socks) { + struct connectdata *conn = data->conn; + (void)socks; + /* Not using `conn->sockfd` as `Curl_setup_transfer()` initializes + * that *after* the connect. */ + if(conn && conn->sock[FIRSTSOCKET] != CURL_SOCKET_BAD) { + /* Default is to wait to something from the server */ + socks[0] = conn->sock[FIRSTSOCKET]; + return GETSOCK_READSOCK(0); + } + return GETSOCK_BLANK; +} + +static int protocol_getsock(struct Curl_easy *data, curl_socket_t *socks) +{ + struct connectdata *conn = data->conn; + if(conn && conn->handler->proto_getsock) + return conn->handler->proto_getsock(data, conn, socks); + else if(conn && conn->sockfd != CURL_SOCKET_BAD) { + /* Default is to wait to something from the server */ + socks[0] = conn->sockfd; + return GETSOCK_READSOCK(0); + } + return GETSOCK_BLANK; +} + +static int domore_getsock(struct Curl_easy *data, curl_socket_t *socks) +{ + struct connectdata *conn = data->conn; if(conn && conn->handler->domore_getsock) return conn->handler->domore_getsock(data, conn, socks); + else if(conn && conn->sockfd != CURL_SOCKET_BAD) { + /* Default is that we want to send something to the server */ + socks[0] = conn->sockfd; + return GETSOCK_WRITESOCK(0); + } return GETSOCK_BLANK; } -static int doing_getsock(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *socks) +static int doing_getsock(struct Curl_easy *data, curl_socket_t *socks) { + struct connectdata *conn = data->conn; if(conn && conn->handler->doing_getsock) return conn->handler->doing_getsock(data, conn, socks); + else if(conn && conn->sockfd != CURL_SOCKET_BAD) { + /* Default is that we want to send something to the server */ + socks[0] = conn->sockfd; + return GETSOCK_WRITESOCK(0); + } return GETSOCK_BLANK; } -static int protocol_getsock(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *socks) +static int perform_getsock(struct Curl_easy *data, curl_socket_t *sock) { - if(conn->handler->proto_getsock) - return conn->handler->proto_getsock(data, conn, socks); - return GETSOCK_BLANK; + struct connectdata *conn = data->conn; + + if(!conn) + return GETSOCK_BLANK; + else if(conn->handler->perform_getsock) + return conn->handler->perform_getsock(data, conn, sock); + else { + /* Default is to obey the data->req.keepon flags for send/recv */ + int bitmap = GETSOCK_BLANK; + unsigned sockindex = 0; + if(CURL_WANT_RECV(data)) { + DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); + bitmap |= GETSOCK_READSOCK(sockindex); + sock[sockindex] = conn->sockfd; + } + + if(CURL_WANT_SEND(data)) { + if((conn->sockfd != conn->writesockfd) || + bitmap == GETSOCK_BLANK) { + /* only if they are not the same socket and we have a readable + one, we increase index */ + if(bitmap != GETSOCK_BLANK) + sockindex++; /* increase index if we need two entries */ + + DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); + sock[sockindex] = conn->writesockfd; + } + bitmap |= GETSOCK_WRITESOCK(sockindex); + } + return bitmap; + } } /* Initializes `poll_set` with the current socket poll actions needed @@ -1033,45 +1095,61 @@ static void multi_getsock(struct Curl_easy *data, return; switch(data->mstate) { - default: + case MSTATE_INIT: + case MSTATE_PENDING: + case MSTATE_CONNECT: + /* nothing to poll for yet */ break; case MSTATE_RESOLVING: - Curl_pollset_add_socks2(data, ps, Curl_resolv_getsock); + Curl_pollset_add_socks(data, ps, Curl_resolv_getsock); /* connection filters are not involved in this phase */ - return; + break; + + case MSTATE_CONNECTING: + case MSTATE_TUNNELING: + Curl_pollset_add_socks(data, ps, connecting_getsock); + Curl_conn_adjust_pollset(data, ps); + break; - case MSTATE_PROTOCONNECTING: case MSTATE_PROTOCONNECT: + case MSTATE_PROTOCONNECTING: Curl_pollset_add_socks(data, ps, protocol_getsock); + Curl_conn_adjust_pollset(data, ps); break; case MSTATE_DO: case MSTATE_DOING: Curl_pollset_add_socks(data, ps, doing_getsock); - break; - - case MSTATE_TUNNELING: - case MSTATE_CONNECTING: + Curl_conn_adjust_pollset(data, ps); break; case MSTATE_DOING_MORE: Curl_pollset_add_socks(data, ps, domore_getsock); + Curl_conn_adjust_pollset(data, ps); break; - case MSTATE_DID: /* since is set after DO is completed, we switch to - waiting for the same as the PERFORMING state */ + case MSTATE_DID: /* same as PERFORMING in regard to polling */ case MSTATE_PERFORMING: - Curl_pollset_add_socks(data, ps, Curl_single_getsock); + Curl_pollset_add_socks(data, ps, perform_getsock); + Curl_conn_adjust_pollset(data, ps); break; case MSTATE_RATELIMITING: - /* nothing to wait for */ - return; - } + /* we need to let time pass, ignore socket(s) */ + break; + + case MSTATE_DONE: + case MSTATE_COMPLETED: + case MSTATE_MSGSENT: + /* nothing more to poll for */ + break; - /* Let connection filters add/remove as needed */ - Curl_conn_adjust_pollset(data, ps); + default: + failf(data, "multi_getsock: unexpected multi state %d", data->mstate); + DEBUGASSERT(0); + break; + } } CURLMcode curl_multi_fdset(struct Curl_multi *multi, @@ -1942,6 +2020,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } if(!result) { + *nowp = Curl_pgrsTime(data, TIMER_POSTQUEUE); if(async) /* We're now waiting for an asynchronous name lookup */ multistate(data, MSTATE_RESOLVING); @@ -1983,8 +2062,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, if(dns) { #ifdef CURLRES_ASYNCH - conn->resolve_async.dns = dns; - conn->resolve_async.done = TRUE; + data->state.async.dns = dns; + data->state.async.done = TRUE; #endif result = CURLE_OK; infof(data, "Hostname '%s' was found in DNS cache", hostname); @@ -2371,7 +2450,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, { char *newurl = NULL; bool retry = FALSE; - bool comeback = FALSE; DEBUGASSERT(data->state.buffer); /* check if over send speed */ send_timeout_ms = 0; @@ -2402,7 +2480,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } /* read/write data if it is ready to do so */ - result = Curl_readwrite(data->conn, data, &done, &comeback); + result = Curl_readwrite(data, &done); if(done || (result == CURLE_RECV_ERROR)) { /* If CURLE_RECV_ERROR happens early enough, we assume it was a race @@ -2512,7 +2590,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } } } - else if(comeback) { + else if(data->state.select_bits) { /* This avoids CURLM_CALL_MULTI_PERFORM so that a very fast transfer won't get stuck on this transfer at the expense of other concurrent transfers */ @@ -3164,7 +3242,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, if(data->conn && !(data->conn->handler->flags & PROTOPT_DIRLOCK)) /* set socket event bitmask if they're not locked */ - data->conn->cselect_bits = (unsigned char)ev_bitmask; + data->state.select_bits = (unsigned char)ev_bitmask; Curl_expire(data, 0, EXPIRE_RUN_NOW); } diff --git a/lib/noproxy.c b/lib/noproxy.c index 2b9908d89..5241640a3 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -216,7 +216,6 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy, /* case C passes through, not a match */ break; case TYPE_IPV4: - /* FALLTHROUGH */ case TYPE_IPV6: { const char *check = token; char *slash; diff --git a/lib/openldap.c b/lib/openldap.c index 131f47414..1e60ff738 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -130,7 +130,7 @@ const struct Curl_handler Curl_handler_ldap = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ oldap_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_LDAP, /* defport */ @@ -158,7 +158,7 @@ const struct Curl_handler Curl_handler_ldaps = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ oldap_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_LDAPS, /* defport */ @@ -645,7 +645,7 @@ static CURLcode oldap_state_mechs_resp(struct Curl_easy *data, switch(code) { case LDAP_SIZELIMIT_EXCEEDED: infof(data, "Too many authentication mechanisms\n"); - /* FALLTHROUGH */ + FALLTHROUGH(); case LDAP_SUCCESS: case LDAP_NO_RESULTS_RETURNED: if(Curl_sasl_can_authenticate(&li->sasl, data)) @@ -793,10 +793,13 @@ static CURLcode oldap_connecting(struct Curl_easy *data, bool *done) result = oldap_perform_bind(data, OLDAP_BIND); break; } - /* FALLTHROUGH */ + result = Curl_ssl_cfilter_add(data, conn, FIRSTSOCKET); + if(result) + break; + FALLTHROUGH(); case OLDAP_TLS: result = oldap_ssl_connect(data, OLDAP_TLS); - if(result && data->set.use_ssl != CURLUSESSL_TRY) + if(result) result = oldap_map_error(code, CURLE_USE_SSL_FAILED); else if(ssl_installed(conn)) { conn->bits.tls_upgraded = TRUE; @@ -887,10 +890,14 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done) result = oldap_url_parse(data, &lud); if(!result) { - Sockbuf *sb; - /* re-install the libcurl SSL handlers into the sockbuf. */ - ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb); - ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data); +#ifdef USE_SSL + if(ssl_installed(conn)) { + Sockbuf *sb; + /* re-install the libcurl SSL handlers into the sockbuf. */ + ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb); + ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data); + } +#endif rc = ldap_search_ext(li->ld, lud->lud_dn, lud->lud_scope, lud->lud_filter, lud->lud_attrs, 0, @@ -1014,7 +1021,7 @@ static ssize_t oldap_recv(struct Curl_easy *data, int sockindex, char *buf, switch(code) { case LDAP_SIZELIMIT_EXCEEDED: infof(data, "There are more than %d entries", lr->nument); - /* FALLTHROUGH */ + FALLTHROUGH(); case LDAP_SUCCESS: data->req.size = data->req.bytecount; break; diff --git a/lib/pingpong.c b/lib/pingpong.c index 0081c9ca6..b976ffbea 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -36,6 +36,7 @@ #include "pingpong.h" #include "multiif.h" #include "vtls/vtls.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -105,7 +106,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data, if(Curl_conn_data_pending(data, FIRSTSOCKET)) rc = 1; - else if(Curl_pp_moredata(pp)) + else if(pp->overflow) /* We are receiving and there is data in the cache so just read it */ rc = 1; else if(!pp->sendleft && Curl_conn_data_pending(data, FIRSTSOCKET)) @@ -139,19 +140,13 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data, } /* initialize stuff to prepare for reading a fresh new response */ -void Curl_pp_init(struct Curl_easy *data, struct pingpong *pp) +void Curl_pp_init(struct pingpong *pp) { - DEBUGASSERT(data); pp->nread_resp = 0; - pp->linestart_resp = data->state.buffer; - pp->pending_resp = TRUE; pp->response = Curl_now(); /* start response time-out now! */ -} - -/* setup for the coming transfer */ -void Curl_pp_setup(struct pingpong *pp) -{ + pp->pending_resp = TRUE; Curl_dyn_init(&pp->sendbuf, DYN_PINGPPONG_CMD); + Curl_dyn_init(&pp->recvbuf, DYN_PINGPPONG_CMD); } /*********************************************************************** @@ -197,9 +192,9 @@ CURLcode Curl_pp_vsendf(struct Curl_easy *data, if(result) return result; + pp->pending_resp = TRUE; write_len = Curl_dyn_len(&pp->sendbuf); s = Curl_dyn_ptr(&pp->sendbuf); - Curl_pp_init(data, pp); #ifdef HAVE_GSSAPI conn->data_prot = PROT_CMD; @@ -255,6 +250,25 @@ CURLcode Curl_pp_sendf(struct Curl_easy *data, struct pingpong *pp, return result; } +static CURLcode pingpong_read(struct Curl_easy *data, + curl_socket_t sockfd, + char *buffer, + size_t buflen, + ssize_t *nread) +{ + CURLcode result; +#ifdef HAVE_GSSAPI + enum protection_level prot = data->conn->data_prot; + data->conn->data_prot = PROT_CLEAR; +#endif + result = Curl_read(data, sockfd, buffer, buflen, nread); +#ifdef HAVE_GSSAPI + DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); + data->conn->data_prot = (unsigned char)prot; +#endif + return result; +} + /* * Curl_pp_readresp() * @@ -266,181 +280,96 @@ CURLcode Curl_pp_readresp(struct Curl_easy *data, int *code, /* return the server code if done */ size_t *size) /* size of the response */ { - ssize_t perline; /* count bytes per line */ - bool keepon = TRUE; - ssize_t gotbytes; - char *ptr; struct connectdata *conn = data->conn; - char * const buf = data->state.buffer; CURLcode result = CURLE_OK; *code = 0; /* 0 for errors or not done */ *size = 0; - ptr = buf + pp->nread_resp; + if(pp->nfinal) { + /* a previous call left this many bytes in the beginning of the buffer as + that was the final line; now ditch that */ + size_t full = Curl_dyn_len(&pp->recvbuf); - /* number of bytes in the current line, so far */ - perline = (ssize_t)(ptr-pp->linestart_resp); + /* trim off the "final" leading part */ + Curl_dyn_tail(&pp->recvbuf, full - pp->nfinal); - while((pp->nread_resp < (size_t)data->set.buffer_size) && - (keepon && !result)) { + pp->nfinal = 0; /* now gone */ + } + if(!pp->overflow) { + ssize_t gotbytes = 0; + char buffer[900]; - if(pp->cache) { - /* we had data in the "cache", copy that instead of doing an actual - * read - * - * pp->cache_size is cast to ssize_t here. This should be safe, because - * it would have been populated with something of size int to begin - * with, even though its datatype may be larger than an int. - */ - if((ptr + pp->cache_size) > (buf + data->set.buffer_size + 1)) { - failf(data, "cached response data too big to handle"); - return CURLE_WEIRD_SERVER_REPLY; - } - memcpy(ptr, pp->cache, pp->cache_size); - gotbytes = (ssize_t)pp->cache_size; - free(pp->cache); /* free the cache */ - pp->cache = NULL; /* clear the pointer */ - pp->cache_size = 0; /* zero the size just in case */ - } - else { -#ifdef HAVE_GSSAPI - enum protection_level prot = conn->data_prot; - conn->data_prot = PROT_CLEAR; -#endif - DEBUGASSERT((ptr + data->set.buffer_size - pp->nread_resp) <= - (buf + data->set.buffer_size + 1)); - result = Curl_read(data, sockfd, ptr, - data->set.buffer_size - pp->nread_resp, - &gotbytes); -#ifdef HAVE_GSSAPI - DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST); - conn->data_prot = (unsigned char)prot; -#endif - if(result == CURLE_AGAIN) - return CURLE_OK; /* return */ + result = pingpong_read(data, sockfd, buffer, sizeof(buffer), &gotbytes); + if(result == CURLE_AGAIN) + return CURLE_OK; - if(result) - /* Set outer result variable to this error. */ - keepon = FALSE; - } + if(result) + return result; - if(!keepon) - ; - else if(gotbytes <= 0) { - keepon = FALSE; - result = CURLE_RECV_ERROR; + if(gotbytes <= 0) { failf(data, "response reading failed (errno: %d)", SOCKERRNO); + return CURLE_RECV_ERROR; } - else { - /* we got a whole chunk of data, which can be anything from one - * byte to a set of lines and possible just a piece of the last - * line */ - ssize_t i; - ssize_t clipamount = 0; - bool restart = FALSE; - - data->req.headerbytecount += (unsigned int)gotbytes; - - pp->nread_resp += gotbytes; - for(i = 0; i < gotbytes; ptr++, i++) { - perline++; - if(*ptr == '\n') { - /* a newline is CRLF in pp-talk, so the CR is ignored as - the line isn't really terminated until the LF comes */ - - /* output debug output if that is requested */ + + result = Curl_dyn_addn(&pp->recvbuf, buffer, gotbytes); + if(result) + return result; + + data->req.headerbytecount += (unsigned int)gotbytes; + + pp->nread_resp += gotbytes; + } + + do { + char *line = Curl_dyn_ptr(&pp->recvbuf); + char *nl = memchr(line, '\n', Curl_dyn_len(&pp->recvbuf)); + if(nl) { + /* a newline is CRLF in pp-talk, so the CR is ignored as + the line isn't really terminated until the LF comes */ + size_t length = nl - line + 1; + + /* output debug output if that is requested */ #ifdef HAVE_GSSAPI - if(!conn->sec_complete) + if(!conn->sec_complete) #endif - Curl_debug(data, CURLINFO_HEADER_IN, - pp->linestart_resp, (size_t)perline); - - /* - * We pass all response-lines to the callback function registered - * for "headers". The response lines can be seen as a kind of - * headers. - */ - result = Curl_client_write(data, CLIENTWRITE_INFO, - pp->linestart_resp, perline); - if(result) - return result; - - if(pp->endofresp(data, conn, pp->linestart_resp, perline, code)) { - /* This is the end of the last line, copy the last line to the - start of the buffer and null-terminate, for old times sake */ - size_t n = ptr - pp->linestart_resp; - memmove(buf, pp->linestart_resp, n); - buf[n] = 0; /* null-terminate */ - keepon = FALSE; - pp->linestart_resp = ptr + 1; /* advance pointer */ - i++; /* skip this before getting out */ - - *size = pp->nread_resp; /* size of the response */ - pp->nread_resp = 0; /* restart */ - break; - } - perline = 0; /* line starts over here */ - pp->linestart_resp = ptr + 1; - } - } + Curl_debug(data, CURLINFO_HEADER_IN, line, length); - if(!keepon && (i != gotbytes)) { - /* We found the end of the response lines, but we didn't parse the - full chunk of data we have read from the server. We therefore need - to store the rest of the data to be checked on the next invoke as - it may actually contain another end of response already! */ - clipamount = gotbytes - i; - restart = TRUE; - DEBUGF(infof(data, "Curl_pp_readresp_ %d bytes of trailing " - "server response left", - (int)clipamount)); - } - else if(keepon) { - - if((perline == gotbytes) && - (gotbytes > (ssize_t)data->set.buffer_size/2)) { - /* We got an excessive line without newlines and we need to deal - with it. We keep the first bytes of the line then we throw - away the rest. */ - infof(data, "Excessive server response line length received, " - "%zd bytes. Stripping", gotbytes); - restart = TRUE; - - /* we keep 40 bytes since all our pingpong protocols are only - interested in the first piece */ - clipamount = 40; - } - else if(pp->nread_resp > (size_t)data->set.buffer_size/2) { - /* We got a large chunk of data and there's potentially still - trailing data to take care of, so we put any such part in the - "cache", clear the buffer to make space and restart. */ - clipamount = perline; - restart = TRUE; - } - } - else if(i == gotbytes) - restart = TRUE; - - if(clipamount) { - pp->cache_size = clipamount; - pp->cache = malloc(pp->cache_size); - if(pp->cache) - memcpy(pp->cache, pp->linestart_resp, pp->cache_size); + /* + * Pass all response-lines to the callback function registered for + * "headers". The response lines can be seen as a kind of headers. + */ + result = Curl_client_write(data, CLIENTWRITE_INFO, line, length); + if(result) + return result; + + if(pp->endofresp(data, conn, line, length, code)) { + /* When at "end of response", keep the endofresp line first in the + buffer since it will be accessed outside (by pingpong + parsers). Store the overflow counter to inform about additional + data in this buffer after the endofresp line. */ + pp->nfinal = length; + if(Curl_dyn_len(&pp->recvbuf) > length) + pp->overflow = Curl_dyn_len(&pp->recvbuf) - length; else - return CURLE_OUT_OF_MEMORY; + pp->overflow = 0; + *size = pp->nread_resp; /* size of the response */ + pp->nread_resp = 0; /* restart */ + break; } - if(restart) { - /* now reset a few variables to start over nicely from the start of - the big buffer */ - pp->nread_resp = 0; /* start over from scratch in the buffer */ - ptr = pp->linestart_resp = buf; - perline = 0; - } - - } /* there was data */ + if(Curl_dyn_len(&pp->recvbuf) > length) + /* keep the remaining piece */ + Curl_dyn_tail((&pp->recvbuf), Curl_dyn_len(&pp->recvbuf) - length); + else + Curl_dyn_reset(&pp->recvbuf); + } + else { + /* without a newline, there is no overflow */ + pp->overflow = 0; + break; + } - } /* while there's buffer left and loop is requested */ + } while(1); /* while there's buffer left to scan */ pp->pending_resp = FALSE; @@ -488,14 +417,13 @@ CURLcode Curl_pp_flushsend(struct Curl_easy *data, CURLcode Curl_pp_disconnect(struct pingpong *pp) { Curl_dyn_free(&pp->sendbuf); - Curl_safefree(pp->cache); + Curl_dyn_free(&pp->recvbuf); return CURLE_OK; } bool Curl_pp_moredata(struct pingpong *pp) { - return (!pp->sendleft && pp->cache && pp->nread_resp < pp->cache_size) ? - TRUE : FALSE; + return (!pp->sendleft && Curl_dyn_len(&pp->recvbuf)); } #endif diff --git a/lib/pingpong.h b/lib/pingpong.h index 80d3f7718..006b9c538 100644 --- a/lib/pingpong.h +++ b/lib/pingpong.h @@ -47,16 +47,11 @@ typedef enum { * It holds response cache and non-blocking sending data. */ struct pingpong { - char *cache; /* data cache between getresponse()-calls */ - size_t cache_size; /* size of cache in bytes */ size_t nread_resp; /* number of bytes currently read of a server response */ - char *linestart_resp; /* line start pointer for the server response - reader function */ bool pending_resp; /* set TRUE when a server response is pending or in progress, and is cleared once the last response is read */ - char *sendthis; /* allocated pointer to a buffer that is to be sent to the - server */ + char *sendthis; /* pointer to a buffer that is to be sent to the server */ size_t sendleft; /* number of bytes left to send from the sendthis buffer */ size_t sendsize; /* total size of the sendthis buffer */ struct curltime response; /* set to Curl_now() when a command has been sent @@ -64,6 +59,10 @@ struct pingpong { timediff_t response_time; /* When no timeout is given, this is the amount of milliseconds we await for a server response. */ struct dynbuf sendbuf; + struct dynbuf recvbuf; + size_t overflow; /* number of bytes left after a final response line */ + size_t nfinal; /* number of bytes in the final response line, which + after a match is first in the receice buffer */ /* Function pointers the protocols MUST implement and provide for the pingpong layer to function */ @@ -90,10 +89,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data, struct pingpong *pp, bool block, bool disconnecting); /* initialize stuff to prepare for reading a fresh new response */ -void Curl_pp_init(struct Curl_easy *data, struct pingpong *pp); - -/* setup for the transfer */ -void Curl_pp_setup(struct pingpong *pp); +void Curl_pp_init(struct pingpong *pp); /* Returns timeout in ms. 0 or negative number means the timeout has already triggered */ @@ -113,7 +109,7 @@ timediff_t Curl_pp_state_timeout(struct Curl_easy *data, */ CURLcode Curl_pp_sendf(struct Curl_easy *data, struct pingpong *pp, - const char *fmt, ...); + const char *fmt, ...) CURL_PRINTF(3, 4); /*********************************************************************** * @@ -128,7 +124,7 @@ CURLcode Curl_pp_sendf(struct Curl_easy *data, CURLcode Curl_pp_vsendf(struct Curl_easy *data, struct pingpong *pp, const char *fmt, - va_list args); + va_list args) CURL_PRINTF(3, 0); /* * Curl_pp_readresp() diff --git a/lib/pop3.c b/lib/pop3.c index 3e0f20a69..cf2519282 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -77,6 +77,7 @@ #include "curl_sasl.h" #include "curl_md5.h" #include "warnless.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" @@ -124,7 +125,7 @@ const struct Curl_handler Curl_handler_pop3 = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ pop3_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_POP3, /* defport */ @@ -153,7 +154,7 @@ const struct Curl_handler Curl_handler_pop3s = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ pop3_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_POP3S, /* defport */ @@ -251,8 +252,8 @@ static bool pop3_endofresp(struct Curl_easy *data, struct connectdata *conn, */ static CURLcode pop3_get_message(struct Curl_easy *data, struct bufref *out) { - char *message = data->state.buffer; - size_t len = strlen(message); + char *message = Curl_dyn_ptr(&data->conn->proto.pop3c.pp.recvbuf); + size_t len = data->conn->proto.pop3c.pp.nfinal; if(len > 2) { /* Find the start of the message */ @@ -648,8 +649,8 @@ static CURLcode pop3_state_servergreet_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; struct connectdata *conn = data->conn; struct pop3_conn *pop3c = &conn->proto.pop3c; - const char *line = data->state.buffer; - size_t len = strlen(line); + const char *line = Curl_dyn_ptr(&data->conn->proto.pop3c.pp.recvbuf); + size_t len = data->conn->proto.pop3c.pp.nfinal; (void)instate; /* no use for this yet */ @@ -657,44 +658,35 @@ static CURLcode pop3_state_servergreet_resp(struct Curl_easy *data, failf(data, "Got unexpected pop3-server response"); result = CURLE_WEIRD_SERVER_REPLY; } - else { + else if(len > 3) { /* Does the server support APOP authentication? */ - if(len >= 4 && line[len - 2] == '>') { - /* Look for the APOP timestamp */ - size_t i; - for(i = 3; i < len - 2; ++i) { - if(line[i] == '<') { - /* Calculate the length of the timestamp */ - size_t timestamplen = len - 1 - i; - char *at; - if(!timestamplen) - break; - - /* Allocate some memory for the timestamp */ - pop3c->apoptimestamp = (char *)calloc(1, timestamplen + 1); - - if(!pop3c->apoptimestamp) - break; - - /* Copy the timestamp */ - memcpy(pop3c->apoptimestamp, line + i, timestamplen); - pop3c->apoptimestamp[timestamplen] = '\0'; - - /* If the timestamp does not contain '@' it is not (as required by - RFC-1939) conformant to the RFC-822 message id syntax, and we - therefore do not use APOP authentication. */ - at = strchr(pop3c->apoptimestamp, '@'); - if(!at) - Curl_safefree(pop3c->apoptimestamp); - else - /* Store the APOP capability */ - pop3c->authtypes |= POP3_TYPE_APOP; - break; - } + char *lt; + char *gt = NULL; + + /* Look for the APOP timestamp */ + lt = memchr(line, '<', len); + if(lt) + /* search the remainder for '>' */ + gt = memchr(lt, '>', len - (lt - line)); + if(gt) { + /* the length of the timestamp, including the brackets */ + size_t timestamplen = gt - lt + 1; + char *at = memchr(lt, '@', timestamplen); + /* If the timestamp does not contain '@' it is not (as required by + RFC-1939) conformant to the RFC-822 message id syntax, and we + therefore do not use APOP authentication. */ + if(at) { + /* dupe the timestamp */ + pop3c->apoptimestamp = Curl_memdup0(lt, timestamplen); + if(!pop3c->apoptimestamp) + return CURLE_OUT_OF_MEMORY; + /* Store the APOP capability */ + pop3c->authtypes |= POP3_TYPE_APOP; } } - result = pop3_perform_capa(data, conn); + if(!result) + result = pop3_perform_capa(data, conn); } return result; @@ -707,8 +699,8 @@ static CURLcode pop3_state_capa_resp(struct Curl_easy *data, int pop3code, CURLcode result = CURLE_OK; struct connectdata *conn = data->conn; struct pop3_conn *pop3c = &conn->proto.pop3c; - const char *line = data->state.buffer; - size_t len = strlen(line); + const char *line = Curl_dyn_ptr(&data->conn->proto.pop3c.pp.recvbuf); + size_t len = data->conn->proto.pop3c.pp.nfinal; (void)instate; /* no use for this yet */ @@ -795,7 +787,7 @@ static CURLcode pop3_state_starttls_resp(struct Curl_easy *data, (void)instate; /* no use for this yet */ /* Pipelining in response is forbidden. */ - if(data->conn->proto.pop3c.pp.cache_size) + if(data->conn->proto.pop3c.pp.overflow) return CURLE_WEIRD_SERVER_REPLY; if(pop3code != '+') { @@ -944,24 +936,29 @@ static CURLcode pop3_state_command_resp(struct Curl_easy *data, /* POP3 download */ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1); - if(pp->cache) { - /* The header "cache" contains a bunch of data that is actually body - content so send it as such. Note that there may even be additional - "headers" after the body */ + if(pp->overflow) { + /* The recv buffer contains data that is actually body content so send + it as such. Note that there may even be additional "headers" after + the body */ + + /* keep only the overflow */ + Curl_dyn_tail(&pp->recvbuf, pp->overflow); + pp->nfinal = 0; /* done */ if(!data->req.no_body) { - result = Curl_pop3_write(data, pp->cache, pp->cache_size); + result = Curl_pop3_write(data, Curl_dyn_ptr(&pp->recvbuf), + Curl_dyn_len(&pp->recvbuf)); if(result) return result; } - /* Free the cache */ - Curl_safefree(pp->cache); - - /* Reset the cache size */ - pp->cache_size = 0; + /* reset the buffer */ + Curl_dyn_reset(&pp->recvbuf); + pp->overflow = 0; } } + else + pp->overflow = 0; /* End of DO phase */ pop3_state(data, POP3_STOP); @@ -1131,8 +1128,7 @@ static CURLcode pop3_connect(struct Curl_easy *data, bool *done) Curl_sasl_init(&pop3c->sasl, data, &saslpop3); /* Initialise the pingpong layer */ - Curl_pp_setup(pp); - Curl_pp_init(data, pp); + Curl_pp_init(pp); /* Parse the URL options */ result = pop3_parse_url_options(conn); diff --git a/lib/progress.c b/lib/progress.c index e96cbf7af..d05fcc3eb 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -174,10 +174,18 @@ void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer, data->progress.t_startop = timestamp; break; case TIMER_STARTSINGLE: - /* This is set at the start of each single fetch */ + /* This is set at the start of each single transfer */ data->progress.t_startsingle = timestamp; data->progress.is_t_startransfer_set = false; break; + case TIMER_POSTQUEUE: + /* Set when the transfer starts (after potentially having been brought + back from the waiting queue). It needs to count from t_startop and not + t_startsingle since the latter is reset when a connection is brought + back from the pending queue. */ + data->progress.t_postqueue = + Curl_timediff_us(timestamp, data->progress.t_startop); + break; case TIMER_STARTACCEPT: data->progress.t_acceptdata = timestamp; break; diff --git a/lib/progress.h b/lib/progress.h index fc39e34d2..73749419a 100644 --- a/lib/progress.h +++ b/lib/progress.h @@ -30,7 +30,8 @@ typedef enum { TIMER_NONE, TIMER_STARTOP, - TIMER_STARTSINGLE, + TIMER_STARTSINGLE, /* start of transfer, might get queued */ + TIMER_POSTQUEUE, /* start, immediately after dequeue */ TIMER_NAMELOOKUP, TIMER_CONNECT, TIMER_APPCONNECT, diff --git a/lib/rand.c b/lib/rand.c index 3383c490b..c62b1a403 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -201,7 +201,7 @@ CURLcode Curl_rand(struct Curl_easy *data, unsigned char *rnd, size_t num) { CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT; - DEBUGASSERT(num > 0); + DEBUGASSERT(num); while(num) { unsigned int r; @@ -241,9 +241,11 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, memset(buffer, 0, sizeof(buffer)); #endif - if((num/2 >= sizeof(buffer)) || !(num&1)) + if((num/2 >= sizeof(buffer)) || !(num&1)) { /* make sure it fits in the local buffer and that it is an odd number! */ + DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex")); return CURLE_BAD_FUNCTION_ARGUMENT; + } num--; /* save one for null-termination */ diff --git a/lib/rtsp.c b/lib/rtsp.c index e673bb8dc..26f473534 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -58,21 +58,20 @@ static int rtsp_getsock_do(struct Curl_easy *data, struct connectdata *conn, curl_socket_t *socks); /* - * Parse and write out any available RTP data. + * Parse and write out an RTSP response. * @param data the transfer * @param conn the connection * @param buf data read from connection * @param blen amount of data in buf - * @param consumed out, number of blen consumed + * @param is_eos TRUE iff this is the last write * @param readmore out, TRUE iff complete buf was consumed and more data * is needed */ -static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data, - struct connectdata *conn, - const char *buf, - size_t blen, - size_t *pconsumed, - bool *readmore); +static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data, + const char *buf, + size_t blen, + bool is_eos, + bool *done); static CURLcode rtsp_setup_connection(struct Curl_easy *data, struct connectdata *conn); @@ -115,7 +114,7 @@ const struct Curl_handler Curl_handler_rtsp = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ rtsp_disconnect, /* disconnect */ - rtsp_rtp_readwrite, /* readwrite */ + rtsp_rtp_write_resp, /* write_resp */ rtsp_conncheck, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_RTSP, /* defport */ @@ -590,26 +589,48 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) return result; } +/** + * write any BODY bytes missing to the client, ignore the rest. + */ +static CURLcode rtp_write_body_junk(struct Curl_easy *data, + const char *buf, + size_t blen) +{ + struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); + curl_off_t body_remain; + bool in_body; + + in_body = (data->req.headerline && !rtspc->in_header) && + (data->req.size >= 0) && + (data->req.bytecount < data->req.size); + body_remain = in_body? (data->req.size - data->req.bytecount) : 0; + DEBUGASSERT(body_remain >= 0); + if(body_remain) { + if((curl_off_t)blen > body_remain) + blen = (size_t)body_remain; + return Curl_client_write(data, CLIENTWRITE_BODY, (char *)buf, blen); + } + return CURLE_OK; +} + static CURLcode rtsp_filter_rtp(struct Curl_easy *data, - struct connectdata *conn, const char *buf, size_t blen, - bool in_body, size_t *pconsumed) { - struct rtsp_conn *rtspc = &(conn->proto.rtspc); + struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); CURLcode result = CURLE_OK; + size_t skip_len = 0; *pconsumed = 0; while(blen) { + bool in_body = (data->req.headerline && !rtspc->in_header) && + (data->req.size >= 0) && + (data->req.bytecount < data->req.size); switch(rtspc->state) { case RTP_PARSE_SKIP: { DEBUGASSERT(Curl_dyn_len(&rtspc->buf) == 0); - if(in_body && buf[0] != '$') { - /* in BODY and no valid start, do not consume and return */ - goto out; - } while(blen && buf[0] != '$') { if(!in_body && buf[0] == 'R' && data->set.rtspreq != RTSPREQ_RECEIVE) { @@ -624,13 +645,22 @@ static CURLcode rtsp_filter_rtp(struct Curl_easy *data, goto out; } } - /* junk, consume without buffering */ + /* junk/BODY, consume without buffering */ *pconsumed += 1; ++buf; --blen; + ++skip_len; } if(blen && buf[0] == '$') { /* possible start of an RTP message, buffer */ + if(skip_len) { + /* end of junk/BODY bytes, flush */ + result = rtp_write_body_junk(data, + (char *)(buf - skip_len), skip_len); + skip_len = 0; + if(result) + goto out; + } if(Curl_dyn_addn(&rtspc->buf, buf, 1)) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -650,35 +680,22 @@ static CURLcode rtsp_filter_rtp(struct Curl_easy *data, if(!(data->state.rtp_channel_mask[idx] & (1 << off))) { /* invalid channel number, junk or BODY data */ rtspc->state = RTP_PARSE_SKIP; - if(in_body) { - /* we do not consume this byte, it is BODY data */ - DEBUGF(infof(data, "RTSP: invalid RTP channel %d in BODY, " - "treating as BODY data", idx)); - if(*pconsumed == 0) { - /* We did not consume the initial '$' in our buffer, but had - * it from an earlier call. We cannot un-consume it and have - * to write it directly as BODY data */ - result = Curl_client_write(data, CLIENTWRITE_BODY, - Curl_dyn_ptr(&rtspc->buf), 1); - Curl_dyn_free(&rtspc->buf); - if(result) - goto out; - } - else { - /* un-consume the '$' and leave */ - Curl_dyn_free(&rtspc->buf); - *pconsumed -= 1; - --buf; - ++blen; + DEBUGASSERT(skip_len == 0); + /* we do not consume this byte, it is BODY data */ + DEBUGF(infof(data, "RTSP: invalid RTP channel %d, skipping", idx)); + if(*pconsumed == 0) { + /* We did not consume the initial '$' in our buffer, but had + * it from an earlier call. We cannot un-consume it and have + * to write it directly as BODY data */ + result = rtp_write_body_junk(data, Curl_dyn_ptr(&rtspc->buf), 1); + if(result) goto out; - } } else { - /* not BODY, forget the junk '$'. Do not consume this byte, - * it might be a start */ - infof(data, "RTSP: invalid RTP channel %d, skipping", idx); - Curl_dyn_free(&rtspc->buf); + /* count the '$' as skip and continue */ + skip_len = 1; } + Curl_dyn_free(&rtspc->buf); break; } /* a valid channel, so we expect this to be a real RTP message */ @@ -754,52 +771,51 @@ static CURLcode rtsp_filter_rtp(struct Curl_easy *data, } } out: + if(!result && skip_len) + result = rtp_write_body_junk(data, (char *)(buf - skip_len), skip_len); return result; } -static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data, - struct connectdata *conn, - const char *buf, - size_t blen, - size_t *pconsumed, - bool *readmore) +static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data, + const char *buf, + size_t blen, + bool is_eos, + bool *done) { - struct rtsp_conn *rtspc = &(conn->proto.rtspc); + struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); CURLcode result = CURLE_OK; size_t consumed = 0; - bool in_body; if(!data->req.header) rtspc->in_header = FALSE; - in_body = (data->req.headerline && !rtspc->in_header) && - (data->req.size >= 0) && - (data->req.bytecount < data->req.size); - - *readmore = FALSE; - *pconsumed = 0; + *done = FALSE; if(!blen) { goto out; } + DEBUGF(infof(data, "rtsp_rtp_write_resp(len=%zu, in_header=%d, eos=%d)", + blen, rtspc->in_header, is_eos)); + /* If header parsing is not onging, extract RTP messages */ if(!rtspc->in_header) { - result = rtsp_filter_rtp(data, conn, buf, blen, in_body, &consumed); + result = rtsp_filter_rtp(data, buf, blen, &consumed); if(result) goto out; - *pconsumed += consumed; buf += consumed; blen -= consumed; + /* either we consumed all or are at the start of header parsing */ + if(blen && !data->req.header) + DEBUGF(infof(data, "RTSP: %zu bytes, possibly excess in response body", + blen)); } /* we want to parse headers, do so */ if(data->req.header && blen) { rtspc->in_header = TRUE; - result = Curl_http_readwrite_headers(data, conn, buf, blen, - &consumed); + result = Curl_http_write_resp_hds(data, buf, blen, &consumed, done); if(result) goto out; - *pconsumed += consumed; buf += consumed; blen -= consumed; @@ -807,26 +823,41 @@ static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data, rtspc->in_header = FALSE; if(!rtspc->in_header) { - /* If header parsing is done and data left, extract RTP messages */ - in_body = (data->req.headerline && !rtspc->in_header) && - (data->req.size >= 0) && - (data->req.bytecount < data->req.size); - result = rtsp_filter_rtp(data, conn, buf, blen, in_body, &consumed); + /* If header parsing is done, extract interleaved RTP messages */ + if(data->req.size <= -1) { + /* Respect section 4.4 of rfc2326: If the Content-Length header is + absent, a length 0 must be assumed. */ + data->req.size = 0; + data->req.download_done = TRUE; + } + result = rtsp_filter_rtp(data, buf, blen, &consumed); if(result) goto out; - *pconsumed += consumed; + blen -= consumed; } } if(rtspc->state != RTP_PARSE_SKIP) - *readmore = TRUE; + *done = FALSE; + /* we SHOULD have consumed all bytes, unless the response is borked. + * In which case we write out the left over bytes, letting the client + * writer deal with it (it will report EXCESS and fail the transfer). */ + DEBUGF(infof(data, "rtsp_rtp_write_resp(len=%zu, in_header=%d, done=%d " + " rtspc->state=%d, req.size=%" CURL_FORMAT_CURL_OFF_T ")", + blen, rtspc->in_header, *done, rtspc->state, data->req.size)); + if(!result && (is_eos || blen)) { + result = Curl_client_write(data, CLIENTWRITE_BODY| + (is_eos? CLIENTWRITE_EOS:0), + (char *)buf, blen); + } out: - if(!*readmore && data->set.rtspreq == RTSPREQ_RECEIVE) { + if((data->set.rtspreq == RTSPREQ_RECEIVE) && + (rtspc->state == RTP_PARSE_SKIP)) { /* In special mode RECEIVE, we just process one chunk of network * data, so we stop the transfer here, if we have no incomplete * RTP message pending. */ - data->req.keepon &= ~KEEP_RECV; + data->req.download_done = TRUE; } return result; } @@ -922,7 +953,7 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, char *header) /* If the Session ID is set, then compare */ if(strlen(data->set.str[STRING_RTSP_SESSION_ID]) != idlen || - strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen) != 0) { + strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen)) { failf(data, "Got RTSP Session ID Line [%s], but wanted ID [%s]", start, data->set.str[STRING_RTSP_SESSION_ID]); return CURLE_RTSP_SESSION_ERROR; @@ -934,11 +965,9 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, char *header) */ /* Copy the id substring into a new buffer */ - data->set.str[STRING_RTSP_SESSION_ID] = malloc(idlen + 1); + data->set.str[STRING_RTSP_SESSION_ID] = Curl_memdup0(start, idlen); if(!data->set.str[STRING_RTSP_SESSION_ID]) return CURLE_OUT_OF_MEMORY; - memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, idlen); - (data->set.str[STRING_RTSP_SESSION_ID])[idlen] = '\0'; } } else if(checkprefix("Transport:", header)) { diff --git a/lib/sendf.c b/lib/sendf.c index a2fac0c4e..db3189a29 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -296,13 +296,6 @@ static CURLcode chop_write(struct Curl_easy *data, if(!skip_body_write && ((type & CLIENTWRITE_BODY) || ((type & CLIENTWRITE_HEADER) && data->set.include_header))) { -#ifdef USE_WEBSOCKETS - if(conn->handler->protocol & (CURLPROTO_WS|CURLPROTO_WSS)) { - writebody = Curl_ws_writecb; - writebody_ptr = data; - } - else -#endif writebody = data->set.fwrite_func; } if((type & (CLIENTWRITE_HEADER|CLIENTWRITE_INFO)) && @@ -345,7 +338,7 @@ static CURLcode chop_write(struct Curl_easy *data, len -= chunklen; } -#ifndef CURL_DISABLE_HTTP +#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HEADERS_API) /* HTTP header, but not status-line */ if((conn->handler->protocol & PROTO_FAMILY_HTTP) && (type & CLIENTWRITE_HEADER) && !(type & CLIENTWRITE_STATUS) ) { @@ -404,10 +397,12 @@ CURLcode Curl_client_write(struct Curl_easy *data, #endif /* it is one of those, at least */ DEBUGASSERT(type & (CLIENTWRITE_BODY|CLIENTWRITE_HEADER|CLIENTWRITE_INFO)); - /* BODY is only BODY */ - DEBUGASSERT(!(type & CLIENTWRITE_BODY) || (type == CLIENTWRITE_BODY)); - /* INFO is only INFO */ - DEBUGASSERT(!(type & CLIENTWRITE_INFO) || (type == CLIENTWRITE_INFO)); + /* BODY is only BODY (with optional EOS) */ + DEBUGASSERT(!(type & CLIENTWRITE_BODY) || + ((type & ~(CLIENTWRITE_BODY|CLIENTWRITE_EOS)) == 0)); + /* INFO is only INFO (with optional EOS) */ + DEBUGASSERT(!(type & CLIENTWRITE_INFO) || + ((type & ~(CLIENTWRITE_INFO|CLIENTWRITE_EOS)) == 0)); if(!data->req.writer_stack) { result = do_init_stack(data); @@ -477,8 +472,6 @@ CURLcode Curl_cwriter_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - if(!nbytes) - return CURLE_OK; if(!writer) return CURLE_WRITE_ERROR; return writer->cwt->do_write(data, writer, type, buf, nbytes); @@ -556,7 +549,6 @@ static CURLcode cw_download_write(struct Curl_easy *data, { CURLcode result; size_t nwrite, excess_len = 0; - const char *excess_data = NULL; if(!(type & CLIENTWRITE_BODY)) { if((type & CLIENTWRITE_CONNECT) && data->set.suppress_connect_headers) @@ -564,13 +556,38 @@ static CURLcode cw_download_write(struct Curl_easy *data, return Curl_cwriter_write(data, writer->next, type, buf, nbytes); } + if(!data->req.bytecount) { + Curl_pgrsTime(data, TIMER_STARTTRANSFER); + if(data->req.exp100 > EXP100_SEND_DATA) + /* set time stamp to compare with when waiting for the 100 */ + data->req.start100 = Curl_now(); + } + + /* Here, we deal with REAL BODY bytes. All filtering and transfer + * encodings have been applied and only the true content, e.g. BODY, + * bytes are passed here. + * This allows us to check sizes, update stats, etc. independent + * from the protocol in play. */ + + if(data->req.no_body && nbytes > 0) { + /* BODY arrives although we want none, bail out */ + streamclose(data->conn, "ignoring body"); + DEBUGF(infof(data, "did not want a BODY, but seeing %zu bytes", + nbytes)); + data->req.download_done = TRUE; + return CURLE_WEIRD_SERVER_REPLY; + } + + /* Determine if we see any bytes in excess to what is allowed. + * We write the allowed bytes and handle excess further below. + * This gives deterministic BODY writes on varying buffer receive + * lengths. */ nwrite = nbytes; if(-1 != data->req.maxdownload) { size_t wmax = get_max_body_write_len(data, data->req.maxdownload); if(nwrite > wmax) { excess_len = nbytes - wmax; nwrite = wmax; - excess_data = buf + nwrite; } if(nwrite == wmax) { @@ -578,6 +595,8 @@ static CURLcode cw_download_write(struct Curl_easy *data, } } + /* Error on too large filesize is handled below, after writing + * the permitted bytes */ if(data->set.max_filesize) { size_t wmax = get_max_body_write_len(data, data->set.max_filesize); if(nwrite > wmax) { @@ -585,6 +604,7 @@ static CURLcode cw_download_write(struct Curl_easy *data, } } + /* Update stats, write and report progress */ data->req.bytecount += nwrite; ++data->req.bodywrites; if(!data->req.ignorebody && nwrite) { @@ -597,23 +617,7 @@ static CURLcode cw_download_write(struct Curl_easy *data, return result; if(excess_len) { - if(data->conn->handler->readwrite) { - /* RTSP hack moved from transfer loop to here */ - bool readmore = FALSE; /* indicates data is incomplete, need more */ - size_t consumed = 0; - result = data->conn->handler->readwrite(data, data->conn, - excess_data, excess_len, - &consumed, &readmore); - if(result) - return result; - DEBUGASSERT(consumed <= excess_len); - excess_len -= consumed; - if(readmore) { - data->req.download_done = FALSE; - data->req.keepon |= KEEP_RECV; /* we're not done reading */ - } - } - if(excess_len && !data->req.ignorebody) { + if(!data->req.ignorebody) { infof(data, "Excess found writing body:" " excess = %zu" @@ -762,6 +766,21 @@ CURLcode Curl_cwriter_add(struct Curl_easy *data, return CURLE_OK; } +void Curl_cwriter_remove_by_name(struct Curl_easy *data, + const char *name) +{ + struct Curl_cwriter **anchor = &data->req.writer_stack; + + while(*anchor) { + if(!strcmp(name, (*anchor)->cwt->name)) { + struct Curl_cwriter *w = (*anchor); + *anchor = w->next; + Curl_cwriter_free(data, w); + continue; + } + anchor = &((*anchor)->next); + } +} /* * Internal read-from-socket function. This is meant to deal with plain diff --git a/lib/sendf.h b/lib/sendf.h index a70189f2f..7deae2ac3 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -49,6 +49,7 @@ #define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */ #define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */ #define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */ +#define CLIENTWRITE_EOS (1<<7) /* End Of transfer download Stream */ /** * Write `len` bytes at `prt` to the client. `type` indicates what @@ -147,6 +148,9 @@ size_t Curl_cwriter_count(struct Curl_easy *data, Curl_cwriter_phase phase); CURLcode Curl_cwriter_add(struct Curl_easy *data, struct Curl_cwriter *writer); +void Curl_cwriter_remove_by_name(struct Curl_easy *data, + const char *name); + /** * Convenience method for calling `writer->do_write()` that * checks for NULL writer. diff --git a/lib/setopt.c b/lib/setopt.c index a08140cce..a5270773f 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -51,7 +51,7 @@ #include "altsvc.h" #include "hsts.h" #include "tftp.h" - +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" @@ -366,6 +366,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) else return CURLE_BAD_FUNCTION_ARGUMENT; break; + case CURLOPT_SERVER_RESPONSE_TIMEOUT_MS: + /* + * Option that specifies how quickly a server response must be obtained + * before it is considered failure. For pingpong protocols. + */ + arg = va_arg(param, long); + if((arg >= 0) && (arg <= INT_MAX)) + data->set.server_response_timeout = (unsigned int)arg; + else + return CURLE_BAD_FUNCTION_ARGUMENT; + break; #ifndef CURL_DISABLE_TFTP case CURLOPT_TFTP_NO_OPTIONS: /* @@ -497,26 +508,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) (data->set.postfieldsize > (curl_off_t)((size_t)-1)))) result = CURLE_OUT_OF_MEMORY; else { - char *p; - - (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); - /* Allocate even when size == 0. This satisfies the need of possible - later address compare to detect the COPYPOSTFIELDS mode, and - to mark that postfields is used rather than read function or - form data. + later address compare to detect the COPYPOSTFIELDS mode, and to + mark that postfields is used rather than read function or form + data. */ - p = malloc((size_t)(data->set.postfieldsize? - data->set.postfieldsize:1)); - + char *p = Curl_memdup0(argptr, (size_t)data->set.postfieldsize); + (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); if(!p) result = CURLE_OUT_OF_MEMORY; - else { - if(data->set.postfieldsize) - memcpy(p, argptr, (size_t)data->set.postfieldsize); - + else data->set.str[STRING_COPYPOSTFIELDS] = p; - } } } @@ -670,6 +672,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) data->set.opt_no_body = FALSE; /* this is implied */ Curl_mime_cleanpart(data->state.formp); Curl_safefree(data->state.formp); + data->state.mimepost = NULL; break; #endif @@ -977,6 +980,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) #ifndef CURL_DISABLE_FORM_API Curl_mime_cleanpart(data->state.formp); Curl_safefree(data->state.formp); + data->state.mimepost = NULL; #endif } break; @@ -3109,6 +3113,10 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) return CURLE_OUT_OF_MEMORY; } arg = va_arg(param, long); + if(!arg) { + DEBUGF(infof(data, "bad CURLOPT_ALTSVC_CTRL input")); + return CURLE_BAD_FUNCTION_ARGUMENT; + } result = Curl_altsvc_ctrl(data->asi, arg); if(result) return result; @@ -3163,5 +3171,9 @@ CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...) result = Curl_vsetopt(data, tag, arg); va_end(arg); +#ifdef DEBUGBUILD + if(result == CURLE_BAD_FUNCTION_ARGUMENT) + infof(data, "setopt arg 0x%x returned CURLE_BAD_FUNCTION_ARGUMENT", tag); +#endif return result; } diff --git a/lib/setup-win32.h b/lib/setup-win32.h index 4e034d4bb..d7e2e6be1 100644 --- a/lib/setup-win32.h +++ b/lib/setup-win32.h @@ -24,18 +24,53 @@ * ***************************************************************************/ +#undef USE_WINSOCK +/* ---------------------------------------------------------------- */ +/* Watt-32 TCP/IP SPECIFIC */ +/* ---------------------------------------------------------------- */ +#ifdef USE_WATT32 +# include +# undef byte +# undef word +# define HAVE_SYS_IOCTL_H +# define HAVE_SYS_SOCKET_H +# define HAVE_NETINET_IN_H +# define HAVE_NETDB_H +# define HAVE_ARPA_INET_H +# define SOCKET int +/* ---------------------------------------------------------------- */ +/* BSD-style lwIP TCP/IP stack SPECIFIC */ +/* ---------------------------------------------------------------- */ +#elif defined(USE_LWIPSOCK) + /* Define to use BSD-style lwIP TCP/IP stack. */ + /* #define USE_LWIPSOCK 1 */ +# undef HAVE_GETHOSTNAME +# undef LWIP_POSIX_SOCKETS_IO_NAMES +# undef RECV_TYPE_ARG1 +# undef RECV_TYPE_ARG3 +# undef SEND_TYPE_ARG1 +# undef SEND_TYPE_ARG3 +# define HAVE_GETHOSTBYNAME_R +# define HAVE_GETHOSTBYNAME_R_6 +# define LWIP_POSIX_SOCKETS_IO_NAMES 0 +# define RECV_TYPE_ARG1 int +# define RECV_TYPE_ARG3 size_t +# define SEND_TYPE_ARG1 int +# define SEND_TYPE_ARG3 size_t +#elif defined(_WIN32) +# define USE_WINSOCK 2 +#endif + /* * Include header files for windows builds before redefining anything. * Use this preprocessor block only to include or exclude windows.h, * winsock2.h or ws2tcpip.h. Any other windows thing belongs * to any other further and independent block. Under Cygwin things work * just as under linux (e.g. ) and the winsock headers should - * never be included when __CYGWIN__ is defined. configure script takes - * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK2_H, - * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. + * never be included when __CYGWIN__ is defined. */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # if defined(UNICODE) && !defined(_UNICODE) # error "UNICODE is defined but _UNICODE is not defined" # endif @@ -53,12 +88,8 @@ # ifndef NOGDI # define NOGDI # endif -# ifdef HAVE_WINSOCK2_H -# include -# ifdef HAVE_WS2TCPIP_H -# include -# endif -# endif +# include +# include # include # include # include @@ -67,17 +98,6 @@ # endif #endif -/* - * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else - * undefine USE_WINSOCK. - */ - -#undef USE_WINSOCK - -#ifdef HAVE_WINSOCK2_H -# define USE_WINSOCK 2 -#endif - /* * Define _WIN32_WINNT_[OS] symbols because not all Windows build systems have * those symbols to compare against, and even those that do may be missing diff --git a/lib/share.c b/lib/share.c index c0a8d806f..8fa5cda00 100644 --- a/lib/share.c +++ b/lib/share.c @@ -133,13 +133,13 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...) res = CURLSHE_BAD_OPTION; } if(!res) - share->specifier |= (1<specifier |= (unsigned int)(1<specifier &= ~(1<specifier &= ~(unsigned int)(1<specifier & (1<specifier & (unsigned int)(1<lockfunc) /* only call this if set! */ share->lockfunc(data, type, accesstype, share->clientdata); } @@ -281,7 +281,7 @@ Curl_share_unlock(struct Curl_easy *data, curl_lock_data type) if(!share) return CURLSHE_INVALID; - if(share->specifier & (1<specifier & (unsigned int)(1<unlockfunc) /* only call this if set! */ share->unlockfunc (data, type, share->clientdata); } diff --git a/lib/smb.c b/lib/smb.c index 6c8a47c7f..1d1867cc2 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -272,7 +272,7 @@ const struct Curl_handler Curl_handler_smb = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ smb_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SMB, /* defport */ @@ -299,7 +299,7 @@ const struct Curl_handler Curl_handler_smbs = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ smb_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SMBS, /* defport */ diff --git a/lib/smtp.c b/lib/smtp.c index 65fbc5b6c..bfe7b8f12 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -130,7 +130,7 @@ const struct Curl_handler Curl_handler_smtp = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ smtp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SMTP, /* defport */ @@ -159,7 +159,7 @@ const struct Curl_handler Curl_handler_smtps = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ smtp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SMTPS, /* defport */ @@ -250,8 +250,8 @@ static bool smtp_endofresp(struct Curl_easy *data, struct connectdata *conn, */ static CURLcode smtp_get_message(struct Curl_easy *data, struct bufref *out) { - char *message = data->state.buffer; - size_t len = strlen(message); + char *message = Curl_dyn_ptr(&data->conn->proto.smtpc.pp.recvbuf); + size_t len = data->conn->proto.smtpc.pp.nfinal; if(len > 4) { /* Find the start of the message */ @@ -859,7 +859,7 @@ static CURLcode smtp_state_starttls_resp(struct Curl_easy *data, (void)instate; /* no use for this yet */ /* Pipelining in response is forbidden. */ - if(data->conn->proto.smtpc.pp.cache_size) + if(data->conn->proto.smtpc.pp.overflow) return CURLE_WEIRD_SERVER_REPLY; if(smtpcode != 220) { @@ -883,8 +883,8 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data, { CURLcode result = CURLE_OK; struct smtp_conn *smtpc = &conn->proto.smtpc; - const char *line = data->state.buffer; - size_t len = strlen(line); + const char *line = Curl_dyn_ptr(&smtpc->pp.recvbuf); + size_t len = smtpc->pp.nfinal; (void)instate; /* no use for this yet */ @@ -1033,8 +1033,8 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data, int smtpcode, { CURLcode result = CURLE_OK; struct SMTP *smtp = data->req.p.smtp; - char *line = data->state.buffer; - size_t len = strlen(line); + char *line = Curl_dyn_ptr(&data->conn->proto.smtpc.pp.recvbuf); + size_t len = data->conn->proto.smtpc.pp.nfinal; (void)instate; /* no use for this yet */ @@ -1044,12 +1044,8 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data, int smtpcode, result = CURLE_WEIRD_SERVER_REPLY; } else { - /* Temporarily add the LF character back and send as body to the client */ - if(!data->req.no_body) { - line[len] = '\n'; - result = Curl_client_write(data, CLIENTWRITE_BODY, line, len + 1); - line[len] = '\0'; - } + if(!data->req.no_body) + result = Curl_client_write(data, CLIENTWRITE_BODY, line, len); if(smtpcode != 1) { if(smtp->rcpt) { @@ -1268,7 +1264,6 @@ static CURLcode smtp_statemachine(struct Curl_easy *data, break; case SMTP_QUIT: - /* fallthrough, just stop! */ default: /* internal error */ smtp_state(data, SMTP_STOP); @@ -1362,8 +1357,7 @@ static CURLcode smtp_connect(struct Curl_easy *data, bool *done) Curl_sasl_init(&smtpc->sasl, data, &saslsmtp); /* Initialise the pingpong layer */ - Curl_pp_setup(pp); - Curl_pp_init(data, pp); + Curl_pp_init(pp); /* Parse the URL options */ result = smtp_parse_url_options(conn); @@ -1541,6 +1535,8 @@ static CURLcode smtp_perform(struct Curl_easy *data, bool *connected, static CURLcode smtp_do(struct Curl_easy *data, bool *done) { CURLcode result = CURLE_OK; + DEBUGASSERT(data); + DEBUGASSERT(data->conn); *done = FALSE; /* default to false */ /* Parse the custom request */ diff --git a/lib/socketpair.c b/lib/socketpair.c index e3d40ff94..d01b25513 100644 --- a/lib/socketpair.c +++ b/lib/socketpair.c @@ -33,9 +33,6 @@ * This is a socketpair() implementation for Windows. */ #include -#include -#include -#include #include #else #ifdef HAVE_NETDB_H diff --git a/lib/socks.c b/lib/socks.c index 3a396de62..ecd2f7eab 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -71,9 +71,18 @@ enum connect_t { CONNECT_DONE /* 17 connected fine to the remote or the SOCKS proxy */ }; +#define CURL_SOCKS_BUF_SIZE 600 + +/* make sure we configure it not too low */ +#if CURL_SOCKS_BUF_SIZE < 600 +#error CURL_SOCKS_BUF_SIZE must be at least 600 +#endif + + struct socks_state { enum connect_t state; ssize_t outstanding; /* send this many bytes more */ + unsigned char buffer[CURL_SOCKS_BUF_SIZE]; unsigned char *outp; /* send from this pointer */ const char *hostname; @@ -249,7 +258,7 @@ static CURLproxycode socks_state_recv(struct Curl_cfilter *cf, failf(data, "connection to proxy closed"); return CURLPX_CLOSED; } - failf(data, "SOCKS4: Failed receiving %s: %s", description, + failf(data, "SOCKS: Failed receiving %s: %s", description, curl_easy_strerror(result)); return failcode; } @@ -278,14 +287,11 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, struct connectdata *conn = cf->conn; const bool protocol4a = (conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE; - unsigned char *socksreq = (unsigned char *)data->state.buffer; + unsigned char *socksreq = sx->buffer; CURLcode result; CURLproxycode presult; struct Curl_dns_entry *dns = NULL; - /* make sure that the buffer is at least 600 bytes */ - DEBUGASSERT(READBUFFER_MIN >= 600); - switch(sx->state) { case CONNECT_SOCKS_INIT: /* SOCKS4 can only do IPv4, insist! */ @@ -339,8 +345,8 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, if(dns) { #ifdef CURLRES_ASYNCH - conn->resolve_async.dns = dns; - conn->resolve_async.done = TRUE; + data->state.async.dns = dns; + data->state.async.done = TRUE; #endif infof(data, "Hostname '%s' was found", sx->hostname); sxstate(sx, data, CONNECT_RESOLVED); @@ -353,9 +359,10 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, return CURLPX_OK; } } - /* FALLTHROUGH */ + FALLTHROUGH(); + case CONNECT_RESOLVED: CONNECT_RESOLVED: - case CONNECT_RESOLVED: { + { struct Curl_addrinfo *hp = NULL; /* * We cannot use 'hostent' as a struct that Curl_resolv() returns. It @@ -393,9 +400,9 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, if(!hp) return CURLPX_RESOLVE_HOST; } - /* FALLTHROUGH */ -CONNECT_REQ_INIT: + FALLTHROUGH(); case CONNECT_REQ_INIT: +CONNECT_REQ_INIT: /* * This is currently not supporting "Identification Protocol (RFC1413)". */ @@ -430,7 +437,7 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, /* append hostname */ hostnamelen = strlen(sx->hostname) + 1; /* length including NUL */ if((hostnamelen <= 255) && - (packetsize + hostnamelen < data->set.buffer_size)) + (packetsize + hostnamelen < sizeof(sx->buffer))) strcpy((char *)socksreq + packetsize, sx->hostname); else { failf(data, "SOCKS4: too long host name"); @@ -439,10 +446,11 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, packetsize += hostnamelen; } sx->outp = socksreq; + DEBUGASSERT(packetsize <= sizeof(sx->buffer)); sx->outstanding = packetsize; sxstate(sx, data, CONNECT_REQ_SENDING); } - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_REQ_SENDING: /* Send request */ presult = socks_state_send(cf, sx, data, CURLPX_SEND_CONNECT, @@ -458,7 +466,7 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, sx->outp = socksreq; sxstate(sx, data, CONNECT_SOCKS_READ); - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_SOCKS_READ: /* Receive response */ presult = socks_state_recv(cf, sx, data, CURLPX_RECV_CONNECT, @@ -570,14 +578,14 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, o X'00' succeeded */ struct connectdata *conn = cf->conn; - unsigned char *socksreq = (unsigned char *)data->state.buffer; - int idx; + unsigned char *socksreq = sx->buffer; + size_t idx; CURLcode result; CURLproxycode presult; bool socks5_resolve_local = (conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE; const size_t hostname_len = strlen(sx->hostname); - ssize_t len = 0; + size_t len = 0; const unsigned char auth = data->set.socks5auth; bool allow_gssapi = FALSE; struct Curl_dns_entry *dns = NULL; @@ -620,6 +628,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, socksreq[1] = (unsigned char) (idx - 2); sx->outp = socksreq; + DEBUGASSERT(idx <= sizeof(sx->buffer)); sx->outstanding = idx; presult = socks_state_send(cf, sx, data, CURLPX_SEND_CONNECT, "initial SOCKS5 request"); @@ -640,12 +649,12 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, /* remain in sending state */ return CURLPX_OK; } - /* FALLTHROUGH */ -CONNECT_SOCKS_READ_INIT: + FALLTHROUGH(); case CONNECT_SOCKS_READ_INIT: +CONNECT_SOCKS_READ_INIT: sx->outstanding = 2; /* expect two bytes */ sx->outp = socksreq; /* store it here */ - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_SOCKS_READ: presult = socks_state_recv(cf, sx, data, CURLPX_RECV_CONNECT, "initial SOCKS5 response"); @@ -746,10 +755,11 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, } len += proxy_password_len; sxstate(sx, data, CONNECT_AUTH_SEND); + DEBUGASSERT(len <= sizeof(sx->buffer)); sx->outstanding = len; sx->outp = socksreq; } - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_AUTH_SEND: presult = socks_state_send(cf, sx, data, CURLPX_SEND_AUTH, "SOCKS5 sub-negotiation request"); @@ -762,7 +772,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, sx->outp = socksreq; sx->outstanding = 2; sxstate(sx, data, CONNECT_AUTH_READ); - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_AUTH_READ: presult = socks_state_recv(cf, sx, data, CURLPX_RECV_AUTH, "SOCKS5 sub-negotiation response"); @@ -781,9 +791,9 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, /* Everything is good so far, user was authenticated! */ sxstate(sx, data, CONNECT_REQ_INIT); - /* FALLTHROUGH */ -CONNECT_REQ_INIT: + FALLTHROUGH(); case CONNECT_REQ_INIT: +CONNECT_REQ_INIT: if(socks5_resolve_local) { enum resolve_t rc = Curl_resolv(data, sx->hostname, sx->remote_port, TRUE, &dns); @@ -806,8 +816,8 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, if(dns) { #ifdef CURLRES_ASYNCH - conn->resolve_async.dns = dns; - conn->resolve_async.done = TRUE; + data->state.async.dns = dns; + data->state.async.done = TRUE; #endif infof(data, "SOCKS5: hostname '%s' found", sx->hostname); } @@ -820,9 +830,10 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, return CURLPX_OK; } } - /* FALLTHROUGH */ + FALLTHROUGH(); + case CONNECT_RESOLVED: CONNECT_RESOLVED: - case CONNECT_RESOLVED: { + { char dest[MAX_IPADR_LEN]; /* printable address */ struct Curl_addrinfo *hp = NULL; if(dns) @@ -923,10 +934,10 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, infof(data, "SOCKS5 connect to %s:%d (remotely resolved)", sx->hostname, sx->remote_port); } - /* FALLTHROUGH */ + FALLTHROUGH(); -CONNECT_REQ_SEND: case CONNECT_REQ_SEND: +CONNECT_REQ_SEND: /* PORT MSB */ socksreq[len++] = (unsigned char)((sx->remote_port >> 8) & 0xff); /* PORT LSB */ @@ -939,9 +950,10 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, } #endif sx->outp = socksreq; + DEBUGASSERT(len <= sizeof(sx->buffer)); sx->outstanding = len; sxstate(sx, data, CONNECT_REQ_SENDING); - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_REQ_SENDING: presult = socks_state_send(cf, sx, data, CURLPX_SEND_REQUEST, "SOCKS5 connect request"); @@ -960,7 +972,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, sx->outstanding = 10; /* minimum packet size is 10 */ sx->outp = socksreq; sxstate(sx, data, CONNECT_REQ_READ); - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_REQ_READ: presult = socks_state_recv(cf, sx, data, CURLPX_RECV_REQACK, "SOCKS5 connect request ack"); @@ -1038,6 +1050,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, /* decrypt_gssapi_blockread already read the whole packet */ #endif if(len > 10) { + DEBUGASSERT(len <= sizeof(sx->buffer)); sx->outstanding = len - 10; /* get the rest */ sx->outp = &socksreq[10]; sxstate(sx, data, CONNECT_REQ_READ_MORE); @@ -1049,7 +1062,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) } #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CONNECT_REQ_READ_MORE: presult = socks_state_recv(cf, sx, data, CURLPX_RECV_ADDRESS, "SOCKS5 connect request address"); diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 2ede8c7c2..243715055 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -35,6 +35,7 @@ #include "timeval.h" #include "socks.h" #include "warnless.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -139,10 +140,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, /* prepare service name */ if(strchr(serviceptr, '/')) { service.length = serviceptr_length; - service.value = malloc(service.length); + service.value = Curl_memdup(serviceptr, service.length); if(!service.value) return CURLE_OUT_OF_MEMORY; - memcpy(service.value, serviceptr, service.length); gss_major_status = gss_import_name(&gss_minor_status, &service, (gss_OID) GSS_C_NULL_OID, &server); @@ -387,12 +387,11 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } else { gss_send_token.length = 1; - gss_send_token.value = malloc(1); + gss_send_token.value = Curl_memdup(&gss_enc, 1); if(!gss_send_token.value) { gss_delete_sec_context(&gss_status, &gss_context, NULL); return CURLE_OUT_OF_MEMORY; } - memcpy(gss_send_token.value, &gss_enc, 1); gss_major_status = gss_wrap(&gss_minor_status, gss_context, 0, GSS_C_QOP_DEFAULT, &gss_send_token, diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index d1200ea03..2baae2c2b 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -331,9 +331,15 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, failf(data, "Failed to determine user name."); return CURLE_COULDNT_CONNECT; } - infof(data, "SOCKS5 server authenticated user %s with GSS-API.", - names.sUserName); - s_pSecFn->FreeContextBuffer(names.sUserName); + else { +#ifndef CURL_DISABLE_VERBOSE_STRINGS + char *user_utf8 = curlx_convert_tchar_to_UTF8(names.sUserName); + infof(data, "SOCKS5 server authenticated user %s with GSS-API.", + (user_utf8 ? user_utf8 : "(unknown)")); + curlx_unicodefree(user_utf8); +#endif + s_pSecFn->FreeContextBuffer(names.sUserName); + } /* Do encryption */ socksreq[0] = 1; /* GSS-API subnegotiation version */ diff --git a/lib/strdup.c b/lib/strdup.c index 2578441c3..299c9cc36 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -101,21 +101,17 @@ void *Curl_memdup(const void *src, size_t length) /*************************************************************************** * - * Curl_strndup(source, length) + * Curl_memdup0(source, length) * * Copies the 'source' string to a newly allocated buffer (that is returned). - * Copies not more than 'length' bytes (up to a null terminator) then adds a - * null terminator. + * Copies 'length' bytes then adds a null terminator. * * Returns the new pointer or NULL on failure. * ***************************************************************************/ -void *Curl_strndup(const char *src, size_t length) +void *Curl_memdup0(const char *src, size_t length) { - char *buf = memchr(src, '\0', length); - if(buf) - length = buf - src; - buf = malloc(length + 1); + char *buf = malloc(length + 1); if(!buf) return NULL; memcpy(buf, src, length); diff --git a/lib/strdup.h b/lib/strdup.h index 9f12b2548..238a2611f 100644 --- a/lib/strdup.h +++ b/lib/strdup.h @@ -33,6 +33,6 @@ wchar_t* Curl_wcsdup(const wchar_t* src); #endif void *Curl_memdup(const void *src, size_t buffer_length); void *Curl_saferealloc(void *ptr, size_t size); -void *Curl_strndup(const char *src, size_t length); +void *Curl_memdup0(const char *src, size_t length); #endif /* HEADER_CURL_STRDUP_H */ diff --git a/lib/strerror.c b/lib/strerror.c index 0d5f9276f..a900e78d1 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -319,6 +319,9 @@ curl_easy_strerror(CURLcode error) case CURLE_UNRECOVERABLE_POLL: return "Unrecoverable error in select/poll"; + case CURLE_TOO_LARGE: + return "A value or data field grew larger than allowed"; + /* error codes not used by current libcurl */ case CURLE_OBSOLETE20: case CURLE_OBSOLETE24: @@ -553,6 +556,9 @@ curl_url_strerror(CURLUcode error) case CURLUE_LACKS_IDN: return "libcurl lacks IDN support"; + case CURLUE_TOO_LARGE: + return "A value or data field is larger than allowed"; + case CURLUE_LAST: break; } @@ -572,10 +578,11 @@ curl_url_strerror(CURLUcode error) * Returns NULL if no error message was found for error code. */ static const char * -get_winsock_error (int err, char *buf, size_t len) +get_winsock_error(int err, char *buf, size_t len) { #ifndef CURL_DISABLE_VERBOSE_STRINGS const char *p; + size_t alen; #endif if(!len) @@ -755,8 +762,9 @@ get_winsock_error (int err, char *buf, size_t len) default: return NULL; } - strncpy(buf, p, len); - buf [len-1] = '\0'; + alen = strlen(p); + if(alen < len) + strcpy(buf, p); return buf; #endif } @@ -832,7 +840,6 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) #endif int old_errno = errno; char *p; - size_t max; if(!buflen) return NULL; @@ -841,23 +848,22 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) DEBUGASSERT(err >= 0); #endif - max = buflen - 1; *buf = '\0'; #if defined(_WIN32) || defined(_WIN32_WCE) #if defined(_WIN32) /* 'sys_nerr' is the maximum errno number, it is not widely portable */ if(err >= 0 && err < sys_nerr) - strncpy(buf, sys_errlist[err], max); + msnprintf(buf, buflen, "%s", sys_errlist[err]); else #endif { if( #ifdef USE_WINSOCK - !get_winsock_error(err, buf, max) && + !get_winsock_error(err, buf, buflen) && #endif - !get_winapi_error((DWORD)err, buf, max)) - msnprintf(buf, max, "Unknown error %d (%#x)", err, err); + !get_winapi_error((DWORD)err, buf, buflen)) + msnprintf(buf, buflen, "Unknown error %d (%#x)", err, err); } #else /* not Windows coming up */ @@ -867,9 +873,9 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated * message string, or EINVAL if 'errnum' is not a valid error number. */ - if(0 != strerror_r(err, buf, max)) { + if(0 != strerror_r(err, buf, buflen)) { if('\0' == buf[0]) - msnprintf(buf, max, "Unknown error %d", err); + msnprintf(buf, buflen, "Unknown error %d", err); } #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R) /* @@ -881,25 +887,23 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) char buffer[256]; char *msg = strerror_r(err, buffer, sizeof(buffer)); if(msg) - strncpy(buf, msg, max); + msnprintf(buf, buflen, "%s", msg); else - msnprintf(buf, max, "Unknown error %d", err); + msnprintf(buf, buflen, "Unknown error %d", err); } #else { /* !checksrc! disable STRERROR 1 */ const char *msg = strerror(err); if(msg) - strncpy(buf, msg, max); + msnprintf(buf, buflen, "%s", msg); else - msnprintf(buf, max, "Unknown error %d", err); + msnprintf(buf, buflen, "Unknown error %d", err); } #endif #endif /* end of not Windows */ - buf[max] = '\0'; /* make sure the string is null-terminated */ - /* strip trailing '\r\n' or '\n'. */ p = strrchr(buf, '\n'); if(p && (p - buf) >= 2) @@ -943,8 +947,8 @@ const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen) #else { const char *txt = (err == ERROR_SUCCESS) ? "No error" : "Error"; - strncpy(buf, txt, buflen); - buf[buflen - 1] = '\0'; + if(strlen(txt) < buflen) + strcpy(buf, txt); } #endif @@ -1081,17 +1085,11 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen) err); } else { - char txtbuf[80]; char msgbuf[256]; - - msnprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err); - if(get_winapi_error(err, msgbuf, sizeof(msgbuf))) - msnprintf(buf, buflen, "%s - %s", txtbuf, msgbuf); - else { - strncpy(buf, txtbuf, buflen); - buf[buflen - 1] = '\0'; - } + msnprintf(buf, buflen, "%s (0x%08X) - %s", txt, err, msgbuf); + else + msnprintf(buf, buflen, "%s (0x%08X)", txt, err); } #else @@ -1099,8 +1097,8 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen) txt = "No error"; else txt = "Error"; - strncpy(buf, txt, buflen); - buf[buflen - 1] = '\0'; + if(buflen > strlen(txt)) + strcpy(buf, txt); #endif if(errno != old_errno) diff --git a/lib/system_win32.c b/lib/system_win32.c index 9408d026b..d2862de92 100644 --- a/lib/system_win32.c +++ b/lib/system_win32.c @@ -38,16 +38,23 @@ LARGE_INTEGER Curl_freq; bool Curl_isVistaOrGreater; +bool Curl_isWindows8OrGreater; /* Handle of iphlpapp.dll */ static HMODULE s_hIpHlpApiDll = NULL; -/* Pointer to the if_nametoindex function */ +/* Function pointers */ IF_NAMETOINDEX_FN Curl_if_nametoindex = NULL; +FREEADDRINFOEXW_FN Curl_FreeAddrInfoExW = NULL; +GETADDRINFOEXCANCEL_FN Curl_GetAddrInfoExCancel = NULL; +GETADDRINFOEXW_FN Curl_GetAddrInfoExW = NULL; /* Curl_win32_init() performs win32 global initialization */ CURLcode Curl_win32_init(long flags) { +#ifdef USE_WINSOCK + HMODULE ws2_32Dll; +#endif /* CURL_GLOBAL_WIN32 controls the *optional* part of the initialization which is just for Winsock at the moment. Any required win32 initialization should take place after this block. */ @@ -104,6 +111,18 @@ CURLcode Curl_win32_init(long flags) Curl_if_nametoindex = pIfNameToIndex; } +#ifdef USE_WINSOCK + ws2_32Dll = GetModuleHandleA("ws2_32"); + if(ws2_32Dll) { + Curl_FreeAddrInfoExW = CURLX_FUNCTION_CAST(FREEADDRINFOEXW_FN, + GetProcAddress(ws2_32Dll, "FreeAddrInfoExW")); + Curl_GetAddrInfoExCancel = CURLX_FUNCTION_CAST(GETADDRINFOEXCANCEL_FN, + GetProcAddress(ws2_32Dll, "GetAddrInfoExCancel")); + Curl_GetAddrInfoExW = CURLX_FUNCTION_CAST(GETADDRINFOEXW_FN, + GetProcAddress(ws2_32Dll, "GetAddrInfoExW")); + } +#endif + /* curlx_verify_windows_version must be called during init at least once because it has its own initialization routine. */ if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT, @@ -113,6 +132,13 @@ CURLcode Curl_win32_init(long flags) else Curl_isVistaOrGreater = FALSE; + if(curlx_verify_windows_version(6, 2, 0, PLATFORM_WINNT, + VERSION_GREATER_THAN_EQUAL)) { + Curl_isWindows8OrGreater = TRUE; + } + else + Curl_isWindows8OrGreater = FALSE; + QueryPerformanceFrequency(&Curl_freq); return CURLE_OK; } @@ -120,6 +146,9 @@ CURLcode Curl_win32_init(long flags) /* Curl_win32_cleanup() is the opposite of Curl_win32_init() */ void Curl_win32_cleanup(long init_flags) { + Curl_FreeAddrInfoExW = NULL; + Curl_GetAddrInfoExCancel = NULL; + Curl_GetAddrInfoExW = NULL; if(s_hIpHlpApiDll) { FreeLibrary(s_hIpHlpApiDll); s_hIpHlpApiDll = NULL; diff --git a/lib/system_win32.h b/lib/system_win32.h index 256676668..bd490cabc 100644 --- a/lib/system_win32.h +++ b/lib/system_win32.h @@ -26,10 +26,11 @@ #include "curl_setup.h" -#if defined(_WIN32) +#ifdef _WIN32 extern LARGE_INTEGER Curl_freq; extern bool Curl_isVistaOrGreater; +extern bool Curl_isWindows8OrGreater; CURLcode Curl_win32_init(long flags); void Curl_win32_cleanup(long init_flags); @@ -40,6 +41,33 @@ typedef unsigned int(WINAPI *IF_NAMETOINDEX_FN)(const char *); /* This is used instead of if_nametoindex if available on Windows */ extern IF_NAMETOINDEX_FN Curl_if_nametoindex; +/* Identical copy of addrinfoexW/ADDRINFOEXW */ +typedef struct addrinfoexW_ +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + PWSTR ai_canonname; + struct sockaddr *ai_addr; + void *ai_blob; + size_t ai_bloblen; + LPGUID ai_provider; + struct addrinfoexW_ *ai_next; +} ADDRINFOEXW_; + +typedef void (CALLBACK *LOOKUP_COMPLETION_FN)(DWORD, DWORD, LPWSAOVERLAPPED); +typedef void (WSAAPI *FREEADDRINFOEXW_FN)(ADDRINFOEXW_*); +typedef int (WSAAPI *GETADDRINFOEXCANCEL_FN)(LPHANDLE); +typedef int (WSAAPI *GETADDRINFOEXW_FN)(PCWSTR, PCWSTR, DWORD, LPGUID, + const ADDRINFOEXW_*, ADDRINFOEXW_**, struct timeval*, LPOVERLAPPED, + LOOKUP_COMPLETION_FN, LPHANDLE); + +extern FREEADDRINFOEXW_FN Curl_FreeAddrInfoExW; +extern GETADDRINFOEXCANCEL_FN Curl_GetAddrInfoExCancel; +extern GETADDRINFOEXW_FN Curl_GetAddrInfoExW; + /* This is used to dynamically load DLLs */ HMODULE Curl_load_library(LPCTSTR filename); #else /* _WIN32 */ diff --git a/lib/telnet.c b/lib/telnet.c index 836e255c9..34dc5e806 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -160,6 +160,7 @@ struct TELNET { unsigned short subopt_wsy; /* Set with suboption NAWS */ TelnetReceive telrcv_state; struct curl_slist *telnet_vars; /* Environment variables */ + struct dynbuf out; /* output buffer */ /* suboptions */ unsigned char subbuffer[SUBBUFSIZE]; @@ -185,7 +186,7 @@ const struct Curl_handler Curl_handler_telnet = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_TELNET, /* defport */ @@ -204,6 +205,7 @@ CURLcode init_telnet(struct Curl_easy *data) if(!tn) return CURLE_OUT_OF_MEMORY; + Curl_dyn_init(&tn->out, 0xffff); data->req.p.telnet = tn; /* make us known */ tn->telrcv_state = CURL_TS_DATA; @@ -799,8 +801,10 @@ static CURLcode check_telnet_options(struct Curl_easy *data) was given on the command line */ if(data->state.aptr.user) { char buffer[256]; - if(str_is_nonascii(data->conn->user)) + if(str_is_nonascii(data->conn->user)) { + DEBUGF(infof(data, "set a non ASCII user name in telnet")); return CURLE_BAD_FUNCTION_ARGUMENT; + } msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user); beg = curl_slist_append(tn->telnet_vars, buffer); if(!beg) { @@ -826,23 +830,27 @@ static CURLcode check_telnet_options(struct Curl_easy *data) case 5: /* Terminal type */ if(strncasecompare(option, "TTYPE", 5)) { - strncpy(tn->subopt_ttype, arg, 31); - tn->subopt_ttype[31] = 0; /* String termination */ - tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES; + size_t l = strlen(arg); + if(l < sizeof(tn->subopt_ttype)) { + strcpy(tn->subopt_ttype, arg); + tn->us_preferred[CURL_TELOPT_TTYPE] = CURL_YES; + break; + } } - else - result = CURLE_UNKNOWN_OPTION; + result = CURLE_UNKNOWN_OPTION; break; case 8: /* Display variable */ if(strncasecompare(option, "XDISPLOC", 8)) { - strncpy(tn->subopt_xdisploc, arg, 127); - tn->subopt_xdisploc[127] = 0; /* String termination */ - tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES; + size_t l = strlen(arg); + if(l < sizeof(tn->subopt_xdisploc)) { + strcpy(tn->subopt_xdisploc, arg); + tn->us_preferred[CURL_TELOPT_XDISPLOC] = CURL_YES; + break; + } } - else - result = CURLE_UNKNOWN_OPTION; + result = CURLE_UNKNOWN_OPTION; break; case 7: @@ -1223,37 +1231,33 @@ CURLcode telrcv(struct Curl_easy *data, static CURLcode send_telnet_data(struct Curl_easy *data, char *buffer, ssize_t nread) { - ssize_t escapes, i, outlen; - unsigned char *outbuf = NULL; + ssize_t i, outlen; + unsigned char *outbuf; CURLcode result = CURLE_OK; - ssize_t bytes_written, total_written; + ssize_t bytes_written, total_written = 0; struct connectdata *conn = data->conn; + struct TELNET *tn = data->req.p.telnet; - /* Determine size of new buffer after escaping */ - escapes = 0; - for(i = 0; i < nread; i++) - if((unsigned char)buffer[i] == CURL_IAC) - escapes++; - outlen = nread + escapes; + DEBUGASSERT(tn); - if(outlen == nread) - outbuf = (unsigned char *)buffer; - else { - ssize_t j; - outbuf = malloc(nread + escapes + 1); - if(!outbuf) - return CURLE_OUT_OF_MEMORY; + if(memchr(buffer, CURL_IAC, nread)) { + /* only use the escape buffer when necessary */ + Curl_dyn_reset(&tn->out); - j = 0; - for(i = 0; i < nread; i++) { - outbuf[j++] = (unsigned char)buffer[i]; - if((unsigned char)buffer[i] == CURL_IAC) - outbuf[j++] = CURL_IAC; + for(i = 0; i < nread && !result; i++) { + result = Curl_dyn_addn(&tn->out, &buffer[i], 1); + if(!result && ((unsigned char)buffer[i] == CURL_IAC)) + /* IAC is FF in hex */ + result = Curl_dyn_addn(&tn->out, "\xff", 1); } - outbuf[j] = '\0'; - } - total_written = 0; + outlen = Curl_dyn_len(&tn->out); + outbuf = Curl_dyn_uptr(&tn->out); + } + else { + outlen = nread; + outbuf = (unsigned char *)buffer; + } while(!result && total_written < outlen) { /* Make sure socket is writable to avoid EWOULDBLOCK condition */ struct pollfd pfd[1]; @@ -1266,19 +1270,13 @@ static CURLcode send_telnet_data(struct Curl_easy *data, break; default: /* write! */ bytes_written = 0; - result = Curl_nwrite(data, FIRSTSOCKET, - outbuf + total_written, - outlen - total_written, - &bytes_written); + result = Curl_nwrite(data, FIRSTSOCKET, outbuf + total_written, + outlen - total_written, &bytes_written); total_written += bytes_written; break; } } - /* Free malloc copy if escaped */ - if(outbuf != (unsigned char *)buffer) - free(outbuf); - return result; } @@ -1294,6 +1292,7 @@ static CURLcode telnet_done(struct Curl_easy *data, curl_slist_free_all(tn->telnet_vars); tn->telnet_vars = NULL; + Curl_dyn_free(&tn->out); return CURLE_OK; } @@ -1321,7 +1320,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) ssize_t nread; struct curltime now; bool keepon = TRUE; - char *buf = data->state.buffer; + char buffer[4*1024]; struct TELNET *tn; *done = TRUE; /* unconditionally */ @@ -1378,7 +1377,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) /* Keep on listening and act on events */ while(keepon) { - const DWORD buf_size = (DWORD)data->set.buffer_size; + const DWORD buf_size = (DWORD)sizeof(buffer); DWORD waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout); switch(waitret) { @@ -1389,7 +1388,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) if(data->set.is_fread_set) { size_t n; /* read from user-supplied method */ - n = data->state.fread_func(buf, 1, buf_size, data->state.in); + n = data->state.fread_func(buffer, 1, buf_size, data->state.in); if(n == CURL_READFUNC_ABORT) { keepon = FALSE; result = CURLE_READ_ERROR; @@ -1417,7 +1416,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) if(!readfile_read) break; - if(!ReadFile(stdin_handle, buf, buf_size, + if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) { keepon = FALSE; result = CURLE_READ_ERROR; @@ -1425,7 +1424,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } } - result = send_telnet_data(data, buf, readfile_read); + result = send_telnet_data(data, buffer, readfile_read); if(result) { keepon = FALSE; break; @@ -1436,14 +1435,14 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) case WAIT_OBJECT_0 + 1: { - if(!ReadFile(stdin_handle, buf, buf_size, + if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) { keepon = FALSE; result = CURLE_READ_ERROR; break; } - result = send_telnet_data(data, buf, readfile_read); + result = send_telnet_data(data, buffer, readfile_read); if(result) { keepon = FALSE; break; @@ -1465,7 +1464,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } if(events.lNetworkEvents & FD_READ) { /* read data from network */ - result = Curl_read(data, sockfd, buf, data->set.buffer_size, &nread); + result = Curl_read(data, sockfd, buffer, sizeof(buffer), &nread); /* read would've blocked. Loop again */ if(result == CURLE_AGAIN) break; @@ -1481,7 +1480,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) break; } - result = telrcv(data, (unsigned char *) buf, nread); + result = telrcv(data, (unsigned char *) buffer, nread); if(result) { keepon = FALSE; break; @@ -1542,11 +1541,11 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) case 0: /* timeout */ pfd[0].revents = 0; pfd[1].revents = 0; - /* FALLTHROUGH */ + FALLTHROUGH(); default: /* read! */ if(pfd[0].revents & POLLIN) { /* read data from network */ - result = Curl_read(data, sockfd, buf, data->set.buffer_size, &nread); + result = Curl_read(data, sockfd, buffer, sizeof(buffer), &nread); /* read would've blocked. Loop again */ if(result == CURLE_AGAIN) break; @@ -1572,7 +1571,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) total_dl += nread; result = Curl_pgrsSetDownloadCounter(data, total_dl); if(!result) - result = telrcv(data, (unsigned char *)buf, nread); + result = telrcv(data, (unsigned char *)buffer, nread); if(result) { keepon = FALSE; break; @@ -1590,12 +1589,12 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) nread = 0; if(poll_cnt == 2) { if(pfd[1].revents & POLLIN) { /* read from in file */ - nread = read(pfd[1].fd, buf, data->set.buffer_size); + nread = read(pfd[1].fd, buffer, sizeof(buffer)); } } else { /* read from user-supplied method */ - nread = (int)data->state.fread_func(buf, 1, data->set.buffer_size, + nread = (int)data->state.fread_func(buffer, 1, sizeof(buffer), data->state.in); if(nread == CURL_READFUNC_ABORT) { keepon = FALSE; @@ -1606,7 +1605,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } if(nread > 0) { - result = send_telnet_data(data, buf, nread); + result = send_telnet_data(data, buffer, nread); if(result) { keepon = FALSE; break; diff --git a/lib/tftp.c b/lib/tftp.c index 663015502..4288110da 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -181,7 +181,7 @@ const struct Curl_handler Curl_handler_tftp = { ZERO_NULL, /* domore_getsock */ ZERO_NULL, /* perform_getsock */ tftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_TFTP, /* defport */ diff --git a/lib/transfer.c b/lib/transfer.c index 96f1fde75..3ae4b61c0 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -413,321 +413,148 @@ bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc) return TRUE; } +/** + * Receive raw response data for the transfer. + * @param data the transfer + * @param buf buffer to keep response data received + * @param blen length of `buf` + * @param eos_reliable if EOS detection in underlying connection is reliable + * @param err error code in case of -1 return + * @return number of bytes read or -1 for error + */ +static ssize_t Curl_xfer_recv_resp(struct Curl_easy *data, + char *buf, size_t blen, + bool eos_reliable, + CURLcode *err) +{ + ssize_t nread; + + DEBUGASSERT(blen > 0); + /* If we are reading BODY data and the connection does NOT handle EOF + * and we know the size of the BODY data, limit the read amount */ + if(!eos_reliable && !data->req.header && data->req.size != -1) { + curl_off_t totalleft = data->req.size - data->req.bytecount; + if(totalleft <= 0) + blen = 0; + else if(totalleft < (curl_off_t)blen) + blen = (size_t)totalleft; + } + + if(!blen) { + /* want nothing - continue as if read nothing. */ + DEBUGF(infof(data, "readwrite_data: we're done")); + *err = CURLE_OK; + return 0; + } + + *err = Curl_read(data, data->conn->sockfd, buf, blen, &nread); + if(*err) + return -1; + DEBUGASSERT(nread >= 0); + *err = CURLE_OK; + return nread; +} + /* * Go ahead and do a read if we have a readable socket or if * the stream was rewound (in which case we have data in a * buffer) - * - * return '*comeback' TRUE if we didn't properly drain the socket so this - * function should get called again without select() or similar in between! */ static CURLcode readwrite_data(struct Curl_easy *data, - struct connectdata *conn, struct SingleRequest *k, - int *didwhat, bool *done, - bool *comeback) + int *didwhat, bool *done) { + struct connectdata *conn = data->conn; CURLcode result = CURLE_OK; char *buf; size_t blen; - size_t consumed; - int maxloops = 100; - curl_off_t max_recv = data->set.max_recv_speed? - data->set.max_recv_speed : CURL_OFF_T_MAX; - bool data_eof_handled = FALSE; + int maxloops = 10; + curl_off_t total_received = 0; + bool is_multiplex = FALSE; DEBUGASSERT(data->state.buffer); *done = FALSE; - *comeback = FALSE; /* This is where we loop until we have read everything there is to read or we get a CURLE_AGAIN */ do { - bool is_empty_data = FALSE; - size_t bytestoread = data->set.buffer_size; - /* For HTTP/2 and HTTP/3, read data without caring about the content - length. This is safe because body in HTTP/2 is always segmented - thanks to its framing layer. Meanwhile, we have to call Curl_read - to ensure that http2_handle_stream_close is called when we read all - incoming bytes for a particular stream. */ - bool is_http3 = Curl_conn_is_http3(data, conn, FIRSTSOCKET); - data_eof_handled = is_http3 || Curl_conn_is_http2(data, conn, FIRSTSOCKET); - - /* Each loop iteration starts with a fresh buffer and handles - * all data read into it. */ + bool is_eos = FALSE; + size_t bytestoread; + ssize_t nread; + + if(!is_multiplex) { + /* Multiplexed connection have inherent handling of EOF and we do not + * have to carefully restrict the amount we try to read. + * Multiplexed changes only in one direction. */ + is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET); + } + buf = data->state.buffer; - blen = 0; - - /* If we are reading BODY data and the connection does NOT handle EOF - * and we know the size of the BODY data, limit the read amount */ - if(!k->header && !data_eof_handled && k->size != -1) { - curl_off_t totalleft = k->size - k->bytecount; - if(totalleft <= 0) - bytestoread = 0; - else if(totalleft < (curl_off_t)bytestoread) - bytestoread = (size_t)totalleft; + bytestoread = data->set.buffer_size; + + /* Observe any imposed speed limit */ + if(bytestoread && data->set.max_recv_speed) { + curl_off_t net_limit = data->set.max_recv_speed - total_received; + if(net_limit <= 0) + break; + if((size_t)net_limit < bytestoread) + bytestoread = (size_t)net_limit; } - if(bytestoread) { - /* receive data from the network! */ - ssize_t nread; /* number of bytes read */ - result = Curl_read(data, conn->sockfd, buf, bytestoread, &nread); + nread = Curl_xfer_recv_resp(data, buf, bytestoread, + is_multiplex, &result); + if(nread < 0) { if(CURLE_AGAIN == result) { result = CURLE_OK; break; /* get out of loop */ } - else if(result) - goto out; - DEBUGASSERT(nread >= 0); - blen = (size_t)nread; - } - else { - /* read nothing but since we wanted nothing we consider this an OK - situation to proceed from */ - DEBUGF(infof(data, "readwrite_data: we're done")); - } - - if(!k->bytecount) { - Curl_pgrsTime(data, TIMER_STARTTRANSFER); - if(k->exp100 > EXP100_SEND_DATA) - /* set time stamp to compare with when waiting for the 100 */ - k->start100 = Curl_now(); + goto out; /* real error */ } + /* We only get a 0-length read on EndOfStream */ + blen = (size_t)nread; + is_eos = (blen == 0); *didwhat |= KEEP_RECV; - /* indicates data of zero size, i.e. empty file */ - is_empty_data = ((blen == 0) && (k->bodywrites == 0)) ? TRUE : FALSE; - - if(0 < blen || is_empty_data) { - /* data->state.buffer is allocated 1 byte larger than - * data->set.buffer_size admits. *wink* */ - /* TODO: we should really not rely on this being 0-terminated, since - * the actual data read might contain 0s. */ - buf[blen] = 0; - } if(!blen) { /* if we receive 0 or less here, either the data transfer is done or the server closed the connection and we bail out from this! */ - if(data_eof_handled) + if(is_multiplex) DEBUGF(infof(data, "nread == 0, stream closed, bailing")); else DEBUGF(infof(data, "nread <= 0, server closed connection, bailing")); - k->keepon = 0; /* stop sending as well */ - if(!is_empty_data) - break; - } - - if(conn->handler->readwrite) { - bool readmore = FALSE; /* indicates data is incomplete, need more */ - consumed = 0; - result = conn->handler->readwrite(data, conn, buf, blen, - &consumed, &readmore); - if(result) - goto out; - if(readmore) - break; - buf += consumed; - blen -= consumed; - if(k->download_done) { - /* We've stopped dealing with input, get out of the do-while loop */ - if(blen > 0) { - infof(data, - "Excess found:" - " excess = %zu" - " url = %s (zero-length body)", - blen, data->state.up.path); - } - - /* we make sure that this socket isn't read more now */ - k->keepon &= ~KEEP_RECV; + if(k->eos_written) { /* already did write this to client, leave */ + k->keepon = 0; /* stop sending as well */ break; } } + total_received += blen; -#ifndef CURL_DISABLE_HTTP - /* Since this is a two-state thing, we check if we are parsing - headers at the moment or not. */ - if(k->header) { - consumed = 0; - result = Curl_http_readwrite_headers(data, conn, buf, blen, &consumed); - if(result) - goto out; - buf += consumed; - blen -= consumed; - - if(conn->handler->readwrite && - (k->maxdownload <= 0 && blen > 0)) { - bool readmore = FALSE; /* indicates data is incomplete, need more */ - consumed = 0; - result = conn->handler->readwrite(data, conn, buf, blen, - &consumed, &readmore); - if(result) - goto out; - if(readmore) - break; - buf += consumed; - blen -= consumed; - } - - if(k->download_done) { - /* We've stopped dealing with input, get out of the do-while loop */ - if(blen > 0) { - infof(data, - "Excess found:" - " excess = %zu" - " url = %s (zero-length body)", - blen, data->state.up.path); - } - - /* we make sure that this socket isn't read more now */ - k->keepon &= ~KEEP_RECV; - break; - } - } -#endif /* CURL_DISABLE_HTTP */ - - - /* This is not an 'else if' since it may be a rest from the header - parsing, where the beginning of the buffer is headers and the end - is non-headers. */ - if(!k->header && (blen > 0 || is_empty_data)) { - - if(data->req.no_body && blen > 0) { - /* data arrives although we want none, bail out */ - streamclose(conn, "ignoring body"); - DEBUGF(infof(data, "did not want a BODY, but seeing %zu bytes", - blen)); - *done = TRUE; - result = CURLE_WEIRD_SERVER_REPLY; - goto out; - } - -#ifndef CURL_DISABLE_HTTP - if(0 == k->bodywrites && !is_empty_data) { - /* These checks are only made the first time we are about to - write a piece of the body */ - if(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP)) { - /* HTTP-only checks */ - result = Curl_http_firstwrite(data, conn, done); - if(result || *done) - goto out; - } - } /* this is the first time we write a body part */ -#endif /* CURL_DISABLE_HTTP */ - -#ifndef CURL_DISABLE_HTTP - if(k->chunk) { - /* - * Here comes a chunked transfer flying and we need to decode this - * properly. While the name says read, this function both reads - * and writes away the data. - */ - CURLcode extra; - CHUNKcode res; - - consumed = 0; - res = Curl_httpchunk_read(data, buf, blen, &consumed, &extra); - - if(CHUNKE_OK < res) { - if(CHUNKE_PASSTHRU_ERROR == res) { - failf(data, "Failed reading the chunked-encoded stream"); - result = extra; - goto out; - } - failf(data, "%s in chunked-encoding", Curl_chunked_strerror(res)); - result = CURLE_RECV_ERROR; - goto out; - } - - buf += consumed; - blen -= consumed; - if(CHUNKE_STOP == res) { - /* we're done reading chunks! */ - k->keepon &= ~KEEP_RECV; /* read no more */ - /* chunks read successfully, download is complete */ - k->download_done = TRUE; - - /* N number of bytes at the end of the str buffer that weren't - written to the client. */ - if(conn->chunk.datasize) { - infof(data, "Leftovers after chunking: % " - CURL_FORMAT_CURL_OFF_T "u bytes", - conn->chunk.datasize); - } - } - /* If it returned OK, we just keep going */ - } -#endif /* CURL_DISABLE_HTTP */ - - max_recv -= blen; - - if(!k->chunk && (blen || k->badheader || is_empty_data)) { - /* If this is chunky transfer, it was already written */ - - if(k->badheader) { - /* we parsed a piece of data wrongly assuming it was a header - and now we output it as body instead */ - size_t headlen = Curl_dyn_len(&data->state.headerb); - - /* Don't let excess data pollute body writes */ - if(k->maxdownload != -1 && (curl_off_t)headlen > k->maxdownload) - headlen = (size_t)k->maxdownload; - - result = Curl_client_write(data, CLIENTWRITE_BODY, - Curl_dyn_ptr(&data->state.headerb), - headlen); - if(result) - goto out; - } - - if(blen) { -#ifndef CURL_DISABLE_POP3 - if(conn->handler->protocol & PROTO_FAMILY_POP3) { - result = k->ignorebody? CURLE_OK : - Curl_pop3_write(data, buf, blen); - } - else -#endif /* CURL_DISABLE_POP3 */ - result = Curl_client_write(data, CLIENTWRITE_BODY, buf, blen); - } - k->badheader = FALSE; /* taken care of now */ - - if(result) - goto out; - } - - if(k->download_done && !is_http3) { - /* HTTP/3 over QUIC should keep reading until QUIC connection - is closed. In contrast to HTTP/2 which can stop reading - from TCP connection, HTTP/3 over QUIC needs ACK from server - to ensure stream closure. It should keep reading. */ - k->keepon &= ~KEEP_RECV; /* we're done reading */ - } - } /* if(!header and data to read) */ + result = Curl_xfer_write_resp(data, buf, blen, is_eos, done); + if(result || *done) + goto out; - if(is_empty_data) { - /* if we received nothing, the server closed the connection and we - are done */ - k->keepon &= ~KEEP_RECV; - k->download_done = TRUE; + /* if we are done, we stop receiving. On multiplexed connections, + * we should read the EOS. Which may arrive as meta data after + * the bytes. Not taking it in might lead to RST of streams. */ + if((!is_multiplex && data->req.download_done) || is_eos) { + data->req.keepon &= ~KEEP_RECV; } - - if((k->keepon & KEEP_RECV_PAUSE) || !(k->keepon & KEEP_RECV)) { - /* this is a paused or stopped transfer */ + /* if we are PAUSEd or stopped receiving, leave the loop */ + if((k->keepon & KEEP_RECV_PAUSE) || !(k->keepon & KEEP_RECV)) break; - } - } while((max_recv > 0) && data_pending(data) && maxloops--); + } while(maxloops-- && data_pending(data)); - if(maxloops <= 0 || max_recv <= 0) { - /* we mark it as read-again-please */ - data->state.dselect_bits = CURL_CSELECT_IN; - *comeback = TRUE; + if(maxloops <= 0) { + /* did not read until EAGAIN, mark read-again-please */ + data->state.select_bits = CURL_CSELECT_IN; + if((k->keepon & KEEP_SENDBITS) == KEEP_SEND) + data->state.select_bits |= CURL_CSELECT_OUT; } if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) && - (conn->bits.close || data_eof_handled)) { + (conn->bits.close || is_multiplex)) { /* When we've read the entire thing and the close bit is set, the server may now close the connection. If there's now any kind of sending going on from our side, we need to stop that immediately. */ @@ -1023,46 +850,41 @@ static int select_bits_paused(struct Curl_easy *data, int select_bits) * of our state machine are handling PAUSED transfers correctly. So, we * do not want to go there. * NOTE: we are only interested in PAUSE, not HOLD. */ - return (((select_bits & CURL_CSELECT_IN) && - (data->req.keepon & KEEP_RECV_PAUSE)) || - ((select_bits & CURL_CSELECT_OUT) && - (data->req.keepon & KEEP_SEND_PAUSE))); + + /* if there is data in a direction not paused, return false */ + if(((select_bits & CURL_CSELECT_IN) && + !(data->req.keepon & KEEP_RECV_PAUSE)) || + ((select_bits & CURL_CSELECT_OUT) && + !(data->req.keepon & KEEP_SEND_PAUSE))) + return FALSE; + + return (data->req.keepon & (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)); } /* * Curl_readwrite() is the low-level function to be called when data is to * be read and written to/from the connection. - * - * return '*comeback' TRUE if we didn't properly drain the socket so this - * function should get called again without select() or similar in between! */ -CURLcode Curl_readwrite(struct connectdata *conn, - struct Curl_easy *data, - bool *done, - bool *comeback) +CURLcode Curl_readwrite(struct Curl_easy *data, + bool *done) { + struct connectdata *conn = data->conn; struct SingleRequest *k = &data->req; CURLcode result; struct curltime now; int didwhat = 0; int select_bits; - if(data->state.dselect_bits) { - if(select_bits_paused(data, data->state.dselect_bits)) { + if(data->state.select_bits) { + if(select_bits_paused(data, data->state.select_bits)) { /* leave the bits unchanged, so they'll tell us what to do when * this transfer gets unpaused. */ - DEBUGF(infof(data, "readwrite, dselect_bits, early return on PAUSED")); + DEBUGF(infof(data, "readwrite, select_bits, early return on PAUSED")); result = CURLE_OK; goto out; } - select_bits = data->state.dselect_bits; - data->state.dselect_bits = 0; - } - else if(conn->cselect_bits) { - /* CAVEAT: adding `select_bits_paused()` check here makes test640 hang - * (among others). Which hints at strange state handling in FTP land... */ - select_bits = conn->cselect_bits; - conn->cselect_bits = 0; + select_bits = data->state.select_bits; + data->state.select_bits = 0; } else { curl_socket_t fd_read; @@ -1100,7 +922,7 @@ CURLcode Curl_readwrite(struct connectdata *conn, the stream was rewound (in which case we have data in a buffer) */ if((k->keepon & KEEP_RECV) && (select_bits & CURL_CSELECT_IN)) { - result = readwrite_data(data, conn, k, &didwhat, done, comeback); + result = readwrite_data(data, k, &didwhat, done); if(result || *done) goto out; } @@ -1196,21 +1018,6 @@ CURLcode Curl_readwrite(struct connectdata *conn, result = CURLE_PARTIAL_FILE; goto out; } - if(!(data->req.no_body) && k->chunk && - (conn->chunk.state != CHUNK_STOP)) { - /* - * In chunked mode, return an error if the connection is closed prior to - * the empty (terminating) chunk is read. - * - * The condition above used to check for - * conn->proto.http->chunk.datasize != 0 which is true after reading - * *any* chunk, not just the empty chunk. - * - */ - failf(data, "transfer closed with outstanding read data remaining"); - result = CURLE_PARTIAL_FILE; - goto out; - } if(Curl_pgrsUpdate(data)) { result = CURLE_ABORTED_BY_CALLBACK; goto out; @@ -1225,52 +1032,6 @@ CURLcode Curl_readwrite(struct connectdata *conn, return result; } -/* - * Curl_single_getsock() gets called by the multi interface code when the app - * has requested to get the sockets for the current connection. This function - * will then be called once for every connection that the multi interface - * keeps track of. This function will only be called for connections that are - * in the proper state to have this information available. - */ -int Curl_single_getsock(struct Curl_easy *data, - struct connectdata *conn, - curl_socket_t *sock) -{ - int bitmap = GETSOCK_BLANK; - unsigned sockindex = 0; - - if(conn->handler->perform_getsock) - return conn->handler->perform_getsock(data, conn, sock); - - /* don't include HOLD and PAUSE connections */ - if((data->req.keepon & KEEP_RECVBITS) == KEEP_RECV) { - - DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD); - - bitmap |= GETSOCK_READSOCK(sockindex); - sock[sockindex] = conn->sockfd; - } - - /* don't include HOLD and PAUSE connections */ - if((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) { - if((conn->sockfd != conn->writesockfd) || - bitmap == GETSOCK_BLANK) { - /* only if they are not the same socket and we have a readable - one, we increase index */ - if(bitmap != GETSOCK_BLANK) - sockindex++; /* increase index if we need two entries */ - - DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD); - - sock[sockindex] = conn->writesockfd; - } - - bitmap |= GETSOCK_WRITESOCK(sockindex); - } - - return bitmap; -} - /* Curl_init_CONNECT() gets called each time the handle switches to CONNECT which means this gets called once for each subsequent redirect etc */ void Curl_init_CONNECT(struct Curl_easy *data) @@ -1917,3 +1678,41 @@ Curl_setup_transfer( } /* if(k->getheader || !data->req.no_body) */ } + +CURLcode Curl_xfer_write_resp(struct Curl_easy *data, + char *buf, size_t blen, + bool is_eos, bool *done) +{ + CURLcode result = CURLE_OK; + + if(data->conn->handler->write_resp) { + /* protocol handlers offering this function take full responsibility + * for writing all received download data to the client. */ + result = data->conn->handler->write_resp(data, buf, blen, is_eos, done); + } + else { + /* No special handling by protocol handler, write all received data + * as BODY to the client. */ + if(blen || is_eos) { + int cwtype = CLIENTWRITE_BODY; + if(is_eos) + cwtype |= CLIENTWRITE_EOS; + +#ifndef CURL_DISABLE_POP3 + if(blen && data->conn->handler->protocol & PROTO_FAMILY_POP3) { + result = data->req.ignorebody? CURLE_OK : + Curl_pop3_write(data, buf, blen); + } + else +#endif /* CURL_DISABLE_POP3 */ + result = Curl_client_write(data, cwtype, buf, blen); + } + } + + if(!result && is_eos) { + /* If we wrote the EOS, we are definitely done */ + data->req.eos_written = TRUE; + data->req.download_done = TRUE; + } + return result; +} diff --git a/lib/transfer.h b/lib/transfer.h index 536ac249b..0507f1a45 100644 --- a/lib/transfer.h +++ b/lib/transfer.h @@ -45,9 +45,7 @@ typedef enum { CURLcode Curl_follow(struct Curl_easy *data, char *newurl, followtype type); -CURLcode Curl_readwrite(struct connectdata *conn, - struct Curl_easy *data, bool *done, - bool *comeback); +CURLcode Curl_readwrite(struct Curl_easy *data, bool *done); int Curl_single_getsock(struct Curl_easy *data, struct connectdata *conn, curl_socket_t *socks); CURLcode Curl_fillreadbuffer(struct Curl_easy *data, size_t bytes, @@ -59,6 +57,23 @@ CURLcode Curl_get_upload_buffer(struct Curl_easy *data); CURLcode Curl_done_sending(struct Curl_easy *data, struct SingleRequest *k); +/** + * Write the transfer raw response bytes, as received from the connection. + * Will handle all passed bytes or return an error. By default, this will + * write the bytes as BODY to the client. Protocols may provide a + * "write_resp" callback in their handler to add specific treatment. E.g. + * HTTP parses response headers and passes them differently to the client. + * @param data the transfer + * @param buf the raw response bytes + * @param blen the amount of bytes in `buf` + * @param is_eos TRUE iff the connection indicates this to be the last + * bytes of the response + * @param done on returnm, TRUE iff the response is complete + */ +CURLcode Curl_xfer_write_resp(struct Curl_easy *data, + char *buf, size_t blen, + bool is_eos, bool *done); + /* This sets up a forthcoming transfer */ void Curl_setup_transfer (struct Curl_easy *data, diff --git a/lib/url.c b/lib/url.c index b81785fe2..36395a155 100644 --- a/lib/url.c +++ b/lib/url.c @@ -298,6 +298,10 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_safefree(data->info.contenttype); Curl_safefree(data->info.wouldredirect); + /* this destroys the channel and we cannot use it anymore after this */ + Curl_resolver_cancel(data); + Curl_resolver_cleanup(data->state.async.resolver); + data_priority_cleanup(data); /* No longer a dirty share, if it exists */ @@ -430,11 +434,13 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) /* Set the default CA cert bundle/path detected/specified at build time. * - * If Schannel is the selected SSL backend then these locations are - * ignored. We allow setting CA location for schannel only when explicitly - * specified by the user via CURLOPT_CAINFO / --cacert. + * If Schannel or SecureTransport is the selected SSL backend then these + * locations are ignored. We allow setting CA location for schannel and + * securetransport when explicitly specified by the user via + * CURLOPT_CAINFO / --cacert. */ - if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) { + if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL && + Curl_ssl_backend() != CURLSSLBACKEND_SECURETRANSPORT) { #if defined(CURL_CA_BUNDLE) result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE); if(result) @@ -514,6 +520,13 @@ CURLcode Curl_open(struct Curl_easy **curl) data->magic = CURLEASY_MAGIC_NUMBER; + result = Curl_resolver_init(data, &data->state.async.resolver); + if(result) { + DEBUGF(fprintf(stderr, "Error: resolver_init failed\n")); + free(data); + return result; + } + result = Curl_init_userdefined(data); if(!result) { Curl_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER); @@ -530,6 +543,7 @@ CURLcode Curl_open(struct Curl_easy **curl) } if(result) { + Curl_resolver_cleanup(data->state.async.resolver); Curl_dyn_free(&data->state.headerb); Curl_freeset(data); free(data); @@ -563,7 +577,6 @@ static void conn_free(struct Curl_easy *data, struct connectdata *conn) Curl_conn_cf_discard_all(data, conn, (int)i); } - Curl_resolver_cleanup(conn->resolve_async.resolver); Curl_free_idnconverted_hostname(&conn->host); Curl_free_idnconverted_hostname(&conn->conn_to_host); #ifndef CURL_DISABLE_PROXY @@ -581,9 +594,6 @@ static void conn_free(struct Curl_easy *data, struct connectdata *conn) Curl_safefree(conn->sasl_authzid); Curl_safefree(conn->options); Curl_safefree(conn->oauth_bearer); -#ifndef CURL_DISABLE_HTTP - Curl_dyn_free(&conn->trailer); -#endif Curl_safefree(conn->host.rawalloc); /* host name buffer */ Curl_safefree(conn->conn_to_host.rawalloc); /* host name buffer */ Curl_safefree(conn->hostname_resolve); @@ -663,7 +673,6 @@ void Curl_disconnect(struct Curl_easy *data, conn->handler->disconnect(data, conn, dead_connection); conn_shutdown(data); - Curl_resolver_cancel(data); /* detach it again */ Curl_detach_connection(data); @@ -1346,6 +1355,8 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ + conn->sockfd = CURL_SOCKET_BAD; + conn->writesockfd = CURL_SOCKET_BAD; conn->connection_id = -1; /* no ID */ conn->port = -1; /* unknown at this point */ conn->remote_port = -1; /* unknown at this point */ @@ -1680,8 +1691,9 @@ static CURLcode findprotocol(struct Curl_easy *data, /* The protocol was not found in the table, but we don't have to assign it to anything since it is already assigned to a dummy-struct in the create_conn() function when the connectdata struct is allocated. */ - failf(data, "Protocol \"%s\" not supported or disabled in " LIBCURL_NAME, - protostr); + failf(data, "Protocol \"%s\" %s%s", protostr, + p ? "disabled" : "not supported", + data->state.this_is_a_follow ? " (in redirect)":""); return CURLE_UNSUPPORTED_PROTOCOL; } @@ -3739,35 +3751,7 @@ static CURLcode create_conn(struct Curl_easy *data, goto out; } - result = Curl_resolver_init(data, &conn->resolve_async.resolver); - if(result) { - DEBUGF(fprintf(stderr, "Error: resolver_init failed\n")); - goto out; - } - Curl_attach_connection(data, conn); - -#ifdef USE_ARES - result = Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]); - if(result && result != CURLE_NOT_BUILT_IN) - goto out; - - result = Curl_set_dns_interface(data, - data->set.str[STRING_DNS_INTERFACE]); - if(result && result != CURLE_NOT_BUILT_IN) - goto out; - - result = Curl_set_dns_local_ip4(data, - data->set.str[STRING_DNS_LOCAL_IP4]); - if(result && result != CURLE_NOT_BUILT_IN) - goto out; - - result = Curl_set_dns_local_ip6(data, - data->set.str[STRING_DNS_LOCAL_IP6]); - if(result && result != CURLE_NOT_BUILT_IN) - goto out; -#endif /* USE_ARES */ - result = Curl_conncache_add_conn(data); if(result) goto out; diff --git a/lib/urlapi.c b/lib/urlapi.c index 0d11e48c9..3cd0362c5 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -126,6 +126,9 @@ static const char *find_host_sep(const char *url) return sep < query ? sep : query; } +/* convert CURLcode to CURLUcode */ +#define cc2cu(x) ((x) == CURLE_TOO_LARGE ? CURLUE_TOO_LARGE : \ + CURLUE_OUT_OF_MEMORY) /* * Decide whether a character in a URL must be escaped. */ @@ -146,6 +149,7 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url, bool left = !query; const unsigned char *iptr; const unsigned char *host_sep = (const unsigned char *) url; + CURLcode result; if(!relative) host_sep = (const unsigned char *) find_host_sep(url); @@ -154,20 +158,19 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url, len; iptr++, len--) { if(iptr < host_sep) { - if(Curl_dyn_addn(o, iptr, 1)) - return CURLUE_OUT_OF_MEMORY; + result = Curl_dyn_addn(o, iptr, 1); + if(result) + return cc2cu(result); continue; } if(*iptr == ' ') { - if(left) { - if(Curl_dyn_addn(o, "%20", 3)) - return CURLUE_OUT_OF_MEMORY; - } - else { - if(Curl_dyn_addn(o, "+", 1)) - return CURLUE_OUT_OF_MEMORY; - } + if(left) + result = Curl_dyn_addn(o, "%20", 3); + else + result = Curl_dyn_addn(o, "+", 1); + if(result) + return cc2cu(result); continue; } @@ -178,13 +181,12 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url, char out[3]={'%'}; out[1] = hexdigits[*iptr>>4]; out[2] = hexdigits[*iptr & 0xf]; - if(Curl_dyn_addn(o, out, 3)) - return CURLUE_OUT_OF_MEMORY; - } - else { - if(Curl_dyn_addn(o, iptr, 1)) - return CURLUE_OUT_OF_MEMORY; + result = Curl_dyn_addn(o, out, 3); } + else + result = Curl_dyn_addn(o, iptr, 1); + if(result) + return cc2cu(result); } return CURLUE_OK; @@ -248,7 +250,7 @@ size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen, * * Note that this function destroys the 'base' string. */ -static char *concat_url(char *base, const char *relurl) +static CURLcode concat_url(char *base, const char *relurl, char **newurl) { /*** TRY to append this new path to the old URL @@ -260,6 +262,9 @@ static char *concat_url(char *base, const char *relurl) char *pathsep; bool host_changed = FALSE; const char *useurl = relurl; + CURLcode result = CURLE_OK; + CURLUcode uc; + *newurl = NULL; /* protsep points to the start of the host name */ protsep = strstr(base, "//"); @@ -360,21 +365,27 @@ static char *concat_url(char *base, const char *relurl) Curl_dyn_init(&newest, CURL_MAX_INPUT_LENGTH); /* copy over the root url part */ - if(Curl_dyn_add(&newest, base)) - return NULL; + result = Curl_dyn_add(&newest, base); + if(result) + return result; /* check if we need to append a slash */ if(('/' == useurl[0]) || (protsep && !*protsep) || ('?' == useurl[0])) ; else { - if(Curl_dyn_addn(&newest, "/", 1)) - return NULL; + result = Curl_dyn_addn(&newest, "/", 1); + if(result) + return result; } /* then append the new piece on the right side */ - urlencode_str(&newest, useurl, strlen(useurl), !host_changed, FALSE); + uc = urlencode_str(&newest, useurl, strlen(useurl), !host_changed, + FALSE); + if(uc) + return (uc == CURLUE_TOO_LARGE) ? CURLE_TOO_LARGE : CURLE_OUT_OF_MEMORY; - return Curl_dyn_ptr(&newest); + *newurl = Curl_dyn_ptr(&newest); + return CURLE_OK; } /* scan for byte values <= 31, 127 and sometimes space */ @@ -712,24 +723,30 @@ static int ipv4_normalize(struct dynbuf *host) Curl_dyn_reset(host); result = Curl_dyn_addf(host, "%u.%u.%u.%u", - parts[0] >> 24, (parts[0] >> 16) & 0xff, - (parts[0] >> 8) & 0xff, parts[0] & 0xff); + (unsigned int)(parts[0] >> 24), + (unsigned int)((parts[0] >> 16) & 0xff), + (unsigned int)((parts[0] >> 8) & 0xff), + (unsigned int)(parts[0] & 0xff)); break; case 1: /* a.b -- 8.24 bits */ if((parts[0] > 0xff) || (parts[1] > 0xffffff)) return HOST_NAME; Curl_dyn_reset(host); result = Curl_dyn_addf(host, "%u.%u.%u.%u", - parts[0], (parts[1] >> 16) & 0xff, - (parts[1] >> 8) & 0xff, parts[1] & 0xff); + (unsigned int)(parts[0]), + (unsigned int)((parts[1] >> 16) & 0xff), + (unsigned int)((parts[1] >> 8) & 0xff), + (unsigned int)(parts[1] & 0xff)); break; case 2: /* a.b.c -- 8.8.16 bits */ if((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xffff)) return HOST_NAME; Curl_dyn_reset(host); result = Curl_dyn_addf(host, "%u.%u.%u.%u", - parts[0], parts[1], (parts[2] >> 8) & 0xff, - parts[2] & 0xff); + (unsigned int)(parts[0]), + (unsigned int)(parts[1]), + (unsigned int)((parts[2] >> 8) & 0xff), + (unsigned int)(parts[2] & 0xff)); break; case 3: /* a.b.c.d -- 8.8.8.8 bits */ if((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff) || @@ -737,7 +754,10 @@ static int ipv4_normalize(struct dynbuf *host) return HOST_NAME; Curl_dyn_reset(host); result = Curl_dyn_addf(host, "%u.%u.%u.%u", - parts[0], parts[1], parts[2], parts[3]); + (unsigned int)(parts[0]), + (unsigned int)(parts[1]), + (unsigned int)(parts[2]), + (unsigned int)(parts[3])); break; } if(result) @@ -766,7 +786,7 @@ static CURLUcode urldecode_host(struct dynbuf *host) result = Curl_dyn_addn(host, decoded, dlen); free(decoded); if(result) - return CURLUE_OUT_OF_MEMORY; + return cc2cu(result); } return CURLUE_OK; @@ -779,22 +799,24 @@ static CURLUcode parse_authority(struct Curl_URL *u, bool has_scheme) { size_t offset; - CURLUcode result; + CURLUcode uc; + CURLcode result; /* * Parse the login details and strip them out of the host name. */ - result = parse_hostname_login(u, auth, authlen, flags, &offset); - if(result) + uc = parse_hostname_login(u, auth, authlen, flags, &offset); + if(uc) goto out; - if(Curl_dyn_addn(host, auth + offset, authlen - offset)) { - result = CURLUE_OUT_OF_MEMORY; + result = Curl_dyn_addn(host, auth + offset, authlen - offset); + if(result) { + uc = cc2cu(result); goto out; } - result = Curl_parse_port(u, host, has_scheme); - if(result) + uc = Curl_parse_port(u, host, has_scheme); + if(uc) goto out; if(!Curl_dyn_len(host)) @@ -804,24 +826,24 @@ static CURLUcode parse_authority(struct Curl_URL *u, case HOST_IPV4: break; case HOST_IPV6: - result = ipv6_parse(u, Curl_dyn_ptr(host), Curl_dyn_len(host)); + uc = ipv6_parse(u, Curl_dyn_ptr(host), Curl_dyn_len(host)); break; case HOST_NAME: - result = urldecode_host(host); - if(!result) - result = hostname_check(u, Curl_dyn_ptr(host), Curl_dyn_len(host)); + uc = urldecode_host(host); + if(!uc) + uc = hostname_check(u, Curl_dyn_ptr(host), Curl_dyn_len(host)); break; case HOST_ERROR: - result = CURLUE_OUT_OF_MEMORY; + uc = CURLUE_OUT_OF_MEMORY; break; case HOST_BAD: default: - result = CURLUE_BAD_HOSTNAME; /* Bad IPv4 address even */ + uc = CURLUE_BAD_HOSTNAME; /* Bad IPv4 address even */ break; } out: - return result; + return uc; } CURLUcode Curl_url_set_authority(CURLU *u, const char *authority, @@ -1070,8 +1092,9 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) len = path - ptr; if(len) { - if(Curl_dyn_addn(&host, ptr, len)) { - result = CURLUE_OUT_OF_MEMORY; + CURLcode code = Curl_dyn_addn(&host, ptr, len); + if(code) { + result = cc2cu(code); goto fail; } uncpath = TRUE; @@ -1224,14 +1247,13 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) if(flags & CURLU_URLENCODE) { struct dynbuf enc; Curl_dyn_init(&enc, CURL_MAX_INPUT_LENGTH); - if(urlencode_str(&enc, fragment + 1, fraglen - 1, TRUE, FALSE)) { - result = CURLUE_OUT_OF_MEMORY; + result = urlencode_str(&enc, fragment + 1, fraglen - 1, TRUE, FALSE); + if(result) goto fail; - } u->fragment = Curl_dyn_ptr(&enc); } else { - u->fragment = Curl_strndup(fragment + 1, fraglen - 1); + u->fragment = Curl_memdup0(fragment + 1, fraglen - 1); if(!u->fragment) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1242,7 +1264,6 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) pathlen -= fraglen; } - DEBUGASSERT(pathlen < urllen); query = memchr(path, '?', pathlen); if(query) { size_t qlen = fragment ? (size_t)(fragment - query) : @@ -1253,14 +1274,13 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) struct dynbuf enc; Curl_dyn_init(&enc, CURL_MAX_INPUT_LENGTH); /* skip the leading question mark */ - if(urlencode_str(&enc, query + 1, qlen - 1, TRUE, TRUE)) { - result = CURLUE_OUT_OF_MEMORY; + result = urlencode_str(&enc, query + 1, qlen - 1, TRUE, TRUE); + if(result) goto fail; - } u->query = Curl_dyn_ptr(&enc); } else { - u->query = Curl_strndup(query + 1, qlen - 1); + u->query = Curl_memdup0(query + 1, qlen - 1); if(!u->query) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1280,10 +1300,9 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) if(pathlen && (flags & CURLU_URLENCODE)) { struct dynbuf enc; Curl_dyn_init(&enc, CURL_MAX_INPUT_LENGTH); - if(urlencode_str(&enc, path, pathlen, TRUE, FALSE)) { - result = CURLUE_OUT_OF_MEMORY; + result = urlencode_str(&enc, path, pathlen, TRUE, FALSE); + if(result) goto fail; - } pathlen = Curl_dyn_len(&enc); path = u->path = Curl_dyn_ptr(&enc); } @@ -1294,7 +1313,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) } else { if(!u->path) { - u->path = Curl_strndup(path, pathlen); + u->path = Curl_memdup0(path, pathlen); if(!u->path) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1592,7 +1611,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what, if(ptr) { size_t partlen = strlen(ptr); size_t i = 0; - *part = Curl_strndup(ptr, partlen); + *part = Curl_memdup0(ptr, partlen); if(!*part) return CURLUE_OUT_OF_MEMORY; if(plusdecode) { @@ -1619,10 +1638,11 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what, } if(urlencode) { struct dynbuf enc; + CURLUcode uc; Curl_dyn_init(&enc, CURL_MAX_INPUT_LENGTH); - if(urlencode_str(&enc, *part, partlen, TRUE, - what == CURLUPART_QUERY)) - return CURLUE_OUT_OF_MEMORY; + uc = urlencode_str(&enc, *part, partlen, TRUE, what == CURLUPART_QUERY); + if(uc) + return uc; free(*part); *part = Curl_dyn_ptr(&enc); } @@ -1807,7 +1827,8 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, * If the existing contents is enough for a URL, allow a relative URL to * replace it. */ - CURLUcode result; + CURLcode result; + CURLUcode uc; char *oldurl; char *redired_url; @@ -1827,14 +1848,14 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, /* apply the relative part to create a new URL * and replace the existing one with it. */ - redired_url = concat_url(oldurl, part); + result = concat_url(oldurl, part, &redired_url); free(oldurl); - if(!redired_url) - return CURLUE_OUT_OF_MEMORY; + if(result) + return cc2cu(result); - result = parseurl_and_replace(redired_url, u, flags); + uc = parseurl_and_replace(redired_url, u, flags); free(redired_url); - return result; + return uc; } default: return CURLUE_UNKNOWN_PART; @@ -1848,7 +1869,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, if(leadingslash && (part[0] != '/')) { CURLcode result = Curl_dyn_addn(&enc, "/", 1); if(result) - return CURLUE_OUT_OF_MEMORY; + return cc2cu(result); } if(urlencode) { const unsigned char *i; @@ -1868,7 +1889,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, equalsencode = FALSE; result = Curl_dyn_addn(&enc, i, 1); if(result) - return CURLUE_OUT_OF_MEMORY; + return cc2cu(result); } else { char out[3]={'%'}; @@ -1876,7 +1897,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, out[2] = hexdigits[*i & 0xf]; result = Curl_dyn_addn(&enc, out, 3); if(result) - return CURLUE_OUT_OF_MEMORY; + return cc2cu(result); } } } @@ -1884,7 +1905,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, char *p; CURLcode result = Curl_dyn_add(&enc, part); if(result) - return CURLUE_OUT_OF_MEMORY; + return cc2cu(result); p = Curl_dyn_ptr(&enc); while(*p) { /* make sure percent encoded are lower case */ diff --git a/lib/urldata.h b/lib/urldata.h index ff661482e..9dcccc703 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -583,7 +583,7 @@ struct hostname { (((data)->req.keepon & KEEP_SENDBITS) == KEEP_SEND) /* transfer receive is not on PAUSE or HOLD */ #define CURL_WANT_RECV(data) \ - (!((data)->req.keepon & (KEEP_RECV_PAUSE|KEEP_RECV_HOLD))) + (((data)->req.keepon & KEEP_RECVBITS) == KEEP_RECV) #if defined(CURLRES_ASYNCH) || !defined(CURL_DISABLE_DOH) #define USE_CURL_ASYNC @@ -683,7 +683,8 @@ struct SingleRequest { enum expect100 exp100; /* expect 100 continue state */ enum upgrade101 upgr101; /* 101 upgrade state */ - /* Content unencoding stack. See sec 3.5, RFC2616. */ + /* Client Writer stack, handles trasnfer- and content-encodings, protocol + * checks, pausing by client callbacks. */ struct Curl_cwriter *writer_stack; time_t timeofdoc; long bodywrites; @@ -730,11 +731,10 @@ struct SingleRequest { #ifndef CURL_DISABLE_COOKIES unsigned char setcookies; #endif - unsigned char writer_stack_depth; /* Unencoding stack depth. */ BIT(header); /* incoming data has HTTP header */ - BIT(badheader); /* header parsing found sth not a header */ BIT(content_range); /* set TRUE if Content-Range: was found */ BIT(download_done); /* set to TRUE when download is complete */ + BIT(eos_written); /* iff EOS has been written to client */ BIT(upload_done); /* set to TRUE when doing chunked transfer-encoding upload and we're uploading the last chunk */ BIT(ignorebody); /* we read a response-body but we ignore it! */ @@ -816,10 +816,10 @@ struct Curl_handler { bool dead_connection); /* If used, this function gets called from transfer.c:readwrite_data() to - allow the protocol to do extra reads/writes */ - CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn, - const char *buf, size_t blen, - size_t *pconsumed, bool *readmore); + allow the protocol to do extra handling in writing response to + the client. */ + CURLcode (*write_resp)(struct Curl_easy *data, const char *buf, size_t blen, + bool is_eos, bool *done); /* This function can perform various checks on the connection. See CONNCHECK_* for more information about the checks that can be performed, @@ -898,11 +898,6 @@ struct ldapconninfo; struct connectdata { struct Curl_llist_element bundle_node; /* conncache */ - /* chunk is for HTTP chunked encoding, but is in the general connectdata - struct only because we can do just about any protocol through an HTTP - proxy and an HTTP proxy may in fact respond using chunked encoding */ - struct Curl_chunker chunk; - curl_closesocket_callback fclosesocket; /* function closing the socket(s) */ void *closesocket_client; @@ -921,9 +916,6 @@ struct connectdata { multi_done(). This entry will be NULL if the connection is reused as then there is no name resolve done. */ struct Curl_dns_entry *dns_entry; -#ifdef USE_CURL_ASYNC - struct Curl_async resolve_async; /* asynchronous name resolver data */ -#endif /* 'remote_addr' is the particular IP we connected to. it is owned, set * and NULLed by the connected socket filter (if there is one). */ @@ -1028,11 +1020,6 @@ struct connectdata { struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */ #endif -#ifndef CURL_DISABLE_HTTP - /* for chunked-encoded trailer */ - struct dynbuf trailer; -#endif - union { #ifndef CURL_DISABLE_FTP struct ftp_conn ftpc; @@ -1103,7 +1090,6 @@ struct connectdata { unsigned short localport; unsigned short secondary_port; /* secondary socket remote port to connect to (ftp) */ - unsigned char cselect_bits; /* bitmask of socket events */ unsigned char alpn; /* APLN TLS negotiated protocol, a CURL_HTTP_VERSION* value */ #ifndef CURL_DISABLE_PROXY @@ -1193,6 +1179,7 @@ struct Progress { curl_off_t dlspeed; curl_off_t ulspeed; + timediff_t t_postqueue; timediff_t t_nslookup; timediff_t t_connect; timediff_t t_appconnect; @@ -1382,6 +1369,9 @@ struct UrlState { #endif struct auth authhost; /* auth details for host */ struct auth authproxy; /* auth details for proxy */ +#ifdef USE_CURL_ASYNC + struct Curl_async async; /* asynchronous name resolver data */ +#endif #if defined(USE_OPENSSL) /* void instead of ENGINE to avoid bleeding OpenSSL into this header */ @@ -1479,7 +1469,7 @@ struct UrlState { server involved in this request */ unsigned char httpreq; /* Curl_HttpReq; what kind of HTTP request (if any) is this */ - unsigned char dselect_bits; /* != 0 -> bitmask of socket events for this + unsigned char select_bits; /* != 0 -> bitmask of socket events for this transfer overriding anything the socket may report */ #ifdef CURLDEBUG diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index 02e36ea5e..4696f29ad 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -211,8 +211,10 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, if(status == SEC_E_INSUFFICIENT_MEMORY) return CURLE_OUT_OF_MEMORY; +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) infof(data, "schannel: InitializeSecurityContext failed: %s", Curl_sspi_strerror(status, buffer, sizeof(buffer))); +#endif return CURLE_AUTH_ERROR; } @@ -603,8 +605,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, if(status == SEC_E_INSUFFICIENT_MEMORY) return CURLE_OUT_OF_MEMORY; +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) infof(data, "schannel: InitializeSecurityContext failed: %s", Curl_sspi_strerror(status, buffer, sizeof(buffer))); +#endif return CURLE_AUTH_ERROR; } diff --git a/lib/vauth/krb5_gssapi.c b/lib/vauth/krb5_gssapi.c index 65eb3e1b5..16b6e4037 100644 --- a/lib/vauth/krb5_gssapi.c +++ b/lib/vauth/krb5_gssapi.c @@ -226,7 +226,8 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, /* Extract the security layer and the maximum message size */ indata = output_token.value; sec_layer = indata[0]; - max_size = (indata[1] << 16) | (indata[2] << 8) | indata[3]; + max_size = ((unsigned int)indata[1] << 16) | + ((unsigned int)indata[2] << 8) | indata[3]; /* Free the challenge as it is not required anymore */ gss_release_buffer(&unused_status, &output_token); diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index c487149b9..17a517a97 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -319,7 +319,8 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, /* Extract the security layer and the maximum message size */ indata = input_buf[1].pvBuffer; sec_layer = indata[0]; - max_size = (indata[1] << 16) | (indata[2] << 8) | indata[3]; + max_size = ((unsigned long)indata[1] << 16) | + ((unsigned long)indata[2] << 8) | indata[3]; /* Free the challenge as it is not required anymore */ s_pSecFn->FreeContextBuffer(input_buf[1].pvBuffer); diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index ed7cee8de..018e6a67e 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -44,6 +44,7 @@ #include "warnless.h" #include "rand.h" #include "vtls/vtls.h" +#include "strdup.h" #define BUILDING_CURL_NTLM_MSGS_C #include "vauth/vauth.h" @@ -184,11 +185,10 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data, } free(ntlm->target_info); /* replace any previous data */ - ntlm->target_info = malloc(target_info_len); + ntlm->target_info = Curl_memdup(&type2[target_info_offset], + target_info_len); if(!ntlm->target_info) return CURLE_OUT_OF_MEMORY; - - memcpy(ntlm->target_info, &type2[target_info_offset], target_info_len); } } diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index 5118963f4..92054316d 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -34,6 +34,7 @@ #include "warnless.h" #include "curl_multibyte.h" #include "sendf.h" +#include "strdup.h" /* The last #include files should be: */ #include "curl_memory.h" @@ -213,11 +214,10 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, } /* Store the challenge for later use */ - ntlm->input_token = malloc(Curl_bufref_len(type2) + 1); + ntlm->input_token = Curl_memdup0((const char *)Curl_bufref_ptr(type2), + Curl_bufref_len(type2)); if(!ntlm->input_token) return CURLE_OUT_OF_MEMORY; - memcpy(ntlm->input_token, Curl_bufref_ptr(type2), Curl_bufref_len(type2)); - ntlm->input_token[Curl_bufref_len(type2)] = '\0'; ntlm->input_token_len = Curl_bufref_len(type2); return CURLE_OK; @@ -314,7 +314,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, &type_3_desc, &attrs, &expiry); if(status != SEC_E_OK) { - infof(data, "NTLM handshake failure (type-3 message): Status=%x", + infof(data, "NTLM handshake failure (type-3 message): Status=%lx", status); if(status == SEC_E_INSUFFICIENT_MEMORY) diff --git a/lib/version.c b/lib/version.c index f957f085d..01c2a315e 100644 --- a/lib/version.c +++ b/lib/version.c @@ -211,8 +211,12 @@ char *curl_version(void) #endif #ifdef USE_LIBPSL - msnprintf(psl_version, sizeof(psl_version), "libpsl/%s", psl_get_version()); - src[i++] = psl_version; + { + int num = psl_check_version_number(0); + msnprintf(psl_version, sizeof(psl_version), "libpsl/%d.%d.%d", + num >> 16, (num >> 8) & 0xff, num & 0xff); + src[i++] = psl_version; + } #endif #ifdef USE_SSH diff --git a/lib/vquic/curl_msh3.c b/lib/vquic/curl_msh3.c index 8ae367240..7674bc1fc 100644 --- a/lib/vquic/curl_msh3.c +++ b/lib/vquic/curl_msh3.c @@ -204,8 +204,8 @@ static void drain_stream_from_other_thread(struct Curl_easy *data, bits = CURL_CSELECT_IN; if(stream && !stream->upload_done) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - data->state.dselect_bits = bits; + if(data->state.select_bits != bits) { + data->state.select_bits = bits; /* cannot expire from other thread */ } } @@ -220,8 +220,8 @@ static void drain_stream(struct Curl_cfilter *cf, bits = CURL_CSELECT_IN; if(stream && !stream->upload_done) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - data->state.dselect_bits = bits; + if(data->state.select_bits != bits) { + data->state.select_bits = bits; Curl_expire(data, 0, EXPIRE_RUN_NOW); } } diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index f09b10bef..a26b3e429 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -41,7 +41,6 @@ #include "vtls/gtls.h" #elif defined(USE_WOLFSSL) #include -#include "vtls/wolfssl.h" #endif #include "urldata.h" @@ -61,6 +60,7 @@ #include "inet_pton.h" #include "vquic.h" #include "vquic_int.h" +#include "vquic-tls.h" #include "vtls/keylog.h" #include "vtls/vtls.h" #include "curl_ngtcp2.h" @@ -73,9 +73,6 @@ #include "memdebug.h" -#define H3_ALPN_H3_29 "\x5h3-29" -#define H3_ALPN_H3 "\x2h3" - #define QUIC_MAX_STREAMS (256*1024) #define QUIC_MAX_DATA (1*1024*1024) #define QUIC_HANDSHAKE_TIMEOUT (10*NGTCP2_SECONDS) @@ -101,25 +98,6 @@ (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) -#ifdef USE_OPENSSL -#define QUIC_CIPHERS \ - "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_" \ - "POLY1305_SHA256:TLS_AES_128_CCM_SHA256" -#define QUIC_GROUPS "P-256:X25519:P-384:P-521" -#elif defined(USE_GNUTLS) -#define QUIC_PRIORITY \ - "NORMAL:-VERS-ALL:+VERS-TLS1.3:-CIPHER-ALL:+AES-128-GCM:+AES-256-GCM:" \ - "+CHACHA20-POLY1305:+AES-128-CCM:-GROUP-ALL:+GROUP-SECP256R1:" \ - "+GROUP-X25519:+GROUP-SECP384R1:+GROUP-SECP521R1:" \ - "%DISABLE_TLS13_COMPAT_MODE" -#elif defined(USE_WOLFSSL) -#define QUIC_CIPHERS \ - "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_" \ - "POLY1305_SHA256:TLS_AES_128_CCM_SHA256" -#define QUIC_GROUPS "P-256:P-384:P-521" -#endif - - /* * Store ngtcp2 version info in this buffer. */ @@ -134,6 +112,7 @@ void Curl_ngtcp2_ver(char *p, size_t len) struct cf_ngtcp2_ctx { struct cf_quic_ctx q; struct ssl_peer peer; + struct quic_tls_ctx tls; ngtcp2_path connected_path; ngtcp2_conn *qconn; ngtcp2_cid dcid; @@ -143,30 +122,16 @@ struct cf_ngtcp2_ctx { ngtcp2_transport_params transport_params; ngtcp2_ccerr last_error; ngtcp2_crypto_conn_ref conn_ref; -#ifdef USE_OPENSSL - SSL_CTX *sslctx; - SSL *ssl; -#elif defined(USE_GNUTLS) - struct gtls_instance *gtls; -#elif defined(USE_WOLFSSL) - WOLFSSL_CTX *sslctx; - WOLFSSL *ssl; -#endif struct cf_call_data call_data; nghttp3_conn *h3conn; nghttp3_settings h3settings; struct curltime started_at; /* time the current attempt started */ struct curltime handshake_at; /* time connect handshake finished */ - struct curltime first_byte_at; /* when first byte was recvd */ struct curltime reconnect_at; /* time the next attempt should start */ struct bufc_pool stream_bufcp; /* chunk pool for streams */ size_t max_stream_window; /* max flow window for one stream */ uint64_t max_idle_ms; /* max idle time for QUIC connection */ int qlogfd; - BIT(got_first_byte); /* if first byte was received */ -#ifdef USE_OPENSSL - BIT(x509_store_setup); /* if x509 store has been set up */ -#endif }; /* How to access `call_data` from a cf_ngtcp2 filter */ @@ -292,8 +257,8 @@ static void h3_drain_stream(struct Curl_cfilter *cf, bits = CURL_CSELECT_IN; if(stream && stream->upload_left && !stream->send_closed) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - data->state.dselect_bits = bits; + if(data->state.select_bits != bits) { + data->state.select_bits = bits; Curl_expire(data, 0, EXPIRE_RUN_NOW); } } @@ -413,388 +378,8 @@ static void quic_settings(struct cf_ngtcp2_ctx *ctx, } } -#ifdef USE_OPENSSL -static void keylog_callback(const SSL *ssl, const char *line) -{ - (void)ssl; - Curl_tls_keylog_write_line(line); -} -#elif defined(USE_GNUTLS) -static int keylog_callback(gnutls_session_t session, const char *label, - const gnutls_datum_t *secret) -{ - gnutls_datum_t crandom; - gnutls_datum_t srandom; - - gnutls_session_get_random(session, &crandom, &srandom); - if(crandom.size != 32) { - return -1; - } - - Curl_tls_keylog_write(label, crandom.data, secret->data, secret->size); - return 0; -} -#elif defined(USE_WOLFSSL) -#if defined(HAVE_SECRET_CALLBACK) -static void keylog_callback(const WOLFSSL *ssl, const char *line) -{ - (void)ssl; - Curl_tls_keylog_write_line(line); -} -#endif -#endif - static int init_ngh3_conn(struct Curl_cfilter *cf); -#ifdef USE_OPENSSL -static CURLcode quic_ssl_ctx(SSL_CTX **pssl_ctx, - struct Curl_cfilter *cf, struct Curl_easy *data) -{ - struct cf_ngtcp2_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - CURLcode result = CURLE_FAILED_INIT; - - SSL_CTX *ssl_ctx = SSL_CTX_new(TLS_method()); - if(!ssl_ctx) { - result = CURLE_OUT_OF_MEMORY; - goto out; - } - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) { - result = CURLE_FAILED_INIT; - goto out; - } - -#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) - if(ngtcp2_crypto_boringssl_configure_client_context(ssl_ctx) != 0) { - failf(data, "ngtcp2_crypto_boringssl_configure_client_context failed"); - goto out; - } -#else - if(ngtcp2_crypto_quictls_configure_client_context(ssl_ctx) != 0) { - failf(data, "ngtcp2_crypto_quictls_configure_client_context failed"); - goto out; - } -#endif - - SSL_CTX_set_default_verify_paths(ssl_ctx); - - { - const char *curves = conn_config->curves ? - conn_config->curves : QUIC_GROUPS; - if(!SSL_CTX_set1_curves_list(ssl_ctx, curves)) { - failf(data, "failed setting curves list for QUIC: '%s'", curves); - return CURLE_SSL_CIPHER; - } - } - -#ifndef OPENSSL_IS_BORINGSSL - { - const char *ciphers13 = conn_config->cipher_list13 ? - conn_config->cipher_list13 : QUIC_CIPHERS; - if(SSL_CTX_set_ciphersuites(ssl_ctx, ciphers13) != 1) { - failf(data, "failed setting QUIC cipher suite: %s", ciphers13); - return CURLE_SSL_CIPHER; - } - infof(data, "QUIC cipher selection: %s", ciphers13); - } -#endif - - /* Open the file if a TLS or QUIC backend has not done this before. */ - Curl_tls_keylog_open(); - if(Curl_tls_keylog_enabled()) { - SSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback); - } - - /* OpenSSL always tries to verify the peer, this only says whether it should - * fail to connect if the verification fails, or if it should continue - * anyway. In the latter case the result of the verification is checked with - * SSL_get_verify_result() below. */ - SSL_CTX_set_verify(ssl_ctx, conn_config->verifypeer ? - SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL); - - /* give application a chance to interfere with SSL set up. */ - if(data->set.ssl.fsslctx) { - /* When a user callback is installed to modify the SSL_CTX, - * we need to do the full initialization before calling it. - * See: #11800 */ - if(!ctx->x509_store_setup) { - result = Curl_ssl_setup_x509_store(cf, data, ssl_ctx); - if(result) - goto out; - ctx->x509_store_setup = TRUE; - } - Curl_set_in_callback(data, true); - result = (*data->set.ssl.fsslctx)(data, ssl_ctx, - data->set.ssl.fsslctxp); - Curl_set_in_callback(data, false); - if(result) { - failf(data, "error signaled by ssl ctx callback"); - goto out; - } - } - result = CURLE_OK; - -out: - *pssl_ctx = result? NULL : ssl_ctx; - if(result && ssl_ctx) - SSL_CTX_free(ssl_ctx); - return result; -} - -static CURLcode quic_set_client_cert(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_ngtcp2_ctx *ctx = cf->ctx; - SSL_CTX *ssl_ctx = ctx->sslctx; - const struct ssl_config_data *ssl_config; - - ssl_config = Curl_ssl_cf_get_config(cf, data); - DEBUGASSERT(ssl_config); - - if(ssl_config->primary.clientcert || ssl_config->primary.cert_blob - || ssl_config->cert_type) { - return Curl_ossl_set_client_cert( - data, ssl_ctx, ssl_config->primary.clientcert, - ssl_config->primary.cert_blob, ssl_config->cert_type, - ssl_config->key, ssl_config->key_blob, - ssl_config->key_type, ssl_config->key_passwd); - } - - return CURLE_OK; -} - -/** SSL callbacks ***/ - -static CURLcode quic_init_ssl(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_ngtcp2_ctx *ctx = cf->ctx; - const uint8_t *alpn = NULL; - size_t alpnlen = 0; - - DEBUGASSERT(!ctx->ssl); - ctx->ssl = SSL_new(ctx->sslctx); - - SSL_set_app_data(ctx->ssl, &ctx->conn_ref); - SSL_set_connect_state(ctx->ssl); - SSL_set_quic_use_legacy_codepoint(ctx->ssl, 0); - - alpn = (const uint8_t *)H3_ALPN_H3_29 H3_ALPN_H3; - alpnlen = sizeof(H3_ALPN_H3_29) - 1 + sizeof(H3_ALPN_H3) - 1; - if(alpn) - SSL_set_alpn_protos(ctx->ssl, alpn, (int)alpnlen); - - /* set SNI */ - if(ctx->peer.sni) { - if(!SSL_set_tlsext_host_name(ctx->ssl, ctx->peer.sni)) { - failf(data, "Failed set SNI"); - SSL_free(ctx->ssl); - ctx->ssl = NULL; - return CURLE_QUIC_CONNECT_ERROR; - } - } - return CURLE_OK; -} -#elif defined(USE_GNUTLS) -static CURLcode quic_init_ssl(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_ngtcp2_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - CURLcode result; - gnutls_datum_t alpn[2]; - /* this will need some attention when HTTPS proxy over QUIC get fixed */ - long * const pverifyresult = &data->set.ssl.certverifyresult; - int rc; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) - return CURLE_FAILED_INIT; - - DEBUGASSERT(ctx->gtls == NULL); - ctx->gtls = calloc(1, sizeof(*(ctx->gtls))); - if(!ctx->gtls) - return CURLE_OUT_OF_MEMORY; - - result = gtls_client_init(data, conn_config, &data->set.ssl, - &ctx->peer, ctx->gtls, pverifyresult); - if(result) - return result; - - gnutls_session_set_ptr(ctx->gtls->session, &ctx->conn_ref); - - if(ngtcp2_crypto_gnutls_configure_client_session(ctx->gtls->session) != 0) { - CURL_TRC_CF(data, cf, - "ngtcp2_crypto_gnutls_configure_client_session failed\n"); - return CURLE_QUIC_CONNECT_ERROR; - } - - rc = gnutls_priority_set_direct(ctx->gtls->session, QUIC_PRIORITY, NULL); - if(rc < 0) { - CURL_TRC_CF(data, cf, "gnutls_priority_set_direct failed: %s\n", - gnutls_strerror(rc)); - return CURLE_QUIC_CONNECT_ERROR; - } - - /* Open the file if a TLS or QUIC backend has not done this before. */ - Curl_tls_keylog_open(); - if(Curl_tls_keylog_enabled()) { - gnutls_session_set_keylog_function(ctx->gtls->session, keylog_callback); - } - - /* strip the first byte (the length) from NGHTTP3_ALPN_H3 */ - alpn[0].data = (unsigned char *)H3_ALPN_H3_29 + 1; - alpn[0].size = sizeof(H3_ALPN_H3_29) - 2; - alpn[1].data = (unsigned char *)H3_ALPN_H3 + 1; - alpn[1].size = sizeof(H3_ALPN_H3) - 2; - - gnutls_alpn_set_protocols(ctx->gtls->session, - alpn, 2, GNUTLS_ALPN_MANDATORY); - return CURLE_OK; -} -#elif defined(USE_WOLFSSL) - -static CURLcode quic_ssl_ctx(WOLFSSL_CTX **pssl_ctx, - struct Curl_cfilter *cf, struct Curl_easy *data) -{ - CURLcode result = CURLE_FAILED_INIT; - struct ssl_primary_config *conn_config; - WOLFSSL_CTX *ssl_ctx = NULL; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) { - result = CURLE_FAILED_INIT; - goto out; - } - - ssl_ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method()); - if(!ssl_ctx) { - result = CURLE_OUT_OF_MEMORY; - goto out; - } - - if(ngtcp2_crypto_wolfssl_configure_client_context(ssl_ctx) != 0) { - failf(data, "ngtcp2_crypto_wolfssl_configure_client_context failed"); - result = CURLE_FAILED_INIT; - goto out; - } - - wolfSSL_CTX_set_default_verify_paths(ssl_ctx); - - if(wolfSSL_CTX_set_cipher_list(ssl_ctx, conn_config->cipher_list13 ? - conn_config->cipher_list13 : - QUIC_CIPHERS) != 1) { - char error_buffer[256]; - ERR_error_string_n(ERR_get_error(), error_buffer, sizeof(error_buffer)); - failf(data, "wolfSSL failed to set ciphers: %s", error_buffer); - goto out; - } - - if(wolfSSL_CTX_set1_groups_list(ssl_ctx, conn_config->curves ? - conn_config->curves : - (char *)QUIC_GROUPS) != 1) { - failf(data, "wolfSSL failed to set curves"); - goto out; - } - - /* Open the file if a TLS or QUIC backend has not done this before. */ - Curl_tls_keylog_open(); - if(Curl_tls_keylog_enabled()) { -#if defined(HAVE_SECRET_CALLBACK) - wolfSSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback); -#else - failf(data, "wolfSSL was built without keylog callback"); - goto out; -#endif - } - - if(conn_config->verifypeer) { - const char * const ssl_cafile = conn_config->CAfile; - const char * const ssl_capath = conn_config->CApath; - - wolfSSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); - if(ssl_cafile || ssl_capath) { - /* tell wolfSSL where to find CA certificates that are used to verify - the server's certificate. */ - int rc = - wolfSSL_CTX_load_verify_locations_ex(ssl_ctx, ssl_cafile, ssl_capath, - WOLFSSL_LOAD_FLAG_IGNORE_ERR); - if(SSL_SUCCESS != rc) { - /* Fail if we insist on successfully verifying the server. */ - failf(data, "error setting certificate verify locations:" - " CAfile: %s CApath: %s", - ssl_cafile ? ssl_cafile : "none", - ssl_capath ? ssl_capath : "none"); - goto out; - } - infof(data, " CAfile: %s", ssl_cafile ? ssl_cafile : "none"); - infof(data, " CApath: %s", ssl_capath ? ssl_capath : "none"); - } -#ifdef CURL_CA_FALLBACK - else { - /* verifying the peer without any CA certificates won't work so - use wolfssl's built-in default as fallback */ - wolfSSL_CTX_set_default_verify_paths(ssl_ctx); - } -#endif - } - else { - wolfSSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_NONE, NULL); - } - - /* give application a chance to interfere with SSL set up. */ - if(data->set.ssl.fsslctx) { - Curl_set_in_callback(data, true); - result = (*data->set.ssl.fsslctx)(data, ssl_ctx, - data->set.ssl.fsslctxp); - Curl_set_in_callback(data, false); - if(result) { - failf(data, "error signaled by ssl ctx callback"); - goto out; - } - } - result = CURLE_OK; - -out: - *pssl_ctx = result? NULL : ssl_ctx; - if(result && ssl_ctx) - SSL_CTX_free(ssl_ctx); - return result; -} - -/** SSL callbacks ***/ - -static CURLcode quic_init_ssl(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_ngtcp2_ctx *ctx = cf->ctx; - const uint8_t *alpn = NULL; - size_t alpnlen = 0; - /* this will need some attention when HTTPS proxy over QUIC get fixed */ - const char * const hostname = cf->conn->host.name; - - (void)data; - DEBUGASSERT(!ctx->ssl); - ctx->ssl = wolfSSL_new(ctx->sslctx); - - wolfSSL_set_app_data(ctx->ssl, &ctx->conn_ref); - wolfSSL_set_connect_state(ctx->ssl); - wolfSSL_set_quic_use_legacy_codepoint(ctx->ssl, 0); - - alpn = (const uint8_t *)H3_ALPN_H3_29 H3_ALPN_H3; - alpnlen = sizeof(H3_ALPN_H3_29) - 1 + sizeof(H3_ALPN_H3) - 1; - if(alpn) - wolfSSL_set_alpn_protos(ctx->ssl, alpn, (int)alpnlen); - - /* set SNI */ - wolfSSL_UseSNI(ctx->ssl, WOLFSSL_SNI_HOST_NAME, - hostname, (unsigned short)strlen(hostname)); - - return CURLE_OK; -} -#endif /* defined(USE_WOLFSSL) */ - static int cb_handshake_completed(ngtcp2_conn *tconn, void *user_data) { (void)user_data; @@ -1157,18 +742,22 @@ static void cf_ngtcp2_adjust_pollset(struct Curl_cfilter *cf, struct easy_pollset *ps) { struct cf_ngtcp2_ctx *ctx = cf->ctx; - bool want_recv = CURL_WANT_RECV(data); - bool want_send = CURL_WANT_SEND(data); + bool want_recv, want_send; - if(ctx->qconn && (want_recv || want_send)) { + if(!ctx->qconn) + return; + + Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); + if(want_recv || want_send) { struct h3_stream_ctx *stream = H3_STREAM_CTX(data); struct cf_call_data save; bool c_exhaust, s_exhaust; CF_DATA_SAVE(save, cf, data); - c_exhaust = !ngtcp2_conn_get_cwnd_left(ctx->qconn) || - !ngtcp2_conn_get_max_data_left(ctx->qconn); - s_exhaust = stream && stream->id >= 0 && stream->quic_flow_blocked; + c_exhaust = want_send && (!ngtcp2_conn_get_cwnd_left(ctx->qconn) || + !ngtcp2_conn_get_max_data_left(ctx->qconn)); + s_exhaust = want_send && stream && stream->id >= 0 && + stream->quic_flow_blocked; want_recv = (want_recv || c_exhaust || s_exhaust); want_send = (!s_exhaust && want_send) || !Curl_bufq_is_empty(&ctx->q.sendbuf); @@ -1894,6 +1483,8 @@ static ssize_t cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, sent = (ssize_t)len; goto out; } + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " + "-> stream closed", stream->id, len); *err = CURLE_HTTP3; sent = -1; goto out; @@ -1944,49 +1535,12 @@ static CURLcode qng_verify_peer(struct Curl_cfilter *cf, struct Curl_easy *data) { struct cf_ngtcp2_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - CURLcode result = CURLE_OK; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) - return CURLE_FAILED_INIT; cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */ cf->conn->httpversion = 30; cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX; - if(conn_config->verifyhost) { -#ifdef USE_OPENSSL - X509 *server_cert; - server_cert = SSL_get1_peer_certificate(ctx->ssl); - if(!server_cert) { - return CURLE_PEER_FAILED_VERIFICATION; - } - result = Curl_ossl_verifyhost(data, cf->conn, &ctx->peer, server_cert); - X509_free(server_cert); - if(result) - return result; -#elif defined(USE_GNUTLS) - result = Curl_gtls_verifyserver(data, ctx->gtls->session, - conn_config, &data->set.ssl, &ctx->peer, - data->set.str[STRING_SSL_PINNEDPUBLICKEY]); - if(result) - return result; -#elif defined(USE_WOLFSSL) - if(!ctx->peer.sni || - wolfSSL_check_domain_name(ctx->ssl, ctx->peer.sni) == SSL_FAILURE) - return CURLE_PEER_FAILED_VERIFICATION; -#endif - infof(data, "Verified certificate just fine"); - } - else - infof(data, "Skipped certificate verification"); -#ifdef USE_OPENSSL - if(data->set.ssl.certinfo) - /* asked to gather certificate info */ - (void)Curl_ossl_certchain(data, ctx->ssl); -#endif - return result; + return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); } static CURLcode recv_pkt(const unsigned char *pkt, size_t pktlen, @@ -2050,14 +1604,9 @@ static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, pktx_update_time(pktx, cf); } -#ifdef USE_OPENSSL - if(!ctx->x509_store_setup) { - result = Curl_ssl_setup_x509_store(cf, data, ctx->sslctx); - if(result) - return result; - ctx->x509_store_setup = TRUE; - } -#endif + result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); + if(result) + return result; for(i = 0; i < pkts_max; i += pkts_chunk) { pktx->pkt_count = 0; @@ -2382,25 +1931,7 @@ static void cf_ngtcp2_ctx_clear(struct cf_ngtcp2_ctx *ctx) if(ctx->qlogfd != -1) { close(ctx->qlogfd); } -#ifdef USE_OPENSSL - if(ctx->ssl) - SSL_free(ctx->ssl); - if(ctx->sslctx) - SSL_CTX_free(ctx->sslctx); -#elif defined(USE_GNUTLS) - if(ctx->gtls) { - if(ctx->gtls->cred) - gnutls_certificate_free_credentials(ctx->gtls->cred); - if(ctx->gtls->session) - gnutls_deinit(ctx->gtls->session); - free(ctx->gtls); - } -#elif defined(USE_WOLFSSL) - if(ctx->ssl) - wolfSSL_free(ctx->ssl); - if(ctx->sslctx) - wolfSSL_CTX_free(ctx->sslctx); -#endif + Curl_vquic_tls_cleanup(&ctx->tls); vquic_ctx_free(&ctx->q); if(ctx->h3conn) nghttp3_conn_del(ctx->h3conn); @@ -2459,6 +1990,37 @@ static void cf_ngtcp2_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) (void)save; } +static CURLcode tls_ctx_setup(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + (void)cf; +#ifdef USE_OPENSSL +#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) + if(ngtcp2_crypto_boringssl_configure_client_context(ctx->ssl_ctx) != 0) { + failf(data, "ngtcp2_crypto_boringssl_configure_client_context failed"); + return CURLE_FAILED_INIT; + } +#else + if(ngtcp2_crypto_quictls_configure_client_context(ctx->ssl_ctx) != 0) { + failf(data, "ngtcp2_crypto_quictls_configure_client_context failed"); + return CURLE_FAILED_INIT; + } +#endif /* !OPENSSL_IS_BORINGSSL && !OPENSSL_IS_AWSLC */ +#elif defined(USE_GNUTLS) + if(ngtcp2_crypto_gnutls_configure_client_session(ctx->gtls->session) != 0) { + failf(data, "ngtcp2_crypto_gnutls_configure_client_session failed"); + return CURLE_FAILED_INIT; + } +#elif defined(USE_WOLFSSL) + if(ngtcp2_crypto_wolfssl_configure_client_context(ctx->ssl_ctx) != 0) { + failf(data, "ngtcp2_crypto_wolfssl_configure_client_context failed"); + return CURLE_FAILED_INIT; + } +#endif + return CURLE_OK; +} + /* * Might be called twice for happy eyeballs. */ @@ -2483,21 +2045,10 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, if(result) return result; -#ifdef USE_OPENSSL - result = quic_ssl_ctx(&ctx->sslctx, cf, data); - if(result) - return result; - - result = quic_set_client_cert(cf, data); - if(result) - return result; -#elif defined(USE_WOLFSSL) - result = quic_ssl_ctx(&ctx->sslctx, cf, data); - if(result) - return result; -#endif - - result = quic_init_ssl(cf, data); +#define H3_ALPN "\x2h3\x5h3-29" + result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, + H3_ALPN, sizeof(H3_ALPN) - 1, + tls_ctx_setup, &ctx->conn_ref); if(result) return result; @@ -2544,9 +2095,9 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, return CURLE_QUIC_CONNECT_ERROR; #ifdef USE_GNUTLS - ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->gtls->session); + ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.gtls->session); #else - ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->ssl); + ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.ssl); #endif ngtcp2_ccerr_default(&ctx->last_error); @@ -2677,8 +2228,8 @@ static CURLcode cf_ngtcp2_query(struct Curl_cfilter *cf, return CURLE_OK; } case CF_QUERY_CONNECT_REPLY_MS: - if(ctx->got_first_byte) { - timediff_t ms = Curl_timediff(ctx->first_byte_at, ctx->started_at); + if(ctx->q.got_first_byte) { + timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at); *pres1 = (ms < INT_MAX)? (int)ms : INT_MAX; } else @@ -2686,8 +2237,8 @@ static CURLcode cf_ngtcp2_query(struct Curl_cfilter *cf, return CURLE_OK; case CF_QUERY_TIMER_CONNECT: { struct curltime *when = pres2; - if(ctx->got_first_byte) - *when = ctx->first_byte_at; + if(ctx->q.got_first_byte) + *when = ctx->q.first_byte_at; return CURLE_OK; } case CF_QUERY_TIMER_APPCONNECT: { diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c new file mode 100644 index 000000000..c499a004b --- /dev/null +++ b/lib/vquic/curl_osslq.c @@ -0,0 +1,2237 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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 + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3) + +#include +#include +#include +#include + +#include "urldata.h" +#include "sendf.h" +#include "strdup.h" +#include "rand.h" +#include "multiif.h" +#include "strcase.h" +#include "cfilters.h" +#include "cf-socket.h" +#include "connect.h" +#include "progress.h" +#include "strerror.h" +#include "dynbuf.h" +#include "http1.h" +#include "select.h" +#include "inet_pton.h" +#include "vquic.h" +#include "vquic_int.h" +#include "vquic-tls.h" +#include "vtls/keylog.h" +#include "vtls/vtls.h" +#include "vtls/openssl.h" +#include "curl_osslq.h" + +#include "warnless.h" + +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" +#include "curl_memory.h" +#include "memdebug.h" + +/* A stream window is the maximum amount we need to buffer for + * each active transfer. We use HTTP/3 flow control and only ACK + * when we take things out of the buffer. + * Chunk size is large enough to take a full DATA frame */ +#define H3_STREAM_WINDOW_SIZE (128 * 1024) +#define H3_STREAM_CHUNK_SIZE (16 * 1024) +/* The pool keeps spares around and half of a full stream windows + * seems good. More does not seem to improve performance. + * The benefit of the pool is that stream buffer to not keep + * spares. So memory consumption goes down when streams run empty, + * have a large upload done, etc. */ +#define H3_STREAM_POOL_SPARES \ + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE ) / 2 +/* Receive and Send max number of chunks just follows from the + * chunk size and window size */ +#define H3_STREAM_RECV_CHUNKS \ + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) +#define H3_STREAM_SEND_CHUNKS \ + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) + +#ifndef ARRAYSIZE +#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) +#endif + +#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) +typedef uint32_t sslerr_t; +#else +typedef unsigned long sslerr_t; +#endif + + +/* How to access `call_data` from a cf_osslq filter */ +#undef CF_CTX_CALL_DATA +#define CF_CTX_CALL_DATA(cf) \ + ((struct cf_osslq_ctx *)(cf)->ctx)->call_data + +static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, + struct Curl_easy *data); + +static const char *SSL_ERROR_to_str(int err) +{ + switch(err) { + case SSL_ERROR_NONE: + return "SSL_ERROR_NONE"; + case SSL_ERROR_SSL: + return "SSL_ERROR_SSL"; + case SSL_ERROR_WANT_READ: + return "SSL_ERROR_WANT_READ"; + case SSL_ERROR_WANT_WRITE: + return "SSL_ERROR_WANT_WRITE"; + case SSL_ERROR_WANT_X509_LOOKUP: + return "SSL_ERROR_WANT_X509_LOOKUP"; + case SSL_ERROR_SYSCALL: + return "SSL_ERROR_SYSCALL"; + case SSL_ERROR_ZERO_RETURN: + return "SSL_ERROR_ZERO_RETURN"; + case SSL_ERROR_WANT_CONNECT: + return "SSL_ERROR_WANT_CONNECT"; + case SSL_ERROR_WANT_ACCEPT: + return "SSL_ERROR_WANT_ACCEPT"; +#if defined(SSL_ERROR_WANT_ASYNC) + case SSL_ERROR_WANT_ASYNC: + return "SSL_ERROR_WANT_ASYNC"; +#endif +#if defined(SSL_ERROR_WANT_ASYNC_JOB) + case SSL_ERROR_WANT_ASYNC_JOB: + return "SSL_ERROR_WANT_ASYNC_JOB"; +#endif +#if defined(SSL_ERROR_WANT_EARLY) + case SSL_ERROR_WANT_EARLY: + return "SSL_ERROR_WANT_EARLY"; +#endif + default: + return "SSL_ERROR unknown"; + } +} + +/* Return error string for last OpenSSL error */ +static char *ossl_strerror(unsigned long error, char *buf, size_t size) +{ + DEBUGASSERT(size); + *buf = '\0'; + +#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) + ERR_error_string_n((uint32_t)error, buf, size); +#else + ERR_error_string_n(error, buf, size); +#endif + + if(!*buf) { + const char *msg = error ? "Unknown error" : "No error"; + if(strlen(msg) < size) + strcpy(buf, msg); + } + + return buf; +} + +static CURLcode make_bio_addr(BIO_ADDR **pbio_addr, + const struct Curl_sockaddr_ex *addr) +{ + BIO_ADDR *ba; + CURLcode result = CURLE_FAILED_INIT; + + ba = BIO_ADDR_new(); + if(!ba) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + switch(addr->family) { + case AF_INET: { + struct sockaddr_in * const sin = + (struct sockaddr_in * const)(void *)&addr->sa_addr; + if(!BIO_ADDR_rawmake(ba, AF_INET, &sin->sin_addr, + sizeof(sin->sin_addr), sin->sin_port)) { + goto out; + } + result = CURLE_OK; + break; + } +#ifdef ENABLE_IPV6 + case AF_INET6: { + struct sockaddr_in6 * const sin = + (struct sockaddr_in6 * const)(void *)&addr->sa_addr; + if(!BIO_ADDR_rawmake(ba, AF_INET6, &sin->sin6_addr, + sizeof(sin->sin6_addr), sin->sin6_port)) { + } + result = CURLE_OK; + break; + } +#endif /* ENABLE_IPV6 */ + default: + /* sunsupported */ + DEBUGASSERT(0); + break; + } + +out: + if(result && ba) { + BIO_ADDR_free(ba); + ba = NULL; + } + *pbio_addr = ba; + return result; +} + +/* QUIC stream (not necessarily H3) */ +struct cf_osslq_stream { + int64_t id; + SSL *ssl; + struct bufq recvbuf; /* QUIC war data recv buffer */ + BIT(recvd_eos); + BIT(closed); + BIT(reset); + BIT(send_blocked); +}; + +static CURLcode cf_osslq_stream_open(struct cf_osslq_stream *s, + SSL *conn, + uint64_t flags, + struct bufc_pool *bufcp, + void *user_data) +{ + DEBUGASSERT(!s->ssl); + Curl_bufq_initp(&s->recvbuf, bufcp, 1, BUFQ_OPT_NONE); + s->ssl = SSL_new_stream(conn, flags); + if(!s->ssl) { + return CURLE_FAILED_INIT; + } + s->id = SSL_get_stream_id(s->ssl); + SSL_set_app_data(s->ssl, user_data); + return CURLE_OK; +} + +static void cf_osslq_stream_cleanup(struct cf_osslq_stream *s) +{ + if(s->ssl) { + SSL_set_app_data(s->ssl, NULL); + SSL_free(s->ssl); + } + Curl_bufq_free(&s->recvbuf); + memset(s, 0, sizeof(*s)); +} + +static void cf_osslq_stream_close(struct cf_osslq_stream *s) +{ + if(s->ssl) { + SSL_free(s->ssl); + s->ssl = NULL; + } +} + +struct cf_osslq_h3conn { + nghttp3_conn *conn; + nghttp3_settings settings; + struct cf_osslq_stream s_ctrl; + struct cf_osslq_stream s_qpack_enc; + struct cf_osslq_stream s_qpack_dec; + struct cf_osslq_stream remote_ctrl[3]; /* uni streams opened by the peer */ + size_t remote_ctrl_n; /* number of peer streams opened */ +}; + +static void cf_osslq_h3conn_cleanup(struct cf_osslq_h3conn *h3) +{ + size_t i; + + if(h3->conn) + nghttp3_conn_del(h3->conn); + cf_osslq_stream_cleanup(&h3->s_ctrl); + cf_osslq_stream_cleanup(&h3->s_qpack_enc); + cf_osslq_stream_cleanup(&h3->s_qpack_dec); + for(i = 0; i < h3->remote_ctrl_n; ++i) { + cf_osslq_stream_cleanup(&h3->remote_ctrl[i]); + } +} + +struct cf_osslq_ctx { + struct cf_quic_ctx q; + struct ssl_peer peer; + struct quic_tls_ctx tls; + struct cf_call_data call_data; + struct cf_osslq_h3conn h3; + struct curltime started_at; /* time the current attempt started */ + struct curltime handshake_at; /* time connect handshake finished */ + struct curltime first_byte_at; /* when first byte was recvd */ + struct curltime reconnect_at; /* time the next attempt should start */ + struct bufc_pool stream_bufcp; /* chunk pool for streams */ + size_t max_stream_window; /* max flow window for one stream */ + uint64_t max_idle_ms; /* max idle time for QUIC connection */ + BIT(got_first_byte); /* if first byte was received */ +#ifdef USE_OPENSSL + BIT(x509_store_setup); /* if x509 store has been set up */ + BIT(protocol_shutdown); /* QUIC connection is shut down */ +#endif +}; + +static void cf_osslq_ctx_clear(struct cf_osslq_ctx *ctx) +{ + struct cf_call_data save = ctx->call_data; + + cf_osslq_h3conn_cleanup(&ctx->h3); + Curl_vquic_tls_cleanup(&ctx->tls); + vquic_ctx_free(&ctx->q); + Curl_bufcp_free(&ctx->stream_bufcp); + Curl_ssl_peer_cleanup(&ctx->peer); + + memset(ctx, 0, sizeof(*ctx)); + ctx->call_data = save; +} + +static void cf_osslq_close(struct Curl_cfilter *cf, struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct cf_call_data save; + + CF_DATA_SAVE(save, cf, data); + if(ctx && ctx->tls.ssl) { + /* TODO: send connection close */ + CURL_TRC_CF(data, cf, "cf_osslq_close()"); + cf_osslq_ctx_clear(ctx); + } + + cf->connected = FALSE; + CF_DATA_RESTORE(cf, save); +} + +static void cf_osslq_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct cf_call_data save; + + CF_DATA_SAVE(save, cf, data); + CURL_TRC_CF(data, cf, "destroy"); + if(ctx) { + CURL_TRC_CF(data, cf, "cf_osslq_destroy()"); + cf_osslq_ctx_clear(ctx); + free(ctx); + } + cf->ctx = NULL; + /* No CF_DATA_RESTORE(cf, save) possible */ + (void)save; +} + +static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3, + SSL *stream_ssl, + struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + int64_t stream_id = SSL_get_stream_id(stream_ssl); + + if(h3->remote_ctrl_n >= ARRAYSIZE(h3->remote_ctrl)) { + /* rejected, we are full */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] rejecting additional remote stream", + stream_id); + SSL_free(stream_ssl); + return CURLE_FAILED_INIT; + } + switch(SSL_get_stream_type(stream_ssl)) { + case SSL_STREAM_TYPE_READ: { + struct cf_osslq_stream *nstream = &h3->remote_ctrl[h3->remote_ctrl_n++]; + nstream->id = stream_id; + nstream->ssl = stream_ssl; + Curl_bufq_initp(&nstream->recvbuf, &ctx->stream_bufcp, 1, BUFQ_OPT_NONE); + CURL_TRC_CF(data, cf, "[%" PRId64 "] accepted new remote uni stream", + stream_id); + break; + } + default: + CURL_TRC_CF(data, cf, "[%" PRId64 "] rejecting remote non-uni-read" + " stream", stream_id); + SSL_free(stream_ssl); + return CURLE_FAILED_INIT; + } + return CURLE_OK; + +} + +static CURLcode cf_osslq_ssl_err(struct Curl_cfilter *cf, + struct Curl_easy *data, + int detail, CURLcode def_result) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = def_result; + sslerr_t errdetail; + char ebuf[256] = "unknown"; + const char *err_descr = ebuf; + long lerr; + int lib; + int reason; + struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data); + + errdetail = ERR_get_error(); + lib = ERR_GET_LIB(errdetail); + reason = ERR_GET_REASON(errdetail); + + if((lib == ERR_LIB_SSL) && + ((reason == SSL_R_CERTIFICATE_VERIFY_FAILED) || + (reason == SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED))) { + result = CURLE_PEER_FAILED_VERIFICATION; + + lerr = SSL_get_verify_result(ctx->tls.ssl); + if(lerr != X509_V_OK) { + ssl_config->certverifyresult = lerr; + msnprintf(ebuf, sizeof(ebuf), + "SSL certificate problem: %s", + X509_verify_cert_error_string(lerr)); + } + else + err_descr = "SSL certificate verification failed"; + } +#if defined(SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED) + /* SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED is only available on + OpenSSL version above v1.1.1, not LibreSSL, BoringSSL, or AWS-LC */ + else if((lib == ERR_LIB_SSL) && + (reason == SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED)) { + /* If client certificate is required, communicate the + error to client */ + result = CURLE_SSL_CLIENTCERT; + ossl_strerror(errdetail, ebuf, sizeof(ebuf)); + } +#endif + else if((lib == ERR_LIB_SSL) && (reason == SSL_R_PROTOCOL_IS_SHUTDOWN)) { + ctx->protocol_shutdown = TRUE; + err_descr = "QUIC connectin has been shut down"; + result = def_result; + } + else { + result = def_result; + ossl_strerror(errdetail, ebuf, sizeof(ebuf)); + } + + /* detail is already set to the SSL error above */ + + /* If we e.g. use SSLv2 request-method and the server doesn't like us + * (RST connection, etc.), OpenSSL gives no explanation whatsoever and + * the SO_ERROR is also lost. + */ + if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) { + char extramsg[80]=""; + int sockerr = SOCKERRNO; + const char *r_ip = NULL; + int r_port = 0; + + Curl_cf_socket_peek(cf->next, data, NULL, NULL, + &r_ip, &r_port, NULL, NULL); + if(sockerr && detail == SSL_ERROR_SYSCALL) + Curl_strerror(sockerr, extramsg, sizeof(extramsg)); + failf(data, "QUIC connect: %s in connection to %s:%d (%s)", + extramsg[0] ? extramsg : SSL_ERROR_to_str(detail), + ctx->peer.dispname, r_port, r_ip); + } + else { + /* Could be a CERT problem */ + failf(data, "%s", err_descr); + } + return result; +} + +static CURLcode cf_osslq_verify_peer(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + + cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */ + cf->conn->httpversion = 30; + cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX; + + return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); +} + +/** + * All about the H3 internals of a stream + */ +struct h3_stream_ctx { + struct cf_osslq_stream s; + struct bufq sendbuf; /* h3 request body */ + struct bufq recvbuf; /* h3 response body */ + struct h1_req_parser h1; /* h1 request parsing */ + size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ + size_t upload_blocked_len; /* the amount written last and EGAINed */ + size_t recv_buf_nonflow; /* buffered bytes, not counting for flow control */ + uint64_t error3; /* HTTP/3 stream error code */ + curl_off_t upload_left; /* number of request bytes left to upload */ + curl_off_t download_recvd; /* number of response DATA bytes received */ + int status_code; /* HTTP status code */ + bool resp_hds_complete; /* we have a complete, final response */ + bool closed; /* TRUE on stream close */ + bool reset; /* TRUE on stream reset */ + bool send_closed; /* stream is local closed */ + BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ +}; + +#define H3_STREAM_CTX(d) ((struct h3_stream_ctx *)(((d) && (d)->req.p.http)? \ + ((struct HTTP *)(d)->req.p.http)->h3_ctx \ + : NULL)) +#define H3_STREAM_LCTX(d) ((struct HTTP *)(d)->req.p.http)->h3_ctx +#define H3_STREAM_ID(d) (H3_STREAM_CTX(d)? \ + H3_STREAM_CTX(d)->s.id : -2) + +static CURLcode h3_data_setup(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + + if(!data || !data->req.p.http) { + failf(data, "initialization failure, transfer not http initialized"); + return CURLE_FAILED_INIT; + } + + if(stream) + return CURLE_OK; + + stream = calloc(1, sizeof(*stream)); + if(!stream) + return CURLE_OUT_OF_MEMORY; + + stream->s.id = -1; + /* on send, we control how much we put into the buffer */ + Curl_bufq_initp(&stream->sendbuf, &ctx->stream_bufcp, + H3_STREAM_SEND_CHUNKS, BUFQ_OPT_NONE); + stream->sendbuf_len_in_flight = 0; + /* on recv, we need a flexible buffer limit since we also write + * headers to it that are not counted against the nghttp3 flow limits. */ + Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp, + H3_STREAM_RECV_CHUNKS, BUFQ_OPT_SOFT_LIMIT); + stream->recv_buf_nonflow = 0; + Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); + + H3_STREAM_LCTX(data) = stream; + return CURLE_OK; +} + +static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + + (void)cf; + if(stream) { + CURL_TRC_CF(data, cf, "[%"PRId64"] easy handle is done", stream->s.id); + if(ctx->h3.conn && !stream->closed) { + nghttp3_conn_shutdown_stream_read(ctx->h3.conn, stream->s.id); + nghttp3_conn_close_stream(ctx->h3.conn, stream->s.id, + NGHTTP3_H3_REQUEST_CANCELLED); + nghttp3_conn_set_stream_user_data(ctx->h3.conn, stream->s.id, NULL); + stream->closed = TRUE; + } + + cf_osslq_stream_cleanup(&stream->s); + Curl_bufq_free(&stream->sendbuf); + Curl_bufq_free(&stream->recvbuf); + Curl_h1_req_parse_free(&stream->h1); + free(stream); + H3_STREAM_LCTX(data) = NULL; + } +} + +static struct cf_osslq_stream *cf_osslq_get_qstream(struct Curl_cfilter *cf, + struct Curl_easy *data, + int64_t stream_id) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + struct Curl_easy *sdata; + + if(stream && stream->s.id == stream_id) { + return &stream->s; + } + else if(ctx->h3.s_ctrl.id == stream_id) { + return &ctx->h3.s_ctrl; + } + else if(ctx->h3.s_qpack_enc.id == stream_id) { + return &ctx->h3.s_qpack_enc; + } + else if(ctx->h3.s_qpack_dec.id == stream_id) { + return &ctx->h3.s_qpack_dec; + } + else { + DEBUGASSERT(data->multi); + for(sdata = data->multi->easyp; sdata; sdata = sdata->next) { + if((sdata->conn == data->conn) && H3_STREAM_ID(sdata) == stream_id) { + stream = H3_STREAM_CTX(sdata); + return stream? &stream->s : NULL; + } + } + } + return NULL; +} + +static void h3_drain_stream(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + unsigned char bits; + + (void)cf; + bits = CURL_CSELECT_IN; + if(stream && stream->upload_left && !stream->send_closed) + bits |= CURL_CSELECT_OUT; + if(data->state.select_bits != bits) { + data->state.select_bits = bits; + Curl_expire(data, 0, EXPIRE_RUN_NOW); + } +} + +static CURLcode h3_data_pause(struct Curl_cfilter *cf, + struct Curl_easy *data, + bool pause) +{ + if(!pause) { + /* unpaused. make it run again right away */ + h3_drain_stream(cf, data); + Curl_expire(data, 0, EXPIRE_RUN_NOW); + } + return CURLE_OK; +} + +static int cb_h3_stream_close(nghttp3_conn *conn, int64_t stream_id, + uint64_t app_error_code, void *user_data, + void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + (void)conn; + (void)stream_id; + + /* we might be called by nghttp3 after we already cleaned up */ + if(!stream) + return 0; + + stream->closed = TRUE; + stream->error3 = app_error_code; + if(stream->error3 != NGHTTP3_H3_NO_ERROR) { + stream->reset = TRUE; + stream->send_closed = TRUE; + CURL_TRC_CF(data, cf, "[%" PRId64 "] RESET: error %" PRId64, + stream->s.id, stream->error3); + } + else { + CURL_TRC_CF(data, cf, "[%" PRId64 "] CLOSED", stream->s.id); + } + h3_drain_stream(cf, data); + return 0; +} + +/* + * write_resp_raw() copies response data in raw format to the `data`'s + * receive buffer. If not enough space is available, it appends to the + * `data`'s overflow buffer. + */ +static CURLcode write_resp_raw(struct Curl_cfilter *cf, + struct Curl_easy *data, + const void *mem, size_t memlen, + bool flow) +{ + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + CURLcode result = CURLE_OK; + ssize_t nwritten; + + (void)cf; + if(!stream) { + return CURLE_RECV_ERROR; + } + nwritten = Curl_bufq_write(&stream->recvbuf, mem, memlen, &result); + if(nwritten < 0) { + return result; + } + + if(!flow) + stream->recv_buf_nonflow += (size_t)nwritten; + + if((size_t)nwritten < memlen) { + /* This MUST not happen. Our recbuf is dimensioned to hold the + * full max_stream_window and then some for this very reason. */ + DEBUGASSERT(0); + return CURLE_RECV_ERROR; + } + return result; +} + +static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream3_id, + const uint8_t *buf, size_t buflen, + void *user_data, void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + CURLcode result; + + (void)conn; + (void)stream3_id; + + if(!stream) + return NGHTTP3_ERR_CALLBACK_FAILURE; + + result = write_resp_raw(cf, data, buf, buflen, TRUE); + if(result) { + CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu, ERROR receiving %d", + stream->s.id, buflen, result); + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + stream->download_recvd += (curl_off_t)buflen; + CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu, total=%zd", + stream->s.id, buflen, stream->download_recvd); + h3_drain_stream(cf, data); + return 0; +} + +static int cb_h3_deferred_consume(nghttp3_conn *conn, int64_t stream_id, + size_t consumed, void *user_data, + void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + + (void)conn; + (void)stream_id; + if(stream) + CURL_TRC_CF(data, cf, "[%" PRId64 "] deferred consume %zu bytes", + stream->s.id, consumed); + return 0; +} + +static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id, + int32_t token, nghttp3_rcbuf *name, + nghttp3_rcbuf *value, uint8_t flags, + void *user_data, void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + nghttp3_vec h3name = nghttp3_rcbuf_get_buf(name); + nghttp3_vec h3val = nghttp3_rcbuf_get_buf(value); + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + CURLcode result = CURLE_OK; + (void)conn; + (void)stream_id; + (void)token; + (void)flags; + (void)cf; + + /* we might have cleaned up this transfer already */ + if(!stream) + return 0; + + if(token == NGHTTP3_QPACK_TOKEN__STATUS) { + char line[14]; /* status line is always 13 characters long */ + size_t ncopy; + + result = Curl_http_decode_status(&stream->status_code, + (const char *)h3val.base, h3val.len); + if(result) + return -1; + ncopy = msnprintf(line, sizeof(line), "HTTP/3 %03d \r\n", + stream->status_code); + CURL_TRC_CF(data, cf, "[%" PRId64 "] status: %s", stream_id, line); + result = write_resp_raw(cf, data, line, ncopy, FALSE); + if(result) { + return -1; + } + } + else { + /* store as an HTTP1-style header */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] header: %.*s: %.*s", + stream_id, (int)h3name.len, h3name.base, + (int)h3val.len, h3val.base); + result = write_resp_raw(cf, data, h3name.base, h3name.len, FALSE); + if(result) { + return -1; + } + result = write_resp_raw(cf, data, ": ", 2, FALSE); + if(result) { + return -1; + } + result = write_resp_raw(cf, data, h3val.base, h3val.len, FALSE); + if(result) { + return -1; + } + result = write_resp_raw(cf, data, "\r\n", 2, FALSE); + if(result) { + return -1; + } + } + return 0; +} + +static int cb_h3_end_headers(nghttp3_conn *conn, int64_t stream_id, + int fin, void *user_data, void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + CURLcode result = CURLE_OK; + (void)conn; + (void)stream_id; + (void)fin; + (void)cf; + + if(!stream) + return 0; + /* add a CRLF only if we've received some headers */ + result = write_resp_raw(cf, data, "\r\n", 2, FALSE); + if(result) { + return -1; + } + + CURL_TRC_CF(data, cf, "[%" PRId64 "] end_headers, status=%d", + stream_id, stream->status_code); + if(stream->status_code / 100 != 1) { + stream->resp_hds_complete = TRUE; + } + h3_drain_stream(cf, data); + return 0; +} + +static int cb_h3_stop_sending(nghttp3_conn *conn, int64_t stream_id, + uint64_t app_error_code, void *user_data, + void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + (void)conn; + (void)app_error_code; + + if(!stream || !stream->s.ssl) + return 0; + + CURL_TRC_CF(data, cf, "[%" PRId64 "] stop_sending", stream_id); + cf_osslq_stream_close(&stream->s); + return 0; +} + +static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t stream_id, + uint64_t app_error_code, void *user_data, + void *stream_user_data) { + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + int rv; + (void)conn; + + if(stream && stream->s.ssl) { + SSL_STREAM_RESET_ARGS args = {0}; + args.quic_error_code = app_error_code; + rv = !SSL_stream_reset(stream->s.ssl, &args, sizeof(args)); + CURL_TRC_CF(data, cf, "[%" PRId64 "] reset -> %d", stream_id, rv); + if(!rv) { + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + } + return 0; +} + +static nghttp3_ssize +cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, + nghttp3_vec *vec, size_t veccnt, + uint32_t *pflags, void *user_data, + void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + ssize_t nwritten = 0; + size_t nvecs = 0; + (void)cf; + (void)conn; + (void)stream_id; + (void)user_data; + (void)veccnt; + + if(!stream) + return NGHTTP3_ERR_CALLBACK_FAILURE; + /* nghttp3 keeps references to the sendbuf data until it is ACKed + * by the server (see `cb_h3_acked_req_body()` for updates). + * `sendbuf_len_in_flight` is the amount of bytes in `sendbuf` + * that we have already passed to nghttp3, but which have not been + * ACKed yet. + * Any amount beyond `sendbuf_len_in_flight` we need still to pass + * to nghttp3. Do that now, if we can. */ + if(stream->sendbuf_len_in_flight < Curl_bufq_len(&stream->sendbuf)) { + nvecs = 0; + while(nvecs < veccnt && + Curl_bufq_peek_at(&stream->sendbuf, + stream->sendbuf_len_in_flight, + (const unsigned char **)&vec[nvecs].base, + &vec[nvecs].len)) { + stream->sendbuf_len_in_flight += vec[nvecs].len; + nwritten += vec[nvecs].len; + ++nvecs; + } + DEBUGASSERT(nvecs > 0); /* we SHOULD have been be able to peek */ + } + + if(nwritten > 0 && stream->upload_left != -1) + stream->upload_left -= nwritten; + + /* When we stopped sending and everything in `sendbuf` is "in flight", + * we are at the end of the request body. */ + if(stream->upload_left == 0) { + *pflags = NGHTTP3_DATA_FLAG_EOF; + stream->send_closed = TRUE; + } + else if(!nwritten) { + /* Not EOF, and nothing to give, we signal WOULDBLOCK. */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> AGAIN", + stream->s.id); + return NGHTTP3_ERR_WOULDBLOCK; + } + + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> " + "%d vecs%s with %zu (buffered=%zu, left=%" + CURL_FORMAT_CURL_OFF_T ")", + stream->s.id, (int)nvecs, + *pflags == NGHTTP3_DATA_FLAG_EOF?" EOF":"", + nwritten, Curl_bufq_len(&stream->sendbuf), + stream->upload_left); + return (nghttp3_ssize)nvecs; +} + +static int cb_h3_acked_stream_data(nghttp3_conn *conn, int64_t stream_id, + uint64_t datalen, void *user_data, + void *stream_user_data) +{ + struct Curl_cfilter *cf = user_data; + struct Curl_easy *data = stream_user_data; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + size_t skiplen; + + (void)cf; + if(!stream) + return 0; + /* The server acknowledged `datalen` of bytes from our request body. + * This is a delta. We have kept this data in `sendbuf` for + * re-transmissions and can free it now. */ + if(datalen >= (uint64_t)stream->sendbuf_len_in_flight) + skiplen = stream->sendbuf_len_in_flight; + else + skiplen = (size_t)datalen; + Curl_bufq_skip(&stream->sendbuf, skiplen); + stream->sendbuf_len_in_flight -= skiplen; + + /* Everything ACKed, we resume upload processing */ + if(!stream->sendbuf_len_in_flight) { + int rv = nghttp3_conn_resume_stream(conn, stream_id); + if(rv && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { + return NGHTTP3_ERR_CALLBACK_FAILURE; + } + } + return 0; +} + +static nghttp3_callbacks ngh3_callbacks = { + cb_h3_acked_stream_data, + cb_h3_stream_close, + cb_h3_recv_data, + cb_h3_deferred_consume, + NULL, /* begin_headers */ + cb_h3_recv_header, + cb_h3_end_headers, + NULL, /* begin_trailers */ + cb_h3_recv_header, + NULL, /* end_trailers */ + cb_h3_stop_sending, + NULL, /* end_stream */ + cb_h3_reset_stream, + NULL, /* shutdown */ + NULL /* recv_settings */ +}; + +static CURLcode cf_osslq_h3conn_init(struct cf_osslq_ctx *ctx, SSL *conn, + void *user_data) +{ + struct cf_osslq_h3conn *h3 = &ctx->h3; + CURLcode result; + int rc; + + nghttp3_settings_default(&h3->settings); + rc = nghttp3_conn_client_new(&h3->conn, + &ngh3_callbacks, + &h3->settings, + nghttp3_mem_default(), + user_data); + if(rc) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + result = cf_osslq_stream_open(&h3->s_ctrl, conn, + SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + &ctx->stream_bufcp, NULL); + if(result) { + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + result = cf_osslq_stream_open(&h3->s_qpack_enc, conn, + SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + &ctx->stream_bufcp, NULL); + if(result) { + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + result = cf_osslq_stream_open(&h3->s_qpack_dec, conn, + SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + &ctx->stream_bufcp, NULL); + if(result) { + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + + rc = nghttp3_conn_bind_control_stream(h3->conn, h3->s_ctrl.id); + if(rc) { + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + rc = nghttp3_conn_bind_qpack_streams(h3->conn, h3->s_qpack_enc.id, + h3->s_qpack_dec.id); + if(rc) { + result = CURLE_QUIC_CONNECT_ERROR; + goto out; + } + + result = CURLE_OK; +out: + return result; +} + +static CURLcode cf_osslq_ctx_start(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result; + int rv; + const struct Curl_sockaddr_ex *peer_addr = NULL; + int peer_port; + BIO *bio = NULL; + BIO_ADDR *baddr = NULL; + + Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, + H3_STREAM_POOL_SPARES); + result = Curl_ssl_peer_init(&ctx->peer, cf); + if(result) + goto out; + +#define H3_ALPN "\x2h3" + result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, + H3_ALPN, sizeof(H3_ALPN) - 1, + NULL, NULL); + if(result) + goto out; + + result = vquic_ctx_init(&ctx->q); + if(result) + goto out; + + result = CURLE_QUIC_CONNECT_ERROR; + Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, + &peer_addr, NULL, &peer_port, NULL, NULL); + if(!peer_addr) + goto out; + + ctx->q.local_addrlen = sizeof(ctx->q.local_addr); + rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr, + &ctx->q.local_addrlen); + if(rv == -1) + goto out; + + result = make_bio_addr(&baddr, peer_addr); + if(result) { + failf(data, "error creating BIO_ADDR from sockaddr"); + goto out; + } + + bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE); + if(!bio) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + if(!SSL_set1_initial_peer_addr(ctx->tls.ssl, baddr)) { + failf(data, "failed to set the initial peer address"); + result = CURLE_FAILED_INIT; + goto out; + } + if(!SSL_set_blocking_mode(ctx->tls.ssl, 0)) { + failf(data, "failed to turn off blocking mode"); + result = CURLE_FAILED_INIT; + goto out; + } + + SSL_set_bio(ctx->tls.ssl, bio, bio); + bio = NULL; + SSL_set_connect_state(ctx->tls.ssl); + SSL_set_incoming_stream_policy(ctx->tls.ssl, + SSL_INCOMING_STREAM_POLICY_ACCEPT, 0); + /* setup the H3 things on top of the QUIC connection */ + result = cf_osslq_h3conn_init(ctx, ctx->tls.ssl, cf); + +out: + if(bio) + BIO_free(bio); + if(baddr) + BIO_ADDR_free(baddr); + CURL_TRC_CF(data, cf, "QUIC tls init -> %d", result); + return result; +} + +struct h3_quic_recv_ctx { + struct Curl_cfilter *cf; + struct Curl_easy *data; + struct cf_osslq_stream *s; +}; + +static ssize_t h3_quic_recv(void *reader_ctx, + unsigned char *buf, size_t len, + CURLcode *err) +{ + struct h3_quic_recv_ctx *x = reader_ctx; + size_t nread; + int rv; + + *err = CURLE_OK; + rv = SSL_read_ex(x->s->ssl, buf, len, &nread); + if(rv <= 0) { + int detail = SSL_get_error(x->s->ssl, rv); + if(detail == SSL_ERROR_WANT_READ || detail == SSL_ERROR_WANT_WRITE) { + *err = CURLE_AGAIN; + return -1; + } + else if(detail == SSL_ERROR_ZERO_RETURN) { + CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> EOS", + x->s->id); + x->s->recvd_eos = TRUE; + return 0; + } + else if(SSL_get_stream_read_state(x->s->ssl) == + SSL_STREAM_STATE_RESET_REMOTE) { + uint64_t app_error_code = NGHTTP3_H3_NO_ERROR; + SSL_get_stream_read_error_code(x->s->ssl, &app_error_code); + CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> RESET, " + "rv=%d, app_err=%" PRIu64, + x->s->id, rv, app_error_code); + if(app_error_code != NGHTTP3_H3_NO_ERROR) { + x->s->reset = TRUE; + } + x->s->recvd_eos = TRUE; + return 0; + } + else { + *err = cf_osslq_ssl_err(x->cf, x->data, detail, CURLE_RECV_ERROR); + return -1; + } + } + else { + /* CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> %zu bytes", + x->s->id, nread); */ + } + return (ssize_t)nread; +} + +static CURLcode cf_osslq_stream_recv(struct cf_osslq_stream *s, + struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + ssize_t nread; + struct h3_quic_recv_ctx x; + int rv, eagain = FALSE; + size_t total_recv_len = 0; + + DEBUGASSERT(s); + if(s->closed) + return CURLE_OK; + + x.cf = cf; + x.data = data; + x.s = s; + while(s->ssl && !s->closed && !eagain && + (total_recv_len < H3_STREAM_CHUNK_SIZE)) { + if(Curl_bufq_is_empty(&s->recvbuf) && !s->recvd_eos) { + while(!eagain && !s->recvd_eos && !Curl_bufq_is_full(&s->recvbuf)) { + nread = Curl_bufq_sipn(&s->recvbuf, 0, h3_quic_recv, &x, &result); + if(nread < 0) { + if(result != CURLE_AGAIN) + goto out; + result = CURLE_OK; + eagain = TRUE; + } + } + } + + /* Forward what we have to nghttp3 */ + if(!Curl_bufq_is_empty(&s->recvbuf)) { + const unsigned char *buf; + size_t blen; + + while(Curl_bufq_peek(&s->recvbuf, &buf, &blen)) { + nread = nghttp3_conn_read_stream(ctx->h3.conn, s->id, + buf, blen, 0); + CURL_TRC_CF(data, cf, "[%" PRId64 "] forward %zu bytes " + "to nghttp3 -> %zd", s->id, blen, nread); + if(nread < 0) { + failf(data, "nghttp3_conn_read_stream(len=%zu) error: %s", + blen, nghttp3_strerror((int)nread)); + result = CURLE_RECV_ERROR; + goto out; + } + /* success, `nread` is the flow for QUIC to count as "consumed", + * not sure how that will work with OpenSSL. Anyways, without error, + * all data that we passed is not owned by nghttp3. */ + Curl_bufq_skip(&s->recvbuf, blen); + total_recv_len += blen; + } + } + + /* When we forwarded everything, handle RESET/EOS */ + if(Curl_bufq_is_empty(&s->recvbuf) && !s->closed) { + result = CURLE_OK; + if(s->reset) { + uint64_t app_error; + if(!SSL_get_stream_read_error_code(s->ssl, &app_error)) { + failf(data, "SSL_get_stream_read_error_code returned error"); + result = CURLE_RECV_ERROR; + goto out; + } + rv = nghttp3_conn_close_stream(ctx->h3.conn, s->id, app_error); + s->closed = TRUE; + if(rv < 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { + failf(data, "nghttp3_conn_close_stream returned error: %s", + nghttp3_strerror(rv)); + result = CURLE_RECV_ERROR; + goto out; + } + } + else if(s->recvd_eos) { + rv = nghttp3_conn_close_stream(ctx->h3.conn, s->id, + NGHTTP3_H3_NO_ERROR); + s->closed = TRUE; + CURL_TRC_CF(data, cf, "[%" PRId64 "] close nghttp3 stream -> %d", + s->id, rv); + if(rv < 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { + failf(data, "nghttp3_conn_close_stream returned error: %s", + nghttp3_strerror(rv)); + result = CURLE_RECV_ERROR; + goto out; + } + } + } + } +out: + if(result) + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_osslq_stream_recv -> %d", + s->id, result); + return result; +} + +static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + + if(!ctx->tls.ssl) + goto out; + + ERR_clear_error(); + + /* 1. Check for new incoming streams */ + while(1) { + SSL *snew = SSL_accept_stream(ctx->tls.ssl, SSL_ACCEPT_STREAM_NO_BLOCK); + if(!snew) + break; + + (void)cf_osslq_h3conn_add_stream(&ctx->h3, snew, cf, data); + } + + if(!SSL_handle_events(ctx->tls.ssl)) { + int detail = SSL_get_error(ctx->tls.ssl, 0); + result = cf_osslq_ssl_err(cf, data, detail, CURLE_RECV_ERROR); + } + + if(ctx->h3.conn) { + size_t i; + for(i = 0; i < ctx->h3.remote_ctrl_n; ++i) { + result = cf_osslq_stream_recv(&ctx->h3.remote_ctrl[i], cf, data); + if(result) + goto out; + } + } + + if(ctx->h3.conn) { + struct Curl_easy *sdata; + struct h3_stream_ctx *stream; + /* PULL all open streams */ + DEBUGASSERT(data->multi); + for(sdata = data->multi->easyp; sdata; sdata = sdata->next) { + if(sdata->conn == data->conn && CURL_WANT_RECV(sdata)) { + stream = H3_STREAM_CTX(sdata); + if(stream && !stream->closed && + !Curl_bufq_is_full(&stream->recvbuf)) { + result = cf_osslq_stream_recv(&stream->s, cf, sdata); + if(result) + goto out; + } + } + } + } + +out: + CURL_TRC_CF(data, cf, "progress_ingress -> %d", result); + return result; +} + +/* Iterate over all streams and check if blocked can be unblocked */ +static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct Curl_easy *sdata; + struct h3_stream_ctx *stream; + + if(ctx->h3.conn) { + for(sdata = data->multi->easyp; sdata; sdata = sdata->next) { + if(sdata->conn == data->conn) { + stream = H3_STREAM_CTX(sdata); + if(stream && stream->s.ssl && stream->s.send_blocked && + !SSL_want_write(stream->s.ssl)) { + nghttp3_conn_unblock_stream(ctx->h3.conn, stream->s.id); + stream->s.send_blocked = FALSE; + h3_drain_stream(cf, sdata); + CURL_TRC_CF(sdata, cf, "unblocked"); + } + } + } + } + return CURLE_OK; +} + +static CURLcode h3_send_streams(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + + if(!ctx->tls.ssl || !ctx->h3.conn) + goto out; + + for(;;) { + struct cf_osslq_stream *s = NULL; + nghttp3_vec vec[16]; + nghttp3_ssize n, i; + int64_t stream_id; + size_t written; + int eos, ok, rv; + size_t total_len, acked_len = 0; + bool blocked = FALSE; + + n = nghttp3_conn_writev_stream(ctx->h3.conn, &stream_id, &eos, + vec, ARRAYSIZE(vec)); + if(n < 0) { + failf(data, "nghttp3_conn_writev_stream returned error: %s", + nghttp3_strerror((int)n)); + result = CURLE_SEND_ERROR; + goto out; + } + if(stream_id < 0) { + result = CURLE_OK; + goto out; + } + + /* Get the stream for this data */ + s = cf_osslq_get_qstream(cf, data, stream_id); + if(!s) { + failf(data, "nghttp3_conn_writev_stream gave unknown stream %" PRId64, + stream_id); + result = CURLE_SEND_ERROR; + goto out; + } + /* Now write the data to the stream's SSL*, it may not all fit! */ + DEBUGASSERT(s->id == stream_id); + for(i = 0, total_len = 0; i < n; ++i) { + total_len += vec[i].len; + } + for(i = 0; (i < n) && !blocked; ++i) { + /* Without stream->s.ssl, we closed that already, so + * pretend the write did succeed. */ + written = vec[i].len; + ok = !s->ssl || SSL_write_ex(s->ssl, vec[i].base, vec[i].len, + &written); + if(ok) { + /* As OpenSSL buffers the data, we count this as acknowledged + * from nghttp3's point of view */ + CURL_TRC_CF(data, cf, "[%"PRId64"] send %zu bytes to QUIC ok", + s->id, vec[i].len); + acked_len += vec[i].len; + } + else { + int detail = SSL_get_error(s->ssl, 0); + switch(detail) { + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + /* QUIC blocked us from writing more */ + CURL_TRC_CF(data, cf, "[%"PRId64"] send %zu bytes to QUIC blocked", + s->id, vec[i].len); + written = 0; + nghttp3_conn_block_stream(ctx->h3.conn, s->id); + s->send_blocked = blocked = TRUE; + break; + default: + failf(data, "[%"PRId64"] send %zu bytes to QUIC, SSL error %d", + s->id, vec[i].len, detail); + result = cf_osslq_ssl_err(cf, data, detail, CURLE_SEND_ERROR); + goto out; + } + } + } + + if(acked_len > 0 || (eos && !s->send_blocked)) { + /* Since QUIC buffers the data written internally, we can tell + * nghttp3 that it can move forward on it */ + rv = nghttp3_conn_add_write_offset(ctx->h3.conn, s->id, acked_len); + if(rv && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { + failf(data, "nghttp3_conn_add_write_offset returned error: %s\n", + nghttp3_strerror(rv)); + result = CURLE_SEND_ERROR; + goto out; + } + rv = nghttp3_conn_add_ack_offset(ctx->h3.conn, s->id, acked_len); + if(rv && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { + failf(data, "nghttp3_conn_add_ack_offset returned error: %s\n", + nghttp3_strerror(rv)); + result = CURLE_SEND_ERROR; + goto out; + } + CURL_TRC_CF(data, cf, "[%" PRId64 "] forwarded %zu/%zu h3 bytes " + "to QUIC, eos=%d", s->id, acked_len, total_len, eos); + } + + if(eos && !s->send_blocked) { + /* wrote everything and H3 indicates end of stream */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] closing QUIC stream", s->id); + SSL_stream_conclude(s->ssl, 0); + } + } + +out: + CURL_TRC_CF(data, cf, "h3_send_streams -> %d", result); + return result; +} + +static CURLcode cf_progress_egress(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + + if(!ctx->tls.ssl) + goto out; + + ERR_clear_error(); + result = h3_send_streams(cf, data); + if(result) + goto out; + + if(!SSL_handle_events(ctx->tls.ssl)) { + int detail = SSL_get_error(ctx->tls.ssl, 0); + result = cf_osslq_ssl_err(cf, data, detail, CURLE_SEND_ERROR); + } + + result = cf_osslq_check_and_unblock(cf, data); + +out: + CURL_TRC_CF(data, cf, "progress_egress -> %d", result); + return result; +} + +static CURLcode check_and_set_expiry(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + struct timeval tv; + timediff_t timeoutms; + int is_infinite = TRUE; + + if(ctx->tls.ssl && + SSL_get_event_timeout(ctx->tls.ssl, &tv, &is_infinite) && + !is_infinite) { + timeoutms = curlx_tvtoms(&tv); + /* QUIC want to be called again latest at the returned timeout */ + if(timeoutms <= 0) { + result = cf_progress_ingress(cf, data); + if(result) + goto out; + result = cf_progress_egress(cf, data); + if(result) + goto out; + if(SSL_get_event_timeout(ctx->tls.ssl, &tv, &is_infinite)) { + timeoutms = curlx_tvtoms(&tv); + } + } + if(!is_infinite) { + Curl_expire(data, timeoutms, EXPIRE_QUIC); + CURL_TRC_CF(data, cf, "QUIC expiry in %ldms", (long)timeoutms); + } + } +out: + return result; +} + +static CURLcode cf_osslq_connect(struct Curl_cfilter *cf, + struct Curl_easy *data, + bool blocking, bool *done) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + struct cf_call_data save; + struct curltime now; + int err; + + if(cf->connected) { + *done = TRUE; + return CURLE_OK; + } + + /* Connect the UDP filter first */ + if(!cf->next->connected) { + result = Curl_conn_cf_connect(cf->next, data, blocking, done); + if(result || !*done) + return result; + } + + *done = FALSE; + now = Curl_now(); + CF_DATA_SAVE(save, cf, data); + + if(ctx->reconnect_at.tv_sec && Curl_timediff(now, ctx->reconnect_at) < 0) { + /* Not time yet to attempt the next connect */ + CURL_TRC_CF(data, cf, "waiting for reconnect time"); + goto out; + } + + if(!ctx->tls.ssl) { + ctx->started_at = now; + result = cf_osslq_ctx_start(cf, data); + if(result) + goto out; + } + + if(!ctx->got_first_byte) { + int readable = SOCKET_READABLE(ctx->q.sockfd, 0); + if(readable > 0 && (readable & CURL_CSELECT_IN)) { + ctx->got_first_byte = TRUE; + ctx->first_byte_at = Curl_now(); + } + } + + ERR_clear_error(); + err = SSL_do_handshake(ctx->tls.ssl); + + if(err == 1) { + /* connected */ + ctx->handshake_at = now; + CURL_TRC_CF(data, cf, "handshake complete after %dms", + (int)Curl_timediff(now, ctx->started_at)); + result = cf_osslq_verify_peer(cf, data); + if(!result) { + CURL_TRC_CF(data, cf, "peer verified"); + cf->connected = TRUE; + cf->conn->alpn = CURL_HTTP_VERSION_3; + *done = TRUE; + connkeep(cf->conn, "HTTP/3 default"); + } + } + else { + int detail = SSL_get_error(ctx->tls.ssl, err); + switch(detail) { + case SSL_ERROR_WANT_READ: + CURL_TRC_CF(data, cf, "QUIC SSL_connect() -> WANT_RECV"); + result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); + goto out; + case SSL_ERROR_WANT_WRITE: + CURL_TRC_CF(data, cf, "QUIC SSL_connect() -> WANT_SEND"); + result = CURLE_OK; + goto out; +#ifdef SSL_ERROR_WANT_ASYNC + case SSL_ERROR_WANT_ASYNC: + CURL_TRC_CF(data, cf, "QUIC SSL_connect() -> WANT_ASYNC"); + result = CURLE_OK; + goto out; +#endif +#ifdef SSL_ERROR_WANT_RETRY_VERIFY + case SSL_ERROR_WANT_RETRY_VERIFY: + result = CURLE_OK; + goto out; +#endif + default: + result = cf_osslq_ssl_err(cf, data, detail, CURLE_COULDNT_CONNECT); + goto out; + } + } + +out: + if(result == CURLE_RECV_ERROR && ctx->tls.ssl && ctx->protocol_shutdown) { + /* When a QUIC server instance is shutting down, it may send us a + * CONNECTION_CLOSE right away. Our connection then enters the DRAINING + * state. The CONNECT may work in the near future again. Indicate + * that as a "weird" reply. */ + result = CURLE_WEIRD_SERVER_REPLY; + } + +#ifndef CURL_DISABLE_VERBOSE_STRINGS + if(result) { + const char *r_ip = NULL; + int r_port = 0; + + Curl_cf_socket_peek(cf->next, data, NULL, NULL, + &r_ip, &r_port, NULL, NULL); + infof(data, "QUIC connect to %s port %u failed: %s", + r_ip, r_port, curl_easy_strerror(result)); + } +#endif + if(!result) + result = check_and_set_expiry(cf, data); + if(result || *done) + CURL_TRC_CF(data, cf, "connect -> %d, done=%d", result, *done); + CF_DATA_RESTORE(cf, save); + return result; +} + +static ssize_t h3_stream_open(struct Curl_cfilter *cf, + struct Curl_easy *data, + const void *buf, size_t len, + CURLcode *err) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = NULL; + struct dynhds h2_headers; + size_t nheader; + nghttp3_nv *nva = NULL; + int rc = 0; + unsigned int i; + ssize_t nwritten = -1; + nghttp3_data_reader reader; + nghttp3_data_reader *preader = NULL; + + Curl_dynhds_init(&h2_headers, 0, DYN_HTTP_REQUEST); + + *err = h3_data_setup(cf, data); + if(*err) + goto out; + stream = H3_STREAM_CTX(data); + DEBUGASSERT(stream); + if(!stream) { + *err = CURLE_FAILED_INIT; + goto out; + } + + nwritten = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, 0, err); + if(nwritten < 0) + goto out; + if(!stream->h1.done) { + /* need more data */ + goto out; + } + DEBUGASSERT(stream->h1.req); + + *err = Curl_http_req_to_h2(&h2_headers, stream->h1.req, data); + if(*err) { + nwritten = -1; + goto out; + } + /* no longer needed */ + Curl_h1_req_parse_free(&stream->h1); + + nheader = Curl_dynhds_count(&h2_headers); + nva = malloc(sizeof(nghttp3_nv) * nheader); + if(!nva) { + *err = CURLE_OUT_OF_MEMORY; + nwritten = -1; + goto out; + } + + for(i = 0; i < nheader; ++i) { + struct dynhds_entry *e = Curl_dynhds_getn(&h2_headers, i); + nva[i].name = (unsigned char *)e->name; + nva[i].namelen = e->namelen; + nva[i].value = (unsigned char *)e->value; + nva[i].valuelen = e->valuelen; + nva[i].flags = NGHTTP3_NV_FLAG_NONE; + } + + DEBUGASSERT(stream->s.id == -1); + *err = cf_osslq_stream_open(&stream->s, ctx->tls.ssl, 0, + &ctx->stream_bufcp, data); + if(*err) { + failf(data, "can't get bidi streams"); + *err = CURLE_SEND_ERROR; + goto out; + } + + switch(data->state.httpreq) { + case HTTPREQ_POST: + case HTTPREQ_POST_FORM: + case HTTPREQ_POST_MIME: + case HTTPREQ_PUT: + /* known request body size or -1 */ + if(data->state.infilesize != -1) + stream->upload_left = data->state.infilesize; + else + /* data sending without specifying the data amount up front */ + stream->upload_left = -1; /* unknown */ + break; + default: + /* there is not request body */ + stream->upload_left = 0; /* no request body */ + break; + } + + stream->send_closed = (stream->upload_left == 0); + if(!stream->send_closed) { + reader.read_data = cb_h3_read_req_body; + preader = &reader; + } + + rc = nghttp3_conn_submit_request(ctx->h3.conn, stream->s.id, + nva, nheader, preader, data); + if(rc) { + switch(rc) { + case NGHTTP3_ERR_CONN_CLOSING: + CURL_TRC_CF(data, cf, "h3sid[%"PRId64"] failed to send, " + "connection is closing", stream->s.id); + break; + default: + CURL_TRC_CF(data, cf, "h3sid[%"PRId64"] failed to send -> %d (%s)", + stream->s.id, rc, nghttp3_strerror(rc)); + break; + } + *err = CURLE_SEND_ERROR; + nwritten = -1; + goto out; + } + + if(Curl_trc_is_verbose(data)) { + infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s", + stream->s.id, data->state.url); + for(i = 0; i < nheader; ++i) { + infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->s.id, + (int)nva[i].namelen, nva[i].name, + (int)nva[i].valuelen, nva[i].value); + } + } + +out: + free(nva); + Curl_dynhds_free(&h2_headers); + return nwritten; +} + +static ssize_t cf_osslq_send(struct Curl_cfilter *cf, struct Curl_easy *data, + const void *buf, size_t len, CURLcode *err) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + struct cf_call_data save; + ssize_t nwritten; + CURLcode result; + + CF_DATA_SAVE(save, cf, data); + DEBUGASSERT(cf->connected); + DEBUGASSERT(ctx->tls.ssl); + DEBUGASSERT(ctx->h3.conn); + *err = CURLE_OK; + + result = cf_progress_ingress(cf, data); + if(result) { + *err = result; + nwritten = -1; + goto out; + } + + result = cf_progress_egress(cf, data); + if(result) { + *err = result; + nwritten = -1; + goto out; + } + + if(!stream || stream->s.id < 0) { + nwritten = h3_stream_open(cf, data, buf, len, err); + if(nwritten < 0) { + CURL_TRC_CF(data, cf, "failed to open stream -> %d", *err); + goto out; + } + stream = H3_STREAM_CTX(data); + } + else if(stream->upload_blocked_len) { + /* the data in `buf` has already been submitted or added to the + * buffers, but have been EAGAINed on the last invocation. */ + DEBUGASSERT(len >= stream->upload_blocked_len); + if(len < stream->upload_blocked_len) { + /* Did we get called again with a smaller `len`? This should not + * happen. We are not prepared to handle that. */ + failf(data, "HTTP/3 send again with decreased length"); + *err = CURLE_HTTP3; + nwritten = -1; + goto out; + } + nwritten = (ssize_t)stream->upload_blocked_len; + stream->upload_blocked_len = 0; + } + else if(stream->closed) { + if(stream->resp_hds_complete) { + /* Server decided to close the stream after having sent us a final + * response. This is valid if it is not interested in the request + * body. This happens on 30x or 40x responses. + * We silently discard the data sent, since this is not a transport + * error situation. */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] discarding data" + "on closed stream with response", stream->s.id); + *err = CURLE_OK; + nwritten = (ssize_t)len; + goto out; + } + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " + "-> stream closed", stream->s.id, len); + *err = CURLE_HTTP3; + nwritten = -1; + goto out; + } + else { + nwritten = Curl_bufq_write(&stream->sendbuf, buf, len, err); + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send, add to " + "sendbuf(len=%zu) -> %zd, %d", + stream->s.id, len, nwritten, *err); + if(nwritten < 0) { + goto out; + } + + (void)nghttp3_conn_resume_stream(ctx->h3.conn, stream->s.id); + } + + result = cf_progress_egress(cf, data); + if(result) { + *err = result; + nwritten = -1; + } + + if(stream && nwritten > 0 && stream->sendbuf_len_in_flight) { + /* We have unacknowledged DATA and cannot report success to our + * caller. Instead we EAGAIN and remember how much we have already + * "written" into our various internal connection buffers. */ + stream->upload_blocked_len = nwritten; + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu), " + "%zu bytes in flight -> EGAIN", stream->s.id, len, + stream->sendbuf_len_in_flight); + *err = CURLE_AGAIN; + nwritten = -1; + } + +out: + result = check_and_set_expiry(cf, data); + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu) -> %zd, %d", + stream? stream->s.id : -1, len, nwritten, *err); + CF_DATA_RESTORE(cf, save); + return nwritten; +} + +static ssize_t recv_closed_stream(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h3_stream_ctx *stream, + CURLcode *err) +{ + ssize_t nread = -1; + + (void)cf; + if(stream->reset) { + failf(data, + "HTTP/3 stream %" PRId64 " reset by server", stream->s.id); + *err = stream->resp_hds_complete? CURLE_PARTIAL_FILE : CURLE_HTTP3; + goto out; + } + else if(!stream->resp_hds_complete) { + failf(data, + "HTTP/3 stream %" PRId64 " was closed cleanly, but before getting" + " all response header fields, treated as error", + stream->s.id); + *err = CURLE_HTTP3; + goto out; + } + *err = CURLE_OK; + nread = 0; + +out: + return nread; +} + +static ssize_t cf_osslq_recv(struct Curl_cfilter *cf, struct Curl_easy *data, + char *buf, size_t len, CURLcode *err) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + ssize_t nread = -1; + struct cf_call_data save; + CURLcode result; + + (void)ctx; + CF_DATA_SAVE(save, cf, data); + DEBUGASSERT(cf->connected); + DEBUGASSERT(ctx); + DEBUGASSERT(ctx->tls.ssl); + DEBUGASSERT(ctx->h3.conn); + *err = CURLE_OK; + + if(!stream) { + *err = CURLE_RECV_ERROR; + goto out; + } + + if(!Curl_bufq_is_empty(&stream->recvbuf)) { + nread = Curl_bufq_read(&stream->recvbuf, + (unsigned char *)buf, len, err); + if(nread < 0) { + CURL_TRC_CF(data, cf, "[%" PRId64 "] read recvbuf(len=%zu) " + "-> %zd, %d", stream->s.id, len, nread, *err); + goto out; + } + } + + result = cf_progress_ingress(cf, data); + if(result) { + *err = result; + nread = -1; + goto out; + } + + /* recvbuf had nothing before, maybe after progressing ingress? */ + if(nread < 0 && !Curl_bufq_is_empty(&stream->recvbuf)) { + nread = Curl_bufq_read(&stream->recvbuf, + (unsigned char *)buf, len, err); + if(nread < 0) { + CURL_TRC_CF(data, cf, "[%" PRId64 "] read recvbuf(len=%zu) " + "-> %zd, %d", stream->s.id, len, nread, *err); + goto out; + } + } + + if(nread > 0) { + h3_drain_stream(cf, data); + } + else { + if(stream->closed) { + nread = recv_closed_stream(cf, data, stream, err); + goto out; + } + *err = CURLE_AGAIN; + nread = -1; + } + +out: + if(cf_progress_egress(cf, data)) { + *err = CURLE_SEND_ERROR; + nread = -1; + } + else { + CURLcode result2 = check_and_set_expiry(cf, data); + if(result2) { + *err = result2; + nread = -1; + } + } + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv(len=%zu) -> %zd, %d", + stream? stream->s.id : -1, len, nread, *err); + CF_DATA_RESTORE(cf, save); + return nread; +} + +/* + * Called from transfer.c:data_pending to know if we should keep looping + * to receive more data from the connection. + */ +static bool cf_osslq_data_pending(struct Curl_cfilter *cf, + const struct Curl_easy *data) +{ + const struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + (void)cf; + return stream && !Curl_bufq_is_empty(&stream->recvbuf); +} + +static CURLcode cf_osslq_data_event(struct Curl_cfilter *cf, + struct Curl_easy *data, + int event, int arg1, void *arg2) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + CURLcode result = CURLE_OK; + struct cf_call_data save; + + CF_DATA_SAVE(save, cf, data); + (void)arg1; + (void)arg2; + switch(event) { + case CF_CTRL_DATA_SETUP: + break; + case CF_CTRL_DATA_PAUSE: + result = h3_data_pause(cf, data, (arg1 != 0)); + break; + case CF_CTRL_DATA_DETACH: + h3_data_done(cf, data); + break; + case CF_CTRL_DATA_DONE: + h3_data_done(cf, data); + break; + case CF_CTRL_DATA_DONE_SEND: { + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + if(stream && !stream->send_closed) { + stream->send_closed = TRUE; + stream->upload_left = Curl_bufq_len(&stream->sendbuf); + (void)nghttp3_conn_resume_stream(ctx->h3.conn, stream->s.id); + } + break; + } + case CF_CTRL_DATA_IDLE: { + struct h3_stream_ctx *stream = H3_STREAM_CTX(data); + CURL_TRC_CF(data, cf, "data idle"); + if(stream && !stream->closed) { + result = check_and_set_expiry(cf, data); + } + break; + } + default: + break; + } + CF_DATA_RESTORE(cf, save); + return result; +} + +static bool cf_osslq_conn_is_alive(struct Curl_cfilter *cf, + struct Curl_easy *data, + bool *input_pending) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + bool alive = FALSE; + struct cf_call_data save; + + CF_DATA_SAVE(save, cf, data); + *input_pending = FALSE; + if(!ctx->tls.ssl) + goto out; + + /* TODO: how to check negotiated connection idle time? */ + + if(!cf->next || !cf->next->cft->is_alive(cf->next, data, input_pending)) + goto out; + + alive = TRUE; + if(*input_pending) { + CURLcode result; + /* This happens before we've sent off a request and the connection is + not in use by any other transfer, there shouldn't be any data here, + only "protocol frames" */ + *input_pending = FALSE; + result = cf_progress_ingress(cf, data); + CURL_TRC_CF(data, cf, "is_alive, progress ingress -> %d", result); + alive = result? FALSE : TRUE; + } + +out: + CF_DATA_RESTORE(cf, save); + return alive; +} + +static void cf_osslq_adjust_pollset(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct easy_pollset *ps) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + + if(!ctx->tls.ssl) { + /* NOP */ + } + else if(!cf->connected) { + /* during handshake, transfer has not started yet. we always + * add our socket for polling if SSL wants to send/recv */ + Curl_pollset_set(data, ps, ctx->q.sockfd, + SSL_net_read_desired(ctx->tls.ssl), + SSL_net_write_desired(ctx->tls.ssl)); + } + else { + /* once connected, we only modify the socket if it is present. + * this avoids adding it for paused transfers. */ + bool want_recv, want_send; + Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); + if(want_recv || want_send) { + Curl_pollset_set(data, ps, ctx->q.sockfd, + SSL_net_read_desired(ctx->tls.ssl), + SSL_net_write_desired(ctx->tls.ssl)); + } + } +} + +static CURLcode cf_osslq_query(struct Curl_cfilter *cf, + struct Curl_easy *data, + int query, int *pres1, void *pres2) +{ + struct cf_osslq_ctx *ctx = cf->ctx; + struct cf_call_data save; + + switch(query) { + case CF_QUERY_MAX_CONCURRENT: { + /* TODO: how to get this? */ + CF_DATA_SAVE(save, cf, data); + *pres1 = 100; + CURL_TRC_CF(data, cf, "query max_conncurrent -> %d", *pres1); + CF_DATA_RESTORE(cf, save); + return CURLE_OK; + } + case CF_QUERY_CONNECT_REPLY_MS: + if(ctx->got_first_byte) { + timediff_t ms = Curl_timediff(ctx->first_byte_at, ctx->started_at); + *pres1 = (ms < INT_MAX)? (int)ms : INT_MAX; + } + else + *pres1 = -1; + return CURLE_OK; + case CF_QUERY_TIMER_CONNECT: { + struct curltime *when = pres2; + if(ctx->got_first_byte) + *when = ctx->first_byte_at; + return CURLE_OK; + } + case CF_QUERY_TIMER_APPCONNECT: { + struct curltime *when = pres2; + if(cf->connected) + *when = ctx->handshake_at; + return CURLE_OK; + } + default: + break; + } + return cf->next? + cf->next->cft->query(cf->next, data, query, pres1, pres2) : + CURLE_UNKNOWN_OPTION; +} + +struct Curl_cftype Curl_cft_http3 = { + "HTTP/3", + CF_TYPE_IP_CONNECT | CF_TYPE_SSL | CF_TYPE_MULTIPLEX, + 0, + cf_osslq_destroy, + cf_osslq_connect, + cf_osslq_close, + Curl_cf_def_get_host, + cf_osslq_adjust_pollset, + cf_osslq_data_pending, + cf_osslq_send, + cf_osslq_recv, + cf_osslq_data_event, + cf_osslq_conn_is_alive, + Curl_cf_def_conn_keep_alive, + cf_osslq_query, +}; + +CURLcode Curl_cf_osslq_create(struct Curl_cfilter **pcf, + struct Curl_easy *data, + struct connectdata *conn, + const struct Curl_addrinfo *ai) +{ + struct cf_osslq_ctx *ctx = NULL; + struct Curl_cfilter *cf = NULL, *udp_cf = NULL; + CURLcode result; + + (void)data; + ctx = calloc(1, sizeof(*ctx)); + if(!ctx) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + cf_osslq_ctx_clear(ctx); + + result = Curl_cf_create(&cf, &Curl_cft_http3, ctx); + if(result) + goto out; + + result = Curl_cf_udp_create(&udp_cf, data, conn, ai, TRNSPRT_QUIC); + if(result) + goto out; + + cf->conn = conn; + udp_cf->conn = cf->conn; + udp_cf->sockindex = cf->sockindex; + cf->next = udp_cf; + +out: + *pcf = (!result)? cf : NULL; + if(result) { + if(udp_cf) + Curl_conn_cf_discard_sub(cf, udp_cf, data, TRUE); + Curl_safefree(cf); + Curl_safefree(ctx); + } + return result; +} + +bool Curl_conn_is_osslq(const struct Curl_easy *data, + const struct connectdata *conn, + int sockindex) +{ + struct Curl_cfilter *cf = conn? conn->cfilter[sockindex] : NULL; + + (void)data; + for(; cf; cf = cf->next) { + if(cf->cft == &Curl_cft_http3) + return TRUE; + if(cf->cft->flags & CF_TYPE_IP_CONNECT) + return FALSE; + } + return FALSE; +} + +/* + * Store ngtcp2 version info in this buffer. + */ +void Curl_osslq_ver(char *p, size_t len) +{ + const nghttp3_info *ht3 = nghttp3_version(0); + (void)msnprintf(p, len, "nghttp3/%s", ht3->version_str); +} + +#endif /* USE_OPENSSL_QUIC && USE_NGHTTP3 */ diff --git a/lib/vquic/curl_osslq.h b/lib/vquic/curl_osslq.h new file mode 100644 index 000000000..0e12d7023 --- /dev/null +++ b/lib/vquic/curl_osslq.h @@ -0,0 +1,51 @@ +#ifndef HEADER_CURL_VQUIC_CURL_OSSLQ_H +#define HEADER_CURL_VQUIC_CURL_OSSLQ_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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 + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3) + +#ifdef HAVE_NETINET_UDP_H +#include +#endif + +struct Curl_cfilter; + +#include "urldata.h" + +void Curl_osslq_ver(char *p, size_t len); + +CURLcode Curl_cf_osslq_create(struct Curl_cfilter **pcf, + struct Curl_easy *data, + struct connectdata *conn, + const struct Curl_addrinfo *ai); + +bool Curl_conn_is_osslq(const struct Curl_easy *data, + const struct connectdata *conn, + int sockindex); +#endif + +#endif /* HEADER_CURL_VQUIC_CURL_OSSLQ_H */ diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 7123d63ca..fcb0eb8f8 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -43,6 +43,7 @@ #include "http1.h" #include "vquic.h" #include "vquic_int.h" +#include "vquic-tls.h" #include "curl_quiche.h" #include "transfer.h" #include "inet_pton.h" @@ -84,31 +85,22 @@ void Curl_quiche_ver(char *p, size_t len) (void)msnprintf(p, len, "quiche/%s", quiche_version()); } -static void keylog_callback(const SSL *ssl, const char *line) -{ - (void)ssl; - Curl_tls_keylog_write_line(line); -} - struct cf_quiche_ctx { struct cf_quic_ctx q; struct ssl_peer peer; + struct quic_tls_ctx tls; quiche_conn *qconn; quiche_config *cfg; quiche_h3_conn *h3c; quiche_h3_config *h3config; uint8_t scid[QUICHE_MAX_CONN_ID_LEN]; - SSL_CTX *sslctx; - SSL *ssl; struct curltime started_at; /* time the current attempt started */ struct curltime handshake_at; /* time connect handshake finished */ - struct curltime first_byte_at; /* when first byte was recvd */ struct curltime reconnect_at; /* time the next attempt should start */ struct bufc_pool stream_bufcp; /* chunk pool for streams */ curl_off_t data_recvd; uint64_t max_idle_ms; /* max idle time for QUIC conn */ BIT(goaway); /* got GOAWAY from server */ - BIT(got_first_byte); /* if first byte was received */ BIT(x509_store_setup); /* if x509 store has been set up */ }; @@ -123,121 +115,25 @@ static void quiche_debug_log(const char *line, void *argp) static void cf_quiche_ctx_clear(struct cf_quiche_ctx *ctx) { if(ctx) { - vquic_ctx_free(&ctx->q); - if(ctx->qconn) - quiche_conn_free(ctx->qconn); - if(ctx->h3config) - quiche_h3_config_free(ctx->h3config); if(ctx->h3c) quiche_h3_conn_free(ctx->h3c); + if(ctx->h3config) + quiche_h3_config_free(ctx->h3config); + if(ctx->qconn) + quiche_conn_free(ctx->qconn); if(ctx->cfg) quiche_config_free(ctx->cfg); - Curl_bufcp_free(&ctx->stream_bufcp); + /* quiche just freed ctx->tls.ssl */ + ctx->tls.ssl = NULL; + Curl_vquic_tls_cleanup(&ctx->tls); Curl_ssl_peer_cleanup(&ctx->peer); + vquic_ctx_free(&ctx->q); + Curl_bufcp_free(&ctx->stream_bufcp); memset(ctx, 0, sizeof(*ctx)); } } -static CURLcode quic_x509_store_setup(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_quiche_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) - return CURLE_FAILED_INIT; - - if(!ctx->x509_store_setup) { - if(conn_config->verifypeer) { - const char * const ssl_cafile = conn_config->CAfile; - const char * const ssl_capath = conn_config->CApath; - if(ssl_cafile || ssl_capath) { - SSL_CTX_set_verify(ctx->sslctx, SSL_VERIFY_PEER, NULL); - /* tell OpenSSL where to find CA certificates that are used to verify - the server's certificate. */ - if(!SSL_CTX_load_verify_locations(ctx->sslctx, ssl_cafile, - ssl_capath)) { - /* Fail if we insist on successfully verifying the server. */ - failf(data, "error setting certificate verify locations:" - " CAfile: %s CApath: %s", - ssl_cafile ? ssl_cafile : "none", - ssl_capath ? ssl_capath : "none"); - return CURLE_SSL_CACERT_BADFILE; - } - infof(data, " CAfile: %s", ssl_cafile ? ssl_cafile : "none"); - infof(data, " CApath: %s", ssl_capath ? ssl_capath : "none"); - } -#ifdef CURL_CA_FALLBACK - else { - /* verifying the peer without any CA certificates won't work so - use openssl's built-in default as fallback */ - SSL_CTX_set_default_verify_paths(ctx->sslctx); - } -#endif - } - ctx->x509_store_setup = TRUE; - } - return CURLE_OK; -} - -static CURLcode quic_ssl_setup(struct Curl_cfilter *cf, struct Curl_easy *data) -{ - struct cf_quiche_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - CURLcode result; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) - return CURLE_FAILED_INIT; - - result = Curl_ssl_peer_init(&ctx->peer, cf); - if(result) - return result; - - DEBUGASSERT(!ctx->sslctx); - ctx->sslctx = SSL_CTX_new(TLS_method()); - if(!ctx->sslctx) - return CURLE_OUT_OF_MEMORY; - - SSL_CTX_set_alpn_protos(ctx->sslctx, - (const uint8_t *)QUICHE_H3_APPLICATION_PROTOCOL, - sizeof(QUICHE_H3_APPLICATION_PROTOCOL) - 1); - - SSL_CTX_set_default_verify_paths(ctx->sslctx); - - /* Open the file if a TLS or QUIC backend has not done this before. */ - Curl_tls_keylog_open(); - if(Curl_tls_keylog_enabled()) { - SSL_CTX_set_keylog_callback(ctx->sslctx, keylog_callback); - } - - if(conn_config->curves && - !SSL_CTX_set1_curves_list(ctx->sslctx, conn_config->curves)) { - failf(data, "failed setting curves list for QUIC: '%s'", - conn_config->curves); - return CURLE_SSL_CIPHER; - } - - ctx->ssl = SSL_new(ctx->sslctx); - if(!ctx->ssl) - return CURLE_QUIC_CONNECT_ERROR; - - SSL_set_app_data(ctx->ssl, cf); - - if(ctx->peer.sni) { - if(!SSL_set_tlsext_host_name(ctx->ssl, ctx->peer.sni)) { - failf(data, "Failed set SNI"); - SSL_free(ctx->ssl); - ctx->ssl = NULL; - return CURLE_QUIC_CONNECT_ERROR; - } - } - - return CURLE_OK; -} - /** * All about the H3 internals of a stream */ @@ -337,8 +233,8 @@ static void drain_stream(struct Curl_cfilter *cf, bits = CURL_CSELECT_IN; if(stream && !stream->send_closed && stream->upload_left) bits |= CURL_CSELECT_OUT; - if(data->state.dselect_bits != bits) { - data->state.dselect_bits = bits; + if(data->state.select_bits != bits) { + data->state.select_bits = bits; Curl_expire(data, 0, EXPIRE_RUN_NOW); } } @@ -668,7 +564,7 @@ static CURLcode recv_pkt(const unsigned char *pkt, size_t pktlen, return CURLE_OK; } else if(QUICHE_ERR_TLS_FAIL == nread) { - long verify_ok = SSL_get_verify_result(ctx->ssl); + long verify_ok = SSL_get_verify_result(ctx->tls.ssl); if(verify_ok != X509_V_OK) { failf(r->data, "SSL certificate problem: %s", X509_verify_cert_error_string(verify_ok)); @@ -696,7 +592,7 @@ static CURLcode cf_process_ingress(struct Curl_cfilter *cf, CURLcode result; DEBUGASSERT(ctx->qconn); - result = quic_x509_store_setup(cf, data); + result = Curl_vquic_tls_before_recv(&ctx->tls, cf, data); if(result) return result; @@ -836,7 +732,7 @@ static ssize_t recv_closed_stream(struct Curl_cfilter *cf, if(stream->reset) { failf(data, "HTTP/3 stream %" PRId64 " reset by server", stream->id); - *err = stream->resp_got_header? CURLE_PARTIAL_FILE : CURLE_RECV_ERROR; + *err = stream->resp_got_header? CURLE_PARTIAL_FILE : CURLE_HTTP3; CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv, was reset -> %d", stream->id, *err); } @@ -846,7 +742,7 @@ static ssize_t recv_closed_stream(struct Curl_cfilter *cf, " all response header fields, treated as error", stream->id); /* *err = CURLE_PARTIAL_FILE; */ - *err = CURLE_RECV_ERROR; + *err = CURLE_HTTP3; CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv, closed incomplete" " -> %d", stream->id, *err); } @@ -1078,6 +974,28 @@ static ssize_t cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, goto out; stream = H3_STREAM_CTX(data); } + else if(stream->closed) { + if(stream->resp_hds_complete) { + /* sending request body on a stream that has been closed by the + * server. If the server has send us a final response, we should + * silently discard the send data. + * This happens for example on redirects where the server, instead + * of reading the full request body just closed the stream after + * sending the 30x response. + * This is sort of a race: had the transfer loop called recv first, + * it would see the response and stop/discard sending on its own- */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] discarding data" + "on closed stream with response", stream->id); + *err = CURLE_OK; + nwritten = (ssize_t)len; + goto out; + } + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " + "-> stream closed", stream->id, len); + *err = CURLE_HTTP3; + nwritten = -1; + goto out; + } else { bool eof = (stream->upload_left >= 0 && (curl_off_t)len >= stream->upload_left); @@ -1095,20 +1013,11 @@ static ssize_t cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, nwritten = -1; goto out; } - else if(nwritten == QUICHE_H3_TRANSPORT_ERR_INVALID_STREAM_STATE && - stream->closed && stream->resp_hds_complete) { - /* sending request body on a stream that has been closed by the - * server. If the server has send us a final response, we should - * silently discard the send data. - * This happens for example on redirects where the server, instead - * of reading the full request body just closed the stream after - * sending the 30x response. - * This is sort of a race: had the transfer loop called recv first, - * it would see the response and stop/discard sending on its own- */ - CURL_TRC_CF(data, cf, "[%" PRId64 "] discarding data" - "on closed stream with response", stream->id); - *err = CURLE_OK; - nwritten = (ssize_t)len; + else if(nwritten == QUICHE_H3_TRANSPORT_ERR_INVALID_STREAM_STATE) { + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " + "-> invalid stream state", stream->id, len); + *err = CURLE_HTTP3; + nwritten = -1; goto out; } else if(nwritten == QUICHE_H3_TRANSPORT_ERR_FINAL_SIZE) { @@ -1167,16 +1076,19 @@ static void cf_quiche_adjust_pollset(struct Curl_cfilter *cf, struct easy_pollset *ps) { struct cf_quiche_ctx *ctx = cf->ctx; - bool want_recv = CURL_WANT_RECV(data); - bool want_send = CURL_WANT_SEND(data); + bool want_recv, want_send; + + if(!ctx->qconn) + return; - if(ctx->qconn && (want_recv || want_send)) { + Curl_pollset_check(data, ps, ctx->q.sockfd, &want_recv, &want_send); + if(want_recv || want_send) { struct stream_ctx *stream = H3_STREAM_CTX(data); bool c_exhaust, s_exhaust; c_exhaust = FALSE; /* Have not found any call in quiche that tells us if the connection itself is blocked */ - s_exhaust = stream && stream->id >= 0 && + s_exhaust = want_send && stream && stream->id >= 0 && (stream->quic_flow_blocked || !stream_is_writeable(cf, data)); want_recv = (want_recv || c_exhaust || s_exhaust); want_send = (!s_exhaust && want_send) || @@ -1261,66 +1173,6 @@ static CURLcode cf_quiche_data_event(struct Curl_cfilter *cf, return result; } -static CURLcode cf_verify_peer(struct Curl_cfilter *cf, - struct Curl_easy *data) -{ - struct cf_quiche_ctx *ctx = cf->ctx; - struct ssl_primary_config *conn_config; - CURLcode result = CURLE_OK; - - conn_config = Curl_ssl_cf_get_primary_config(cf); - if(!conn_config) - return CURLE_FAILED_INIT; - - cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */ - cf->conn->httpversion = 30; - cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX; - - if(conn_config->verifyhost) { - X509 *server_cert; - server_cert = SSL_get_peer_certificate(ctx->ssl); - if(!server_cert) { - result = CURLE_PEER_FAILED_VERIFICATION; - goto out; - } - result = Curl_ossl_verifyhost(data, cf->conn, &ctx->peer, server_cert); - X509_free(server_cert); - if(result) - goto out; - } - else - CURL_TRC_CF(data, cf, "Skipped certificate verification"); - - ctx->h3config = quiche_h3_config_new(); - if(!ctx->h3config) { - result = CURLE_OUT_OF_MEMORY; - goto out; - } - - /* Create a new HTTP/3 connection on the QUIC connection. */ - ctx->h3c = quiche_h3_conn_new_with_transport(ctx->qconn, ctx->h3config); - if(!ctx->h3c) { - result = CURLE_OUT_OF_MEMORY; - goto out; - } - if(data->set.ssl.certinfo) - /* asked to gather certificate info */ - (void)Curl_ossl_certchain(data, ctx->ssl); - -out: - if(result) { - if(ctx->h3config) { - quiche_h3_config_free(ctx->h3config); - ctx->h3config = NULL; - } - if(ctx->h3c) { - quiche_h3_conn_free(ctx->h3c); - ctx->h3c = NULL; - } - } - return result; -} - static CURLcode cf_connect_start(struct Curl_cfilter *cf, struct Curl_easy *data) { @@ -1348,6 +1200,10 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, if(result) return result; + result = Curl_ssl_peer_init(&ctx->peer, cf); + if(result) + return result; + ctx->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION); if(!ctx->cfg) { failf(data, "can't create quiche config"); @@ -1376,9 +1232,10 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, sizeof(QUICHE_H3_APPLICATION_PROTOCOL) - 1); - DEBUGASSERT(!ctx->ssl); - DEBUGASSERT(!ctx->sslctx); - result = quic_ssl_setup(cf, data); + result = Curl_vquic_tls_init(&ctx->tls, cf, data, &ctx->peer, + QUICHE_H3_APPLICATION_PROTOCOL, + sizeof(QUICHE_H3_APPLICATION_PROTOCOL) - 1, + NULL, cf); if(result) return result; @@ -1399,7 +1256,7 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, (struct sockaddr *)&ctx->q.local_addr, ctx->q.local_addrlen, &sockaddr->sa_addr, sockaddr->addrlen, - ctx->cfg, ctx->ssl, false); + ctx->cfg, ctx->tls.ssl, false); if(!ctx->qconn) { failf(data, "can't create quiche connection"); return CURLE_OUT_OF_MEMORY; @@ -1438,6 +1295,18 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, return CURLE_OK; } +static CURLcode cf_quiche_verify_peer(struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + struct cf_quiche_ctx *ctx = cf->ctx; + + cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */ + cf->conn->httpversion = 30; + cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX; + + return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer); +} + static CURLcode cf_quiche_connect(struct Curl_cfilter *cf, struct Curl_easy *data, bool blocking, bool *done) @@ -1489,9 +1358,21 @@ static CURLcode cf_quiche_connect(struct Curl_cfilter *cf, ctx->handshake_at = ctx->q.last_op; CURL_TRC_CF(data, cf, "handshake complete after %dms", (int)Curl_timediff(ctx->handshake_at, ctx->started_at)); - result = cf_verify_peer(cf, data); + result = cf_quiche_verify_peer(cf, data); if(!result) { CURL_TRC_CF(data, cf, "peer verified"); + ctx->h3config = quiche_h3_config_new(); + if(!ctx->h3config) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + /* Create a new HTTP/3 connection on the QUIC connection. */ + ctx->h3c = quiche_h3_conn_new_with_transport(ctx->qconn, ctx->h3config); + if(!ctx->h3c) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } cf->connected = TRUE; cf->conn->alpn = CURL_HTTP_VERSION_3; *done = TRUE; @@ -1564,8 +1445,8 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf, return CURLE_OK; } case CF_QUERY_CONNECT_REPLY_MS: - if(ctx->got_first_byte) { - timediff_t ms = Curl_timediff(ctx->first_byte_at, ctx->started_at); + if(ctx->q.got_first_byte) { + timediff_t ms = Curl_timediff(ctx->q.first_byte_at, ctx->started_at); *pres1 = (ms < INT_MAX)? (int)ms : INT_MAX; } else @@ -1573,8 +1454,8 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf, return CURLE_OK; case CF_QUERY_TIMER_CONNECT: { struct curltime *when = pres2; - if(ctx->got_first_byte) - *when = ctx->first_byte_at; + if(ctx->q.got_first_byte) + *when = ctx->q.first_byte_at; return CURLE_OK; } case CF_QUERY_TIMER_APPCONNECT: { diff --git a/lib/vquic/vquic-tls.c b/lib/vquic/vquic-tls.c new file mode 100644 index 000000000..cc7794e40 --- /dev/null +++ b/lib/vquic/vquic-tls.c @@ -0,0 +1,609 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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 + * + ***************************************************************************/ + +#include "curl_setup.h" + +#if defined(ENABLE_QUIC) && \ + (defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_WOLFSSL)) + +#ifdef USE_OPENSSL +#include +#include "vtls/openssl.h" +#elif defined(USE_GNUTLS) +#include +#include +#include +#include +#include +#include "vtls/gtls.h" +#elif defined(USE_WOLFSSL) +#include +#include +#include +#include "vtls/wolfssl.h" +#endif + +#include "urldata.h" +#include "curl_trc.h" +#include "cfilters.h" +#include "multiif.h" +#include "vtls/keylog.h" +#include "vtls/vtls.h" +#include "vquic-tls.h" + +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" +#include "curl_memory.h" +#include "memdebug.h" + +#ifndef ARRAYSIZE +#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) +#endif + +#ifdef USE_OPENSSL +#define QUIC_CIPHERS \ + "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_" \ + "POLY1305_SHA256:TLS_AES_128_CCM_SHA256" +#define QUIC_GROUPS "P-256:X25519:P-384:P-521" +#elif defined(USE_GNUTLS) +#define QUIC_PRIORITY \ + "NORMAL:-VERS-ALL:+VERS-TLS1.3:-CIPHER-ALL:+AES-128-GCM:+AES-256-GCM:" \ + "+CHACHA20-POLY1305:+AES-128-CCM:-GROUP-ALL:+GROUP-SECP256R1:" \ + "+GROUP-X25519:+GROUP-SECP384R1:+GROUP-SECP521R1:" \ + "%DISABLE_TLS13_COMPAT_MODE" +#elif defined(USE_WOLFSSL) +#define QUIC_CIPHERS \ + "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_" \ + "POLY1305_SHA256:TLS_AES_128_CCM_SHA256" +#define QUIC_GROUPS "P-256:P-384:P-521" +#endif + + +#ifdef USE_OPENSSL + +static void keylog_callback(const SSL *ssl, const char *line) +{ + (void)ssl; + Curl_tls_keylog_write_line(line); +} + +static CURLcode curl_ossl_init_ctx(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + Curl_vquic_tls_ctx_setup *ctx_setup) +{ + struct ssl_primary_config *conn_config; + CURLcode result = CURLE_FAILED_INIT; + + DEBUGASSERT(!ctx->ssl_ctx); +#ifdef USE_OPENSSL_QUIC + ctx->ssl_ctx = SSL_CTX_new(OSSL_QUIC_client_method()); +#else + ctx->ssl_ctx = SSL_CTX_new(TLS_method()); +#endif + if(!ctx->ssl_ctx) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + conn_config = Curl_ssl_cf_get_primary_config(cf); + if(!conn_config) { + result = CURLE_FAILED_INIT; + goto out; + } + + if(ctx_setup) { + result = ctx_setup(ctx, cf, data); + if(result) + goto out; + } + + SSL_CTX_set_default_verify_paths(ctx->ssl_ctx); + + { + const char *curves = conn_config->curves ? + conn_config->curves : QUIC_GROUPS; + if(!SSL_CTX_set1_curves_list(ctx->ssl_ctx, curves)) { + failf(data, "failed setting curves list for QUIC: '%s'", curves); + return CURLE_SSL_CIPHER; + } + } + +#ifndef OPENSSL_IS_BORINGSSL + { + const char *ciphers13 = conn_config->cipher_list13 ? + conn_config->cipher_list13 : QUIC_CIPHERS; + if(SSL_CTX_set_ciphersuites(ctx->ssl_ctx, ciphers13) != 1) { + failf(data, "failed setting QUIC cipher suite: %s", ciphers13); + return CURLE_SSL_CIPHER; + } + infof(data, "QUIC cipher selection: %s", ciphers13); + } +#endif + + /* Open the file if a TLS or QUIC backend has not done this before. */ + Curl_tls_keylog_open(); + if(Curl_tls_keylog_enabled()) { + SSL_CTX_set_keylog_callback(ctx->ssl_ctx, keylog_callback); + } + + /* OpenSSL always tries to verify the peer, this only says whether it should + * fail to connect if the verification fails, or if it should continue + * anyway. In the latter case the result of the verification is checked with + * SSL_get_verify_result() below. */ + SSL_CTX_set_verify(ctx->ssl_ctx, conn_config->verifypeer ? + SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL); + + /* give application a chance to interfere with SSL set up. */ + if(data->set.ssl.fsslctx) { + /* When a user callback is installed to modify the SSL_CTX, + * we need to do the full initialization before calling it. + * See: #11800 */ + if(!ctx->x509_store_setup) { + result = Curl_ssl_setup_x509_store(cf, data, ctx->ssl_ctx); + if(result) + goto out; + ctx->x509_store_setup = TRUE; + } + Curl_set_in_callback(data, true); + result = (*data->set.ssl.fsslctx)(data, ctx->ssl_ctx, + data->set.ssl.fsslctxp); + Curl_set_in_callback(data, false); + if(result) { + failf(data, "error signaled by ssl ctx callback"); + goto out; + } + } + result = CURLE_OK; + +out: + if(result && ctx->ssl_ctx) { + SSL_CTX_free(ctx->ssl_ctx); + ctx->ssl_ctx = NULL; + } + return result; +} + +static CURLcode curl_ossl_set_client_cert(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data) +{ + SSL_CTX *ssl_ctx = ctx->ssl_ctx; + const struct ssl_config_data *ssl_config; + + ssl_config = Curl_ssl_cf_get_config(cf, data); + DEBUGASSERT(ssl_config); + + if(ssl_config->primary.clientcert || + ssl_config->primary.cert_blob || + ssl_config->cert_type) { + return Curl_ossl_set_client_cert( + data, ssl_ctx, ssl_config->primary.clientcert, + ssl_config->primary.cert_blob, ssl_config->cert_type, + ssl_config->key, ssl_config->key_blob, + ssl_config->key_type, ssl_config->key_passwd); + } + + return CURLE_OK; +} + +/** SSL callbacks ***/ + +static CURLcode curl_ossl_init_ssl(struct quic_tls_ctx *ctx, + struct Curl_easy *data, + struct ssl_peer *peer, + const char *alpn, size_t alpn_len, + void *user_data) +{ + DEBUGASSERT(!ctx->ssl); + ctx->ssl = SSL_new(ctx->ssl_ctx); + + SSL_set_app_data(ctx->ssl, user_data); + SSL_set_connect_state(ctx->ssl); +#ifndef USE_OPENSSL_QUIC + SSL_set_quic_use_legacy_codepoint(ctx->ssl, 0); +#endif + + if(alpn) + SSL_set_alpn_protos(ctx->ssl, (const uint8_t *)alpn, (int)alpn_len); + + if(peer->sni) { + if(!SSL_set_tlsext_host_name(ctx->ssl, peer->sni)) { + failf(data, "Failed set SNI"); + SSL_free(ctx->ssl); + ctx->ssl = NULL; + return CURLE_QUIC_CONNECT_ERROR; + } + } + return CURLE_OK; +} + +#elif defined(USE_GNUTLS) +static int keylog_callback(gnutls_session_t session, const char *label, + const gnutls_datum_t *secret) +{ + gnutls_datum_t crandom; + gnutls_datum_t srandom; + + gnutls_session_get_random(session, &crandom, &srandom); + if(crandom.size != 32) { + return -1; + } + + Curl_tls_keylog_write(label, crandom.data, secret->data, secret->size); + return 0; +} + +static CURLcode curl_gtls_init_ctx(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + struct ssl_peer *peer, + const char *alpn, size_t alpn_len, + Curl_vquic_tls_ctx_setup *ctx_setup, + void *user_data) +{ + struct ssl_primary_config *conn_config; + CURLcode result; + gnutls_datum_t alpns[5]; + /* this will need some attention when HTTPS proxy over QUIC get fixed */ + long * const pverifyresult = &data->set.ssl.certverifyresult; + int rc; + + conn_config = Curl_ssl_cf_get_primary_config(cf); + if(!conn_config) + return CURLE_FAILED_INIT; + + DEBUGASSERT(ctx->gtls == NULL); + ctx->gtls = calloc(1, sizeof(*(ctx->gtls))); + if(!ctx->gtls) + return CURLE_OUT_OF_MEMORY; + + result = gtls_client_init(data, conn_config, &data->set.ssl, + peer, ctx->gtls, pverifyresult); + if(result) + return result; + + gnutls_session_set_ptr(ctx->gtls->session, user_data); + + if(ctx_setup) { + result = ctx_setup(ctx, cf, data); + if(result) + return result; + } + + rc = gnutls_priority_set_direct(ctx->gtls->session, QUIC_PRIORITY, NULL); + if(rc < 0) { + CURL_TRC_CF(data, cf, "gnutls_priority_set_direct failed: %s\n", + gnutls_strerror(rc)); + return CURLE_QUIC_CONNECT_ERROR; + } + + /* Open the file if a TLS or QUIC backend has not done this before. */ + Curl_tls_keylog_open(); + if(Curl_tls_keylog_enabled()) { + gnutls_session_set_keylog_function(ctx->gtls->session, keylog_callback); + } + + /* convert the ALPN string from our arguments to a list of strings + * that gnutls wants and will convert internally back to this very + * string for sending to the server. nice. */ + if(alpn) { + size_t i, alen = alpn_len; + unsigned char *s = (unsigned char *)alpn; + unsigned char slen; + for(i = 0; (i < ARRAYSIZE(alpns)) && alen; ++i) { + slen = s[0]; + if(slen >= alen) + return CURLE_FAILED_INIT; + alpns[i].data = s + 1; + alpns[i].size = slen; + s += slen + 1; + alen -= (size_t)slen + 1; + } + if(alen) /* not all alpn chars used, wrong format or too many */ + return CURLE_FAILED_INIT; + if(i) { + gnutls_alpn_set_protocols(ctx->gtls->session, + alpns, (unsigned int)i, + GNUTLS_ALPN_MANDATORY); + } + } + + return CURLE_OK; +} +#elif defined(USE_WOLFSSL) + +#if defined(HAVE_SECRET_CALLBACK) +static void keylog_callback(const WOLFSSL *ssl, const char *line) +{ + (void)ssl; + Curl_tls_keylog_write_line(line); +} +#endif + +static CURLcode curl_wssl_init_ctx(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + Curl_vquic_tls_ctx_setup *ctx_setup) +{ + struct ssl_primary_config *conn_config; + CURLcode result = CURLE_FAILED_INIT; + + conn_config = Curl_ssl_cf_get_primary_config(cf); + if(!conn_config) { + result = CURLE_FAILED_INIT; + goto out; + } + + ctx->ssl_ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method()); + if(!ctx->ssl_ctx) { + result = CURLE_OUT_OF_MEMORY; + goto out; + } + + if(ctx_setup) { + result = ctx_setup(ctx, cf, data); + if(result) + goto out; + } + + wolfSSL_CTX_set_default_verify_paths(ctx->ssl_ctx); + + if(wolfSSL_CTX_set_cipher_list(ctx->ssl_ctx, conn_config->cipher_list13 ? + conn_config->cipher_list13 : + QUIC_CIPHERS) != 1) { + char error_buffer[256]; + ERR_error_string_n(ERR_get_error(), error_buffer, sizeof(error_buffer)); + failf(data, "wolfSSL failed to set ciphers: %s", error_buffer); + goto out; + } + + if(wolfSSL_CTX_set1_groups_list(ctx->ssl_ctx, conn_config->curves ? + conn_config->curves : + (char *)QUIC_GROUPS) != 1) { + failf(data, "wolfSSL failed to set curves"); + goto out; + } + + /* Open the file if a TLS or QUIC backend has not done this before. */ + Curl_tls_keylog_open(); + if(Curl_tls_keylog_enabled()) { +#if defined(HAVE_SECRET_CALLBACK) + wolfSSL_CTX_set_keylog_callback(ctx->ssl_ctx, keylog_callback); +#else + failf(data, "wolfSSL was built without keylog callback"); + goto out; +#endif + } + + if(conn_config->verifypeer) { + const char * const ssl_cafile = conn_config->CAfile; + const char * const ssl_capath = conn_config->CApath; + + wolfSSL_CTX_set_verify(ctx->ssl_ctx, SSL_VERIFY_PEER, NULL); + if(ssl_cafile || ssl_capath) { + /* tell wolfSSL where to find CA certificates that are used to verify + the server's certificate. */ + int rc = + wolfSSL_CTX_load_verify_locations_ex(ctx->ssl_ctx, ssl_cafile, + ssl_capath, + WOLFSSL_LOAD_FLAG_IGNORE_ERR); + if(SSL_SUCCESS != rc) { + /* Fail if we insist on successfully verifying the server. */ + failf(data, "error setting certificate verify locations:" + " CAfile: %s CApath: %s", + ssl_cafile ? ssl_cafile : "none", + ssl_capath ? ssl_capath : "none"); + goto out; + } + infof(data, " CAfile: %s", ssl_cafile ? ssl_cafile : "none"); + infof(data, " CApath: %s", ssl_capath ? ssl_capath : "none"); + } +#ifdef CURL_CA_FALLBACK + else { + /* verifying the peer without any CA certificates won't work so + use wolfssl's built-in default as fallback */ + wolfSSL_CTX_set_default_verify_paths(ctx->ssl_ctx); + } +#endif + } + else { + wolfSSL_CTX_set_verify(ctx->ssl_ctx, SSL_VERIFY_NONE, NULL); + } + + /* give application a chance to interfere with SSL set up. */ + if(data->set.ssl.fsslctx) { + Curl_set_in_callback(data, true); + result = (*data->set.ssl.fsslctx)(data, ctx->ssl_ctx, + data->set.ssl.fsslctxp); + Curl_set_in_callback(data, false); + if(result) { + failf(data, "error signaled by ssl ctx callback"); + goto out; + } + } + result = CURLE_OK; + +out: + if(result && ctx->ssl_ctx) { + SSL_CTX_free(ctx->ssl_ctx); + ctx->ssl_ctx = NULL; + } + return result; +} + +/** SSL callbacks ***/ + +static CURLcode curl_wssl_init_ssl(struct quic_tls_ctx *ctx, + struct Curl_easy *data, + struct ssl_peer *peer, + const char *alpn, size_t alpn_len, + void *user_data) +{ + (void)data; + DEBUGASSERT(!ctx->ssl); + DEBUGASSERT(ctx->ssl_ctx); + ctx->ssl = wolfSSL_new(ctx->ssl_ctx); + + wolfSSL_set_app_data(ctx->ssl, user_data); + wolfSSL_set_connect_state(ctx->ssl); + wolfSSL_set_quic_use_legacy_codepoint(ctx->ssl, 0); + + if(alpn) + wolfSSL_set_alpn_protos(ctx->ssl, (const unsigned char *)alpn, + (int)alpn_len); + + if(peer->sni) { + wolfSSL_UseSNI(ctx->ssl, WOLFSSL_SNI_HOST_NAME, + peer->sni, (unsigned short)strlen(peer->sni)); + } + + return CURLE_OK; +} +#endif /* defined(USE_WOLFSSL) */ + +CURLcode Curl_vquic_tls_init(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + struct ssl_peer *peer, + const char *alpn, size_t alpn_len, + Curl_vquic_tls_ctx_setup *ctx_setup, + void *user_data) +{ + CURLcode result; + +#ifdef USE_OPENSSL + result = curl_ossl_init_ctx(ctx, cf, data, ctx_setup); + if(result) + return result; + + result = curl_ossl_set_client_cert(ctx, cf, data); + if(result) + return result; + + return curl_ossl_init_ssl(ctx, data, peer, alpn, alpn_len, user_data); +#elif defined(USE_GNUTLS) + (void)result; + return curl_gtls_init_ctx(ctx, cf, data, peer, alpn, alpn_len, + ctx_setup, user_data); +#elif defined(USE_WOLFSSL) + result = curl_wssl_init_ctx(ctx, cf, data, ctx_setup); + if(result) + return result; + + return curl_wssl_init_ssl(ctx, data, peer, alpn, alpn_len, user_data); +#else +#error "no TLS lib in used, should not happen" + return CURLE_FAILED_INIT; +#endif +} + +void Curl_vquic_tls_cleanup(struct quic_tls_ctx *ctx) +{ +#ifdef USE_OPENSSL + if(ctx->ssl) + SSL_free(ctx->ssl); + if(ctx->ssl_ctx) + SSL_CTX_free(ctx->ssl_ctx); +#elif defined(USE_GNUTLS) + if(ctx->gtls) { + if(ctx->gtls->cred) + gnutls_certificate_free_credentials(ctx->gtls->cred); + if(ctx->gtls->session) + gnutls_deinit(ctx->gtls->session); + free(ctx->gtls); + } +#elif defined(USE_WOLFSSL) + if(ctx->ssl) + wolfSSL_free(ctx->ssl); + if(ctx->ssl_ctx) + wolfSSL_CTX_free(ctx->ssl_ctx); +#endif + memset(ctx, 0, sizeof(*ctx)); +} + +CURLcode Curl_vquic_tls_before_recv(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data) +{ +#ifdef USE_OPENSSL + if(!ctx->x509_store_setup) { + CURLcode result = Curl_ssl_setup_x509_store(cf, data, ctx->ssl_ctx); + if(result) + return result; + ctx->x509_store_setup = TRUE; + } +#else + (void)ctx; (void)cf; (void)data; +#endif + return CURLE_OK; +} + +CURLcode Curl_vquic_tls_verify_peer(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + struct ssl_peer *peer) +{ + struct ssl_primary_config *conn_config; + CURLcode result = CURLE_OK; + + conn_config = Curl_ssl_cf_get_primary_config(cf); + if(!conn_config) + return CURLE_FAILED_INIT; + + if(conn_config->verifyhost) { +#ifdef USE_OPENSSL + X509 *server_cert; + server_cert = SSL_get1_peer_certificate(ctx->ssl); + if(!server_cert) { + return CURLE_PEER_FAILED_VERIFICATION; + } + result = Curl_ossl_verifyhost(data, cf->conn, peer, server_cert); + X509_free(server_cert); + if(result) + return result; +#elif defined(USE_GNUTLS) + result = Curl_gtls_verifyserver(data, ctx->gtls->session, + conn_config, &data->set.ssl, peer, + data->set.str[STRING_SSL_PINNEDPUBLICKEY]); + if(result) + return result; +#elif defined(USE_WOLFSSL) + if(!peer->sni || + wolfSSL_check_domain_name(ctx->ssl, peer->sni) == SSL_FAILURE) + return CURLE_PEER_FAILED_VERIFICATION; +#endif + infof(data, "Verified certificate just fine"); + } + else + infof(data, "Skipped certificate verification"); +#ifdef USE_OPENSSL + if(data->set.ssl.certinfo) + /* asked to gather certificate info */ + (void)Curl_ossl_certchain(data, ctx->ssl); +#endif + return result; +} + + +#endif /* !ENABLE_QUIC && (USE_OPENSSL || USE_GNUTLS || USE_WOLFSSL) */ diff --git a/lib/vquic/vquic-tls.h b/lib/vquic/vquic-tls.h new file mode 100644 index 000000000..9c0dfd8d5 --- /dev/null +++ b/lib/vquic/vquic-tls.h @@ -0,0 +1,98 @@ +#ifndef HEADER_CURL_VQUIC_TLS_H +#define HEADER_CURL_VQUIC_TLS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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 + * + ***************************************************************************/ + +#include "curl_setup.h" +#include "bufq.h" + +#if defined(ENABLE_QUIC) && \ + (defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_WOLFSSL)) + +struct quic_tls_ctx { +#ifdef USE_OPENSSL + SSL_CTX *ssl_ctx; + SSL *ssl; +#elif defined(USE_GNUTLS) + struct gtls_instance *gtls; +#elif defined(USE_WOLFSSL) + WOLFSSL_CTX *ssl_ctx; + WOLFSSL *ssl; +#endif + BIT(x509_store_setup); /* if x509 store has been set up */ +}; + +/** + * Callback passed to `Curl_vquic_tls_init()` that can + * do early initializations on the not otherwise configured TLS + * instances created. This varies by TLS backend: + * - openssl/wolfssl: SSL_CTX* has just been created + * - gnutls: gtls_client_init() has run + */ +typedef CURLcode Curl_vquic_tls_ctx_setup(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data); + +/** + * Initialize the QUIC TLS instances based of the SSL configurations + * for the connection filter, transfer and peer. + * @param ctx the TLS context to initialize + * @param cf the connection filter involved + * @param data the transfer involved + * @param peer the peer that will be connected to + * @param alpn the ALPN string in protocol format ((len+bytes+)+), + * may be NULL + * @param alpn_len the overall number of bytes in `alpn` + * @param ctx_setup optional callback for very early TLS config + * @param user_data optional pointer to set in TLS application context + */ +CURLcode Curl_vquic_tls_init(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + struct ssl_peer *peer, + const char *alpn, size_t alpn_len, + Curl_vquic_tls_ctx_setup *ctx_setup, + void *user_data); + +/** + * Cleanup all data that has been initialized. + */ +void Curl_vquic_tls_cleanup(struct quic_tls_ctx *ctx); + +CURLcode Curl_vquic_tls_before_recv(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data); + +/** + * After the QUIC basic handshake has been, verify that the peer + * (and its certificate) fulfill our requirements. + */ +CURLcode Curl_vquic_tls_verify_peer(struct quic_tls_ctx *ctx, + struct Curl_cfilter *cf, + struct Curl_easy *data, + struct ssl_peer *peer); + +#endif /* !ENABLE_QUIC && (USE_OPENSSL || USE_GNUTLS || USE_WOLFSSL) */ + +#endif /* HEADER_CURL_VQUIC_TLS_H */ diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 523b807bc..612d25bb0 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -46,6 +46,7 @@ #include "curl_trc.h" #include "curl_msh3.h" #include "curl_ngtcp2.h" +#include "curl_osslq.h" #include "curl_quiche.h" #include "rand.h" #include "vquic.h" @@ -74,6 +75,8 @@ void Curl_quic_ver(char *p, size_t len) { #if defined(USE_NGTCP2) && defined(USE_NGHTTP3) Curl_ngtcp2_ver(p, len); +#elif defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3) + Curl_osslq_ver(p, len); #elif defined(USE_QUICHE) Curl_quiche_ver(p, len); #elif defined(USE_MSH3) @@ -179,7 +182,7 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, qctx->no_gso = TRUE; return send_packet_no_gso(cf, data, qctx, pkt, pktlen, gsolen, psent); } - /* FALLTHROUGH */ + FALLTHROUGH(); default: failf(data, "sendmsg() returned %zd (errno %d)", sent, SOCKERRNO); return CURLE_SEND_ERROR; @@ -543,8 +546,13 @@ CURLcode vquic_recv_packets(struct Curl_cfilter *cf, #else result = recvfrom_packets(cf, data, qctx, max_pkts, recv_cb, userp); #endif - if(!result) + if(!result) { + if(!qctx->got_first_byte) { + qctx->got_first_byte = TRUE; + qctx->first_byte_at = qctx->last_op; + } qctx->last_io = qctx->last_op; + } return result; } @@ -603,6 +611,8 @@ CURLcode Curl_cf_quic_create(struct Curl_cfilter **pcf, DEBUGASSERT(transport == TRNSPRT_QUIC); #if defined(USE_NGTCP2) && defined(USE_NGHTTP3) return Curl_cf_ngtcp2_create(pcf, data, conn, ai); +#elif defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3) + return Curl_cf_osslq_create(pcf, data, conn, ai); #elif defined(USE_QUICHE) return Curl_cf_quiche_create(pcf, data, conn, ai); #elif defined(USE_MSH3) @@ -622,6 +632,8 @@ bool Curl_conn_is_http3(const struct Curl_easy *data, { #if defined(USE_NGTCP2) && defined(USE_NGHTTP3) return Curl_conn_is_ngtcp2(data, conn, sockindex); +#elif defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3) + return Curl_conn_is_osslq(data, conn, sockindex); #elif defined(USE_QUICHE) return Curl_conn_is_quiche(data, conn, sockindex); #elif defined(USE_MSH3) diff --git a/lib/vquic/vquic_int.h b/lib/vquic/vquic_int.h index a820f39ae..c218a949c 100644 --- a/lib/vquic/vquic_int.h +++ b/lib/vquic/vquic_int.h @@ -40,6 +40,7 @@ struct cf_quic_ctx { socklen_t local_addrlen; /* length of local address */ struct bufq sendbuf; /* buffer for sending one or more packets */ + struct curltime first_byte_at; /* when first byte was recvd */ struct curltime last_op; /* last (attempted) send/recv operation */ struct curltime last_io; /* last successful socket IO */ size_t gsolen; /* length of individual packets in send buf */ @@ -48,7 +49,8 @@ struct cf_quic_ctx { #ifdef DEBUGBUILD int wblock_percent; /* percent of writes doing EAGAIN */ #endif - bool no_gso; /* do not use gso on sending */ + BIT(got_first_byte); /* if first byte was received */ + BIT(no_gso); /* do not use gso on sending */ }; CURLcode vquic_ctx_init(struct cf_quic_ctx *qctx); diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 97143c477..c6dc63ae6 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -31,6 +31,8 @@ #include +/* in 0.10.0 or later, ignore deprecated warnings */ +#define SSH_SUPPRESS_DEPRECATED #include #include @@ -89,14 +91,6 @@ #include "curl_memory.h" #include "memdebug.h" -/* in 0.10.0 or later, ignore deprecated warnings */ -#if defined(__GNUC__) && \ - (LIBSSH_VERSION_MINOR >= 10) || \ - (LIBSSH_VERSION_MAJOR > 0) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - /* A recent macro provided by libssh. Or make our own. */ #ifndef SSH_STRING_FREE_CHAR #define SSH_STRING_FREE_CHAR(x) \ @@ -167,7 +161,7 @@ const struct Curl_handler Curl_handler_scp = { ZERO_NULL, /* domore_getsock */ myssh_getsock, /* perform_getsock */ scp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SSH, /* defport */ @@ -194,7 +188,7 @@ const struct Curl_handler Curl_handler_sftp = { ZERO_NULL, /* domore_getsock */ myssh_getsock, /* perform_getsock */ sftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SSH, /* defport */ @@ -445,11 +439,8 @@ static int myssh_is_known(struct Curl_easy *data) keymatch = CURLKHMATCH_OK; break; case SSH_KNOWN_HOSTS_OTHER: - /* fallthrough */ case SSH_KNOWN_HOSTS_NOT_FOUND: - /* fallthrough */ case SSH_KNOWN_HOSTS_UNKNOWN: - /* fallthrough */ case SSH_KNOWN_HOSTS_ERROR: keymatch = CURLKHMATCH_MISSING; break; @@ -465,7 +456,6 @@ static int myssh_is_known(struct Curl_easy *data) keymatch = CURLKHMATCH_OK; break; case SSH_SERVER_FILE_NOT_FOUND: - /* fallthrough */ case SSH_SERVER_NOT_KNOWN: keymatch = CURLKHMATCH_MISSING; break; @@ -629,7 +619,7 @@ int myssh_auth_interactive(struct connectdata *conn) if(rc < 0) return SSH_ERROR; - /* FALLTHROUGH */ + FALLTHROUGH(); case 1: sshc->kbd_state = 1; @@ -704,7 +694,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) ssh_set_blocking(sshc->ssh_session, 0); state(data, SSH_S_STARTUP); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_S_STARTUP: rc = ssh_connect(sshc->ssh_session); @@ -719,7 +709,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) state(data, SSH_HOSTKEY); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_HOSTKEY: rc = myssh_is_known(data); @@ -729,7 +719,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) } state(data, SSH_AUTHLIST); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_AUTHLIST:{ sshc->authed = FALSE; @@ -910,7 +900,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) break; } state(data, SSH_AUTH_PASS); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_AUTH_PASS: rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd); @@ -973,7 +963,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) break; } state(data, SSH_SFTP_REALPATH); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_SFTP_REALPATH: /* * Get the "home" directory @@ -1161,22 +1151,22 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) } else if(statvfs) { #ifdef _MSC_VER - #define LIBSSH_VFS_SIZE_MASK "I64u" + #define CURL_LIBSSH_VFS_SIZE_MASK "I64u" #else - #define LIBSSH_VFS_SIZE_MASK PRIu64 + #define CURL_LIBSSH_VFS_SIZE_MASK PRIu64 #endif char *tmp = aprintf("statvfs:\n" - "f_bsize: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_frsize: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_blocks: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_bfree: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_bavail: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_files: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_ffree: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_favail: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_fsid: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_flag: %" LIBSSH_VFS_SIZE_MASK "\n" - "f_namemax: %" LIBSSH_VFS_SIZE_MASK "\n", + "f_bsize: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_frsize: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_blocks: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_bfree: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_bavail: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_files: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_ffree: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_favail: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_fsid: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_flag: %" CURL_LIBSSH_VFS_SIZE_MASK "\n" + "f_namemax: %" CURL_LIBSSH_VFS_SIZE_MASK "\n", statvfs->f_bsize, statvfs->f_frsize, statvfs->f_blocks, statvfs->f_bfree, statvfs->f_bavail, statvfs->f_files, @@ -1318,13 +1308,14 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) } /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ do { + char scratch[4*1024]; size_t readthisamountnow = - (data->state.resume_from - passed > data->set.buffer_size) ? - (size_t)data->set.buffer_size : - curlx_sotouz(data->state.resume_from - passed); + (data->state.resume_from - passed > + (curl_off_t)sizeof(scratch)) ? + sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread = - data->state.fread_func(data->state.buffer, 1, + data->state.fread_func(scratch, 1, readthisamountnow, data->state.in); passed += actuallyread; @@ -1370,7 +1361,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _sending_ function even when the socket turns out readable as the underlying libssh sftp send function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_OUT; /* since we don't really wait for anything at this point, we want the state machine to move on as soon as possible so we set a very short @@ -1560,7 +1551,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) sshc->readdir_longentry = NULL; state(data, SSH_SFTP_READDIR_BOTTOM); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_SFTP_READDIR_BOTTOM: if(Curl_dyn_addn(&sshc->readdir_buf, "\n", 1)) result = CURLE_OUT_OF_MEMORY; @@ -1740,7 +1731,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _receiving_ function even when the socket turns out writableable as the underlying libssh recv function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; if(result) { /* this should never occur; the close state should be entered @@ -1868,7 +1859,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _sending_ function even when the socket turns out readable as the underlying libssh scp send function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_OUT; state(data, SSH_STOP); @@ -1884,7 +1875,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) break; } state(data, SSH_SCP_DOWNLOAD); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_SCP_DOWNLOAD:{ curl_off_t bytecount; @@ -1908,7 +1899,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _receiving_ function even when the socket turns out writableable as the underlying libssh recv function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; state(data, SSH_STOP); break; @@ -1948,7 +1939,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) ssh_set_blocking(sshc->ssh_session, 0); state(data, SSH_SESSION_DISCONNECT); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_SESSION_DISCONNECT: /* during weird times when we've been prematurely aborted, the channel @@ -1971,7 +1962,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) data->state.most_recent_ftp_entrypath = NULL; state(data, SSH_SESSION_FREE); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_SESSION_FREE: if(sshc->ssh_session) { ssh_free(sshc->ssh_session); @@ -2022,7 +2013,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) break; case SSH_QUIT: - /* fallthrough, just stop! */ default: /* internal error */ sshc->nextstate = SSH_NO_STATE; @@ -2613,7 +2603,7 @@ static ssize_t sftp_recv(struct Curl_easy *data, int sockindex, return -1; } - /* FALLTHROUGH */ + FALLTHROUGH(); case 1: conn->proto.sshc.sftp_recv_state = 1; @@ -2957,10 +2947,4 @@ void Curl_ssh_version(char *buffer, size_t buflen) (void)msnprintf(buffer, buflen, "libssh/%s", ssh_version(0)); } -#if defined(__GNUC__) && \ - (LIBSSH_VERSION_MINOR >= 10) || \ - (LIBSSH_VERSION_MAJOR > 0) -#pragma GCC diagnostic pop -#endif - #endif /* USE_LIBSSH */ diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 11f5f4fd5..e9dfef950 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -138,7 +138,7 @@ const struct Curl_handler Curl_handler_scp = { ZERO_NULL, /* domore_getsock */ ssh_getsock, /* perform_getsock */ scp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ssh_attach, /* attach */ PORT_SSH, /* defport */ @@ -167,7 +167,7 @@ const struct Curl_handler Curl_handler_sftp = { ZERO_NULL, /* domore_getsock */ ssh_getsock, /* perform_getsock */ sftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ssh_attach, /* attach */ PORT_SSH, /* defport */ @@ -589,10 +589,9 @@ static CURLcode ssh_knownhost(struct Curl_easy *data) switch(rc) { default: /* unknown return codes will equal reject */ - /* FALLTHROUGH */ case CURLKHSTAT_REJECT: state(data, SSH_SESSION_FREE); - /* FALLTHROUGH */ + FALLTHROUGH(); case CURLKHSTAT_DEFER: /* DEFER means bail out but keep the SSH_HOSTKEY state */ result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION; @@ -601,9 +600,8 @@ static CURLcode ssh_knownhost(struct Curl_easy *data) /* remove old host+key that doesn't match */ if(host) libssh2_knownhost_del(sshc->kh, host); - /* FALLTHROUGH */ + FALLTHROUGH(); case CURLKHSTAT_FINE: - /* FALLTHROUGH */ case CURLKHSTAT_FINE_ADD_TO_FILE: /* proceed */ if(keycheck != LIBSSH2_KNOWNHOST_CHECK_MATCH) { @@ -997,7 +995,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) } state(data, SSH_S_STARTUP); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_S_STARTUP: rc = session_startup(sshc->ssh_session, sock); @@ -1016,7 +1014,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) state(data, SSH_HOSTKEY); - /* FALLTHROUGH */ + FALLTHROUGH(); case SSH_HOSTKEY: /* * Before we authenticate we should check the hostkey's fingerprint @@ -1961,22 +1959,22 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) } else if(rc == 0) { #ifdef _MSC_VER - #define LIBSSH2_VFS_SIZE_MASK "I64u" + #define CURL_LIBSSH2_VFS_SIZE_MASK "I64u" #else - #define LIBSSH2_VFS_SIZE_MASK "llu" + #define CURL_LIBSSH2_VFS_SIZE_MASK "llu" #endif char *tmp = aprintf("statvfs:\n" - "f_bsize: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_frsize: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_blocks: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_bfree: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_bavail: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_files: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_ffree: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_favail: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_fsid: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_flag: %" LIBSSH2_VFS_SIZE_MASK "\n" - "f_namemax: %" LIBSSH2_VFS_SIZE_MASK "\n", + "f_bsize: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_frsize: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_blocks: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_bfree: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_bavail: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_files: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_ffree: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_favail: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_fsid: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_flag: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n" + "f_namemax: %" CURL_LIBSSH2_VFS_SIZE_MASK "\n", statvfs.f_bsize, statvfs.f_frsize, statvfs.f_blocks, statvfs.f_bfree, statvfs.f_bavail, statvfs.f_files, @@ -2160,14 +2158,15 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) } /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ do { + char scratch[4*1024]; size_t readthisamountnow = - (data->state.resume_from - passed > data->set.buffer_size) ? - (size_t)data->set.buffer_size : - curlx_sotouz(data->state.resume_from - passed); + (data->state.resume_from - passed > + (curl_off_t)sizeof(scratch)) ? + sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread; Curl_set_in_callback(data, true); - actuallyread = data->state.fread_func(data->state.buffer, 1, + actuallyread = data->state.fread_func(scratch, 1, readthisamountnow, data->state.in); Curl_set_in_callback(data, false); @@ -2213,7 +2212,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _sending_ function even when the socket turns out readable as the underlying libssh2 sftp send function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_OUT; /* since we don't really wait for anything at this point, we want the state machine to move on as soon as possible so we set a very short @@ -2602,7 +2601,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _receiving_ function even when the socket turns out writableable as the underlying libssh2 recv function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; if(result) { /* this should never occur; the close state should be entered @@ -2757,7 +2756,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _sending_ function even when the socket turns out readable as the underlying libssh2 scp send function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_OUT; state(data, SSH_STOP); } @@ -2819,7 +2818,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _receiving_ function even when the socket turns out writableable as the underlying libssh2 recv function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; if(result) { state(data, SSH_SCP_CHANNEL_FREE); @@ -3024,7 +3023,6 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block) break; case SSH_QUIT: - /* fallthrough, just stop! */ default: /* internal error */ sshc->nextstate = SSH_NO_STATE; @@ -3292,6 +3290,27 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) #ifndef CURL_DISABLE_PROXY if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) { + /* + Setup libssh2 callbacks to make it read/write TLS from the socket. + + ssize_t + recvcb(libssh2_socket_t sock, void *buffer, size_t length, + int flags, void **abstract); + + ssize_t + sendcb(libssh2_socket_t sock, const void *buffer, size_t length, + int flags, void **abstract); + + */ +#if LIBSSH2_VERSION_NUM >= 0x010b01 + infof(data, "Uses HTTPS proxy"); + libssh2_session_callback_set2(sshc->ssh_session, + LIBSSH2_CALLBACK_RECV, + (libssh2_cb_generic *)ssh_tls_recv); + libssh2_session_callback_set2(sshc->ssh_session, + LIBSSH2_CALLBACK_SEND, + (libssh2_cb_generic *)ssh_tls_send); +#else /* * This crazy union dance is here to avoid assigning a void pointer a * function pointer as it is invalid C. The problem is of course that @@ -3312,22 +3331,11 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) sshsend.sendptr = ssh_tls_send; infof(data, "Uses HTTPS proxy"); - /* - Setup libssh2 callbacks to make it read/write TLS from the socket. - - ssize_t - recvcb(libssh2_socket_t sock, void *buffer, size_t length, - int flags, void **abstract); - - ssize_t - sendcb(libssh2_socket_t sock, const void *buffer, size_t length, - int flags, void **abstract); - - */ libssh2_session_callback_set(sshc->ssh_session, LIBSSH2_CALLBACK_RECV, sshrecv.recvp); libssh2_session_callback_set(sshc->ssh_session, LIBSSH2_CALLBACK_SEND, sshsend.sendp); +#endif /* Store the underlying TLS recv/send function pointers to be used when reading from the proxy */ diff --git a/lib/vssh/wolfssh.c b/lib/vssh/wolfssh.c index 4da7e9dea..7396791ce 100644 --- a/lib/vssh/wolfssh.c +++ b/lib/vssh/wolfssh.c @@ -42,6 +42,7 @@ #include "select.h" #include "multiif.h" #include "warnless.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -92,7 +93,7 @@ const struct Curl_handler Curl_handler_scp = { ZERO_NULL, /* domore_getsock */ wssh_getsock, /* perform_getsock */ wscp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SSH, /* defport */ @@ -121,7 +122,7 @@ const struct Curl_handler Curl_handler_sftp = { ZERO_NULL, /* domore_getsock */ wssh_getsock, /* perform_getsock */ wsftp_disconnect, /* disconnect */ - ZERO_NULL, /* readwrite */ + ZERO_NULL, /* write_resp */ ZERO_NULL, /* connection_check */ ZERO_NULL, /* attach connection */ PORT_SSH, /* defport */ @@ -512,15 +513,9 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) return CURLE_OK; } else if(name && (rc == WS_SUCCESS)) { - sshc->homedir = malloc(name->fSz + 1); - if(!sshc->homedir) { + sshc->homedir = Curl_memdup0(name->fName, name->fSz); + if(!sshc->homedir) sshc->actualcode = CURLE_OUT_OF_MEMORY; - } - else { - memcpy(sshc->homedir, name->fName, name->fSz); - sshc->homedir[name->fSz] = 0; - infof(data, "wolfssh SFTP realpath succeeded"); - } wolfSSH_SFTPNAME_list_free(name); state(data, SSH_STOP); return CURLE_OK; @@ -646,14 +641,15 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) } /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */ do { + char scratch[4*1024]; size_t readthisamountnow = - (data->state.resume_from - passed > data->set.buffer_size) ? - (size_t)data->set.buffer_size : - curlx_sotouz(data->state.resume_from - passed); + (data->state.resume_from - passed > + (curl_off_t)sizeof(scratch)) ? + sizeof(scratch) : curlx_sotouz(data->state.resume_from - passed); size_t actuallyread; Curl_set_in_callback(data, true); - actuallyread = data->state.fread_func(data->state.buffer, 1, + actuallyread = data->state.fread_func(scratch, 1, readthisamountnow, data->state.in); Curl_set_in_callback(data, false); @@ -699,7 +695,7 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _sending_ function even when the socket turns out readable as the underlying libssh2 sftp send function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_OUT; + data->state.select_bits = CURL_CSELECT_OUT; /* since we don't really wait for anything at this point, we want the state machine to move on as soon as possible so we set a very short @@ -795,7 +791,7 @@ static CURLcode wssh_statemach_act(struct Curl_easy *data, bool *block) /* we want to use the _receiving_ function even when the socket turns out writableable as the underlying libssh2 recv function will deal with both accordingly */ - conn->cselect_bits = CURL_CSELECT_IN; + data->state.select_bits = CURL_CSELECT_IN; if(result) { /* this should never occur; the close state should be entered diff --git a/lib/vtls/bearssl.c b/lib/vtls/bearssl.c index a6566f4d9..58394bab9 100644 --- a/lib/vtls/bearssl.c +++ b/lib/vtls/bearssl.c @@ -509,7 +509,6 @@ static CURLcode bearssl_set_selected_ciphers(struct Curl_easy *data, { uint16_t selected_ciphers[NUM_OF_CIPHERS]; size_t selected_count = 0; - char cipher_name[CIPHER_NAME_BUF_LEN]; const char *cipher_start = ciphers; const char *cipher_end; size_t i, j; @@ -518,41 +517,48 @@ static CURLcode bearssl_set_selected_ciphers(struct Curl_easy *data, return CURLE_SSL_CIPHER; while(true) { + const char *cipher; + size_t clen; + /* Extract the next cipher name from the ciphers string */ while(is_separator(*cipher_start)) ++cipher_start; - if(*cipher_start == '\0') + if(!*cipher_start) break; cipher_end = cipher_start; - while(*cipher_end != '\0' && !is_separator(*cipher_end)) + while(*cipher_end && !is_separator(*cipher_end)) ++cipher_end; - j = cipher_end - cipher_start < CIPHER_NAME_BUF_LEN - 1 ? - cipher_end - cipher_start : CIPHER_NAME_BUF_LEN - 1; - strncpy(cipher_name, cipher_start, j); - cipher_name[j] = '\0'; + + clen = cipher_end - cipher_start; + cipher = cipher_start; + cipher_start = cipher_end; /* Lookup the cipher name in the table of available ciphers. If the cipher name starts with "TLS_" we do the lookup by IANA name. Otherwise, we try to match cipher name by an (OpenSSL) alias. */ - if(strncasecompare(cipher_name, "TLS_", 4)) { + if(strncasecompare(cipher, "TLS_", 4)) { for(i = 0; i < NUM_OF_CIPHERS && - !strcasecompare(cipher_name, ciphertable[i].name); ++i); + (strlen(ciphertable[i].name) == clen) && + !strncasecompare(cipher, ciphertable[i].name, clen); ++i); } else { for(i = 0; i < NUM_OF_CIPHERS && - !strcasecompare(cipher_name, ciphertable[i].alias_name); ++i); + (strlen(ciphertable[i].alias_name) == clen) && + !strncasecompare(cipher, ciphertable[i].alias_name, clen); ++i); } if(i == NUM_OF_CIPHERS) { - infof(data, "BearSSL: unknown cipher in list: %s", cipher_name); + infof(data, "BearSSL: unknown cipher in list: %.*s", + (int)clen, cipher); continue; } /* No duplicates allowed */ for(j = 0; j < selected_count && - selected_ciphers[j] != ciphertable[i].num; j++); + selected_ciphers[j] != ciphertable[i].num; j++); if(j < selected_count) { - infof(data, "BearSSL: duplicate cipher in list: %s", cipher_name); + infof(data, "BearSSL: duplicate cipher in list: %.*s", + (int)clen, cipher); continue; } diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 4e337f5dd..b95c5be3c 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -584,13 +584,9 @@ CURLcode gtls_client_init(struct Curl_easy *data, /* Only add SRP to the cipher list if SRP is requested. Otherwise * GnuTLS will disable TLS 1.3 support. */ if(config->username) { - size_t len = strlen(prioritylist); - - char *prioritysrp = malloc(len + sizeof(GNUTLS_SRP) + 1); + char *prioritysrp = aprintf("%s:" GNUTLS_SRP, prioritylist); if(!prioritysrp) return CURLE_OUT_OF_MEMORY; - strcpy(prioritysrp, prioritylist); - strcpy(prioritysrp + len, ":" GNUTLS_SRP); rc = gnutls_priority_set_direct(gtls->session, prioritysrp, &err); free(prioritysrp); @@ -822,16 +818,17 @@ Curl_gtls_verifyserver(struct Curl_easy *data, char certname[65] = ""; /* limited to 64 chars by ASN.1 */ size_t size; time_t certclock; - const char *ptr; int rc; CURLcode result = CURLE_OK; #ifndef CURL_DISABLE_VERBOSE_STRINGS + const char *ptr; unsigned int algo; unsigned int bits; gnutls_protocol_t version = gnutls_protocol_get_version(session); #endif long * const certverifyresult = &ssl_config->certverifyresult; +#ifndef CURL_DISABLE_VERBOSE_STRINGS /* the name of the cipher suite used, e.g. ECDHE_RSA_AES_256_GCM_SHA384. */ ptr = gnutls_cipher_suite_get_name(gnutls_kx_get(session), gnutls_cipher_get(session), @@ -839,6 +836,7 @@ Curl_gtls_verifyserver(struct Curl_easy *data, infof(data, "SSL connection using %s / %s", gnutls_protocol_get_name(version), ptr); +#endif /* This function will return the peer's raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 38f7de7f7..7d70de53b 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -36,6 +36,13 @@ /* Define this to enable lots of debugging for mbedTLS */ /* #define MBEDTLS_DEBUG */ +#ifdef __GNUC__ +#pragma GCC diagnostic push +/* mbedTLS (as of v3.5.1) has a duplicate function declaration + in its public headers. Disable the warning that detects it. */ +#pragma GCC diagnostic ignored "-Wredundant-decls" +#endif + #include #if MBEDTLS_VERSION_NUMBER >= 0x02040000 #include @@ -56,6 +63,10 @@ # endif #endif +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "urldata.h" #include "sendf.h" #include "inet_pton.h" @@ -67,6 +78,7 @@ #include "select.h" #include "multiif.h" #include "mbedtls_threadlock.h" +#include "strdup.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -153,7 +165,6 @@ static void mbed_debug(void *context, int level, const char *f_name, infof(data, "%s", line); (void) level; } -#else #endif static int mbedtls_bio_cf_write(void *bio, @@ -165,6 +176,9 @@ static int mbedtls_bio_cf_write(void *bio, CURLcode result; DEBUGASSERT(data); + if(!data) + return 0; + nwritten = Curl_conn_cf_send(cf->next, data, (char *)buf, blen, &result); CURL_TRC_CF(data, cf, "mbedtls_bio_cf_out_write(len=%zu) -> %zd, err=%d", blen, nwritten, result); @@ -182,6 +196,8 @@ static int mbedtls_bio_cf_read(void *bio, unsigned char *buf, size_t blen) CURLcode result; DEBUGASSERT(data); + if(!data) + return 0; /* OpenSSL catches this case, so should we. */ if(!buf) return 0; @@ -367,11 +383,10 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* Unfortunately, mbedtls_x509_crt_parse() requires the data to be null terminated even when provided the exact length, forcing us to waste extra memory here. */ - unsigned char *newblob = malloc(ca_info_blob->len + 1); + unsigned char *newblob = Curl_memdup0(ca_info_blob->data, + ca_info_blob->len); if(!newblob) return CURLE_OUT_OF_MEMORY; - memcpy(newblob, ca_info_blob->data, ca_info_blob->len); - newblob[ca_info_blob->len] = 0; /* null terminate */ ret = mbedtls_x509_crt_parse(&backend->cacert, newblob, ca_info_blob->len + 1); free(newblob); @@ -441,11 +456,10 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* Unfortunately, mbedtls_x509_crt_parse() requires the data to be null terminated even when provided the exact length, forcing us to waste extra memory here. */ - unsigned char *newblob = malloc(ssl_cert_blob->len + 1); + unsigned char *newblob = Curl_memdup0(ssl_cert_blob->data, + ssl_cert_blob->len); if(!newblob) return CURLE_OUT_OF_MEMORY; - memcpy(newblob, ssl_cert_blob->data, ssl_cert_blob->len); - newblob[ssl_cert_blob->len] = 0; /* null terminate */ ret = mbedtls_x509_crt_parse(&backend->clicert, newblob, ssl_cert_blob->len + 1); free(newblob); @@ -1207,6 +1221,9 @@ static int mbedtls_init(void) static void mbedtls_cleanup(void) { +#ifdef THREADING_SUPPORT + mbedtls_entropy_free(&ts_entropy); +#endif /* THREADING_SUPPORT */ (void)Curl_mbedtlsthreadlock_thread_cleanup(); } diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 8c8f43e83..8d6087022 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -954,8 +954,9 @@ static char *ossl_strerror(unsigned long error, char *buf, size_t size) #endif if(!*buf) { - strncpy(buf, (error ? "Unknown error" : "No error"), size); - buf[size - 1] = '\0'; + const char *msg = error ? "Unknown error" : "No error"; + if(strlen(msg) < size) + strcpy(buf, msg); } return buf; @@ -1087,6 +1088,7 @@ static int ssl_ui_reader(UI *ui, UI_STRING *uis) UI_set_result(ui, uis, password); return 1; } + FALLTHROUGH(); default: break; } @@ -1105,6 +1107,7 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis) (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD)) { return 1; } + FALLTHROUGH(); default: break; } @@ -1522,7 +1525,7 @@ int cert_stuff(struct Curl_easy *data, case SSL_FILETYPE_PEM: if(cert_done) break; - /* FALLTHROUGH */ + FALLTHROUGH(); case SSL_FILETYPE_ASN1: cert_use_result = key_blob ? SSL_CTX_use_PrivateKey_blob(ctx, key_blob, file_type, key_passwd) : @@ -1752,7 +1755,7 @@ static int ossl_init(void) static void ossl_cleanup(void) { #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \ - !defined(LIBRESSL_VERSION_NUMBER) + (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER >= 0x2070000fL) /* OpenSSL 1.1 deprecates all these cleanup functions and turns them into no-ops in OpenSSL 1.0 compatibility mode */ #else @@ -2848,7 +2851,7 @@ ossl_set_ssl_version_min_max_legacy(ctx_option_t *ctx_options, failf(data, OSSL_PACKAGE " was built without TLS 1.3 support"); return CURLE_NOT_BUILT_IN; #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_SSLVERSION_TLSv1_2: #if OPENSSL_VERSION_NUMBER >= 0x1000100FL *ctx_options |= SSL_OP_NO_TLSv1_1; @@ -2856,7 +2859,7 @@ ossl_set_ssl_version_min_max_legacy(ctx_option_t *ctx_options, failf(data, OSSL_PACKAGE " was built without TLS 1.2 support"); return CURLE_NOT_BUILT_IN; #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_SSLVERSION_TLSv1_1: #if OPENSSL_VERSION_NUMBER >= 0x1000100FL *ctx_options |= SSL_OP_NO_TLSv1; @@ -2864,7 +2867,7 @@ ossl_set_ssl_version_min_max_legacy(ctx_option_t *ctx_options, failf(data, OSSL_PACKAGE " was built without TLS 1.1 support"); return CURLE_NOT_BUILT_IN; #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_SSLVERSION_TLSv1_0: case CURL_SSLVERSION_TLSv1: break; @@ -2875,12 +2878,12 @@ ossl_set_ssl_version_min_max_legacy(ctx_option_t *ctx_options, #if OPENSSL_VERSION_NUMBER >= 0x1000100FL *ctx_options |= SSL_OP_NO_TLSv1_1; #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_SSLVERSION_MAX_TLSv1_1: #if OPENSSL_VERSION_NUMBER >= 0x1000100FL *ctx_options |= SSL_OP_NO_TLSv1_2; #endif - /* FALLTHROUGH */ + FALLTHROUGH(); case CURL_SSLVERSION_MAX_TLSv1_2: #ifdef TLS1_3_VERSION *ctx_options |= SSL_OP_NO_TLSv1_3; @@ -3174,6 +3177,8 @@ static CURLcode populate_x509_store(struct Curl_cfilter *cf, bool imported_native_ca = false; bool imported_ca_info_blob = false; + CURL_TRC_CF(data, cf, "populate_x509_store, path=%s, blob=%d", + ssl_cafile? ssl_cafile : "none", !!ca_info_blob); if(!store) return CURLE_OUT_OF_MEMORY; @@ -4346,6 +4351,20 @@ static CURLcode servercert(struct Curl_cfilter *cf, /* don't do this after Session ID reuse */ result = verifystatus(cf, data); if(result) { + /* when verifystatus failed, remove the session id from the cache again + if present */ + if(!Curl_ssl_cf_is_proxy(cf)) { + void *old_ssl_sessionid = NULL; + bool incache; + Curl_ssl_sessionid_lock(data); + incache = !(Curl_ssl_getsessionid(cf, data, &old_ssl_sessionid, NULL)); + if(incache) { + infof(data, "Remove session ID again from cache"); + Curl_ssl_delsessionid(data, old_ssl_sessionid); + } + Curl_ssl_sessionid_unlock(data); + } + X509_free(backend->server_cert); backend->server_cert = NULL; return result; @@ -4592,10 +4611,10 @@ static ssize_t ossl_send(struct Curl_cfilter *cf, ossl_strerror(sslerror, error_buffer, sizeof(error_buffer)); else if(sockerr) Curl_strerror(sockerr, error_buffer, sizeof(error_buffer)); - else { - strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer)); - error_buffer[sizeof(error_buffer) - 1] = '\0'; - } + else + msnprintf(error_buffer, sizeof(error_buffer), "%s", + SSL_ERROR_to_str(err)); + failf(data, OSSL_PACKAGE " SSL_write: %s, errno %d", error_buffer, sockerr); *curlcode = CURLE_SEND_ERROR; @@ -4688,10 +4707,9 @@ static ssize_t ossl_recv(struct Curl_cfilter *cf, ossl_strerror(sslerror, error_buffer, sizeof(error_buffer)); else if(sockerr && err == SSL_ERROR_SYSCALL) Curl_strerror(sockerr, error_buffer, sizeof(error_buffer)); - else { - strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer)); - error_buffer[sizeof(error_buffer) - 1] = '\0'; - } + else + msnprintf(error_buffer, sizeof(error_buffer), "%s", + SSL_ERROR_to_str(err)); failf(data, OSSL_PACKAGE " SSL_read: %s, errno %d", error_buffer, sockerr); *curlcode = CURLE_RECV_ERROR; diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 8751fd981..d58970910 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -156,7 +156,7 @@ static ssize_t tls_recv_more(struct Curl_cfilter *cf, size_t errorlen; rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen); failf(data, "rustls_connection_process_new_packets: %.*s", - errorlen, errorbuf); + (int)errorlen, errorbuf); *err = map_error(rresult); return -1; } @@ -225,7 +225,7 @@ cr_recv(struct Curl_cfilter *cf, struct Curl_easy *data, char errorbuf[255]; size_t errorlen; rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen); - failf(data, "rustls_connection_read: %.*s", errorlen, errorbuf); + failf(data, "rustls_connection_read: %.*s", (int)errorlen, errorbuf); *err = CURLE_READ_ERROR; nread = -1; goto out; @@ -301,7 +301,7 @@ cr_send(struct Curl_cfilter *cf, struct Curl_easy *data, &plainwritten); if(rresult != RUSTLS_RESULT_OK) { rustls_error(rresult, errorbuf, sizeof(errorbuf), &errorlen); - failf(data, "rustls_connection_write: %.*s", errorlen, errorbuf); + failf(data, "rustls_connection_write: %.*s", (int)errorlen, errorbuf); *err = CURLE_WRITE_ERROR; return -1; } @@ -459,7 +459,7 @@ cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data, } if(result != RUSTLS_RESULT_OK) { rustls_error(result, errorbuf, sizeof(errorbuf), &errorlen); - failf(data, "rustls_client_connection_new: %.*s", errorlen, errorbuf); + failf(data, "rustls_client_connection_new: %.*s", (int)errorlen, errorbuf); return CURLE_COULDNT_CONNECT; } rustls_connection_set_userdata(rconn, backend); @@ -563,8 +563,8 @@ cr_connect_common(struct Curl_cfilter *cf, return CURLE_SSL_CONNECT_ERROR; } if(blocking && 0 == what) { - failf(data, "rustls connection timeout after %d ms", - socket_check_timeout); + failf(data, "rustls connection timeout after %" + CURL_FORMAT_TIMEDIFF_T " ms", socket_check_timeout); return CURLE_OPERATION_TIMEDOUT; } if(0 == what) { diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index ae7f2956d..45c337371 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -439,6 +439,12 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, return CURLE_OK; } #endif + +static bool algo(const char *check, char *namep, size_t nlen) +{ + return (strlen(check) == nlen) && !strncmp(check, namep, nlen); +} + static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, struct Curl_easy *data) @@ -660,7 +666,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, cert_showfilename_error); else failf(data, "schannel: Failed to import cert file %s, " - "last error is 0x%x", + "last error is 0x%lx", cert_showfilename_error, errorcode); return CURLE_SSL_CERTPROBLEM; } @@ -671,7 +677,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(!client_certs[0]) { failf(data, "schannel: Failed to get certificate from file %s" - ", last error is 0x%x", + ", last error is 0x%lx", cert_showfilename_error, GetLastError()); CertCloseStore(cert_store, 0); return CURLE_SSL_CERTPROBLEM; @@ -684,10 +690,15 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name, cert_store_path); if(!cert_store) { - failf(data, "schannel: Failed to open cert store %x %s, " - "last error is 0x%x", - cert_store_name, cert_store_path, GetLastError()); + char *path_utf8 = + curlx_convert_tchar_to_UTF8(cert_store_path); + failf(data, "schannel: Failed to open cert store %lx %s, " + "last error is 0x%lx", + cert_store_name, + (path_utf8 ? path_utf8 : "(unknown)"), + GetLastError()); free(cert_store_path); + curlx_unicodefree(path_utf8); curlx_unicodefree(cert_path); return CURLE_SSL_CERTPROBLEM; } @@ -790,9 +801,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, char *startCur = ciphers13; int algCount = 0; - char tmp[LONGEST_ALG_ID] = { 0 }; char *nameEnd; - size_t n; disable_aes_gcm_sha384 = TRUE; disable_aes_gcm_sha256 = TRUE; @@ -801,40 +810,34 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, disable_aes_ccm_sha256 = TRUE; while(startCur && (0 != *startCur) && (algCount < remaining_ciphers)) { + size_t n; + char *namep; nameEnd = strchr(startCur, ':'); n = nameEnd ? (size_t)(nameEnd - startCur) : strlen(startCur); + namep = startCur; - /* reject too-long cipher names */ - if(n > (LONGEST_ALG_ID - 1)) { - failf(data, "schannel: Cipher name too long, not checked"); - return CURLE_SSL_CIPHER; - } - - strncpy(tmp, startCur, n); - tmp[n] = 0; - - if(disable_aes_gcm_sha384 - && !strcmp("TLS_AES_256_GCM_SHA384", tmp)) { + if(disable_aes_gcm_sha384 && + algo("TLS_AES_256_GCM_SHA384", namep, n)) { disable_aes_gcm_sha384 = FALSE; } else if(disable_aes_gcm_sha256 - && !strcmp("TLS_AES_128_GCM_SHA256", tmp)) { + && algo("TLS_AES_128_GCM_SHA256", namep, n)) { disable_aes_gcm_sha256 = FALSE; } else if(disable_chacha_poly - && !strcmp("TLS_CHACHA20_POLY1305_SHA256", tmp)) { + && algo("TLS_CHACHA20_POLY1305_SHA256", namep, n)) { disable_chacha_poly = FALSE; } else if(disable_aes_ccm_8_sha256 - && !strcmp("TLS_AES_128_CCM_8_SHA256", tmp)) { + && algo("TLS_AES_128_CCM_8_SHA256", namep, n)) { disable_aes_ccm_8_sha256 = FALSE; } else if(disable_aes_ccm_sha256 - && !strcmp("TLS_AES_128_CCM_SHA256", tmp)) { + && algo("TLS_AES_128_CCM_SHA256", namep, n)) { disable_aes_ccm_sha256 = FALSE; } else { - failf(data, "schannel: Unknown TLS 1.3 cipher: %s", tmp); + failf(data, "schannel: Unknown TLS 1.3 cipher: %.*s", (int)n, namep); return CURLE_SSL_CIPHER; } @@ -1195,9 +1198,8 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) cur += proto.len; *list_len = curlx_uitous(cur - list_start_index); - *extension_len = *list_len + - (unsigned short)sizeof(unsigned int) + - (unsigned short)sizeof(unsigned short); + *extension_len = (unsigned int)(*list_len + + sizeof(unsigned int) + sizeof(unsigned short)); InitSecBuffer(&inbuf, SECBUFFER_APPLICATION_PROTOCOLS, alpn_buffer, cur); InitSecBufferDesc(&inbuf_desc, &inbuf, 1); @@ -2332,10 +2334,10 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, else { #ifndef CURL_DISABLE_VERBOSE_STRINGS char buffer[STRERROR_LEN]; -#endif - *err = CURLE_RECV_ERROR; infof(data, "schannel: failed to read data from server: %s", Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer))); +#endif + *err = CURLE_RECV_ERROR; goto cleanup; } } diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index e7c8bc66b..24146d0bd 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -172,7 +172,7 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store, /* Sanity check that the cert_context object is the right type */ if(CERT_QUERY_CONTENT_CERT != actual_content_type) { failf(data, - "schannel: unexpected content type '%d' when extracting " + "schannel: unexpected content type '%lu' when extracting " "certificate from CA file '%s'", actual_content_type, ca_file_text); result = CURLE_SSL_CACERT_BADFILE; @@ -753,7 +753,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf, failf(data, "schannel: CertGetCertificateChain trust error" " CERT_TRUST_REVOCATION_STATUS_UNKNOWN"); else - failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x", + failf(data, "schannel: CertGetCertificateChain error mask: 0x%08lx", dwTrustErrorMask); result = CURLE_PEER_FAILED_VERIFICATION; } diff --git a/lib/vtls/sectransp.c b/lib/vtls/sectransp.c index 0a22ff60b..1f37305ce 100644 --- a/lib/vtls/sectransp.c +++ b/lib/vtls/sectransp.c @@ -906,7 +906,6 @@ static OSStatus sectransp_bio_cf_out_write(SSLConnectionRef connection, return rtn; } -#ifndef CURL_DISABLE_VERBOSE_STRINGS CF_INLINE const char *TLSCipherNameForNumber(SSLCipherSuite cipher) { /* The first ciphers in the ciphertable are continuous. Here we do small @@ -925,7 +924,6 @@ CF_INLINE const char *TLSCipherNameForNumber(SSLCipherSuite cipher) } return ciphertable[SSL_NULL_WITH_NULL_NULL].name; } -#endif /* !CURL_DISABLE_VERBOSE_STRINGS */ #if CURL_BUILD_MAC CF_INLINE void GetDarwinVersionNumber(int *major, int *minor) @@ -2369,19 +2367,15 @@ static CURLcode verify_cert(struct Curl_cfilter *cf, const struct curl_blob *ca_info_blob, SSLContextRef ctx) { - int result; + CURLcode result; unsigned char *certbuf; size_t buflen; + bool free_certbuf = FALSE; if(ca_info_blob) { CURL_TRC_CF(data, cf, "verify_peer, CA from config blob"); - certbuf = (unsigned char *)malloc(ca_info_blob->len + 1); - if(!certbuf) { - return CURLE_OUT_OF_MEMORY; - } + certbuf = ca_info_blob->data; buflen = ca_info_blob->len; - memcpy(certbuf, ca_info_blob->data, ca_info_blob->len); - certbuf[ca_info_blob->len]='\0'; } else if(cafile) { CURL_TRC_CF(data, cf, "verify_peer, CA from file '%s'", cafile); @@ -2389,12 +2383,14 @@ static CURLcode verify_cert(struct Curl_cfilter *cf, failf(data, "SSL: failed to read or invalid CA certificate"); return CURLE_SSL_CACERT_BADFILE; } + free_certbuf = TRUE; } else return CURLE_SSL_CACERT_BADFILE; result = verify_cert_buf(cf, data, certbuf, buflen, ctx); - free(certbuf); + if(free_certbuf) + free(certbuf); return result; } diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 34eda3e5a..e928ba5d0 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -883,28 +883,21 @@ CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data, size_t valuelen) { struct curl_certinfo *ci = &data->info.certs; - char *output; struct curl_slist *nl; CURLcode result = CURLE_OK; - size_t labellen = strlen(label); - size_t outlen = labellen + 1 + valuelen + 1; /* label:value\0 */ + struct dynbuf build; - output = malloc(outlen); - if(!output) - return CURLE_OUT_OF_MEMORY; - - /* sprintf the label and colon */ - msnprintf(output, outlen, "%s:", label); + Curl_dyn_init(&build, 10000); - /* memcpy the value (it might not be null-terminated) */ - memcpy(&output[labellen + 1], value, valuelen); - - /* null-terminate the output */ - output[labellen + 1 + valuelen] = 0; + if(Curl_dyn_add(&build, label) || + Curl_dyn_addn(&build, ":", 1) || + Curl_dyn_addn(&build, value, valuelen)) + return CURLE_OUT_OF_MEMORY; - nl = Curl_slist_append_nodup(ci->certinfo[certnum], output); + nl = Curl_slist_append_nodup(ci->certinfo[certnum], + Curl_dyn_ptr(&build)); if(!nl) { - free(output); + Curl_dyn_free(&build); curl_slist_free_all(ci->certinfo[certnum]); result = CURLE_OUT_OF_MEMORY; } @@ -1002,7 +995,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, /* only do this if pinnedpubkey starts with "sha256//", length 8 */ if(strncmp(pinnedpubkey, "sha256//", 8) == 0) { CURLcode encode; - size_t encodedlen = 0, pinkeylen; + size_t encodedlen = 0; char *encoded = NULL, *pinkeycopy, *begin_pos, *end_pos; unsigned char *sha256sumdigest; @@ -1030,13 +1023,11 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, infof(data, " public key hash: sha256//%s", encoded); /* it starts with sha256//, copy so we can modify it */ - pinkeylen = strlen(pinnedpubkey) + 1; - pinkeycopy = malloc(pinkeylen); + pinkeycopy = strdup(pinnedpubkey); if(!pinkeycopy) { Curl_safefree(encoded); return CURLE_OUT_OF_MEMORY; } - memcpy(pinkeycopy, pinnedpubkey, pinkeylen); /* point begin_pos to the copy, and start extracting keys */ begin_pos = pinkeycopy; do { @@ -1422,17 +1413,13 @@ static size_t multissl_version(char *buffer, size_t size) backends_len = p - backends; } - if(!size) - return 0; - - if(size <= backends_len) { - strncpy(buffer, backends, size - 1); - buffer[size - 1] = '\0'; - return size - 1; + if(size) { + if(backends_len < size) + strcpy(buffer, backends); + else + *buffer = 0; /* did not fit */ } - - strcpy(buffer, backends); - return backends_len; + return 0; } static int multissl_setup(const struct Curl_ssl *backend) @@ -1728,18 +1715,34 @@ static ssize_t ssl_cf_recv(struct Curl_cfilter *cf, { struct cf_call_data save; ssize_t nread; + size_t ntotal = 0; CF_DATA_SAVE(save, cf, data); *err = CURLE_OK; - nread = Curl_ssl->recv_plain(cf, data, buf, len, err); - if(nread > 0) { - DEBUGASSERT((size_t)nread <= len); - } - else if(nread == 0) { - /* eof */ + /* Do receive until we fill the buffer somehwhat or EGAIN, error or EOF */ + while(!ntotal || (len - ntotal) > (4*1024)) { *err = CURLE_OK; + nread = Curl_ssl->recv_plain(cf, data, buf + ntotal, len - ntotal, err); + if(nread < 0) { + if(*err == CURLE_AGAIN && ntotal > 0) { + /* we EAGAINed after having reed data, return the success amount */ + *err = CURLE_OK; + break; + } + /* we have a an error to report */ + goto out; + } + else if(nread == 0) { + /* eof */ + break; + } + ntotal += (size_t)nread; + DEBUGASSERT((size_t)ntotal <= len); } - CURL_TRC_CF(data, cf, "cf_recv(len=%zu) -> %zd, %d", len, nread, *err); + nread = (ssize_t)ntotal; +out: + CURL_TRC_CF(data, cf, "cf_recv(len=%zu) -> %zd, %d", len, + nread, *err); CF_DATA_RESTORE(cf, save); return nread; } @@ -1855,6 +1858,8 @@ struct Curl_cftype Curl_cft_ssl = { ssl_cf_query, }; +#ifndef CURL_DISABLE_PROXY + struct Curl_cftype Curl_cft_ssl_proxy = { "SSL-PROXY", CF_TYPE_SSL, @@ -1873,6 +1878,8 @@ struct Curl_cftype Curl_cft_ssl_proxy = { Curl_cf_def_query, }; +#endif /* !CURL_DISABLE_PROXY */ + static CURLcode cf_ssl_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn) @@ -1980,8 +1987,12 @@ bool Curl_ssl_supports(struct Curl_easy *data, int option) static struct Curl_cfilter *get_ssl_filter(struct Curl_cfilter *cf) { for(; cf; cf = cf->next) { - if(cf->cft == &Curl_cft_ssl || cf->cft == &Curl_cft_ssl_proxy) + if(cf->cft == &Curl_cft_ssl) + return cf; +#ifndef CURL_DISABLE_PROXY + if(cf->cft == &Curl_cft_ssl_proxy) return cf; +#endif } return NULL; } @@ -2027,7 +2038,12 @@ CURLcode Curl_ssl_cfilter_remove(struct Curl_easy *data, bool Curl_ssl_cf_is_proxy(struct Curl_cfilter *cf) { +#ifndef CURL_DISABLE_PROXY return (cf->cft == &Curl_cft_ssl_proxy); +#else + (void)cf; + return FALSE; +#endif } struct ssl_config_data * diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index f1856bd33..744bbf8fd 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -228,7 +228,9 @@ struct ssl_primary_config * Curl_ssl_cf_get_primary_config(struct Curl_cfilter *cf); extern struct Curl_cftype Curl_cft_ssl; +#ifndef CURL_DISABLE_PROXY extern struct Curl_cftype Curl_cft_ssl_proxy; +#endif #else /* if not USE_SSL */ diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index 5890bb609..a3c017cea 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -583,12 +583,25 @@ wolfssl_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) if(ssl_config->primary.clientcert && ssl_config->key) { int file_type = do_file_type(ssl_config->cert_type); - if(wolfSSL_CTX_use_certificate_file(backend->ctx, - ssl_config->primary.clientcert, - file_type) != 1) { - failf(data, "unable to use client certificate (no key or wrong pass" - " phrase?)"); - return CURLE_SSL_CONNECT_ERROR; + if(file_type == WOLFSSL_FILETYPE_PEM) { + if(wolfSSL_CTX_use_certificate_chain_file(backend->ctx, + ssl_config->primary.clientcert) + != 1) { + failf(data, "unable to use client certificate"); + return CURLE_SSL_CONNECT_ERROR; + } + } + else if(file_type == WOLFSSL_FILETYPE_ASN1) { + if(wolfSSL_CTX_use_certificate_file(backend->ctx, + ssl_config->primary.clientcert, + file_type) != 1) { + failf(data, "unable to use client certificate"); + return CURLE_SSL_CONNECT_ERROR; + } + } + else { + failf(data, "unknown cert type"); + return CURLE_BAD_FUNCTION_ARGUMENT; } file_type = do_file_type(ssl_config->key_type); @@ -1084,9 +1097,7 @@ static ssize_t wolfssl_recv(struct Curl_cfilter *cf, *curlcode = CURLE_OK; return 0; case SSL_ERROR_NONE: - /* FALLTHROUGH */ case SSL_ERROR_WANT_READ: - /* FALLTHROUGH */ case SSL_ERROR_WANT_WRITE: /* there's data pending, re-invoke wolfSSL_read() */ CURL_TRC_CF(data, cf, "wolfssl_recv(len=%zu) -> AGAIN", blen); diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index 8b1eed63f..da079361d 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -97,6 +97,11 @@ #define CURL_ASN1_CHARACTER_STRING 29 #define CURL_ASN1_BMP_STRING 30 +/* Max sixes */ + +#define MAX_X509_STR 10000 +#define MAX_X509_CERT 100000 + #ifdef WANT_EXTRACT_CERTINFO /* ASN.1 OID table entry. */ struct Curl_OID { @@ -255,61 +260,61 @@ static const struct Curl_OID *searchOID(const char *oid) } /* - * Convert an ASN.1 Boolean value into its string representation. Return the - * dynamically allocated string, or NULL if source is not an ASN.1 Boolean - * value. + * Convert an ASN.1 Boolean value into its string representation. + * + * Return error code. */ -static const char *bool2str(const char *beg, const char *end) +static CURLcode bool2str(struct dynbuf *store, + const char *beg, const char *end) { if(end - beg != 1) - return NULL; - return strdup(*beg? "TRUE": "FALSE"); + return CURLE_BAD_FUNCTION_ARGUMENT; + return Curl_dyn_add(store, *beg? "TRUE": "FALSE"); } /* * Convert an ASN.1 octet string to a printable string. - * Return the dynamically allocated string, or NULL if an error occurs. + * + * Return error code. */ -static const char *octet2str(const char *beg, const char *end) +static CURLcode octet2str(struct dynbuf *store, + const char *beg, const char *end) { - struct dynbuf buf; - CURLcode result; - - Curl_dyn_init(&buf, 3 * CURL_ASN1_MAX + 1); - result = Curl_dyn_addn(&buf, "", 0); + CURLcode result = CURLE_OK; while(!result && beg < end) - result = Curl_dyn_addf(&buf, "%02x:", (unsigned char) *beg++); + result = Curl_dyn_addf(store, "%02x:", (unsigned char) *beg++); - return Curl_dyn_ptr(&buf); + return result; } -static const char *bit2str(const char *beg, const char *end) +static CURLcode bit2str(struct dynbuf *store, + const char *beg, const char *end) { - /* Convert an ASN.1 bit string to a printable string. - Return the dynamically allocated string, or NULL if an error occurs. */ + /* Convert an ASN.1 bit string to a printable string. */ if(++beg > end) - return NULL; - return octet2str(beg, end); + return CURLE_BAD_FUNCTION_ARGUMENT; + return octet2str(store, beg, end); } /* * Convert an ASN.1 integer value into its string representation. - * Return the dynamically allocated string, or NULL if source is not an - * ASN.1 integer value. + * + * Returns error. */ -static const char *int2str(const char *beg, const char *end) +static CURLcode int2str(struct dynbuf *store, + const char *beg, const char *end) { unsigned int val = 0; size_t n = end - beg; if(!n) - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; if(n > 4) - return octet2str(beg, end); + return octet2str(store, beg, end); /* Represent integers <= 32-bit as a single value. */ if(*beg & 0x80) @@ -318,25 +323,24 @@ static const char *int2str(const char *beg, const char *end) do val = (val << 8) | *(const unsigned char *) beg++; while(beg < end); - return curl_maprintf("%s%x", val >= 10? "0x": "", val); + return Curl_dyn_addf(store, "%s%x", val >= 10? "0x": "", val); } /* - * Perform a lazy conversion from an ASN.1 typed string to UTF8. Allocate the - * destination buffer dynamically. The allocation size will normally be too - * large: this is to avoid buffer overflows. - * Terminate the string with a nul byte and return the converted - * string length. + * Convert from an ASN.1 typed string to UTF8. + * + * The result is stored in a dynbuf that is inited by the user of this + * function. + * + * Returns error. */ -static ssize_t -utf8asn1str(char **to, int type, const char *from, const char *end) +static CURLcode +utf8asn1str(struct dynbuf *to, int type, const char *from, const char *end) { size_t inlength = end - from; int size = 1; - size_t outlength; - char *buf; + CURLcode result = CURLE_OK; - *to = NULL; switch(type) { case CURL_ASN1_BMP_STRING: size = 2; @@ -352,133 +356,85 @@ utf8asn1str(char **to, int type, const char *from, const char *end) case CURL_ASN1_UTF8_STRING: break; default: - return -1; /* Conversion not supported. */ + return CURLE_BAD_FUNCTION_ARGUMENT; /* Conversion not supported. */ } if(inlength % size) - return -1; /* Length inconsistent with character size. */ - if(inlength / size > (SIZE_T_MAX - 1) / 4) - return -1; /* Too big. */ - buf = malloc(4 * (inlength / size) + 1); - if(!buf) - return -1; /* Not enough memory. */ + /* Length inconsistent with character size. */ + return CURLE_BAD_FUNCTION_ARGUMENT; if(type == CURL_ASN1_UTF8_STRING) { /* Just copy. */ - outlength = inlength; - if(outlength) - memcpy(buf, from, outlength); + if(inlength) + result = Curl_dyn_addn(to, from, inlength); } else { - for(outlength = 0; from < end;) { - int charsize; - unsigned int wc; + while(!result && (from < end)) { + char buf[4]; /* decode buffer */ + int charsize = 1; + unsigned int wc = 0; - wc = 0; switch(size) { case 4: wc = (wc << 8) | *(const unsigned char *) from++; wc = (wc << 8) | *(const unsigned char *) from++; - /* FALLTHROUGH */ + FALLTHROUGH(); case 2: wc = (wc << 8) | *(const unsigned char *) from++; - /* FALLTHROUGH */ + FALLTHROUGH(); default: /* case 1: */ wc = (wc << 8) | *(const unsigned char *) from++; } - charsize = 1; if(wc >= 0x00000080) { if(wc >= 0x00000800) { if(wc >= 0x00010000) { if(wc >= 0x00200000) { free(buf); - return -1; /* Invalid char. size for target encoding. */ + /* Invalid char. size for target encoding. */ + return CURLE_WEIRD_SERVER_REPLY; } - buf[outlength + 3] = (char) (0x80 | (wc & 0x3F)); + buf[3] = (char) (0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x00010000; charsize++; } - buf[outlength + 2] = (char) (0x80 | (wc & 0x3F)); + buf[2] = (char) (0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x00000800; charsize++; } - buf[outlength + 1] = (char) (0x80 | (wc & 0x3F)); + buf[1] = (char) (0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x000000C0; charsize++; } - buf[outlength] = (char) wc; - outlength += charsize; + buf[0] = (char) wc; + result = Curl_dyn_addn(to, buf, charsize); } } - buf[outlength] = '\0'; - *to = buf; - return outlength; -} - -/* - * Convert an ASN.1 String into its UTF-8 string representation. - * Return the dynamically allocated string, or NULL if an error occurs. - */ -static const char *string2str(int type, const char *beg, const char *end) -{ - char *buf; - if(utf8asn1str(&buf, type, beg, end) < 0) - return NULL; - return buf; -} - -/* - * Decimal ASCII encode unsigned integer `x' into the buflen sized buffer at - * buf. Return the total number of encoded digits, even if larger than - * `buflen'. - */ -static size_t encodeUint(char *buf, size_t buflen, unsigned int x) -{ - size_t i = 0; - unsigned int y = x / 10; - - if(y) { - i = encodeUint(buf, buflen, y); - x -= y * 10; - } - if(i < buflen) - buf[i] = (char) ('0' + x); - i++; - if(i < buflen) - buf[i] = '\0'; /* Store a terminator if possible. */ - return i; + return result; } /* * Convert an ASN.1 OID into its dotted string representation. - * Store the result in th `n'-byte buffer at `buf'. - * Return the converted string length, or 0 on errors. + * + * Return error code. */ -static size_t encodeOID(char *buf, size_t buflen, - const char *beg, const char *end) +static CURLcode encodeOID(struct dynbuf *store, + const char *beg, const char *end) { - size_t i; unsigned int x; unsigned int y; + CURLcode result = CURLE_OK; /* Process the first two numbers. */ y = *(const unsigned char *) beg++; x = y / 40; y -= x * 40; - i = encodeUint(buf, buflen, x); - if(i < buflen) - buf[i] = '.'; - i++; - if(i >= buflen) - i += encodeUint(NULL, 0, y); - else - i += encodeUint(buf + i, buflen - i, y); + + result = Curl_dyn_addf(store, "%u.%u", x, y); + if(result) + return result; /* Process the trailing numbers. */ while(beg < end) { - if(i < buflen) - buf[i] = '.'; - i++; x = 0; do { if(x & 0xFF000000) @@ -486,46 +442,42 @@ static size_t encodeOID(char *buf, size_t buflen, y = *(const unsigned char *) beg++; x = (x << 7) | (y & 0x7F); } while(y & 0x80); - if(i >= buflen) - i += encodeUint(NULL, 0, x); - else - i += encodeUint(buf + i, buflen - i, x); + result = Curl_dyn_addf(store, ".%u", x); } - if(i < buflen) - buf[i] = '\0'; - return i; + return result; } /* * Convert an ASN.1 OID into its dotted or symbolic string representation. - * Return the dynamically allocated string, or NULL if an error occurs. + * + * Return error code. */ -static const char *OID2str(const char *beg, const char *end, bool symbolic) +static CURLcode OID2str(struct dynbuf *store, + const char *beg, const char *end, bool symbolic) { - char *buf = NULL; + CURLcode result = CURLE_OK; if(beg < end) { - size_t buflen = encodeOID(NULL, 0, beg, end); - if(buflen) { - buf = malloc(buflen + 1); /* one extra for the zero byte */ - if(buf) { - encodeOID(buf, buflen, beg, end); - buf[buflen] = '\0'; - - if(symbolic) { - const struct Curl_OID *op = searchOID(buf); - if(op) { - free(buf); - buf = strdup(op->textoid); - } - } + if(symbolic) { + struct dynbuf buf; + Curl_dyn_init(&buf, MAX_X509_STR); + result = encodeOID(&buf, beg, end); + + if(!result) { + const struct Curl_OID *op = searchOID(Curl_dyn_ptr(&buf)); + if(op) + result = Curl_dyn_add(store, op->textoid); + Curl_dyn_free(&buf); } } + else + result = encodeOID(store, beg, end); } - return buf; + return result; } -static const char *GTime2str(const char *beg, const char *end) +static CURLcode GTime2str(struct dynbuf *store, + const char *beg, const char *end) { const char *tzp; const char *fracp; @@ -548,12 +500,12 @@ static const char *GTime2str(const char *beg, const char *end) break; case 2: sec1 = fracp[-2]; - /* FALLTHROUGH */ + FALLTHROUGH(); case 1: sec2 = fracp[-1]; break; default: - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; } /* Scan for timezone, measure fractional seconds. */ @@ -582,7 +534,8 @@ static const char *GTime2str(const char *beg, const char *end) } tzl = end - tzp; - return curl_maprintf("%.4s-%.2s-%.2s %.2s:%.2s:%c%c%s%.*s%s%.*s", + return Curl_dyn_addf(store, + "%.4s-%.2s-%.2s %.2s:%.2s:%c%c%s%.*s%s%.*s", beg, beg + 4, beg + 6, beg + 8, beg + 10, sec1, sec2, fracl? ".": "", (int)fracl, fracp, @@ -590,10 +543,12 @@ static const char *GTime2str(const char *beg, const char *end) } /* - * Convert an ASN.1 UTC time to a printable string. - * Return the dynamically allocated string, or NULL if an error occurs. + * Convert an ASN.1 UTC time to a printable string. + * + * Return error code. */ -static const char *UTime2str(const char *beg, const char *end) +static CURLcode UTime2str(struct dynbuf *store, + const char *beg, const char *end) { const char *tzp; size_t tzl; @@ -606,15 +561,16 @@ static const char *UTime2str(const char *beg, const char *end) switch(tzp - sec) { case 0: sec = "00"; + FALLTHROUGH(); case 2: break; default: - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; } /* Process timezone. */ if(tzp >= end) - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; if(*tzp == 'Z') { tzp = "GMT"; end = tzp + 3; @@ -623,7 +579,7 @@ static const char *UTime2str(const char *beg, const char *end) tzp++; tzl = end - tzp; - return curl_maprintf("%u%.2s-%.2s-%.2s %.2s:%.2s:%.2s %.*s", + return Curl_dyn_addf(store, "%u%.2s-%.2s-%.2s %.2s:%.2s:%.2s %.*s", 20 - (*beg >= '5'), beg, beg + 2, beg + 4, beg + 6, beg + 8, sec, (int)tzl, tzp); @@ -631,34 +587,45 @@ static const char *UTime2str(const char *beg, const char *end) /* * Convert an ASN.1 element to a printable string. - * Return the dynamically allocated string, or NULL if an error occurs. + * + * Return error */ -static const char *ASN1tostr(struct Curl_asn1Element *elem, int type) +static CURLcode ASN1tostr(struct dynbuf *store, + struct Curl_asn1Element *elem, int type) { + CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT; if(elem->constructed) - return NULL; /* No conversion of structured elements. */ + return CURLE_OK; /* No conversion of structured elements. */ if(!type) type = elem->tag; /* Type not forced: use element tag as type. */ switch(type) { case CURL_ASN1_BOOLEAN: - return bool2str(elem->beg, elem->end); + result = bool2str(store, elem->beg, elem->end); + break; case CURL_ASN1_INTEGER: case CURL_ASN1_ENUMERATED: - return int2str(elem->beg, elem->end); + result = int2str(store, elem->beg, elem->end); + break; case CURL_ASN1_BIT_STRING: - return bit2str(elem->beg, elem->end); + result = bit2str(store, elem->beg, elem->end); + break; case CURL_ASN1_OCTET_STRING: - return octet2str(elem->beg, elem->end); + result = octet2str(store, elem->beg, elem->end); + break; case CURL_ASN1_NULL: - return strdup(""); + result = Curl_dyn_addn(store, "", 1); + break; case CURL_ASN1_OBJECT_IDENTIFIER: - return OID2str(elem->beg, elem->end, TRUE); + result = OID2str(store, elem->beg, elem->end, TRUE); + break; case CURL_ASN1_UTC_TIME: - return UTime2str(elem->beg, elem->end); + result = UTime2str(store, elem->beg, elem->end); + break; case CURL_ASN1_GENERALIZED_TIME: - return GTime2str(elem->beg, elem->end); + result = GTime2str(store, elem->beg, elem->end); + break; case CURL_ASN1_UTF8_STRING: case CURL_ASN1_NUMERIC_STRING: case CURL_ASN1_PRINTABLE_STRING: @@ -667,87 +634,96 @@ static const char *ASN1tostr(struct Curl_asn1Element *elem, int type) case CURL_ASN1_VISIBLE_STRING: case CURL_ASN1_UNIVERSAL_STRING: case CURL_ASN1_BMP_STRING: - return string2str(type, elem->beg, elem->end); + result = utf8asn1str(store, type, elem->beg, elem->end); + break; } - return NULL; /* Unsupported. */ + return result; } /* - * ASCII encode distinguished name at `dn' into the `buflen'-sized buffer at - * `buf'. + * ASCII encode distinguished name at `dn' into the store dynbuf. * - * Returns the total string length, even if larger than `buflen' or -1 on - * error. + * Returns error. */ -static ssize_t encodeDN(char *buf, size_t buflen, struct Curl_asn1Element *dn) +static CURLcode encodeDN(struct dynbuf *store, struct Curl_asn1Element *dn) { struct Curl_asn1Element rdn; struct Curl_asn1Element atv; struct Curl_asn1Element oid; struct Curl_asn1Element value; - size_t l = 0; const char *p1; const char *p2; const char *p3; const char *str; + CURLcode result = CURLE_OK; + bool added = FALSE; + struct dynbuf temp; + Curl_dyn_init(&temp, MAX_X509_STR); for(p1 = dn->beg; p1 < dn->end;) { p1 = getASN1Element(&rdn, p1, dn->end); - if(!p1) - return -1; + if(!p1) { + result = CURLE_BAD_FUNCTION_ARGUMENT; + goto error; + } for(p2 = rdn.beg; p2 < rdn.end;) { p2 = getASN1Element(&atv, p2, rdn.end); - if(!p2) - return -1; + if(!p2) { + result = CURLE_BAD_FUNCTION_ARGUMENT; + goto error; + } p3 = getASN1Element(&oid, atv.beg, atv.end); - if(!p3) - return -1; - if(!getASN1Element(&value, p3, atv.end)) - return -1; - str = ASN1tostr(&oid, 0); - if(!str) - return -1; + if(!p3) { + result = CURLE_BAD_FUNCTION_ARGUMENT; + goto error; + } + if(!getASN1Element(&value, p3, atv.end)) { + result = CURLE_BAD_FUNCTION_ARGUMENT; + goto error; + } + Curl_dyn_reset(&temp); + result = ASN1tostr(&temp, &oid, 0); + if(result) + goto error; + + str = Curl_dyn_ptr(&temp); /* Encode delimiter. If attribute has a short uppercase name, delimiter is ", ". */ - if(l) { - for(p3 = str; ISUPPER(*p3); p3++) - ; - for(p3 = (*p3 || p3 - str > 2)? "/": ", "; *p3; p3++) { - if(l < buflen) - buf[l] = *p3; - l++; - } + for(p3 = str; ISUPPER(*p3); p3++) + ; + if(added) { + if(p3 - str > 2) + result = Curl_dyn_addn(store, "/", 1); + else + result = Curl_dyn_addn(store, ", ", 2); + if(result) + goto error; } /* Encode attribute name. */ - for(p3 = str; *p3; p3++) { - if(l < buflen) - buf[l] = *p3; - l++; - } - free((char *) str); + result = Curl_dyn_add(store, str); + if(result) + goto error; /* Generate equal sign. */ - if(l < buflen) - buf[l] = '='; - l++; + result = Curl_dyn_addn(store, "=", 1); + if(result) + goto error; /* Generate value. */ - str = ASN1tostr(&value, 0); - if(!str) - return -1; - for(p3 = str; *p3; p3++) { - if(l < buflen) - buf[l] = *p3; - l++; - } - free((char *) str); + result = ASN1tostr(store, &value, 0); + if(result) + goto error; + Curl_dyn_reset(&temp); + added = TRUE; /* use separator for next */ } } +error: + Curl_dyn_free(&temp); - return l; + return result; } #endif /* WANT_EXTRACT_CERTINFO */ @@ -876,25 +852,9 @@ int Curl_parseX509(struct Curl_X509certificate *cert, #ifdef WANT_EXTRACT_CERTINFO -/* - * Copy at most 64-characters, terminate with a newline and returns the - * effective number of stored characters. - */ -static size_t copySubstring(char *to, const char *from) -{ - size_t i; - for(i = 0; i < 64; i++) { - to[i] = *from; - if(!*from++) - break; - } - - to[i++] = '\n'; - return i; -} - -static const char *dumpAlgo(struct Curl_asn1Element *param, - const char *beg, const char *end) +static CURLcode dumpAlgo(struct dynbuf *store, + struct Curl_asn1Element *param, + const char *beg, const char *end) { struct Curl_asn1Element oid; @@ -902,14 +862,16 @@ static const char *dumpAlgo(struct Curl_asn1Element *param, beg = getASN1Element(&oid, beg, end); if(!beg) - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; param->header = NULL; param->tag = 0; param->beg = param->end = end; - if(beg < end) - if(!getASN1Element(param, beg, end)) - return NULL; - return OID2str(oid.beg, oid.end, TRUE); + if(beg < end) { + const char *p = getASN1Element(param, beg, end); + if(!p) + return CURLE_BAD_FUNCTION_ARGUMENT; + } + return OID2str(store, oid.beg, oid.end, TRUE); } /* @@ -926,24 +888,47 @@ static CURLcode ssl_push_certinfo(struct Curl_easy *data, return Curl_ssl_push_certinfo_len(data, certnum, label, value, valuelen); } -/* return 0 on success, 1 on error */ -static int do_pubkey_field(struct Curl_easy *data, int certnum, - const char *label, struct Curl_asn1Element *elem) +/* + * This is a convenience function for push_certinfo_len that takes a + * dynbuf value. + * + * It also does the verbose output if !certnum. + */ +static CURLcode ssl_push_certinfo_dyn(struct Curl_easy *data, + int certnum, + const char *label, + struct dynbuf *ptr) { - const char *output; - CURLcode result = CURLE_OK; + size_t valuelen = Curl_dyn_len(ptr); + char *value = Curl_dyn_ptr(ptr); + + CURLcode result = Curl_ssl_push_certinfo_len(data, certnum, label, + value, valuelen); + + if(!certnum && !result) + infof(data, " %s: %s", label, value); + + return result; +} + +static CURLcode do_pubkey_field(struct Curl_easy *data, int certnum, + const char *label, + struct Curl_asn1Element *elem) +{ + CURLcode result; + struct dynbuf out; + + Curl_dyn_init(&out, MAX_X509_STR); /* Generate a certificate information record for the public key. */ - output = ASN1tostr(elem, 0); - if(output) { + result = ASN1tostr(&out, elem, 0); + if(!result) { if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, label, output); - if(!certnum && !result) - infof(data, " %s: %s", label, output); - free((char *) output); + result = ssl_push_certinfo_dyn(data, certnum, label, &out); + Curl_dyn_free(&out); } - return result ? 1 : 0; + return result; } /* return 0 on success, 1 on error */ @@ -964,7 +949,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum, */ const size_t len = ((pubkey->end - pubkey->beg - 2) * 4); if(!certnum) - infof(data, " ECC Public Key (%lu bits)", len); + infof(data, " ECC Public Key (%zu bits)", len); if(data->set.ssl.certinfo) { char q[sizeof(len) * 8 / 3 + 1]; (void)msnprintf(q, sizeof(q), "%zu", len); @@ -998,7 +983,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum, if(len > 32) elem.beg = q; /* Strip leading zero bytes. */ if(!certnum) - infof(data, " RSA Public Key (%lu bits)", len); + infof(data, " RSA Public Key (%zu bits)", len); if(data->set.ssl.certinfo) { char r[sizeof(len) * 8 / 3 + 1]; msnprintf(r, sizeof(r), "%zu", len); @@ -1049,24 +1034,12 @@ static int do_pubkey(struct Curl_easy *data, int certnum, /* * Convert an ASN.1 distinguished name into a printable string. - * Return the dynamically allocated string, or NULL if an error occurs. + * Return error. */ -static const char *DNtostr(struct Curl_asn1Element *dn) +static CURLcode DNtostr(struct dynbuf *store, + struct Curl_asn1Element *dn) { - char *buf = NULL; - ssize_t buflen = encodeDN(NULL, 0, dn); - - if(buflen >= 0) { - buf = malloc(buflen + 1); - if(buf) { - if(encodeDN(buf, buflen + 1, dn) == -1) { - free(buf); - return NULL; - } - buf[buflen] = '\0'; - } - } - return buf; + return encodeDN(store, dn); } CURLcode Curl_extract_certinfo(struct Curl_easy *data, @@ -1076,19 +1049,19 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, { struct Curl_X509certificate cert; struct Curl_asn1Element param; - const char *ccp; - char *cp1; - size_t cl1; - char *cp2; + char *certptr; + size_t clen; + struct dynbuf out; CURLcode result = CURLE_OK; unsigned int version; - size_t i; - size_t j; + const char *ptr; + int rc; if(!data->set.ssl.certinfo) if(certnum) return CURLE_OK; + Curl_dyn_init(&out, MAX_X509_STR); /* Prepare the certificate information for curl_easy_getinfo(). */ /* Extract the certificate ASN.1 elements. */ @@ -1096,135 +1069,126 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, return CURLE_PEER_FAILED_VERIFICATION; /* Subject. */ - ccp = DNtostr(&cert.subject); - if(!ccp) - return CURLE_OUT_OF_MEMORY; + result = DNtostr(&out, &cert.subject); + if(result) + goto done; if(data->set.ssl.certinfo) { - result = ssl_push_certinfo(data, certnum, "Subject", ccp); + result = ssl_push_certinfo_dyn(data, certnum, "Subject", &out); if(result) - return result; + goto done; } - if(!certnum) - infof(data, "%2d Subject: %s", certnum, ccp); - free((char *) ccp); + Curl_dyn_reset(&out); /* Issuer. */ - ccp = DNtostr(&cert.issuer); - if(!ccp) - return CURLE_OUT_OF_MEMORY; + result = DNtostr(&out, &cert.issuer); + if(result) + goto done; if(data->set.ssl.certinfo) { - result = ssl_push_certinfo(data, certnum, "Issuer", ccp); + result = ssl_push_certinfo_dyn(data, certnum, "Issuer", &out); + if(result) + goto done; } - if(!certnum) - infof(data, " Issuer: %s", ccp); - free((char *) ccp); - if(result) - return result; + Curl_dyn_reset(&out); /* Version (always fits in less than 32 bits). */ version = 0; - for(ccp = cert.version.beg; ccp < cert.version.end; ccp++) - version = (version << 8) | *(const unsigned char *) ccp; + for(ptr = cert.version.beg; ptr < cert.version.end; ptr++) + version = (version << 8) | *(const unsigned char *) ptr; if(data->set.ssl.certinfo) { - ccp = curl_maprintf("%x", version); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - result = ssl_push_certinfo(data, certnum, "Version", ccp); - free((char *) ccp); + result = Curl_dyn_addf(&out, "%x", version); + if(result) + goto done; + result = ssl_push_certinfo_dyn(data, certnum, "Version", &out); if(result) - return result; + goto done; + Curl_dyn_reset(&out); } - if(!certnum) - infof(data, " Version: %u (0x%x)", version + 1, version); /* Serial number. */ - ccp = ASN1tostr(&cert.serialNumber, 0); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Serial Number", ccp); - if(!certnum) - infof(data, " Serial Number: %s", ccp); - free((char *) ccp); + result = ASN1tostr(&out, &cert.serialNumber, 0); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Serial Number", &out); + if(result) + goto done; + } + Curl_dyn_reset(&out); /* Signature algorithm .*/ - ccp = dumpAlgo(¶m, cert.signatureAlgorithm.beg, - cert.signatureAlgorithm.end); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Signature Algorithm", ccp); - if(!certnum) - infof(data, " Signature Algorithm: %s", ccp); - free((char *) ccp); + result = dumpAlgo(&out, ¶m, cert.signatureAlgorithm.beg, + cert.signatureAlgorithm.end); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Signature Algorithm", + &out); + if(result) + goto done; + } + Curl_dyn_reset(&out); /* Start Date. */ - ccp = ASN1tostr(&cert.notBefore, 0); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Start Date", ccp); - if(!certnum) - infof(data, " Start Date: %s", ccp); - free((char *) ccp); + result = ASN1tostr(&out, &cert.notBefore, 0); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Start Date", &out); + if(result) + goto done; + } + Curl_dyn_reset(&out); /* Expire Date. */ - ccp = ASN1tostr(&cert.notAfter, 0); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Expire Date", ccp); - if(!certnum) - infof(data, " Expire Date: %s", ccp); - free((char *) ccp); + result = ASN1tostr(&out, &cert.notAfter, 0); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Expire Date", &out); + if(result) + goto done; + } + Curl_dyn_reset(&out); /* Public Key Algorithm. */ - ccp = dumpAlgo(¶m, cert.subjectPublicKeyAlgorithm.beg, - cert.subjectPublicKeyAlgorithm.end); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Public Key Algorithm", - ccp); - if(!result) { - int ret; - if(!certnum) - infof(data, " Public Key Algorithm: %s", ccp); - ret = do_pubkey(data, certnum, ccp, ¶m, &cert.subjectPublicKey); - if(ret) - result = CURLE_OUT_OF_MEMORY; /* the most likely error */ - } - free((char *) ccp); + result = dumpAlgo(&out, ¶m, cert.subjectPublicKeyAlgorithm.beg, + cert.subjectPublicKeyAlgorithm.end); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Public Key Algorithm", + &out); + if(result) + goto done; + } + + rc = do_pubkey(data, certnum, Curl_dyn_ptr(&out), + ¶m, &cert.subjectPublicKey); + if(rc) { + result = CURLE_OUT_OF_MEMORY; /* the most likely error */ + goto done; + } + Curl_dyn_reset(&out); /* Signature. */ - ccp = ASN1tostr(&cert.signature, 0); - if(!ccp) - return CURLE_OUT_OF_MEMORY; - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Signature", ccp); - if(!certnum) - infof(data, " Signature: %s", ccp); - free((char *) ccp); + result = ASN1tostr(&out, &cert.signature, 0); if(result) - return result; + goto done; + if(data->set.ssl.certinfo) { + result = ssl_push_certinfo_dyn(data, certnum, "Signature", &out); + if(result) + goto done; + } + Curl_dyn_reset(&out); /* Generate PEM certificate. */ result = Curl_base64_encode(cert.certificate.beg, cert.certificate.end - cert.certificate.beg, - &cp1, &cl1); + &certptr, &clen); if(result) - return result; - /* Compute the number of characters in final certificate string. Format is: + goto done; + + /* Generate the final output certificate string. Format is: -----BEGIN CERTIFICATE-----\n \n . @@ -1232,207 +1196,34 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, . -----END CERTIFICATE-----\n */ - i = 28 + cl1 + (cl1 + 64 - 1) / 64 + 26; - cp2 = malloc(i + 1); - if(!cp2) { - free(cp1); - return CURLE_OUT_OF_MEMORY; - } - /* Build the certificate string. */ - i = copySubstring(cp2, "-----BEGIN CERTIFICATE-----"); - for(j = 0; j < cl1; j += 64) - i += copySubstring(cp2 + i, cp1 + j); - i += copySubstring(cp2 + i, "-----END CERTIFICATE-----"); - cp2[i] = '\0'; - free(cp1); - if(data->set.ssl.certinfo) - result = ssl_push_certinfo(data, certnum, "Cert", cp2); - if(!certnum) - infof(data, "%s", cp2); - free(cp2); - return result; -} -#endif /* WANT_EXTRACT_CERTINFO */ - -#endif /* USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL or USE_SECTRANSP */ + Curl_dyn_reset(&out); -#ifdef WANT_VERIFYHOST - -static const char *checkOID(const char *beg, const char *end, - const char *oid) -{ - struct Curl_asn1Element e; - const char *ccp; - const char *p; - bool matched; - - /* Check if first ASN.1 element at `beg' is the given OID. - Return a pointer in the source after the OID if found, else NULL. */ - - ccp = getASN1Element(&e, beg, end); - if(!ccp || e.tag != CURL_ASN1_OBJECT_IDENTIFIER) - return NULL; - - p = OID2str(e.beg, e.end, FALSE); - if(!p) - return NULL; - - matched = !strcmp(p, oid); - free((char *) p); - return matched? ccp: NULL; -} - -CURLcode Curl_verifyhost(struct Curl_cfilter *cf, - struct Curl_easy *data, - const char *beg, const char *end) -{ - struct ssl_connect_data *connssl = cf->ctx; - struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); - struct Curl_X509certificate cert; - struct Curl_asn1Element dn; - struct Curl_asn1Element elem; - struct Curl_asn1Element ext; - struct Curl_asn1Element name; - const char *p; - const char *q; - char *dnsname; - int matched = -1; - size_t addrlen = (size_t) -1; - ssize_t len; - size_t hostlen; - -#ifdef ENABLE_IPV6 - struct in6_addr addr; -#else - struct in_addr addr; -#endif - - /* Verify that connection server matches info in X509 certificate at - `beg'..`end'. */ - - if(!conn_config->verifyhost) - return CURLE_OK; - - if(Curl_parseX509(&cert, beg, end)) - return CURLE_PEER_FAILED_VERIFICATION; - - hostlen = strlen(connssl->peer.hostname); - - /* Get the server IP address. */ -#ifdef ENABLE_IPV6 - if(cf->conn->bits.ipv6_ip && - Curl_inet_pton(AF_INET6, connssl->peer.hostname, &addr)) - addrlen = sizeof(struct in6_addr); - else -#endif - if(Curl_inet_pton(AF_INET, connssl->peer.hostname, &addr)) - addrlen = sizeof(struct in_addr); - - /* Process extensions. */ - for(p = cert.extensions.beg; p < cert.extensions.end && matched != 1;) { - p = getASN1Element(&ext, p, cert.extensions.end); - if(!p) - return CURLE_PEER_FAILED_VERIFICATION; - - /* Check if extension is a subjectAlternativeName. */ - ext.beg = checkOID(ext.beg, ext.end, sanOID); - if(ext.beg) { - ext.beg = getASN1Element(&elem, ext.beg, ext.end); - if(!ext.beg) - return CURLE_PEER_FAILED_VERIFICATION; - /* Skip critical if present. */ - if(elem.tag == CURL_ASN1_BOOLEAN) { - ext.beg = getASN1Element(&elem, ext.beg, ext.end); - if(!ext.beg) - return CURLE_PEER_FAILED_VERIFICATION; - } - /* Parse the octet string contents: is a single sequence. */ - if(!getASN1Element(&elem, elem.beg, elem.end)) - return CURLE_PEER_FAILED_VERIFICATION; - /* Check all GeneralNames. */ - for(q = elem.beg; matched != 1 && q < elem.end;) { - q = getASN1Element(&name, q, elem.end); - if(!q) - break; - switch(name.tag) { - case 2: /* DNS name. */ - len = utf8asn1str(&dnsname, CURL_ASN1_IA5_STRING, - name.beg, name.end); - if(len > 0 && (size_t)len == strlen(dnsname)) - matched = Curl_cert_hostcheck(dnsname, (size_t)len, - connssl->peer.hostname, hostlen); - else - matched = 0; - free(dnsname); - break; - - case 7: /* IP address. */ - matched = (size_t)(name.end - name.beg) == addrlen && - !memcmp(&addr, name.beg, addrlen); - break; - } - } - } - } - - switch(matched) { - case 1: - /* an alternative name matched the server hostname */ - infof(data, " subjectAltName: %s matched", connssl->dispname); - return CURLE_OK; - case 0: - /* an alternative name field existed, but didn't match and then - we MUST fail */ - infof(data, " subjectAltName does not match %s", connssl->dispname); - return CURLE_PEER_FAILED_VERIFICATION; - } - - /* Process subject. */ - name.header = NULL; - name.beg = name.end = ""; - q = cert.subject.beg; - /* we have to look to the last occurrence of a commonName in the - distinguished one to get the most significant one. */ - while(q < cert.subject.end) { - q = getASN1Element(&dn, q, cert.subject.end); - if(!q) - break; - for(p = dn.beg; p < dn.end;) { - p = getASN1Element(&elem, p, dn.end); - if(!p) - return CURLE_PEER_FAILED_VERIFICATION; - /* We have a DN's AttributeTypeAndValue: check it in case it's a CN. */ - elem.beg = checkOID(elem.beg, elem.end, cnOID); - if(elem.beg) - name = elem; /* Latch CN. */ - } - } - - /* Check the CN if found. */ - if(!getASN1Element(&elem, name.beg, name.end)) - failf(data, "SSL: unable to obtain common name from peer certificate"); - else { - len = utf8asn1str(&dnsname, elem.tag, elem.beg, elem.end); - if(len < 0) { - free(dnsname); - return CURLE_OUT_OF_MEMORY; - } - if(strlen(dnsname) != (size_t) len) /* Nul byte in string ? */ - failf(data, "SSL: illegal cert name field"); - else if(Curl_cert_hostcheck((const char *) dnsname, - len, connssl->peer.hostname, hostlen)) { - infof(data, " common name: %s (matched)", dnsname); - free(dnsname); - return CURLE_OK; + /* Build the certificate string. */ + result = Curl_dyn_add(&out, "-----BEGIN CERTIFICATE-----\n"); + if(!result) { + size_t j = 0; + + while(!result && (j < clen)) { + size_t chunksize = (clen - j) > 64 ? 64 : (clen - j); + result = Curl_dyn_addn(&out, &certptr[j], chunksize); + if(!result) + result = Curl_dyn_addn(&out, "\n", 1); + j += chunksize; } - else - failf(data, "SSL: certificate subject name '%s' does not match " - "target host name '%s'", dnsname, connssl->dispname); - free(dnsname); + if(!result) + result = Curl_dyn_add(&out, "-----END CERTIFICATE-----\n"); } + free(certptr); + if(!result) + if(data->set.ssl.certinfo) + result = ssl_push_certinfo_dyn(data, certnum, "Cert", &out); - return CURLE_PEER_FAILED_VERIFICATION; +done: + Curl_dyn_free(&out); + return result; } -#endif /* WANT_VERIFYHOST */ +#endif /* WANT_EXTRACT_CERTINFO */ + +#endif /* USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL or USE_SECTRANSP */ diff --git a/lib/ws.c b/lib/ws.c index adde531f5..d9765182d 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -24,7 +24,7 @@ #include "curl_setup.h" #include -#ifdef USE_WEBSOCKETS +#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) #include "urldata.h" #include "bufq.h" @@ -225,6 +225,10 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, dec->payload_len = (dec->head[2] << 8) | dec->head[3]; break; case 10: + if(dec->head[2] > 127) { + failf(data, "WS: frame length longer than 64 signed not supported"); + return CURLE_RECV_ERROR; + } dec->payload_len = ((curl_off_t)dec->head[2] << 56) | (curl_off_t)dec->head[3] << 48 | (curl_off_t)dec->head[4] << 40 | @@ -296,7 +300,7 @@ static CURLcode ws_dec_pass(struct ws_decoder *dec, case WS_DEC_INIT: ws_dec_reset(dec); dec->state = WS_DEC_HEAD; - /* FALLTHROUGH */ + FALLTHROUGH(); case WS_DEC_HEAD: result = ws_dec_read_head(dec, data, inraw); if(result) { @@ -321,7 +325,7 @@ static CURLcode ws_dec_pass(struct ws_decoder *dec, dec->state = WS_DEC_INIT; break; } - /* FALLTHROUGH */ + FALLTHROUGH(); case WS_DEC_PAYLOAD: result = ws_dec_pass_payload(dec, data, inraw, write_payload, write_ctx); ws_dec_info(dec, data, "passing"); @@ -350,6 +354,136 @@ static void update_meta(struct websocket *ws, ws->frame.bytesleft = (payload_len - payload_offset - cur_len); } +/* WebSockets decoding client writer */ +struct ws_cw_ctx { + struct Curl_cwriter super; + struct bufq buf; +}; + +static CURLcode ws_cw_init(struct Curl_easy *data, + struct Curl_cwriter *writer) +{ + struct ws_cw_ctx *ctx = (struct ws_cw_ctx *)writer; + (void)data; + Curl_bufq_init2(&ctx->buf, WS_CHUNK_SIZE, 1, BUFQ_OPT_SOFT_LIMIT); + return CURLE_OK; +} + +static void ws_cw_close(struct Curl_easy *data, struct Curl_cwriter *writer) +{ + struct ws_cw_ctx *ctx = (struct ws_cw_ctx *)writer; + (void) data; + Curl_bufq_free(&ctx->buf); +} + +struct ws_cw_dec_ctx { + struct Curl_easy *data; + struct websocket *ws; + struct Curl_cwriter *next_writer; + int cw_type; +}; + +static ssize_t ws_cw_dec_next(const unsigned char *buf, size_t buflen, + int frame_age, int frame_flags, + curl_off_t payload_offset, + curl_off_t payload_len, + void *user_data, + CURLcode *err) +{ + struct ws_cw_dec_ctx *ctx = user_data; + struct Curl_easy *data = ctx->data; + struct websocket *ws = ctx->ws; + curl_off_t remain = (payload_len - (payload_offset + buflen)); + + (void)frame_age; + if((frame_flags & CURLWS_PING) && !remain) { + /* auto-respond to PINGs, only works for single-frame payloads atm */ + size_t bytes; + infof(data, "WS: auto-respond to PING with a PONG"); + /* send back the exact same content as a PONG */ + *err = curl_ws_send(data, buf, buflen, &bytes, 0, CURLWS_PONG); + if(*err) + return -1; + } + else if(buflen || !remain) { + /* forward the decoded frame to the next client writer. */ + update_meta(ws, frame_age, frame_flags, payload_offset, + payload_len, buflen); + + *err = Curl_cwriter_write(data, ctx->next_writer, ctx->cw_type, + (const char *)buf, buflen); + if(*err) + return -1; + } + *err = CURLE_OK; + return (ssize_t)buflen; +} + +static CURLcode ws_cw_write(struct Curl_easy *data, + struct Curl_cwriter *writer, int type, + const char *buf, size_t nbytes) +{ + struct ws_cw_ctx *ctx = (struct ws_cw_ctx *)writer; + struct websocket *ws; + CURLcode result; + + if(!(type & CLIENTWRITE_BODY) || data->set.ws_raw_mode) + return Curl_cwriter_write(data, writer->next, type, buf, nbytes); + + ws = data->conn->proto.ws; + if(!ws) { + failf(data, "WS: not a websocket transfer"); + return CURLE_FAILED_INIT; + } + + if(nbytes) { + ssize_t nwritten; + nwritten = Curl_bufq_write(&ctx->buf, (const unsigned char *)buf, + nbytes, &result); + if(nwritten < 0) { + infof(data, "WS: error adding data to buffer %d", result); + return result; + } + } + + while(!Curl_bufq_is_empty(&ctx->buf)) { + struct ws_cw_dec_ctx pass_ctx; + pass_ctx.data = data; + pass_ctx.ws = ws; + pass_ctx.next_writer = writer->next; + pass_ctx.cw_type = type; + result = ws_dec_pass(&ws->dec, data, &ctx->buf, + ws_cw_dec_next, &pass_ctx); + if(result == CURLE_AGAIN) + /* insufficient amount of data, keep it for later. + * we pretend to have written all since we have a copy */ + return CURLE_OK; + else if(result) { + infof(data, "WS: decode error %d", (int)result); + return result; + } + } + + if((type & CLIENTWRITE_EOS) && !Curl_bufq_is_empty(&ctx->buf)) { + infof(data, "WS: decode ending with %zd frame bytes remaining", + Curl_bufq_len(&ctx->buf)); + return CURLE_RECV_ERROR; + } + + return CURLE_OK; +} + +/* WebSocket payload decoding client writer. */ +static const struct Curl_cwtype ws_cw_decode = { + "ws-decode", + NULL, + ws_cw_init, + ws_cw_write, + ws_cw_close, + sizeof(struct ws_cw_ctx) +}; + + static void ws_enc_info(struct ws_encoder *enc, struct Curl_easy *data, const char *msg) { @@ -410,6 +544,13 @@ static ssize_t ws_enc_write_head(struct Curl_easy *data, size_t hlen; ssize_t n; + if(payload_len < 0) { + failf(data, "WS: starting new frame with negative payload length %" + CURL_FORMAT_CURL_OFF_T, payload_len); + *err = CURLE_SEND_ERROR; + return -1; + } + if(enc->payload_remain > 0) { /* trying to write a new frame before the previous one is finished */ failf(data, "WS: starting new frame with %zd bytes from last one" @@ -607,6 +748,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, { struct SingleRequest *k = &data->req; struct websocket *ws; + struct Curl_cwriter *ws_dec_writer; CURLcode result; DEBUGASSERT(data->conn); @@ -616,7 +758,8 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, if(!ws) return CURLE_OUT_OF_MEMORY; data->conn->proto.ws = ws; - Curl_bufq_init(&ws->recvbuf, WS_CHUNK_SIZE, WS_CHUNK_COUNT); + Curl_bufq_init2(&ws->recvbuf, WS_CHUNK_SIZE, WS_CHUNK_COUNT, + BUFQ_OPT_SOFT_LIMIT); Curl_bufq_init2(&ws->sendbuf, WS_CHUNK_SIZE, WS_CHUNK_COUNT, BUFQ_OPT_SOFT_LIMIT); ws_dec_init(&ws->dec); @@ -655,6 +798,18 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, infof(data, "Received 101, switch to WebSocket; mask %02x%02x%02x%02x", ws->enc.mask[0], ws->enc.mask[1], ws->enc.mask[2], ws->enc.mask[3]); + /* Install our client writer that decodes WS frames payload */ + result = Curl_cwriter_create(&ws_dec_writer, data, &ws_cw_decode, + CURL_CW_CONTENT_DECODE); + if(result) + return result; + + result = Curl_cwriter_add(data, ws_dec_writer); + if(result) { + Curl_cwriter_free(data, ws_dec_writer); + return result; + } + if(data->set.connect_only) { ssize_t nwritten; /* In CONNECT_ONLY setup, the payloads from `mem` need to be received @@ -666,105 +821,15 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, return result; infof(data, "%zu bytes websocket payload", nread); } - k->upgr101 = UPGR101_RECEIVED; - - return result; -} - -static ssize_t ws_client_write(const unsigned char *buf, size_t buflen, - int frame_age, int frame_flags, - curl_off_t payload_offset, - curl_off_t payload_len, - void *userp, - CURLcode *err) -{ - struct Curl_easy *data = userp; - struct websocket *ws; - size_t wrote; - curl_off_t remain = (payload_len - (payload_offset + buflen)); - - (void)frame_age; - if(!data->conn || !data->conn->proto.ws) { - *err = CURLE_FAILED_INIT; - return -1; - } - ws = data->conn->proto.ws; - - if((frame_flags & CURLWS_PING) && !remain) { - /* auto-respond to PINGs, only works for single-frame payloads atm */ - size_t bytes; - infof(data, "WS: auto-respond to PING with a PONG"); - /* send back the exact same content as a PONG */ - *err = curl_ws_send(data, buf, buflen, &bytes, 0, CURLWS_PONG); - if(*err) - return -1; - } - else if(buflen || !remain) { - /* deliver the decoded frame to the user callback. The application - * may invoke curl_ws_meta() to access frame information. */ - update_meta(ws, frame_age, frame_flags, payload_offset, - payload_len, buflen); - Curl_set_in_callback(data, true); - wrote = data->set.fwrite_func((char *)buf, 1, - buflen, data->set.out); - Curl_set_in_callback(data, false); - if(wrote != buflen) { - *err = CURLE_RECV_ERROR; - return -1; + else { /* !connect_only */ + /* And pass any additional data to the writers */ + if(nread) { + result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)mem, nread); } } - *err = CURLE_OK; - return (ssize_t)buflen; -} - -/* Curl_ws_writecb() is the write callback for websocket traffic. The - websocket data is provided to this raw, in chunks. This function should - handle/decode the data and call the "real" underlying callback accordingly. -*/ -size_t Curl_ws_writecb(char *buffer, size_t size /* 1 */, - size_t nitems, void *userp) -{ - struct Curl_easy *data = userp; - - if(data->set.ws_raw_mode) - return data->set.fwrite_func(buffer, size, nitems, data->set.out); - else if(nitems) { - struct websocket *ws; - CURLcode result; - - if(!data->conn || !data->conn->proto.ws) { - failf(data, "WS: not a websocket transfer"); - return nitems - 1; - } - ws = data->conn->proto.ws; - - if(buffer) { - ssize_t nwritten; - - nwritten = Curl_bufq_write(&ws->recvbuf, (const unsigned char *)buffer, - nitems, &result); - if(nwritten < 0) { - infof(data, "WS: error adding data to buffer %d", (int)result); - return nitems - 1; - } - buffer = NULL; - } - - while(!Curl_bufq_is_empty(&ws->recvbuf)) { + k->upgr101 = UPGR101_RECEIVED; - result = ws_dec_pass(&ws->dec, data, &ws->recvbuf, - ws_client_write, data); - if(result == CURLE_AGAIN) - /* insufficient amount of data, keep it for later. - * we pretend to have written all since we have a copy */ - return nitems; - else if(result) { - infof(data, "WS: decode error %d", (int)result); - return nitems - 1; - } - } - } - return nitems; + return result; } struct ws_collect { @@ -997,8 +1062,11 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *data, const void *buffer, ws = data->conn->proto.ws; if(data->set.ws_raw_mode) { - if(fragsize || flags) + if(fragsize || flags) { + DEBUGF(infof(data, "ws_send: " + "fragsize and flags cannot be non-zero in raw mode")); return CURLE_BAD_FUNCTION_ARGUMENT; + } if(!buflen) /* nothing to do */ return CURLE_OK; @@ -1071,14 +1139,23 @@ static void ws_free(struct connectdata *conn) } } +static CURLcode ws_setup_conn(struct Curl_easy *data, + struct connectdata *conn) +{ + /* websockets is 1.1 only (for now) */ + data->state.httpwant = CURL_HTTP_VERSION_1_1; + return Curl_http_setup_conn(data, conn); +} + + void Curl_ws_done(struct Curl_easy *data) { (void)data; } -CURLcode Curl_ws_disconnect(struct Curl_easy *data, - struct connectdata *conn, - bool dead_connection) +static CURLcode ws_disconnect(struct Curl_easy *data, + struct connectdata *conn, + bool dead_connection) { (void)data; (void)dead_connection; @@ -1096,6 +1173,57 @@ CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(struct Curl_easy *data) return NULL; } +const struct Curl_handler Curl_handler_ws = { + "WS", /* scheme */ + ws_setup_conn, /* setup_connection */ + Curl_http, /* do_it */ + Curl_http_done, /* done */ + ZERO_NULL, /* do_more */ + Curl_http_connect, /* connect_it */ + ZERO_NULL, /* connecting */ + ZERO_NULL, /* doing */ + ZERO_NULL, /* proto_getsock */ + Curl_http_getsock_do, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ws_disconnect, /* disconnect */ + Curl_http_write_resp, /* write_resp */ + ZERO_NULL, /* connection_check */ + ZERO_NULL, /* attach connection */ + PORT_HTTP, /* defport */ + CURLPROTO_WS, /* protocol */ + CURLPROTO_HTTP, /* family */ + PROTOPT_CREDSPERREQUEST | /* flags */ + PROTOPT_USERPWDCTRL +}; + +#ifdef USE_SSL +const struct Curl_handler Curl_handler_wss = { + "WSS", /* scheme */ + ws_setup_conn, /* setup_connection */ + Curl_http, /* do_it */ + Curl_http_done, /* done */ + ZERO_NULL, /* do_more */ + Curl_http_connect, /* connect_it */ + NULL, /* connecting */ + ZERO_NULL, /* doing */ + NULL, /* proto_getsock */ + Curl_http_getsock_do, /* doing_getsock */ + ZERO_NULL, /* domore_getsock */ + ZERO_NULL, /* perform_getsock */ + ws_disconnect, /* disconnect */ + Curl_http_write_resp, /* write_resp */ + ZERO_NULL, /* connection_check */ + ZERO_NULL, /* attach connection */ + PORT_HTTPS, /* defport */ + CURLPROTO_WSS, /* protocol */ + CURLPROTO_HTTP, /* family */ + PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */ + PROTOPT_USERPWDCTRL +}; +#endif + + #else CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, diff --git a/lib/ws.h b/lib/ws.h index 0308a4254..5f40d4528 100644 --- a/lib/ws.h +++ b/lib/ws.h @@ -25,7 +25,7 @@ ***************************************************************************/ #include "curl_setup.h" -#ifdef USE_WEBSOCKETS +#if defined(USE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) #ifdef USE_HYPER #define REQTYPE void @@ -75,11 +75,14 @@ struct websocket { CURLcode Curl_ws_request(struct Curl_easy *data, REQTYPE *req); CURLcode Curl_ws_accept(struct Curl_easy *data, const char *mem, size_t len); -size_t Curl_ws_writecb(char *buffer, size_t size, size_t nitems, void *userp); void Curl_ws_done(struct Curl_easy *data); -CURLcode Curl_ws_disconnect(struct Curl_easy *data, - struct connectdata *conn, - bool dead_connection); + +extern const struct Curl_handler Curl_handler_ws; +#ifdef USE_SSL +extern const struct Curl_handler Curl_handler_wss; +#endif + + #else #define Curl_ws_request(x,y) CURLE_OK #define Curl_ws_done(x) Curl_nop_stmt diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index 35ba19866..9a4547709 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -194,7 +194,6 @@ AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [ flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast" flags_opt_yes="-O2" flags_opt_off="-O0" - CURL_CHECK_DEF([_WIN32], [], [silent]) else AC_MSG_RESULT([no]) fi @@ -831,7 +830,8 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ # dnl Only clang 2.9 or later if test "$compiler_num" -ge "209"; then - tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion" + CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) + tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow]) # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs fi @@ -839,6 +839,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ dnl Only clang 3.0 or later if test "$compiler_num" -ge "300"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [language-extension-token]) + tmp_CFLAGS="$tmp_CFLAGS -Wformat=2" fi # dnl Only clang 3.2 or later @@ -887,6 +888,10 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum]) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt]) fi + dnl clang 10 or later + if test "$compiler_num" -ge "1000"; then + tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" # we have silencing markup for clang 10.0 and above only + fi fi dnl Disable pointer to bool conversion warnings since they cause dnl lib/securetransp.c cause several warnings for checks we want. @@ -1016,8 +1021,9 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration]) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body]) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers]) - CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion]) - tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion" + CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion trampolines]) + CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) + tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla]) dnl required for -Warray-bounds, included in -Wall tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp" @@ -1026,7 +1032,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ dnl Only gcc 4.5 or later if test "$compiler_num" -ge "405"; then dnl Only windows targets - if test "$curl_cv_have_def__WIN32" = "yes"; then + if test "$curl_cv_native_windows" = "yes"; then tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format" fi fi @@ -1063,10 +1069,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero]) tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2" tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2" - if test "$compiler_num" -lt "1200"; then - dnl gcc 12 doesn't acknowledge our comment markups - tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough=4" - fi + tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" fi # dnl Only gcc 10 or later diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 28f4b8b9a..425d9f96f 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -46,7 +46,7 @@ curl_includes_arpa_inet="\ #ifdef HAVE_ARPA_INET_H # include #endif -#ifdef HAVE_WINSOCK2_H +#ifdef _WIN32 #include #include #endif @@ -414,18 +414,14 @@ dnl included when winsock2.h is to be included. AC_DEFUN([CURL_INCLUDES_WINSOCK2], [ curl_includes_winsock2="\ /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# endif -# include +# include #endif /* includes end */" - CURL_CHECK_HEADER_WINDOWS - CURL_CHECK_HEADER_WINSOCK2 + CURL_CHECK_NATIVE_WINDOWS ]) @@ -437,22 +433,15 @@ dnl included when ws2tcpip.h is to be included. AC_DEFUN([CURL_INCLUDES_WS2TCPIP], [ curl_includes_ws2tcpip="\ /* includes start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif -# ifdef HAVE_WINSOCK2_H -# include -# ifdef HAVE_WS2TCPIP_H -# include -# endif -# endif -# include +# include +# include #endif /* includes end */" - CURL_CHECK_HEADER_WINDOWS - CURL_CHECK_HEADER_WINSOCK2 - CURL_CHECK_HEADER_WS2TCPIP + CURL_CHECK_NATIVE_WINDOWS ]) @@ -510,7 +499,7 @@ dnl defines function calling convention. AC_DEFUN([CURL_PREPROCESS_CALLCONV], [ curl_preprocess_callconv="\ /* preprocess start */ -#ifdef HAVE_WINDOWS_H +#ifdef _WIN32 # define FUNCALLCONV __stdcall #else # define FUNCALLCONV @@ -1794,10 +1783,10 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [ struct addrinfo *ai = 0; int error; - #ifdef HAVE_WINSOCK2_H + #ifdef _WIN32 WSADATA wsa; - if (WSAStartup(MAKEWORD(2,2), &wsa)) - exit(2); + if(WSAStartup(MAKEWORD(2, 2), &wsa)) + exit(2); #endif memset(&hints, 0, sizeof(hints)); diff --git a/m4/curl-gnutls.m4 b/m4/curl-gnutls.m4 index 48813dfad..d4f553d69 100644 --- a/m4/curl-gnutls.m4 +++ b/m4/curl-gnutls.m4 @@ -104,6 +104,7 @@ if test "x$OPT_GNUTLS" != xno; then GNUTLS_ENABLED=1 USE_GNUTLS="yes" ssl_msg="GnuTLS" + QUIC_ENABLED=yes test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [ diff --git a/m4/curl-openssl.m4 b/m4/curl-openssl.m4 index 608653c5c..2fb2abecc 100644 --- a/m4/curl-openssl.m4 +++ b/m4/curl-openssl.m4 @@ -271,6 +271,7 @@ if test "x$OPT_OPENSSL" != xno; then ],[ AC_MSG_RESULT([yes]) ssl_msg="BoringSSL" + OPENSSL_IS_BORINGSSL=1 ],[ AC_MSG_RESULT([no]) ]) @@ -287,6 +288,7 @@ if test "x$OPT_OPENSSL" != xno; then ],[ AC_MSG_RESULT([yes]) ssl_msg="AWS-LC" + OPENSSL_IS_BORINGSSL=1 ],[ AC_MSG_RESULT([no]) ]) @@ -328,6 +330,15 @@ if test "x$OPT_OPENSSL" != xno; then ]) fi + dnl is this OpenSSL (fork) providing the original QUIC API? + AC_CHECK_FUNCS([SSL_set_quic_use_legacy_codepoint], + [QUIC_ENABLED=yes]) + if test "$QUIC_ENABLED" = "yes"; then + AC_MSG_NOTICE([OpenSSL fork speaks QUIC API]) + else + AC_MSG_NOTICE([OpenSSL version does not speak QUIC API]) + fi + if test "$OPENSSL_ENABLED" = "1"; then if test -n "$LIB_OPENSSL"; then dnl when the ssl shared libs were found in a path that the run-time @@ -413,4 +424,23 @@ AS_HELP_STRING([--disable-openssl-auto-load-config],[Disable automatic loading o ]) fi +dnl --- +dnl We may use OpenSSL QUIC. +dnl --- +if test "$OPENSSL_ENABLED" = "1"; then + AC_MSG_CHECKING([for QUIC support in OpenSSL]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ +#include + ]],[[ + OSSL_QUIC_client_method(); + ]]) + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_OPENSSL_QUIC, 1, [if you have the functions OSSL_QUIC_client_method]) + AC_SUBST(HAVE_OPENSSL_QUIC, [1]) + ],[ + AC_MSG_RESULT([no]) + ]) +fi ]) diff --git a/m4/curl-wolfssl.m4 b/m4/curl-wolfssl.m4 index f630685bc..1da47a91e 100644 --- a/m4/curl-wolfssl.m4 +++ b/m4/curl-wolfssl.m4 @@ -107,6 +107,7 @@ if test "x$OPT_WOLFSSL" != xno; then WOLFSSL_ENABLED=1 USE_WOLFSSL="yes" ssl_msg="WolfSSL" + QUIC_ENABLED=yes test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [ diff --git a/maketgz b/maketgz index a0fcd878f..4ebda82a9 100644 --- a/maketgz +++ b/maketgz @@ -145,13 +145,8 @@ fi ############################################################################ # -# Modify the man pages to display the version number and date. -# - -echo "update man pages" -./scripts/updatemanpages.pl $version >/dev/null - # make the generated file newer than the man page + touch src/tool_hugehelp.c ############################################################################ diff --git a/packages/OS400/.gitattributes b/packages/OS400/.gitattributes new file mode 100644 index 000000000..e9b8201b5 --- /dev/null +++ b/packages/OS400/.gitattributes @@ -0,0 +1,6 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl + +# OS400 .cmd files are not windows scripts. +*.cmd text eol=auto diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c index 48f1f5fbd..596c1f1e1 100644 --- a/packages/OS400/ccsidcurl.c +++ b/packages/OS400/ccsidcurl.c @@ -1282,7 +1282,7 @@ curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) result = curl_easy_setopt(easy, tag, &blob); break; } - /* FALLTHROUGH */ + FALLTHROUGH(); case CURLOPT_ERRORBUFFER: /* This is an output buffer. */ result = Curl_vsetopt(easy, tag, arg); break; diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in index d1254ce49..b3a4e9efd 100644 --- a/packages/OS400/curl.inc.in +++ b/packages/OS400/curl.inc.in @@ -667,6 +667,8 @@ d c 98 d CURLE_UNRECOVERABLE_POLL... d c 99 + d CURLE_TOO_LARGE... + d c 100 * /if not defined(CURL_NO_OLDIES) d CURLE_URL_MALFORMAT_USER... @@ -1655,6 +1657,10 @@ d c 00321 d CURLOPT_QUICK_EXIT... d c 00322 + d CURLOPT_HAPROXY_CLIENT_IP... + d c 10323 + d CURLOPT_SERVER_RESPONSE_TIMEOUT_MS... + d c 00324 * /if not defined(CURL_NO_OLDIES) d CURLOPT_FILE c 10001 @@ -1890,6 +1896,12 @@ d c X'0010003D' d CURLINFO_CAPATH... CURLINFO_STRING + 62 d c X'0010003E' + d CURLINFO_XFER_ID... CURLINFO_OFF_T + 63 + d c X'0060003F' + d CURLINFO_CONN_ID... CURLINFO_OFF_T + 64 + d c X'00600040' + d CURLINFO_QUEUE_TIME_T... CURLINFO_OFF_T + 65 + d c X'00600041' * d CURLINFO_HTTP_CODE... Old ...RESPONSE_CODE d c X'00200002' @@ -2251,6 +2263,8 @@ d c 29 d CURLUE_LACKS_IDN... d c 30 + d CURLUE_TOO_LARGE... + d c 31 * d CURLUPart s 10i 0 based(######ptr######) Enum d CURLUPART_URL c 0 @@ -3062,6 +3076,10 @@ d sockfd value like(curl_socket_t) d sockp * value void * * + d curl_multi_get_handles... + d pr * extproc('curl_multi_get_handles') CURL ** + d multi_handle * value CURLM * + * d curl_url pr * extproc('curl_url') CURLU * * d curl_url_cleanup... diff --git a/packages/vms/config_h.com b/packages/vms/config_h.com index 6e4e03963..6378802ad 100644 --- a/packages/vms/config_h.com +++ b/packages/vms/config_h.com @@ -1386,38 +1386,6 @@ $ write tf "#define ''key2' 1" $ write tf "#endif" $ goto cfgh_in_loop1 $ endif -$! -$! This is really do we have the newer MIT Kerberos -$!---------------------------------------------------------------------- -$ if (key2 .eqs. "HAVE_GSSMIT") -$ then -$ if f$search(test_mit) .nes. "" -$ then -$ write tf "#ifndef ''key2'" -$ write tf "#define ''key2' 1" -$ else -$ write tf "#ifdef ''key2'" -$ write tf "#undef ''key2'" -$ endif -$ write tf "#endif" -$ goto cfgh_in_loop1 -$ endif -$! -$! Older MIT looks like Heimdal -$!------------------------------------------------ -$ if (key2 .eqs. "HAVE_HEIMDAL") -$ then -$ if f$search(test_mit) .eqs. "" -$ then -$ write tf "#ifndef ''key2'" -$ write tf "#define ''key2' 1" -$ else -$ write tf "#ifdef ''key2'" -$ write tf "#undef ''key2'" -$ endif -$ write tf "#endif" -$ goto cfgh_in_loop1 -$ endif $ endif $! $ endif diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 9d69cff9c..ae95e85ac 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -22,8 +22,8 @@ # ########################################################################### -EXTRA_DIST = updatemanpages.pl coverage.sh completion.pl firefox-db2pem.sh \ - checksrc.pl mk-ca-bundle.pl schemetable.c +EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl \ + mk-ca-bundle.pl schemetable.c cd2nroff nroff2cd cdall cd2cd ZSH_FUNCTIONS_DIR = @ZSH_FUNCTIONS_DIR@ FISH_FUNCTIONS_DIR = @FISH_FUNCTIONS_DIR@ diff --git a/scripts/cd2cd b/scripts/cd2cd new file mode 100755 index 000000000..a4de2f875 --- /dev/null +++ b/scripts/cd2cd @@ -0,0 +1,226 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +=begin comment + +This script updates a curldown file to current/better curldown. + +Example: cd2cd [--in-place] > + +--in-place: if used, it replaces the original file with the cleaned up + version. When this is used, cd2cd accepts multiple files to work + on and it ignores errors on single files. + +=end comment +=cut + +my $cd2cd = "0.1"; # to keep check +my $dir; +my $extension; +my $inplace = 0; + +while(1) { + if($ARGV[0] eq "--in-place") { + shift @ARGV; + $inplace = 1; + } + else { + last; + } +} + + +use POSIX qw(strftime); +my @ts; +if (defined($ENV{SOURCE_DATE_EPOCH})) { + @ts = localtime($ENV{SOURCE_DATE_EPOCH}); +} else { + @ts = localtime; +} +my $date = strftime "%B %d %Y", @ts; + +sub outseealso { + my (@sa) = @_; + my $comma = 0; + my @o; + push @o, ".SH SEE ALSO\n"; + for my $s (sort @sa) { + push @o, sprintf "%s.BR $s", $comma ? ",\n": ""; + $comma = 1; + } + push @o, "\n"; + return @o; +} + +sub single { + my @head; + my @seealso; + my ($f)=@_; + my $title; + my $section; + my $source; + my $start = 0; + my $d; + my $line = 0; + open(F, "<:crlf", "$f") || + return 1; + while() { + $line++; + $d = $_; + if(!$start) { + if(/^---/) { + # header starts here + $start = 1; + push @head, $d; + } + next; + } + if(/^Title: *(.*)/i) { + $title=$1; + } + elsif(/^Section: *(.*)/i) { + $section=$1; + } + elsif(/^Source: *(.*)/i) { + $source=$1; + } + elsif(/^See-also: +(.*)/i) { + $salist = 0; + push @seealso, $1; + } + elsif(/^See-also: */i) { + if($seealso[0]) { + print STDERR "$f:$line:1:ERROR: bad See-Also, needs list\n"; + return 2; + } + $salist = 1; + } + elsif(/^ +- (.*)/i) { + # the only list we support is the see-also + if($salist) { + push @seealso, $1; + } + } + # REUSE-IgnoreStart + elsif(/^C: (.*)/i) { + $copyright=$1; + } + elsif(/^SPDX-License-Identifier: (.*)/i) { + $spdx=$1; + } + # REUSE-IgnoreEnd + elsif(/^---/) { + # end of the header section + if(!$title) { + print STDERR "ERROR: no 'Title:' in $f\n"; + return 1; + } + if(!$section) { + print STDERR "ERROR: no 'Section:' in $f\n"; + return 2; + } + if(!$seealso[0]) { + print STDERR "$f:$line:1:ERROR: no 'See-also:' present\n"; + return 2; + } + if(!$copyright) { + print STDERR "$f:$line:1:ERROR: no 'C:' field present\n"; + return 2; + } + if(!$spdx) { + print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n"; + return 2; + } + last; + } + else { + chomp; + print STDERR "WARN: unrecognized line in $f, ignoring:\n:'$_';" + } + } + + if(!$start) { + print STDERR "$f:$line:1:ERROR: no header present\n"; + return 2; + } + + my @desc; + + push @desc, sprintf <, et al. +SPDX-License-Identifier: curl +Title: $title +Section: $section +Source: $source +HEAD + ; + push @desc, "See-also:\n"; + for my $s (sort @seealso) { + push @desc, " - $s\n" if($s); + } + push @desc, "---\n"; + + my $blankline = 0; + while() { + $d = $_; + $line++; + if($d =~ /^[ \t]*\n/) { + $blankline++; + } + else { + $blankline = 0; + } + # *italics* for curl symbol links get the asterisks removed + $d =~ s/\*((lib|)curl[^ ]*\(3\))\*/$1/gi; + + if(length($d) > 90) { + print STDERR "$f:$line:1:WARN: excessive line length\n"; + } + + push @desc, $d if($blankline < 2); + } + close(F); + + if($inplace) { + open(O, ">$f") || return 1; + print O @desc; + close(O); + } + else { + print @desc; + } + return 0; +} + +if($inplace) { + for my $a (@ARGV) { + # this ignores errors + single($a); + } +} +else { + exit single($ARGV[0]); +} diff --git a/scripts/cd2nroff b/scripts/cd2nroff new file mode 100755 index 000000000..17a83b49c --- /dev/null +++ b/scripts/cd2nroff @@ -0,0 +1,373 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +=begin comment + +Converts a curldown file to nroff (man page). + +=end comment +=cut + +use strict; +use warnings; + +my $cd2nroff = "0.1"; # to keep check +my $dir; +my $extension; +my $keepfilename; + +while(@ARGV) { + if($ARGV[0] eq "-d") { + shift @ARGV; + $dir = shift @ARGV; + } + elsif($ARGV[0] eq "-e") { + shift @ARGV; + $extension = shift @ARGV; + } + elsif($ARGV[0] eq "-k") { + shift @ARGV; + $keepfilename = 1; + } + elsif($ARGV[0] eq "-h") { + print < Write the output to the file name from the meta-data in the + specified directory, instead of writing to stdout +-e If -d is used, this option can provide an added "extension", arbitrary + text really, to append to the file name. +-h This help text, +-v Show version then exit +HELP + ; + exit 0; + } + elsif($ARGV[0] eq "-v") { + print "cd2nroff version $cd2nroff\n"; + exit 0; + } + else { + last; + } +} + +use POSIX qw(strftime); +my @ts; +if (defined($ENV{SOURCE_DATE_EPOCH})) { + @ts = localtime($ENV{SOURCE_DATE_EPOCH}); +} else { + @ts = localtime; +} +my $date = strftime "%B %d %Y", @ts; + +sub outseealso { + my (@sa) = @_; + my $comma = 0; + my @o; + push @o, ".SH SEE ALSO\n"; + for my $s (sort @sa) { + push @o, sprintf "%s.BR $s", $comma ? ",\n": ""; + $comma = 1; + } + push @o, "\n"; + return @o; +} + +sub single { + my @seealso; + my $d; + my ($f)=@_; + my $copyright; + my $errors = 0; + my $fh; + my $line; + my $salist; + my $section; + my $source; + my $spdx; + my $start = 0; + my $title; + + if(defined($f)) { + if(!open($fh, "<:crlf", "$f")) { + print STDERR "Failed to open $f : $!\n"; + return 1; + } + } + else { + $f = "STDIN"; + $fh = \*STDIN; + binmode($fh, ":crlf"); + } + while(<$fh>) { + $line++; + if(!$start) { + if(/^---/) { + # header starts here + $start = 1; + } + next; + } + if(/^Title: *(.*)/i) { + $title=$1; + } + elsif(/^Section: *(.*)/i) { + $section=$1; + } + elsif(/^Source: *(.*)/i) { + $source=$1; + } + elsif(/^See-also: +(.*)/i) { + $salist = 0; + push @seealso, $1; + } + elsif(/^See-also: */i) { + if($seealso[0]) { + print STDERR "$f:$line:1:ERROR: bad See-Also, needs list\n"; + return 2; + } + $salist = 1; + } + elsif(/^ +- (.*)/i) { + # the only list we support is the see-also + if($salist) { + push @seealso, $1; + } + } + # REUSE-IgnoreStart + elsif(/^C: (.*)/i) { + $copyright=$1; + } + elsif(/^SPDX-License-Identifier: (.*)/i) { + $spdx=$1; + } + # REUSE-IgnoreEnd + elsif(/^---/) { + # end of the header section + if(!$title) { + print STDERR "ERROR: no 'Title:' in $f\n"; + return 1; + } + if(!$section) { + print STDERR "ERROR: no 'Section:' in $f\n"; + return 2; + } + if(!$seealso[0]) { + print STDERR "$f:$line:1:ERROR: no 'See-also:' present\n"; + return 2; + } + if(!$copyright) { + print STDERR "$f:$line:1:ERROR: no 'C:' field present\n"; + return 2; + } + if(!$spdx) { + print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n"; + return 2; + } + last; + } + else { + chomp; + print STDERR "WARN: unrecognized line in $f, ignoring:\n:'$_';" + } + } + + if(!$start) { + print STDERR "$f:$line:1:ERROR: no header present\n"; + return 2; + } + + my @desc; + my $quote = 0; + my $blankline = 0; + my $header = 0; + + # cut off the leading path from the file name, if any + $f =~ s/^(.*[\\\/])//; + + push @desc, ".\\\" generated by cd2nroff $cd2nroff from $f\n"; + push @desc, ".TH $title $section \"$date\" $source\n"; + while(<$fh>) { + $line++; + + $d = $_; + + if($quote) { + if($quote == 4) { + # remove the indentation + if($d =~ /^ (.*)/) { + push @desc, "$1\n"; + next; + } + else { + # end of quote + $quote = 0; + push @desc, ".fi\n"; + next; + } + } + if(/^~~~/) { + # end of quote + $quote = 0; + push @desc, ".fi\n"; + next; + } + # convert single backslahes to doubles + $d =~ s/\\/\\\\/g; + # lines starting with a period needs it escaped + $d =~ s/^\./\\&./; + push @desc, $d; + next; + } + + # **bold** + $d =~ s/\*\*(\S.*?)\*\*/\\fB$1\\fP/g; + # *italics* + $d =~ s/\*(\S.*?)\*/\\fI$1\\fP/g; + + # mentions of curl symbols with man pages use italics by default + $d =~ s/((lib|)curl([^ ]*\(3\)))/\\fI$1\\fP/gi; + + # backticked becomes italics + $d =~ s/\`(.*?)\`/\\fI$1\\fP/g; + + if(/^## (.*)/) { + my $word = $1; + # if there are enclosing quotes, remove them first + $word =~ s/[\"\'](.*)[\"\']\z/$1/; + + # enclose in double quotes if there is a space present + if($word =~ / /) { + push @desc, ".IP \"$word\"\n"; + } + else { + push @desc, ".IP $word\n"; + } + $header = 1; + } + elsif(/^# (.*)/) { + my $word = $1; + # if there are enclosing quotes, remove them first + $word =~ s/[\"\'](.*)[\"\']\z/$1/; + push @desc, ".SH $word\n"; + $header = 1; + } + elsif(/^~~~c/) { + # start of a code section, not indented + $quote = 1; + push @desc, "\n" if($blankline && !$header); + $header = 0; + push @desc, ".nf\n"; + } + elsif(/^~~~/) { + # start of a quote section; not code, not indented + $quote = 1; + push @desc, "\n" if($blankline && !$header); + $header = 0; + push @desc, ".nf\n"; + } + elsif(/^ (.*)/) { + # quoted, indented by 4 space + $quote = 4; + push @desc, "\n" if($blankline && !$header); + $header = 0; + push @desc, ".nf\n$1\n"; + } + elsif(/^[ \t]*\n/) { + # count and ignore blank lines + $blankline++; + } + else { + # don't output newlines if this is the first content after a + # header + push @desc, "\n" if($blankline && !$header); + $blankline = 0; + $header = 0; + + # remove single line HTML comments + $d =~ s///g; + + # quote minuses in the output + $d =~ s/([^\\])-/$1\\-/g; + # replace single quotes + $d =~ s/\'/\\(aq/g; + # handle double quotes first on the line + $d =~ s/^(\s*)\"/$1\\&\"/; + + # lines starting with a period needs it escaped + $d =~ s/^\./\\&./; + + if($d =~ /^(.*) /) { + printf STDERR "$f:$line:%d:ERROR: 2 spaces detected\n", + length($1); + $errors++; + } + if($d =~ /^[ \t]*\n/) { + # replaced away all contents + $blankline= 1; + } + else { + push @desc, $d; + } + } + } + if($fh != \*STDIN) { + close($fh); + } + push @desc, outseealso(@seealso); + if($dir) { + if($keepfilename) { + $title = $f; + $title =~ s/\.[^.]*$//; + } + my $outfile = "$dir/$title.$section"; + if(defined($extension)) { + $outfile .= $extension; + } + if(!open(O, ">", $outfile)) { + print STDERR "Failed to open $outfile : $!\n"; + return 1; + } + print O @desc; + close(O); + } + else { + print @desc; + } + return $errors; +} + +if(@ARGV) { + for my $f (@ARGV) { + my $r = single($f); + if($r) { + exit $r; + } + } +} +else { + exit single(); +} diff --git a/scripts/cdall b/scripts/cdall new file mode 100755 index 000000000..507ccc6be --- /dev/null +++ b/scripts/cdall @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +# provide all dir names to scan on the cmdline + +sub convert { + my ($dir)=@_; + opendir(my $dh, $dir) || die "could not open $dir"; + my @cd = grep { /\.md\z/ && -f "$dir/$_" } readdir($dh); + closedir $dh; + + for my $cd (@cd) { + my $nroff = "$cd"; + $nroff =~ s/\.md\z/.3/; + print "$dir/$cd = $dir/$nroff\n"; + system("./scripts/cd2nroff -d $dir $dir/$cd"); + } +} + +for my $d (sort @ARGV) { + convert($d); +} diff --git a/scripts/nroff2cd b/scripts/nroff2cd new file mode 100755 index 000000000..500367f81 --- /dev/null +++ b/scripts/nroff2cd @@ -0,0 +1,193 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +=begin comment + +This script converts an nroff file to curldown + +Example: cd2nroff [options] > + +Note: when converting .nf sections, this tool does not know if the +section is code or just regular quotes. It then assumes and uses ~~~c +for code. + +=end comment +=cut + +my $nroff2cd = "0.1"; # to keep check + +sub single { + my ($f)=@_; + open(F, "<:crlf", "$f") || + return 1; + my $line; + my $title; + my $section; + my $source; + my @seealso; + my @desc; + my $header; # non-zero when TH is passed + my $quote = 0; # quote state + while() { + $line++; + my $d = $_; + if($_ =~ /^.\\\"/) { + # a comment we can ignore + next; + } + if(!$header) { + if($d =~ /.so (.*)/) { + # this is basically an include, so do that + my $f = $1; + # remove leading directory + $f =~ s/(.*?\/)//; + close(F); + open(F, "<:crlf", "$f") || return 1; + } + if($d =~ /^\.TH ([^ ]*) (\d) \"(.*?)\" ([^ \n]*)/) { + # header, this needs to be the first thing after leading comments + $title = $1; + $section = $2; + # date is $3 + $source = $4; + # if there are enclosing quotes around source, remove them + $source =~ s/[\"\'](.*)[\"\']\z/$1/; + $header = 1; + + print <, et al. +SPDX-License-Identifier: curl +Title: $title +Section: $section +Source: $source +HEAD + ; + } + next; + } + + if($quote) { + if($d =~ /^\.SH/) { + #end of quote without an .fi + $quote = 0; + push @desc, "~~~\n"; + } + elsif($d =~ /^\.fi/) { + #end of quote + $quote = 0; + push @desc, "~~~\n"; + next; + } + else { + # double-backslashes converted to single ones + $d =~ s/\\\\/\\/g; + push @desc, $d; + next; + } + } + if($d =~ /^\.SH (.*)/) { + my $word = $1; + # if there are enclosing quotes, remove them first + $word =~ s/[\"\'](.*)[\"\']\z/$1/; + if($word eq "SEE ALSO") { + # we just slurp up this section + next; + } + push @desc, "\n# $word\n\n"; + } + elsif($d =~ /^\.(RS|RE)/) { + # ignore these + } + elsif($d =~ /^\.IP (.*)/) { + my $word = $1; + # if there are enclosing quotes, remove them first + $word =~ s/[\"\'](.*)[\"\']\z/$1/; + push @desc, "\n## $word\n\n"; + } + elsif($d =~ /^\.IP/) { + # .IP with no text we just skip + } + elsif($d =~ /^\.BR (.*)/) { + # only used for SEE ALSO + my $word = $1; + # remove trailing comma + $word =~ s/,\z//; + + for my $s (split(/,/, $word)) { + # remove all double quotes + $s =~ s/\"//g; + # tream leading whitespace + $s =~ s/^ +//g; + push @seealso, $s; + } + } + elsif($d =~ /^\.I (.*)/) { + push @desc, "*$1*\n"; + } + elsif($d =~ /^\.B (.*)/) { + push @desc, "**$1**\n"; + } + elsif($d =~ /^\.nf/) { + push @desc, "~~~c\n"; + $quote = 1; + } + else { + # embolden + $d =~ s/\\fB(.*?)\\fP/**$1**/g; + # links to "curl.*()" are left bare since cd2nroff handles them + # specially + $d =~ s/\\fI(curl.*?\(3\))\\fP/$1/ig; + # emphasize + $d =~ s/\\fI(.*?)\\fP/*$1*/g; + # emphasize on a split line + $d =~ s/\\fI/*/g; + # bold on a split line + $d =~ s/\\fB/**/g; + # remove backslash amp + $d =~ s/\\&//g; + # remove backslashes + $d =~ s/\\//g; + # fix single quotes + $d =~ s/\(aq/'/g; + # fix double quotes + $d =~ s/\(dq/\"/g; + push @desc, $d; + } + } + close(F); + + print "See-also:\n"; + for my $s (sort @seealso) { + print " - $s\n" if($s); + } + print "---\n"; + print @desc; + + return !$header; +} + +exit single($ARGV[0]); + diff --git a/scripts/updatemanpages.pl b/scripts/updatemanpages.pl deleted file mode 100644 index 58a8755e8..000000000 --- a/scripts/updatemanpages.pl +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### - -# Update man pages. - -use strict; -use warnings; -use Tie::File; - -# Data from the command line. - -my $curlver = $ARGV[0]; -my $curldate = $ARGV[1]; - -# Directories and extensions. - -my @dirlist = ("docs/", "docs/libcurl/", "docs/libcurl/opts/", "tests/"); -my @extlist = (".1", ".3"); -my @excludelist = ("mk-ca-bundle.1", "template.3"); - -# Subroutines - -sub printargs{ - # Print arguments and exit. - - print "usage: updatemanpages.pl \n"; - exit; -} - -sub getthline{ - # Process file looking for .TH section. - - my $filename = shift; - my $file_handle; - my $file_line; - - # Open the file. - - open($file_handle, $filename); - - # Look for the .TH section, process it into an array, - # modify it and write to file. - - tie(my @file_data, 'Tie::File', $filename); - foreach my $file_data_line(@file_data) { - if($file_data_line =~ /^.TH/) { - $file_line = $file_data_line; - last; - } - } - - # Close the file. - - close($file_handle); - return $file_line; -} - -sub extractth{ - # Extract .TH section as an array. - - my $input = shift; - - # Split the line into an array. - - my @tharray; - my $inputsize = length($input); - my $inputcurrent = ""; - my $quotemode = 0; - - for(my $inputseek = 0; $inputseek < $inputsize; $inputseek++) { - - if(substr($input, $inputseek, 1) eq " " && $quotemode eq 0) { - push(@tharray, $inputcurrent); - $inputcurrent = ""; - next; - } - - $inputcurrent = $inputcurrent . substr($input, $inputseek, 1); - - if(substr($input, $inputseek, 1) eq "\"") { - if($quotemode eq 0) { - $quotemode = 1; - } - else { - $quotemode = 0; - } - } - } - - if($inputcurrent ne "") { - push(@tharray, $inputcurrent); - } - - return @tharray; -} - -sub getdate{ - # Get the date from the .TH section. - - my $filename = shift; - my $thline; - my @tharray; - my $date = ""; - - $thline = getthline($filename); - - # Return nothing if there is no .TH section found. - - if(!$thline || $thline eq "") { - return ""; - } - - @tharray = extractth($thline); - - # Remove the quotes at the start and end. - - $date = substr($tharray[3], 1, -1); - return $date; -} - -sub processth{ - # Process .TH section. - - my $input = shift; - my $date = shift; - - # Split the line into an array. - - my @tharray = extractth($input); - - # Alter the date. - - my $itemdate = "\""; - $itemdate .= $date; - $itemdate .= "\""; - $tharray[3] = $itemdate; - - # Alter the item version. - - my $itemver = $tharray[4]; - my $itemname = ""; - - for(my $itemnameseek = 1; - $itemnameseek < length($itemver); - $itemnameseek++) { - if(substr($itemver, $itemnameseek, 1) eq " " || - substr($itemver, $itemnameseek, 1) eq "\"") { - last; - } - $itemname .= substr($itemver, $itemnameseek, 1); - } - - $itemver = "\""; - $itemver .= $itemname; - $itemver .= " "; - $itemver .= $curlver; - $itemver .= "\""; - - $tharray[4] = $itemver; - - my $thoutput = ""; - - foreach my $thvalue (@tharray) { - $thoutput .= $thvalue; - $thoutput .= " "; - } - $thoutput =~ s/\s+$//; - $thoutput .= "\n"; - - # Return updated string. - - return $thoutput; -} - -sub processfile{ - # Process file looking for .TH section. - - my $filename = shift; - my $date = shift; - my $file_handle; - my $file_dist_handle; - my $filename_dist; - - # Open a handle for the original file and a second file handle - # for the dist file. - - $filename_dist = $filename . ".dist"; - - open($file_handle, $filename); - open($file_dist_handle, ">" . $filename_dist); - - # Look for the .TH section, process it into an array, - # modify it and write to file. - - tie(my @file_data, 'Tie::File', $filename); - foreach my $file_data_line (@file_data) { - if($file_data_line =~ /^.TH/) { - my $file_dist_line = processth($file_data_line, $date); - print $file_dist_handle $file_dist_line . "\n"; - } - else { - print $file_dist_handle $file_data_line . "\n"; - } - } - - # Close the file. - - close($file_handle); - close($file_dist_handle); -} - -# Check that $curlver is set, otherwise print arguments and exit. - -if(!$curlver) { - printargs(); -} - -# check to see that the git command works, it requires git 2.6 something -my $gitcheck = `git log -1 --date="format:%B %d, %Y" $dirlist[0] 2>/dev/null`; -if(length($gitcheck) < 1) { - print "git version too old or $dirlist[0] is a bad argument\n"; - exit; -} - -# Look in each directory. - -my $dir_handle; - -foreach my $dirname (@dirlist) { - foreach my $extname (@extlist) { - # Go through the directory looking for files ending with - # the current extension. - - opendir($dir_handle, $dirname); - my @filelist = grep(/.$extname$/i, readdir($dir_handle)); - - foreach my $file (@filelist) { - # Skip if file is in exclude list. - - if(grep(/^$file$/, @excludelist)) { - next; - } - - # Load the file and get the date. - - my $filedate; - - # Check if dist version exists and load date from that - # file if it does. - - if(-e ($dirname . $file . ".dist")) { - $filedate = getdate(($dirname . $file . ".dist")); - } - else { - $filedate = getdate(($dirname . $file)); - } - - # Skip if value is empty. - - if(!$filedate || $filedate eq "") { - next; - } - - # Check the man page in the git repository. - - my $repodata = `LC_TIME=C git log -1 --date="format:%B %d, %Y" \\ - --since="$filedate" $dirname$file | grep ^Date:`; - - # If there is output then update the man page - # with the new date/version. - - # Process the file if there is output. - - if($repodata) { - my $thisdate; - if(!$curldate) { - if($repodata =~ /^Date: +(.*)/) { - $thisdate = $1; - } - else { - print STDERR "Warning: " . ($dirname . $file) . ": found no " . - "date\n"; - } - } - else { - $thisdate = $curldate; - } - processfile(($dirname . $file), $thisdate); - print $dirname . $file . " page updated to $thisdate\n"; - } - } - closedir($dir_handle); - } -} - -__END__ - -=pod - -=head1 updatemanpages.pl - -Updates the man pages with the version number and optional date. If the date -isn't provided, the last modified date from git is used. - -=head2 USAGE - -updatemanpages.pl version [date] - -=head3 version - -Specifies version (required) - -=head3 date - -Specifies date (optional) - -=head2 SETTINGS - -=head3 @dirlist - -Specifies the list of directories to look for files in. - -=head3 @extlist - -Specifies the list of files with extensions to process. - -=head3 @excludelist - -Specifies the list of files to not process. - -=head2 NOTES - -This script is used during maketgz. - -=cut diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3c4218ea..5695670f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,8 @@ set(EXE_NAME curl) add_definitions(-DBUILDING_CURL) -if(USE_MANUAL) +if(ENABLE_CURL_MANUAL AND HAVE_MANUAL_TOOLS) + add_definitions("-DUSE_MANUAL") # Use the C locale to ensure that only ASCII characters appear in the # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt add_custom_command( diff --git a/src/Makefile.am b/src/Makefile.am index dced53e0f..7a99c2548 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -157,7 +157,7 @@ tidy: $(TIDY) $(CURL_CFILES) $(TIDYFLAGS) -- $(curl_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H listhelp: - (cd $(top_srcdir)/docs/cmdline-opts && ./gen.pl listhelp *.d) > tool_listhelp.c + (cd $(top_srcdir)/docs/cmdline-opts && make listhelp) if HAVE_WINDRES .rc.o: diff --git a/src/Makefile.mk b/src/Makefile.mk index 66882b353..83dd65d16 100644 --- a/src/Makefile.mk +++ b/src/Makefile.mk @@ -32,31 +32,13 @@ include $(PROOT)/lib/Makefile.mk ### Local -RCFLAGS += -DCURL_EMBED_MANIFEST CPPFLAGS += -I$(PROOT)/lib LDFLAGS += -L$(PROOT)/lib LIBS := -lcurl $(LIBS) -ifdef WIN32 - ifneq ($(findstring -dyn,$(CFG)),) - DYN := 1 - endif -endif - -ifdef DYN - curl_DEPENDENCIES := $(PROOT)/lib/libcurl$(CURL_DLL_SUFFIX).dll - curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a -else - curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a - ifdef WIN32 - CPPFLAGS += -DCURL_STATICLIB - LDFLAGS += -static - endif -endif - ### Sources and targets -# Provides CURL_CFILES, CURLX_CFILES, CURL_RCFILES +# Provides CURL_CFILES, CURLX_CFILES include Makefile.inc TARGETS := curl$(BIN_EXT) @@ -64,12 +46,9 @@ TARGETS := curl$(BIN_EXT) CURL_CFILES += $(notdir $(CURLX_CFILES)) curl_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(strip $(CURL_CFILES))) -ifdef WIN32 -curl_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(CURL_RCFILES))) -endif ifdef MAP CURL_MAP := curl.map -CURL_LDFLAGS_BIN += -Wl,-Map,$(CURL_MAP) +LDFLAGS += -Wl,-Map,$(CURL_MAP) TOVCLEAN := $(CURL_MAP) endif vpath %.c $(PROOT)/lib @@ -105,7 +84,7 @@ tool_hugehelp.c: endif endif -$(TARGETS): $(curl_OBJECTS) $(curl_DEPENDENCIES) - $(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $(curl_OBJECTS) $(LIBS) +$(TARGETS): $(curl_OBJECTS) $(PROOT)/lib/libcurl.a + $(CC) $(LDFLAGS) -o $@ $(curl_OBJECTS) $(LIBS) all: $(OBJ_DIR) $(TARGETS) diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index ce5e25e92..cbf57f057 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -217,7 +217,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, switch(type) { case CURLINFO_TEXT: fprintf(output, "%s%s== Info: %.*s", timebuf, idsbuf, (int)size, data); - /* FALLTHROUGH */ + FALLTHROUGH(); default: /* in case a new one is introduced to shock us */ return 0; diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 198a8d050..30ee3b09c 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -178,10 +178,18 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) return CURL_WRITEFUNC_ERROR; } + if(per->config->output_dir) { + outs->filename = aprintf("%s/%s", per->config->output_dir, filename); + free(filename); + if(!outs->filename) + return CURL_WRITEFUNC_ERROR; + } + else + outs->filename = filename; + outs->is_cd_filename = TRUE; outs->s_isreg = TRUE; outs->fopened = FALSE; - outs->filename = filename; outs->alloc_filename = TRUE; hdrcbdata->honor_cd_filename = FALSE; /* done now! */ if(!tool_create_output_file(outs, per->config)) diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index ef47b42da..86b6fa605 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -208,7 +208,14 @@ int tool_progress_cb(void *clientp, memset(line, '#', num); line[num] = '\0'; msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif fprintf(bar->out, format, line, percent); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } fflush(bar->out); bar->prev = point; diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 98063c39c..143cba255 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -57,7 +57,6 @@ bool tool_create_output_file(struct OutStruct *outs, struct GlobalConfig *global; FILE *file = NULL; char *fname = outs->filename; - char *aname = NULL; DEBUGASSERT(outs); DEBUGASSERT(config); global = config->global; @@ -66,15 +65,6 @@ bool tool_create_output_file(struct OutStruct *outs, return FALSE; } - if(config->output_dir && outs->is_cd_filename) { - aname = aprintf("%s/%s", config->output_dir, fname); - if(!aname) { - errorf(global, "out of memory"); - return FALSE; - } - fname = aname; - } - if(config->file_clobber_mode == CLOBBER_ALWAYS || (config->file_clobber_mode == CLOBBER_DEFAULT && !outs->is_cd_filename)) { @@ -94,14 +84,12 @@ bool tool_create_output_file(struct OutStruct *outs, char *newname; /* Guard against wraparound in new filename */ if(newlen < len) { - free(aname); errorf(global, "overflow in filename generation"); return FALSE; } newname = malloc(newlen); if(!newname) { errorf(global, "out of memory"); - free(aname); return FALSE; } memcpy(newname, fname, len); @@ -135,10 +123,8 @@ bool tool_create_output_file(struct OutStruct *outs, if(!file) { warnf(global, "Failed to open the file %s: %s", fname, strerror(errno)); - free(aname); return FALSE; } - free(aname); outs->s_isreg = TRUE; outs->fopened = TRUE; outs->stream = file; diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c index 906e23e14..3259bc7a5 100644 --- a/src/tool_cfgable.c +++ b/src/tool_cfgable.c @@ -25,6 +25,7 @@ #include "tool_cfgable.h" #include "tool_formparse.h" +#include "tool_paramhlp.h" #include "tool_main.h" #include "memdebug.h" /* keep this as LAST include */ @@ -33,7 +34,6 @@ void config_init(struct OperationConfig *config) { memset(config, 0, sizeof(struct OperationConfig)); - config->postfieldsize = -1; config->use_httpget = FALSE; config->create_dirs = FALSE; config->maxredirs = DEFAULT_MAXREDIRS; @@ -45,6 +45,7 @@ void config_init(struct OperationConfig *config) config->http09_allowed = FALSE; config->ftp_skip_ip = TRUE; config->file_clobber_mode = CLOBBER_DEFAULT; + curlx_dyn_init(&config->postdata, MAX_FILE2MEMORY); } static void free_config_fields(struct OperationConfig *config) @@ -59,7 +60,7 @@ static void free_config_fields(struct OperationConfig *config) Curl_safefree(config->cookiejar); curl_slist_free_all(config->cookiefiles); - Curl_safefree(config->postfields); + Curl_dyn_free(&config->postdata); Curl_safefree(config->query); Curl_safefree(config->referer); diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 57e8fce52..dfa74d81f 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -68,7 +68,7 @@ struct OperationConfig { char *proto_default; curl_off_t resume_from; char *postfields; - curl_off_t postfieldsize; + struct curlx_dynbuf postdata; char *referer; char *query; long timeout_ms; diff --git a/src/tool_easysrc.h b/src/tool_easysrc.h index 8c8d13150..f698c8f5c 100644 --- a/src/tool_easysrc.h +++ b/src/tool_easysrc.h @@ -40,7 +40,7 @@ extern int easysrc_slist_count; /* Number of curl_slist variables */ extern CURLcode easysrc_init(void); extern CURLcode easysrc_add(struct slist_wc **plist, const char *bupf); extern CURLcode easysrc_addf(struct slist_wc **plist, - const char *fmt, ...); + const char *fmt, ...) CURL_PRINTF(2, 3); extern CURLcode easysrc_perform(void); extern CURLcode easysrc_cleanup(void); diff --git a/src/tool_formparse.c b/src/tool_formparse.c index fa38698d5..875ce78d6 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -278,7 +278,7 @@ static CURLcode tool2curlparts(CURL *curl, struct tool_mime *m, case TOOLMIME_STDIN: if(!filename) filename = "-"; - /* FALLTHROUGH */ + FALLTHROUGH(); case TOOLMIME_STDINDATA: ret = curl_mime_data_cb(part, m->size, (curl_read_callback) tool_mime_stdin_read, diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 5fa1ace10..4c910fd73 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -51,315 +51,578 @@ # define USE_WATT32 #endif -#define GetStr(str,val) do { \ - if(*(str)) { \ - free(*(str)); \ - *(str) = NULL; \ - } \ - if((val)) { \ - *(str) = strdup((val)); \ - if(!(*(str))) { \ - err = PARAM_NO_MEM; \ - goto error; \ - } \ - } \ - } while(0) +#define ALLOW_BLANK TRUE +#define DENY_BLANK FALSE + +static ParameterError getstr(char **str, const char *val, bool allowblank) +{ + if(*str) { + free(*str); + *str = NULL; + } + if(val) { + if(!allowblank && !val[0]) + return PARAM_BLANK_STRING; + + *str = strdup(val); + if(!*str) + return PARAM_NO_MEM; + } + return PARAM_OK; +} + +/* one enum for every command line option. The name is the verbatim long + option name, but in uppercase with periods and minuses replaced with + underscores using a "C_" prefix. */ +typedef enum { + C_ABSTRACT_UNIX_SOCKET, + C_ALPN, + C_ALT_SVC, + C_ANYAUTH, + C_APPEND, + C_AWS_SIGV4, + C_BASIC, + C_BUFFER, + C_CA_NATIVE, + C_CACERT, + C_CAPATH, + C_CERT, + C_CERT_STATUS, + C_CERT_TYPE, + C_CIPHERS, + C_CLOBBER, + C_COMPRESSED, + C_COMPRESSED_SSH, + C_CONFIG, + C_CONNECT_TIMEOUT, + C_CONNECT_TO, + C_CONTINUE_AT, + C_COOKIE, + C_COOKIE_JAR, + C_CREATE_DIRS, + C_CREATE_FILE_MODE, + C_CRLF, + C_CRLFILE, + C_CURVES, + C_DATA, + C_DATA_ASCII, + C_DATA_BINARY, + C_DATA_RAW, + C_DATA_URLENCODE, + C_DELEGATION, + C_DIGEST, + C_DISABLE, + C_DISABLE_EPRT, + C_DISABLE_EPSV, + C_DISALLOW_USERNAME_IN_URL, + C_DNS_INTERFACE, + C_DNS_IPV4_ADDR, + C_DNS_IPV6_ADDR, + C_DNS_SERVERS, + C_DOH_CERT_STATUS, + C_DOH_INSECURE, + C_DOH_URL, + C_DUMP_HEADER, + C_EGD_FILE, + C_ENGINE, + C_EPRT, + C_EPSV, + C_ETAG_COMPARE, + C_ETAG_SAVE, + C_EXPECT100_TIMEOUT, + C_FAIL, + C_FAIL_EARLY, + C_FAIL_WITH_BODY, + C_FALSE_START, + C_FORM, + C_FORM_ESCAPE, + C_FORM_STRING, + C_FTP_ACCOUNT, + C_FTP_ALTERNATIVE_TO_USER, + C_FTP_CREATE_DIRS, + C_FTP_METHOD, + C_FTP_PASV, + C_FTP_PORT, + C_FTP_PRET, + C_FTP_SKIP_PASV_IP, + C_FTP_SSL, + C_FTP_SSL_CCC, + C_FTP_SSL_CCC_MODE, + C_FTP_SSL_CONTROL, + C_FTP_SSL_REQD, + C_GET, + C_GLOBOFF, + C_HAPPY_EYEBALLS_TIMEOUT_MS, + C_HAPROXY_CLIENTIP, + C_HAPROXY_PROTOCOL, + C_HEAD, + C_HEADER, + C_HELP, + C_HOSTPUBMD5, + C_HOSTPUBSHA256, + C_HSTS, + C_HTTP0_9, + C_HTTP1_0, + C_HTTP1_1, + C_HTTP2, + C_HTTP2_PRIOR_KNOWLEDGE, + C_HTTP3, + C_HTTP3_ONLY, + C_IGNORE_CONTENT_LENGTH, + C_INCLUDE, + C_INSECURE, + C_INTERFACE, + C_IPFS_GATEWAY, + C_IPV4, + C_IPV6, + C_JSON, + C_JUNK_SESSION_COOKIES, + C_KEEPALIVE, + C_KEEPALIVE_TIME, + C_KEY, + C_KEY_TYPE, + C_KRB, + C_KRB4, + C_LIBCURL, + C_LIMIT_RATE, + C_LIST_ONLY, + C_LOCAL_PORT, + C_LOCATION, + C_LOCATION_TRUSTED, + C_LOGIN_OPTIONS, + C_MAIL_AUTH, + C_MAIL_FROM, + C_MAIL_RCPT, + C_MAIL_RCPT_ALLOWFAILS, + C_MANUAL, + C_MAX_FILESIZE, + C_MAX_REDIRS, + C_MAX_TIME, + C_METALINK, + C_NEGOTIATE, + C_NETRC, + C_NETRC_FILE, + C_NETRC_OPTIONAL, + C_NEXT, + C_NOPROXY, + C_NPN, + C_NTLM, + C_NTLM_WB, + C_OAUTH2_BEARER, + C_OUTPUT, + C_OUTPUT_DIR, + C_PARALLEL, + C_PARALLEL_IMMEDIATE, + C_PARALLEL_MAX, + C_PASS, + C_PATH_AS_IS, + C_PINNEDPUBKEY, + C_POST301, + C_POST302, + C_POST303, + C_PREPROXY, + C_PROGRESS_BAR, + C_PROGRESS_METER, + C_PROTO, + C_PROTO_DEFAULT, + C_PROTO_REDIR, + C_PROXY, + C_PROXY_ANYAUTH, + C_PROXY_BASIC, + C_PROXY_CA_NATIVE, + C_PROXY_CACERT, + C_PROXY_CAPATH, + C_PROXY_CERT, + C_PROXY_CERT_TYPE, + C_PROXY_CIPHERS, + C_PROXY_CRLFILE, + C_PROXY_DIGEST, + C_PROXY_HEADER, + C_PROXY_HTTP2, + C_PROXY_INSECURE, + C_PROXY_KEY, + C_PROXY_KEY_TYPE, + C_PROXY_NEGOTIATE, + C_PROXY_NTLM, + C_PROXY_PASS, + C_PROXY_PINNEDPUBKEY, + C_PROXY_SERVICE_NAME, + C_PROXY_SSL_ALLOW_BEAST, + C_PROXY_SSL_AUTO_CLIENT_CERT, + C_PROXY_TLS13_CIPHERS, + C_PROXY_TLSAUTHTYPE, + C_PROXY_TLSPASSWORD, + C_PROXY_TLSUSER, + C_PROXY_TLSV1, + C_PROXY_USER, + C_PROXY1_0, + C_PROXYTUNNEL, + C_PUBKEY, + C_QUOTE, + C_RANDOM_FILE, + C_RANGE, + C_RATE, + C_RAW, + C_REFERER, + C_REMOTE_HEADER_NAME, + C_REMOTE_NAME, + C_REMOTE_NAME_ALL, + C_REMOTE_TIME, + C_REMOVE_ON_ERROR, + C_REQUEST, + C_REQUEST_TARGET, + C_RESOLVE, + C_RETRY, + C_RETRY_ALL_ERRORS, + C_RETRY_CONNREFUSED, + C_RETRY_DELAY, + C_RETRY_MAX_TIME, + C_SASL_AUTHZID, + C_SASL_IR, + C_SERVICE_NAME, + C_SESSIONID, + C_SHOW_ERROR, + C_SILENT, + C_SOCKS4, + C_SOCKS4A, + C_SOCKS5, + C_SOCKS5_BASIC, + C_SOCKS5_GSSAPI, + C_SOCKS5_GSSAPI_NEC, + C_SOCKS5_GSSAPI_SERVICE, + C_SOCKS5_HOSTNAME, + C_SPEED_LIMIT, + C_SPEED_TIME, + C_SSL, + C_SSL_ALLOW_BEAST, + C_SSL_AUTO_CLIENT_CERT, + C_SSL_NO_REVOKE, + C_SSL_REQD, + C_SSL_REVOKE_BEST_EFFORT, + C_SSLV2, + C_SSLV3, + C_STDERR, + C_STYLED_OUTPUT, + C_SUPPRESS_CONNECT_HEADERS, + C_TCP_FASTOPEN, + C_TCP_NODELAY, + C_TELNET_OPTION, + C_TEST_EVENT, + C_TFTP_BLKSIZE, + C_TFTP_NO_OPTIONS, + C_TIME_COND, + C_TLS_MAX, + C_TLS13_CIPHERS, + C_TLSAUTHTYPE, + C_TLSPASSWORD, + C_TLSUSER, + C_TLSV1, + C_TLSV1_0, + C_TLSV1_1, + C_TLSV1_2, + C_TLSV1_3, + C_TR_ENCODING, + C_TRACE, + C_TRACE_ASCII, + C_TRACE_CONFIG, + C_TRACE_IDS, + C_TRACE_TIME, + C_UNIX_SOCKET, + C_UPLOAD_FILE, + C_URL, + C_URL_QUERY, + C_USE_ASCII, + C_USER, + C_USER_AGENT, + C_VARIABLE, + C_VERBOSE, + C_VERSION, + C_WDEBUG, + C_WRITE_OUT, + C_XATTR +} cmdline_t; struct LongShort { - const char *letter; /* short name option */ const char *lname; /* long name option */ enum { - ARG_NONE, /* stand-alone but not a boolean */ - ARG_BOOL, /* accepts a --no-[name] prefix */ - ARG_STRING, /* requires an argument */ - ARG_FILENAME /* requires an argument, usually a file name */ + ARG_NONE, /* stand-alone but not a boolean */ + ARG_BOOL, /* accepts a --no-[name] prefix */ + ARG_STRG, /* requires an argument */ + ARG_FILE /* requires an argument, usually a file name */ } desc; + char letter; /* short name option or ' ' */ + cmdline_t cmd; }; +/* this array MUST be alphasorted based on the 'lname' */ static const struct LongShort aliases[]= { - /* 'letter' strings with more than one character have *no* short option to - mention. */ - {"*@", "url", ARG_STRING}, - {"*4", "dns-ipv4-addr", ARG_STRING}, - {"*6", "dns-ipv6-addr", ARG_STRING}, - {"*a", "random-file", ARG_FILENAME}, - {"*b", "egd-file", ARG_STRING}, - {"*B", "oauth2-bearer", ARG_STRING}, - {"*c", "connect-timeout", ARG_STRING}, - {"*C", "doh-url" , ARG_STRING}, - {"*d", "ciphers", ARG_STRING}, - {"*D", "dns-interface", ARG_STRING}, - {"*e", "disable-epsv", ARG_BOOL}, - {"*f", "disallow-username-in-url", ARG_BOOL}, - {"*E", "epsv", ARG_BOOL}, - /* 'epsv' made like this to make --no-epsv and --epsv to work - although --disable-epsv is the documented option */ - {"*F", "dns-servers", ARG_STRING}, - {"*g", "trace", ARG_FILENAME}, - {"*G", "npn", ARG_BOOL}, - {"*h", "trace-ascii", ARG_FILENAME}, - {"*H", "alpn", ARG_BOOL}, - {"*i", "limit-rate", ARG_STRING}, - {"*I", "rate", ARG_STRING}, - {"*j", "compressed", ARG_BOOL}, - {"*J", "tr-encoding", ARG_BOOL}, - {"*k", "digest", ARG_BOOL}, - {"*l", "negotiate", ARG_BOOL}, - {"*m", "ntlm", ARG_BOOL}, - {"*M", "ntlm-wb", ARG_BOOL}, - {"*n", "basic", ARG_BOOL}, - {"*o", "anyauth", ARG_BOOL}, + {"abstract-unix-socket", ARG_FILE, ' ', C_ABSTRACT_UNIX_SOCKET}, + {"alpn", ARG_BOOL, ' ', C_ALPN}, + {"alt-svc", ARG_STRG, ' ', C_ALT_SVC}, + {"anyauth", ARG_BOOL, ' ', C_ANYAUTH}, + {"append", ARG_BOOL, 'a', C_APPEND}, + {"aws-sigv4", ARG_STRG, ' ', C_AWS_SIGV4}, + {"basic", ARG_BOOL, ' ', C_BASIC}, + {"buffer", ARG_BOOL, 'N', C_BUFFER}, + {"ca-native", ARG_BOOL, ' ', C_CA_NATIVE}, + {"cacert", ARG_FILE, ' ', C_CACERT}, + {"capath", ARG_FILE, ' ', C_CAPATH}, + {"cert", ARG_FILE, 'E', C_CERT}, + {"cert-status", ARG_BOOL, ' ', C_CERT_STATUS}, + {"cert-type", ARG_STRG, ' ', C_CERT_TYPE}, + {"ciphers", ARG_STRG, ' ', C_CIPHERS}, + {"clobber", ARG_BOOL, ' ', C_CLOBBER}, + {"compressed", ARG_BOOL, ' ', C_COMPRESSED}, + {"compressed-ssh", ARG_BOOL, ' ', C_COMPRESSED_SSH}, + {"config", ARG_FILE, 'K', C_CONFIG}, + {"connect-timeout", ARG_STRG, ' ', C_CONNECT_TIMEOUT}, + {"connect-to", ARG_STRG, ' ', C_CONNECT_TO}, + {"continue-at", ARG_STRG, 'C', C_CONTINUE_AT}, + {"cookie", ARG_STRG, 'b', C_COOKIE}, + {"cookie-jar", ARG_STRG, 'c', C_COOKIE_JAR}, + {"create-dirs", ARG_BOOL, ' ', C_CREATE_DIRS}, + {"create-file-mode", ARG_STRG, ' ', C_CREATE_FILE_MODE}, + {"crlf", ARG_BOOL, ' ', C_CRLF}, + {"crlfile", ARG_FILE, ' ', C_CRLFILE}, + {"curves", ARG_STRG, ' ', C_CURVES}, + {"data", ARG_STRG, 'd', C_DATA}, + {"data-ascii", ARG_STRG, ' ', C_DATA_ASCII}, + {"data-binary", ARG_STRG, ' ', C_DATA_BINARY}, + {"data-raw", ARG_STRG, ' ', C_DATA_RAW}, + {"data-urlencode", ARG_STRG, ' ', C_DATA_URLENCODE}, + {"delegation", ARG_STRG, ' ', C_DELEGATION}, + {"digest", ARG_BOOL, ' ', C_DIGEST}, + {"disable", ARG_BOOL, 'q', C_DISABLE}, + {"disable-eprt", ARG_BOOL, ' ', C_DISABLE_EPRT}, + {"disable-epsv", ARG_BOOL, ' ', C_DISABLE_EPSV}, + {"disallow-username-in-url", ARG_BOOL, ' ', C_DISALLOW_USERNAME_IN_URL}, + {"dns-interface", ARG_STRG, ' ', C_DNS_INTERFACE}, + {"dns-ipv4-addr", ARG_STRG, ' ', C_DNS_IPV4_ADDR}, + {"dns-ipv6-addr", ARG_STRG, ' ', C_DNS_IPV6_ADDR}, + {"dns-servers", ARG_STRG, ' ', C_DNS_SERVERS}, + {"doh-cert-status", ARG_BOOL, ' ', C_DOH_CERT_STATUS}, + {"doh-insecure", ARG_BOOL, ' ', C_DOH_INSECURE}, + {"doh-url" , ARG_STRG, ' ', C_DOH_URL}, + {"dump-header", ARG_FILE, 'D', C_DUMP_HEADER}, + {"egd-file", ARG_STRG, ' ', C_EGD_FILE}, + {"engine", ARG_STRG, ' ', C_ENGINE}, + {"eprt", ARG_BOOL, ' ', C_EPRT}, + {"epsv", ARG_BOOL, ' ', C_EPSV}, + {"etag-compare", ARG_FILE, ' ', C_ETAG_COMPARE}, + {"etag-save", ARG_FILE, ' ', C_ETAG_SAVE}, + {"expect100-timeout", ARG_STRG, ' ', C_EXPECT100_TIMEOUT}, + {"fail", ARG_BOOL, 'f', C_FAIL}, + {"fail-early", ARG_BOOL, ' ', C_FAIL_EARLY}, + {"fail-with-body", ARG_BOOL, ' ', C_FAIL_WITH_BODY}, + {"false-start", ARG_BOOL, ' ', C_FALSE_START}, + {"form", ARG_STRG, 'F', C_FORM}, + {"form-escape", ARG_BOOL, ' ', C_FORM_ESCAPE}, + {"form-string", ARG_STRG, ' ', C_FORM_STRING}, + {"ftp-account", ARG_STRG, ' ', C_FTP_ACCOUNT}, + {"ftp-alternative-to-user", ARG_STRG, ' ', C_FTP_ALTERNATIVE_TO_USER}, + {"ftp-create-dirs", ARG_BOOL, ' ', C_FTP_CREATE_DIRS}, + {"ftp-method", ARG_STRG, ' ', C_FTP_METHOD}, + {"ftp-pasv", ARG_BOOL, ' ', C_FTP_PASV}, + {"ftp-port", ARG_STRG, 'P', C_FTP_PORT}, + {"ftp-pret", ARG_BOOL, ' ', C_FTP_PRET}, + {"ftp-skip-pasv-ip", ARG_BOOL, ' ', C_FTP_SKIP_PASV_IP}, + {"ftp-ssl", ARG_BOOL, ' ', C_FTP_SSL}, + {"ftp-ssl-ccc", ARG_BOOL, ' ', C_FTP_SSL_CCC}, + {"ftp-ssl-ccc-mode", ARG_STRG, ' ', C_FTP_SSL_CCC_MODE}, + {"ftp-ssl-control", ARG_BOOL, ' ', C_FTP_SSL_CONTROL}, + {"ftp-ssl-reqd", ARG_BOOL, ' ', C_FTP_SSL_REQD}, + {"get", ARG_BOOL, 'G', C_GET}, + {"globoff", ARG_BOOL, 'g', C_GLOBOFF}, + {"happy-eyeballs-timeout-ms", ARG_STRG, ' ', C_HAPPY_EYEBALLS_TIMEOUT_MS}, + {"haproxy-clientip", ARG_STRG, ' ', C_HAPROXY_CLIENTIP}, + {"haproxy-protocol", ARG_BOOL, ' ', C_HAPROXY_PROTOCOL}, + {"head", ARG_BOOL, 'I', C_HEAD}, + {"header", ARG_STRG, 'H', C_HEADER}, + {"help", ARG_BOOL, 'h', C_HELP}, + {"hostpubmd5", ARG_STRG, ' ', C_HOSTPUBMD5}, + {"hostpubsha256", ARG_STRG, ' ', C_HOSTPUBSHA256}, + {"hsts", ARG_STRG, ' ', C_HSTS}, + {"http0.9", ARG_BOOL, ' ', C_HTTP0_9}, + {"http1.0", ARG_NONE, '0', C_HTTP1_0}, + {"http1.1", ARG_NONE, ' ', C_HTTP1_1}, + {"http2", ARG_NONE, ' ', C_HTTP2}, + {"http2-prior-knowledge", ARG_NONE, ' ', C_HTTP2_PRIOR_KNOWLEDGE}, + {"http3", ARG_NONE, ' ', C_HTTP3}, + {"http3-only", ARG_NONE, ' ', C_HTTP3_ONLY}, + {"ignore-content-length", ARG_BOOL, ' ', C_IGNORE_CONTENT_LENGTH}, + {"include", ARG_BOOL, 'i', C_INCLUDE}, + {"insecure", ARG_BOOL, 'k', C_INSECURE}, + {"interface", ARG_STRG, ' ', C_INTERFACE}, + {"ipfs-gateway", ARG_STRG, ' ', C_IPFS_GATEWAY}, + {"ipv4", ARG_NONE, '4', C_IPV4}, + {"ipv6", ARG_NONE, '6', C_IPV6}, + {"json", ARG_STRG, ' ', C_JSON}, + {"junk-session-cookies", ARG_BOOL, 'j', C_JUNK_SESSION_COOKIES}, + {"keepalive", ARG_BOOL, ' ', C_KEEPALIVE}, + {"keepalive-time", ARG_STRG, ' ', C_KEEPALIVE_TIME}, + {"key", ARG_FILE, ' ', C_KEY}, + {"key-type", ARG_STRG, ' ', C_KEY_TYPE}, + {"krb", ARG_STRG, ' ', C_KRB}, + {"krb4", ARG_STRG, ' ', C_KRB4}, + {"libcurl", ARG_STRG, ' ', C_LIBCURL}, + {"limit-rate", ARG_STRG, ' ', C_LIMIT_RATE}, + {"list-only", ARG_BOOL, 'l', C_LIST_ONLY}, + {"local-port", ARG_STRG, ' ', C_LOCAL_PORT}, + {"location", ARG_BOOL, 'L', C_LOCATION}, + {"location-trusted", ARG_BOOL, ' ', C_LOCATION_TRUSTED}, + {"login-options", ARG_STRG, ' ', C_LOGIN_OPTIONS}, + {"mail-auth", ARG_STRG, ' ', C_MAIL_AUTH}, + {"mail-from", ARG_STRG, ' ', C_MAIL_FROM}, + {"mail-rcpt", ARG_STRG, ' ', C_MAIL_RCPT}, + {"mail-rcpt-allowfails", ARG_BOOL, ' ', C_MAIL_RCPT_ALLOWFAILS}, + {"manual", ARG_BOOL, 'M', C_MANUAL}, + {"max-filesize", ARG_STRG, ' ', C_MAX_FILESIZE}, + {"max-redirs", ARG_STRG, ' ', C_MAX_REDIRS}, + {"max-time", ARG_STRG, 'm', C_MAX_TIME}, + {"metalink", ARG_BOOL, ' ', C_METALINK}, + {"negotiate", ARG_BOOL, ' ', C_NEGOTIATE}, + {"netrc", ARG_BOOL, 'n', C_NETRC}, + {"netrc-file", ARG_FILE, ' ', C_NETRC_FILE}, + {"netrc-optional", ARG_BOOL, ' ', C_NETRC_OPTIONAL}, + {"next", ARG_NONE, ':', C_NEXT}, + {"noproxy", ARG_STRG, ' ', C_NOPROXY}, + {"npn", ARG_BOOL, ' ', C_NPN}, + {"ntlm", ARG_BOOL, ' ', C_NTLM}, + {"ntlm-wb", ARG_BOOL, ' ', C_NTLM_WB}, + {"oauth2-bearer", ARG_STRG, ' ', C_OAUTH2_BEARER}, + {"output", ARG_FILE, 'o', C_OUTPUT}, + {"output-dir", ARG_STRG, ' ', C_OUTPUT_DIR}, + {"parallel", ARG_BOOL, 'Z', C_PARALLEL}, + {"parallel-immediate", ARG_BOOL, ' ', C_PARALLEL_IMMEDIATE}, + {"parallel-max", ARG_STRG, ' ', C_PARALLEL_MAX}, + {"pass", ARG_STRG, ' ', C_PASS}, + {"path-as-is", ARG_BOOL, ' ', C_PATH_AS_IS}, + {"pinnedpubkey", ARG_STRG, ' ', C_PINNEDPUBKEY}, + {"post301", ARG_BOOL, ' ', C_POST301}, + {"post302", ARG_BOOL, ' ', C_POST302}, + {"post303", ARG_BOOL, ' ', C_POST303}, + {"preproxy", ARG_STRG, ' ', C_PREPROXY}, + {"progress-bar", ARG_BOOL, '#', C_PROGRESS_BAR}, + {"progress-meter", ARG_BOOL, ' ', C_PROGRESS_METER}, + {"proto", ARG_STRG, ' ', C_PROTO}, + {"proto-default", ARG_STRG, ' ', C_PROTO_DEFAULT}, + {"proto-redir", ARG_STRG, ' ', C_PROTO_REDIR}, + {"proxy", ARG_STRG, 'x', C_PROXY}, + {"proxy-anyauth", ARG_BOOL, ' ', C_PROXY_ANYAUTH}, + {"proxy-basic", ARG_BOOL, ' ', C_PROXY_BASIC}, + {"proxy-ca-native", ARG_BOOL, ' ', C_PROXY_CA_NATIVE}, + {"proxy-cacert", ARG_FILE, ' ', C_PROXY_CACERT}, + {"proxy-capath", ARG_FILE, ' ', C_PROXY_CAPATH}, + {"proxy-cert", ARG_FILE, ' ', C_PROXY_CERT}, + {"proxy-cert-type", ARG_STRG, ' ', C_PROXY_CERT_TYPE}, + {"proxy-ciphers", ARG_STRG, ' ', C_PROXY_CIPHERS}, + {"proxy-crlfile", ARG_FILE, ' ', C_PROXY_CRLFILE}, + {"proxy-digest", ARG_BOOL, ' ', C_PROXY_DIGEST}, + {"proxy-header", ARG_STRG, ' ', C_PROXY_HEADER}, + {"proxy-http2", ARG_BOOL, ' ', C_PROXY_HTTP2}, + {"proxy-insecure", ARG_BOOL, ' ', C_PROXY_INSECURE}, + {"proxy-key", ARG_FILE, ' ', C_PROXY_KEY}, + {"proxy-key-type", ARG_STRG, ' ', C_PROXY_KEY_TYPE}, + {"proxy-negotiate", ARG_BOOL, ' ', C_PROXY_NEGOTIATE}, + {"proxy-ntlm", ARG_BOOL, ' ', C_PROXY_NTLM}, + {"proxy-pass", ARG_STRG, ' ', C_PROXY_PASS}, + {"proxy-pinnedpubkey", ARG_STRG, ' ', C_PROXY_PINNEDPUBKEY}, + {"proxy-service-name", ARG_STRG, ' ', C_PROXY_SERVICE_NAME}, + {"proxy-ssl-allow-beast", ARG_BOOL, ' ', C_PROXY_SSL_ALLOW_BEAST}, + {"proxy-ssl-auto-client-cert", ARG_BOOL, ' ', C_PROXY_SSL_AUTO_CLIENT_CERT}, + {"proxy-tls13-ciphers", ARG_STRG, ' ', C_PROXY_TLS13_CIPHERS}, + {"proxy-tlsauthtype", ARG_STRG, ' ', C_PROXY_TLSAUTHTYPE}, + {"proxy-tlspassword", ARG_STRG, ' ', C_PROXY_TLSPASSWORD}, + {"proxy-tlsuser", ARG_STRG, ' ', C_PROXY_TLSUSER}, + {"proxy-tlsv1", ARG_NONE, ' ', C_PROXY_TLSV1}, + {"proxy-user", ARG_STRG, 'U', C_PROXY_USER}, + {"proxy1.0", ARG_STRG, ' ', C_PROXY1_0}, + {"proxytunnel", ARG_BOOL, 'p', C_PROXYTUNNEL}, + {"pubkey", ARG_STRG, ' ', C_PUBKEY}, + {"quote", ARG_STRG, 'Q', C_QUOTE}, + {"random-file", ARG_FILE, ' ', C_RANDOM_FILE}, + {"range", ARG_STRG, 'r', C_RANGE}, + {"rate", ARG_STRG, ' ', C_RATE}, + {"raw", ARG_BOOL, ' ', C_RAW}, + {"referer", ARG_STRG, 'e', C_REFERER}, + {"remote-header-name", ARG_BOOL, 'J', C_REMOTE_HEADER_NAME}, + {"remote-name", ARG_BOOL, 'O', C_REMOTE_NAME}, + {"remote-name-all", ARG_BOOL, ' ', C_REMOTE_NAME_ALL}, + {"remote-time", ARG_BOOL, 'R', C_REMOTE_TIME}, + {"remove-on-error", ARG_BOOL, ' ', C_REMOVE_ON_ERROR}, + {"request", ARG_STRG, 'X', C_REQUEST}, + {"request-target", ARG_STRG, ' ', C_REQUEST_TARGET}, + {"resolve", ARG_STRG, ' ', C_RESOLVE}, + {"retry", ARG_STRG, ' ', C_RETRY}, + {"retry-all-errors", ARG_BOOL, ' ', C_RETRY_ALL_ERRORS}, + {"retry-connrefused", ARG_BOOL, ' ', C_RETRY_CONNREFUSED}, + {"retry-delay", ARG_STRG, ' ', C_RETRY_DELAY}, + {"retry-max-time", ARG_STRG, ' ', C_RETRY_MAX_TIME}, + {"sasl-authzid", ARG_STRG, ' ', C_SASL_AUTHZID}, + {"sasl-ir", ARG_BOOL, ' ', C_SASL_IR}, + {"service-name", ARG_STRG, ' ', C_SERVICE_NAME}, + {"sessionid", ARG_BOOL, ' ', C_SESSIONID}, + {"show-error", ARG_BOOL, 'S', C_SHOW_ERROR}, + {"silent", ARG_BOOL, 's', C_SILENT}, + {"socks4", ARG_STRG, ' ', C_SOCKS4}, + {"socks4a", ARG_STRG, ' ', C_SOCKS4A}, + {"socks5", ARG_STRG, ' ', C_SOCKS5}, + {"socks5-basic", ARG_BOOL, ' ', C_SOCKS5_BASIC}, + {"socks5-gssapi", ARG_BOOL, ' ', C_SOCKS5_GSSAPI}, + {"socks5-gssapi-nec", ARG_BOOL, ' ', C_SOCKS5_GSSAPI_NEC}, + {"socks5-gssapi-service", ARG_STRG, ' ', C_SOCKS5_GSSAPI_SERVICE}, + {"socks5-hostname", ARG_STRG, ' ', C_SOCKS5_HOSTNAME}, + {"speed-limit", ARG_STRG, 'Y', C_SPEED_LIMIT}, + {"speed-time", ARG_STRG, 'y', C_SPEED_TIME}, + {"ssl", ARG_BOOL, ' ', C_SSL}, + {"ssl-allow-beast", ARG_BOOL, ' ', C_SSL_ALLOW_BEAST}, + {"ssl-auto-client-cert", ARG_BOOL, ' ', C_SSL_AUTO_CLIENT_CERT}, + {"ssl-no-revoke", ARG_BOOL, ' ', C_SSL_NO_REVOKE}, + {"ssl-reqd", ARG_BOOL, ' ', C_SSL_REQD}, + {"ssl-revoke-best-effort", ARG_BOOL, ' ', C_SSL_REVOKE_BEST_EFFORT}, + {"sslv2", ARG_NONE, '2', C_SSLV2}, + {"sslv3", ARG_NONE, '3', C_SSLV3}, + {"stderr", ARG_FILE, ' ', C_STDERR}, + {"styled-output", ARG_BOOL, ' ', C_STYLED_OUTPUT}, + {"suppress-connect-headers", ARG_BOOL, ' ', C_SUPPRESS_CONNECT_HEADERS}, + {"tcp-fastopen", ARG_BOOL, ' ', C_TCP_FASTOPEN}, + {"tcp-nodelay", ARG_BOOL, ' ', C_TCP_NODELAY}, + {"telnet-option", ARG_STRG, 't', C_TELNET_OPTION}, + {"test-event", ARG_BOOL, ' ', C_TEST_EVENT}, + {"tftp-blksize", ARG_STRG, ' ', C_TFTP_BLKSIZE}, + {"tftp-no-options", ARG_BOOL, ' ', C_TFTP_NO_OPTIONS}, + {"time-cond", ARG_STRG, 'z', C_TIME_COND}, + {"tls-max", ARG_STRG, ' ', C_TLS_MAX}, + {"tls13-ciphers", ARG_STRG, ' ', C_TLS13_CIPHERS}, + {"tlsauthtype", ARG_STRG, ' ', C_TLSAUTHTYPE}, + {"tlspassword", ARG_STRG, ' ', C_TLSPASSWORD}, + {"tlsuser", ARG_STRG, ' ', C_TLSUSER}, + {"tlsv1", ARG_NONE, '1', C_TLSV1}, + {"tlsv1.0", ARG_NONE, ' ', C_TLSV1_0}, + {"tlsv1.1", ARG_NONE, ' ', C_TLSV1_1}, + {"tlsv1.2", ARG_NONE, ' ', C_TLSV1_2}, + {"tlsv1.3", ARG_NONE, ' ', C_TLSV1_3}, + {"tr-encoding", ARG_BOOL, ' ', C_TR_ENCODING}, + {"trace", ARG_FILE, ' ', C_TRACE}, + {"trace-ascii", ARG_FILE, ' ', C_TRACE_ASCII}, + {"trace-config", ARG_STRG, ' ', C_TRACE_CONFIG}, + {"trace-ids", ARG_BOOL, ' ', C_TRACE_IDS}, + {"trace-time", ARG_BOOL, ' ', C_TRACE_TIME}, + {"unix-socket", ARG_FILE, ' ', C_UNIX_SOCKET}, + {"upload-file", ARG_FILE, 'T', C_UPLOAD_FILE}, + {"url", ARG_STRG, ' ', C_URL}, + {"url-query", ARG_STRG, ' ', C_URL_QUERY}, + {"use-ascii", ARG_BOOL, 'B', C_USE_ASCII}, + {"user", ARG_STRG, 'u', C_USER}, + {"user-agent", ARG_STRG, 'A', C_USER_AGENT}, + {"variable", ARG_STRG, ' ', C_VARIABLE}, + {"verbose", ARG_BOOL, 'v', C_VERBOSE}, + {"version", ARG_BOOL, 'V', C_VERSION}, #ifdef USE_WATT32 - {"*p", "wdebug", ARG_BOOL}, + {"wdebug", ARG_BOOL, ' ', C_WDEBUG}, #endif - {"*q", "ftp-create-dirs", ARG_BOOL}, - {"*r", "create-dirs", ARG_BOOL}, - {"*R", "create-file-mode", ARG_STRING}, - {"*s", "max-redirs", ARG_STRING}, - {"*S", "ipfs-gateway", ARG_STRING}, - {"*t", "proxy-ntlm", ARG_BOOL}, - {"*u", "crlf", ARG_BOOL}, - {"*v", "stderr", ARG_FILENAME}, - {"*V", "aws-sigv4", ARG_STRING}, - {"*w", "interface", ARG_STRING}, - {"*x", "krb", ARG_STRING}, - {"*x", "krb4", ARG_STRING}, - /* 'krb4' is the previous name */ - {"*X", "haproxy-protocol", ARG_BOOL}, - {"*P", "haproxy-clientip", ARG_STRING}, - {"*y", "max-filesize", ARG_STRING}, - {"*z", "disable-eprt", ARG_BOOL}, - {"*Z", "eprt", ARG_BOOL}, - /* 'eprt' made like this to make --no-eprt and --eprt to work - although --disable-eprt is the documented option */ - {"*~", "xattr", ARG_BOOL}, - {"$a", "ftp-ssl", ARG_BOOL}, - /* 'ftp-ssl' deprecated name since 7.20.0 */ - {"$a", "ssl", ARG_BOOL}, - /* 'ssl' new option name in 7.20.0, previously this was ftp-ssl */ - {"$b", "ftp-pasv", ARG_BOOL}, - {"$c", "socks5", ARG_STRING}, - {"$d", "tcp-nodelay", ARG_BOOL}, - {"$e", "proxy-digest", ARG_BOOL}, - {"$f", "proxy-basic", ARG_BOOL}, - {"$g", "retry", ARG_STRING}, - {"$V", "retry-connrefused", ARG_BOOL}, - {"$h", "retry-delay", ARG_STRING}, - {"$i", "retry-max-time", ARG_STRING}, - {"$k", "proxy-negotiate", ARG_BOOL}, - {"$l", "form-escape", ARG_BOOL}, - {"$m", "ftp-account", ARG_STRING}, - {"$n", "proxy-anyauth", ARG_BOOL}, - {"$o", "trace-time", ARG_BOOL}, - {"$p", "ignore-content-length", ARG_BOOL}, - {"$q", "ftp-skip-pasv-ip", ARG_BOOL}, - {"$r", "ftp-method", ARG_STRING}, - {"$s", "local-port", ARG_STRING}, - {"$t", "socks4", ARG_STRING}, - {"$T", "socks4a", ARG_STRING}, - {"$u", "ftp-alternative-to-user", ARG_STRING}, - {"$v", "ftp-ssl-reqd", ARG_BOOL}, - /* 'ftp-ssl-reqd' deprecated name since 7.20.0 */ - {"$v", "ssl-reqd", ARG_BOOL}, - /* 'ssl-reqd' new in 7.20.0, previously this was ftp-ssl-reqd */ - {"$w", "sessionid", ARG_BOOL}, - /* 'sessionid' listed as --no-sessionid in the help */ - {"$x", "ftp-ssl-control", ARG_BOOL}, - {"$y", "ftp-ssl-ccc", ARG_BOOL}, - {"$j", "ftp-ssl-ccc-mode", ARG_STRING}, - {"$z", "libcurl", ARG_STRING}, - {"$#", "raw", ARG_BOOL}, - {"$0", "post301", ARG_BOOL}, - {"$1", "keepalive", ARG_BOOL}, - /* 'keepalive' listed as --no-keepalive in the help */ - {"$2", "socks5-hostname", ARG_STRING}, - {"$3", "keepalive-time", ARG_STRING}, - {"$4", "post302", ARG_BOOL}, - {"$5", "noproxy", ARG_STRING}, - {"$7", "socks5-gssapi-nec", ARG_BOOL}, - {"$8", "proxy1.0", ARG_STRING}, - {"$9", "tftp-blksize", ARG_STRING}, - {"$A", "mail-from", ARG_STRING}, - {"$B", "mail-rcpt", ARG_STRING}, - {"$C", "ftp-pret", ARG_BOOL}, - {"$D", "proto", ARG_STRING}, - {"$E", "proto-redir", ARG_STRING}, - {"$F", "resolve", ARG_STRING}, - {"$G", "delegation", ARG_STRING}, - {"$H", "mail-auth", ARG_STRING}, - {"$I", "post303", ARG_BOOL}, - {"$J", "metalink", ARG_BOOL}, - {"$6", "sasl-authzid", ARG_STRING}, - {"$K", "sasl-ir", ARG_BOOL }, - {"$L", "test-event", ARG_BOOL}, - {"$M", "unix-socket", ARG_FILENAME}, - {"$N", "path-as-is", ARG_BOOL}, - {"$O", "socks5-gssapi-service", ARG_STRING}, - /* 'socks5-gssapi-service' merged with'proxy-service-name' and - deprecated since 7.49.0 */ - {"$O", "proxy-service-name", ARG_STRING}, - {"$P", "service-name", ARG_STRING}, - {"$Q", "proto-default", ARG_STRING}, - {"$R", "expect100-timeout", ARG_STRING}, - {"$S", "tftp-no-options", ARG_BOOL}, - {"$U", "connect-to", ARG_STRING}, - {"$W", "abstract-unix-socket", ARG_FILENAME}, - {"$X", "tls-max", ARG_STRING}, - {"$Y", "suppress-connect-headers", ARG_BOOL}, - {"$Z", "compressed-ssh", ARG_BOOL}, - {"$~", "happy-eyeballs-timeout-ms", ARG_STRING}, - {"$!", "retry-all-errors", ARG_BOOL}, - {"$%", "trace-ids", ARG_BOOL}, - {"$&", "trace-config", ARG_STRING}, - {"0", "http1.0", ARG_NONE}, - {"01", "http1.1", ARG_NONE}, - {"02", "http2", ARG_NONE}, - {"03", "http2-prior-knowledge", ARG_NONE}, - {"04", "http3", ARG_NONE}, - {"05", "http3-only", ARG_NONE}, - {"09", "http0.9", ARG_BOOL}, - {"0a", "proxy-http2", ARG_BOOL}, - {"1", "tlsv1", ARG_NONE}, - {"10", "tlsv1.0", ARG_NONE}, - {"11", "tlsv1.1", ARG_NONE}, - {"12", "tlsv1.2", ARG_NONE}, - {"13", "tlsv1.3", ARG_NONE}, - {"1A", "tls13-ciphers", ARG_STRING}, - {"1B", "proxy-tls13-ciphers", ARG_STRING}, - {"2", "sslv2", ARG_NONE}, - {"3", "sslv3", ARG_NONE}, - {"4", "ipv4", ARG_NONE}, - {"6", "ipv6", ARG_NONE}, - {"a", "append", ARG_BOOL}, - {"A", "user-agent", ARG_STRING}, - {"b", "cookie", ARG_STRING}, - {"ba", "alt-svc", ARG_STRING}, - {"bb", "hsts", ARG_STRING}, - {"B", "use-ascii", ARG_BOOL}, - {"c", "cookie-jar", ARG_STRING}, - {"C", "continue-at", ARG_STRING}, - {"d", "data", ARG_STRING}, - {"dr", "data-raw", ARG_STRING}, - {"da", "data-ascii", ARG_STRING}, - {"db", "data-binary", ARG_STRING}, - {"de", "data-urlencode", ARG_STRING}, - {"df", "json", ARG_STRING}, - {"dg", "url-query", ARG_STRING}, - {"D", "dump-header", ARG_FILENAME}, - {"e", "referer", ARG_STRING}, - {"E", "cert", ARG_FILENAME}, - {"Ea", "cacert", ARG_FILENAME}, - {"Eb", "cert-type", ARG_STRING}, - {"Ec", "key", ARG_FILENAME}, - {"Ed", "key-type", ARG_STRING}, - {"Ee", "pass", ARG_STRING}, - {"Ef", "engine", ARG_STRING}, - {"EG", "ca-native", ARG_BOOL}, - {"EH", "proxy-ca-native", ARG_BOOL}, - {"Eg", "capath", ARG_FILENAME}, - {"Eh", "pubkey", ARG_STRING}, - {"Ei", "hostpubmd5", ARG_STRING}, - {"EF", "hostpubsha256", ARG_STRING}, - {"Ej", "crlfile", ARG_FILENAME}, - {"Ek", "tlsuser", ARG_STRING}, - {"El", "tlspassword", ARG_STRING}, - {"Em", "tlsauthtype", ARG_STRING}, - {"En", "ssl-allow-beast", ARG_BOOL}, - {"Eo", "ssl-auto-client-cert", ARG_BOOL}, - {"EO", "proxy-ssl-auto-client-cert", ARG_BOOL}, - {"Ep", "pinnedpubkey", ARG_STRING}, - {"EP", "proxy-pinnedpubkey", ARG_STRING}, - {"Eq", "cert-status", ARG_BOOL}, - {"EQ", "doh-cert-status", ARG_BOOL}, - {"Er", "false-start", ARG_BOOL}, - {"Es", "ssl-no-revoke", ARG_BOOL}, - {"ES", "ssl-revoke-best-effort", ARG_BOOL}, - {"Et", "tcp-fastopen", ARG_BOOL}, - {"Eu", "proxy-tlsuser", ARG_STRING}, - {"Ev", "proxy-tlspassword", ARG_STRING}, - {"Ew", "proxy-tlsauthtype", ARG_STRING}, - {"Ex", "proxy-cert", ARG_FILENAME}, - {"Ey", "proxy-cert-type", ARG_STRING}, - {"Ez", "proxy-key", ARG_FILENAME}, - {"E0", "proxy-key-type", ARG_STRING}, - {"E1", "proxy-pass", ARG_STRING}, - {"E2", "proxy-ciphers", ARG_STRING}, - {"E3", "proxy-crlfile", ARG_FILENAME}, - {"E4", "proxy-ssl-allow-beast", ARG_BOOL}, - {"E5", "login-options", ARG_STRING}, - {"E6", "proxy-cacert", ARG_FILENAME}, - {"E7", "proxy-capath", ARG_FILENAME}, - {"E8", "proxy-insecure", ARG_BOOL}, - {"E9", "proxy-tlsv1", ARG_NONE}, - {"EA", "socks5-basic", ARG_BOOL}, - {"EB", "socks5-gssapi", ARG_BOOL}, - {"EC", "etag-save", ARG_FILENAME}, - {"ED", "etag-compare", ARG_FILENAME}, - {"EE", "curves", ARG_STRING}, - {"f", "fail", ARG_BOOL}, - {"fa", "fail-early", ARG_BOOL}, - {"fb", "styled-output", ARG_BOOL}, - {"fc", "mail-rcpt-allowfails", ARG_BOOL}, - {"fd", "fail-with-body", ARG_BOOL}, - {"fe", "remove-on-error", ARG_BOOL}, - {"F", "form", ARG_STRING}, - {"Fs", "form-string", ARG_STRING}, - {"g", "globoff", ARG_BOOL}, - {"G", "get", ARG_BOOL}, - {"Ga", "request-target", ARG_STRING}, - {"h", "help", ARG_BOOL}, - {"H", "header", ARG_STRING}, - {"Hp", "proxy-header", ARG_STRING}, - {"i", "include", ARG_BOOL}, - {"I", "head", ARG_BOOL}, - {"j", "junk-session-cookies", ARG_BOOL}, - {"J", "remote-header-name", ARG_BOOL}, - {"k", "insecure", ARG_BOOL}, - {"kd", "doh-insecure", ARG_BOOL}, - {"K", "config", ARG_FILENAME}, - {"l", "list-only", ARG_BOOL}, - {"L", "location", ARG_BOOL}, - {"Lt", "location-trusted", ARG_BOOL}, - {"m", "max-time", ARG_STRING}, - {"M", "manual", ARG_BOOL}, - {"n", "netrc", ARG_BOOL}, - {"no", "netrc-optional", ARG_BOOL}, - {"ne", "netrc-file", ARG_FILENAME}, - {"N", "buffer", ARG_BOOL}, - /* 'buffer' listed as --no-buffer in the help */ - {"o", "output", ARG_FILENAME}, - {"O", "remote-name", ARG_BOOL}, - {"Oa", "remote-name-all", ARG_BOOL}, - {"Ob", "output-dir", ARG_STRING}, - {"Oc", "clobber", ARG_BOOL}, - {"p", "proxytunnel", ARG_BOOL}, - {"P", "ftp-port", ARG_STRING}, - {"q", "disable", ARG_BOOL}, - {"Q", "quote", ARG_STRING}, - {"r", "range", ARG_STRING}, - {"R", "remote-time", ARG_BOOL}, - {"s", "silent", ARG_BOOL}, - {"S", "show-error", ARG_BOOL}, - {"t", "telnet-option", ARG_STRING}, - {"T", "upload-file", ARG_FILENAME}, - {"u", "user", ARG_STRING}, - {"U", "proxy-user", ARG_STRING}, - {"v", "verbose", ARG_BOOL}, - {"V", "version", ARG_BOOL}, - {"w", "write-out", ARG_STRING}, - {"x", "proxy", ARG_STRING}, - {"xa", "preproxy", ARG_STRING}, - {"X", "request", ARG_STRING}, - {"Y", "speed-limit", ARG_STRING}, - {"y", "speed-time", ARG_STRING}, - {"z", "time-cond", ARG_STRING}, - {"Z", "parallel", ARG_BOOL}, - {"Zb", "parallel-max", ARG_STRING}, - {"Zc", "parallel-immediate", ARG_BOOL}, - {"#", "progress-bar", ARG_BOOL}, - {"#m", "progress-meter", ARG_BOOL}, - {":", "next", ARG_NONE}, - {":a", "variable", ARG_STRING}, + {"write-out", ARG_STRG, 'w', C_WRITE_OUT}, + {"xattr", ARG_BOOL, ' ', C_XATTR}, }; /* Split the argument of -E to 'certname' and 'passphrase' separated by colon. @@ -495,12 +758,14 @@ static void GetFileAndPassword(char *nextarg, char **file, char **password) { char *certname, *passphrase; - parse_cert_parameter(nextarg, &certname, &passphrase); - Curl_safefree(*file); - *file = certname; - if(passphrase) { - Curl_safefree(*password); - *password = passphrase; + if(nextarg) { + parse_cert_parameter(nextarg, &certname, &passphrase); + Curl_safefree(*file); + *file = certname; + if(passphrase) { + Curl_safefree(*password); + *password = passphrase; + } } } @@ -559,7 +824,7 @@ static ParameterError GetSizeParameter(struct GlobalConfig *global, #ifdef HAVE_WRITABLE_ARGV static void cleanarg(argv_item_t str) { - /* now that GetStr has copied the contents of nextarg, wipe the next + /* now that getstr has copied the contents of nextarg, wipe the next * argument out so that the username:password isn't displayed in the * system process list */ if(str) { @@ -624,7 +889,9 @@ static ParameterError data_urlencode(struct GlobalConfig *global, return err; } else { - GetStr(&postdata, p); + err = getstr(&postdata, p, ALLOW_BLANK); + if(err) + goto error; if(postdata) size = strlen(postdata); } @@ -641,25 +908,18 @@ static ParameterError data_urlencode(struct GlobalConfig *global, char *enc = curl_easy_escape(NULL, postdata, (int)size); Curl_safefree(postdata); /* no matter if it worked or not */ if(enc) { - /* replace (in-place) '%20' by '+' according to RFC1866 */ - size_t enclen = replace_url_encoded_space_by_plus(enc); - /* now make a string with the name from above and append the - encoded string */ - size_t outlen = nlen + enclen + 2; - char *n = malloc(outlen); - if(!n) { - curl_free(enc); - return PARAM_NO_MEM; - } + char *n; + replace_url_encoded_space_by_plus(enc); if(nlen > 0) { /* only append '=' if we have a name */ - msnprintf(n, outlen, "%.*s=%s", (int)nlen, nextarg, enc); - size = outlen-1; - } - else { - strcpy(n, enc); - size = outlen-2; /* since no '=' was inserted */ + n = aprintf("%.*s=%s", (int)nlen, nextarg, enc); + curl_free(enc); + if(!n) + return PARAM_NO_MEM; } - curl_free(enc); + else + n = enc; + + size = strlen(n); postdata = n; } else @@ -738,6 +998,212 @@ static CURLcode set_trace_config(struct GlobalConfig *global, return result; } +static int findarg(const void *a, const void *b) +{ + const struct LongShort *aa = a; + const struct LongShort *bb = b; + return strcmp(aa->lname, bb->lname); +} + +static const struct LongShort *single(char letter) +{ + static const struct LongShort *singles[128 - ' ']; /* ASCII => pointer */ + static bool singles_done = FALSE; + DEBUGASSERT((letter < 127) && (letter > ' ')); + + if(!singles_done) { + unsigned int j; + for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) { + if(aliases[j].letter != ' ') { + unsigned char l = aliases[j].letter; + singles[l - ' '] = &aliases[j]; + } + } + singles_done = TRUE; + } + return singles[letter - ' ']; +} + +#define MAX_QUERY_LEN 100000 /* larger is not likely to ever work */ +static ParameterError url_query(char *nextarg, + struct GlobalConfig *global, + struct OperationConfig *config) +{ + size_t size = 0; + ParameterError err = PARAM_OK; + char *query; + struct curlx_dynbuf dyn; + curlx_dyn_init(&dyn, MAX_QUERY_LEN); + + if(*nextarg == '+') { + /* use without encoding */ + query = strdup(&nextarg[1]); + if(!query) + err = PARAM_NO_MEM; + } + else + err = data_urlencode(global, nextarg, &query, &size); + + if(!err) { + if(config->query) { + CURLcode result = curlx_dyn_addf(&dyn, "%s&%s", config->query, query); + free(query); + if(result) + err = PARAM_NO_MEM; + else { + free(config->query); + config->query = curlx_dyn_ptr(&dyn); + } + } + else + config->query = query; + } + return err; +} + +static ParameterError set_data(cmdline_t cmd, + char *nextarg, + struct GlobalConfig *global, + struct OperationConfig *config) +{ + char *postdata = NULL; + FILE *file; + size_t size = 0; + ParameterError err = PARAM_OK; + + if(cmd == C_DATA_URLENCODE) { /* --data-urlencode */ + err = data_urlencode(global, nextarg, &postdata, &size); + if(err) + return err; + } + else if('@' == *nextarg && (cmd != C_DATA_RAW)) { + /* the data begins with a '@' letter, it means that a file name + or - (stdin) follows */ + nextarg++; /* pass the @ */ + + if(!strcmp("-", nextarg)) { + file = stdin; + if(cmd == C_DATA_BINARY) /* forced data-binary */ + set_binmode(stdin); + } + else { + file = fopen(nextarg, "rb"); + if(!file) { + errorf(global, "Failed to open %s", nextarg); + return PARAM_READ_ERROR; + } + } + + if((cmd == C_DATA_BINARY) || /* --data-binary */ + (cmd == C_JSON) /* --json */) + /* forced binary */ + err = file2memory(&postdata, &size, file); + else { + err = file2string(&postdata, file); + if(postdata) + size = strlen(postdata); + } + + if(file && (file != stdin)) + fclose(file); + if(err) + return err; + + if(!postdata) { + /* no data from the file, point to a zero byte string to make this + get sent as a POST anyway */ + postdata = strdup(""); + if(!postdata) + return PARAM_NO_MEM; + } + } + else { + err = getstr(&postdata, nextarg, ALLOW_BLANK); + if(err) + return err; + if(postdata) + size = strlen(postdata); + } + if(cmd == C_JSON) + config->jsoned = TRUE; + + if(curlx_dyn_len(&config->postdata)) { + /* skip separator append for --json */ + if(!err && (cmd != C_JSON) && + curlx_dyn_addn(&config->postdata, "&", 1)) + err = PARAM_NO_MEM; + } + + if(!err && curlx_dyn_addn(&config->postdata, postdata, size)) + err = PARAM_NO_MEM; + + Curl_safefree(postdata); + + config->postfields = curlx_dyn_ptr(&config->postdata); + return err; +} + +static ParameterError set_rate(struct GlobalConfig *global, + char *nextarg) +{ + /* --rate */ + /* support a few different suffixes, extract the suffix first, then + get the number and convert to per hour. + /s == per second + /m == per minute + /h == per hour (default) + /d == per day (24 hours) + */ + ParameterError err = PARAM_OK; + char *div = strchr(nextarg, '/'); + char number[26]; + long denominator; + long numerator = 60*60*1000; /* default per hour */ + size_t numlen = div ? (size_t)(div - nextarg) : strlen(nextarg); + if(numlen > sizeof(number) -1) + return PARAM_NUMBER_TOO_LARGE; + + strncpy(number, nextarg, numlen); + number[numlen] = 0; + err = str2unum(&denominator, number); + if(err) + return err; + + if(denominator < 1) + return PARAM_BAD_USE; + + if(div) { + char unit = div[1]; + switch(unit) { + case 's': /* per second */ + numerator = 1000; + break; + case 'm': /* per minute */ + numerator = 60*1000; + break; + case 'h': /* per hour */ + break; + case 'd': /* per day */ + numerator = 24*60*60*1000; + break; + default: + errorf(global, "unsupported --rate unit"); + err = PARAM_BAD_USE; + break; + } + } + + if(err) + ; + else if(denominator > numerator) + err = PARAM_NUMBER_TOO_LARGE; + else + global->ms_per_transfer = numerator/denominator; + + return err; +} + + ParameterError getparameter(const char *flag, /* f or -long-flag */ char *nextarg, /* NULL if unset */ argv_item_t cleararg, @@ -746,19 +1212,16 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ struct GlobalConfig *global, struct OperationConfig *config) { - char letter; - char subletter = '\0'; /* subletters can only occur on long options */ int rc; const char *parse = NULL; - unsigned int j; time_t now; - int hit = -1; bool longopt = FALSE; bool singleopt = FALSE; /* when true means '-o foo' used '-ofoo' */ ParameterError err = PARAM_OK; bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled by using --OPTION or --no-OPTION */ bool nextalloc = FALSE; /* if nextarg is allocated */ + struct getout *url; static const char *redir_protos[] = { "http", "https", @@ -766,6 +1229,8 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ "ftps", NULL }; + const struct LongShort *a = NULL; + curl_off_t value; #ifdef HAVE_WRITABLE_ARGV argv_item_t clearthis = NULL; #else @@ -777,10 +1242,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ if(('-' != flag[0]) || ('-' == flag[1])) { /* this should be a long name */ const char *word = ('-' == flag[0]) ? flag + 2 : flag; - size_t fnam = strlen(word); - int numhits = 0; bool noflagged = FALSE; bool expand = FALSE; + struct LongShort key; if(!strncmp(word, "no-", 3)) { /* disable this option but ignore the "no-" part when looking for it */ @@ -793,41 +1257,28 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ word += 7; expand = TRUE; } + key.lname = word; - for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) { - if(curl_strnequal(aliases[j].lname, word, fnam)) { - longopt = TRUE; - numhits++; - if(curl_strequal(aliases[j].lname, word)) { - parse = aliases[j].letter; - hit = j; - numhits = 1; /* a single unique hit */ - break; - } - parse = aliases[j].letter; - hit = j; - } - } - if(numhits > 1) { - /* this is at least the second match! */ - err = PARAM_OPTION_AMBIGUOUS; - goto error; + a = bsearch(&key, aliases, sizeof(aliases)/sizeof(aliases[0]), + sizeof(aliases[0]), findarg); + if(a) { + longopt = TRUE; } - else if(hit < 0) { + else { err = PARAM_OPTION_UNKNOWN; goto error; } - else if(noflagged && (aliases[hit].desc != ARG_BOOL)) { + if(noflagged && (a->desc != ARG_BOOL)) { /* --no- prefixed an option that isn't boolean! */ err = PARAM_NO_NOT_BOOLEAN; goto error; } - else if(expand) { + else if(expand && nextarg) { struct curlx_dynbuf nbuf; bool replaced; - if((aliases[hit].desc != ARG_STRING) && - (aliases[hit].desc != ARG_FILENAME)) { + if((a->desc != ARG_STRG) && + (a->desc != ARG_FILE)) { /* --expand on an option that isn't a string or a filename */ err = PARAM_EXPAND_ERROR; goto error; @@ -845,36 +1296,24 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } else { flag++; /* prefixed with one dash, pass it */ - hit = -1; parse = flag; } do { /* we can loop here if we have multiple single-letters */ + char letter; + cmdline_t cmd; - if(!longopt) { - letter = (char)*parse; - subletter = '\0'; - } - else { - letter = parse[0]; - subletter = parse[1]; - } - - if(hit < 0) { - for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) { - if(letter == aliases[j].letter[0]) { - hit = j; - break; - } - } - if(hit < 0) { + if(!longopt && !a) { + a = single(*parse); + if(!a) { err = PARAM_OPTION_UNKNOWN; break; } } - - if(aliases[hit].desc >= ARG_STRING) { + letter = a->letter; + cmd = a->cmd; + if(a->desc >= ARG_STRG) { /* this option requires an extra parameter */ if(!longopt && parse[1]) { nextarg = (char *)&parse[1]; /* this is the actual extra parameter */ @@ -891,819 +1330,684 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ *usedarg = TRUE; /* mark it as used */ } - if((aliases[hit].desc == ARG_FILENAME) && + if((a->desc == ARG_FILE) && (nextarg[0] == '-') && nextarg[1]) { /* if the file name looks like a command line option */ warnf(global, "The file name argument '%s' looks like a flag.", nextarg); } } - else if((aliases[hit].desc == ARG_NONE) && !toggle) { + else if((a->desc == ARG_NONE) && !toggle) { err = PARAM_NO_PREFIX; break; } - switch(letter) { - case '*': /* options without a short option */ - switch(subletter) { - case '4': /* --dns-ipv4-addr */ - if(!curlinfo->ares_num) { /* c-ares is needed for this */ - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + if(!nextarg) + /* this is a precaution mostly to please scan-build, as all arguments + that use nextarg should be marked as such and they will check that + nextarg is set before continuing, but code analyzers are not always + that aware of that state */ + nextarg = (char *)""; + + switch(cmd) { + case C_DNS_IPV4_ADDR: /* --dns-ipv4-addr */ + if(!curlinfo->ares_num) /* c-ares is needed for this */ + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else /* addr in dot notation */ - GetStr(&config->dns_ipv4_addr, nextarg); - break; - case '6': /* --dns-ipv6-addr */ - if(!curlinfo->ares_num) { /* c-ares is needed for this */ - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + err = getstr(&config->dns_ipv4_addr, nextarg, DENY_BLANK); + break; + case C_DNS_IPV6_ADDR: /* --dns-ipv6-addr */ + if(!curlinfo->ares_num) /* c-ares is needed for this */ + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else /* addr in dot notation */ - GetStr(&config->dns_ipv6_addr, nextarg); - break; - case 'a': /* random-file */ - break; - case 'b': /* egd-file */ - break; - case 'B': /* OAuth 2.0 bearer token */ - GetStr(&config->oauth_bearer, nextarg); + err = getstr(&config->dns_ipv6_addr, nextarg, DENY_BLANK); + break; + case C_RANDOM_FILE: /* --random-file */ + break; + case C_EGD_FILE: /* --egd-file */ + break; + case C_OAUTH2_BEARER: /* --oauth2-bearer */ + err = getstr(&config->oauth_bearer, nextarg, DENY_BLANK); + if(!err) { cleanarg(clearthis); config->authtype |= CURLAUTH_BEARER; - break; - case 'c': /* connect-timeout */ - err = secs2ms(&config->connecttimeout_ms, nextarg); - break; - case 'C': /* doh-url */ - GetStr(&config->doh_url, nextarg); - if(config->doh_url && !config->doh_url[0]) - /* if given a blank string, we make it NULL again */ - Curl_safefree(config->doh_url); - break; - case 'd': /* ciphers */ - GetStr(&config->cipher_list, nextarg); - break; - case 'D': /* --dns-interface */ - if(!curlinfo->ares_num) /* c-ares is needed for this */ - err = PARAM_LIBCURL_DOESNT_SUPPORT; - else - /* interface name */ - GetStr(&config->dns_interface, nextarg); - break; - case 'e': /* --disable-epsv */ - config->disable_epsv = toggle; - break; - case 'f': /* --disallow-username-in-url */ - config->disallow_username_in_url = toggle; - break; - case 'E': /* --epsv */ - config->disable_epsv = (!toggle)?TRUE:FALSE; - break; - case 'F': /* --dns-servers */ - if(!curlinfo->ares_num) /* c-ares is needed for this */ - err = PARAM_LIBCURL_DOESNT_SUPPORT; - else - /* IP addrs of DNS servers */ - GetStr(&config->dns_servers, nextarg); - break; - case 'g': /* --trace */ - GetStr(&global->trace_dump, nextarg); + } + break; + case C_CONNECT_TIMEOUT: /* --connect-timeout */ + err = secs2ms(&config->connecttimeout_ms, nextarg); + break; + case C_DOH_URL: /* --doh-url */ + err = getstr(&config->doh_url, nextarg, ALLOW_BLANK); + if(!err && config->doh_url && !config->doh_url[0]) + /* if given a blank string, make it NULL again */ + Curl_safefree(config->doh_url); + break; + case C_CIPHERS: /* -- ciphers */ + err = getstr(&config->cipher_list, nextarg, DENY_BLANK); + break; + case C_DNS_INTERFACE: /* --dns-interface */ + if(!curlinfo->ares_num) /* c-ares is needed for this */ + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + /* interface name */ + err = getstr(&config->dns_interface, nextarg, DENY_BLANK); + break; + case C_DISABLE_EPSV: /* --disable-epsv */ + config->disable_epsv = toggle; + break; + case C_DISALLOW_USERNAME_IN_URL: /* --disallow-username-in-url */ + config->disallow_username_in_url = toggle; + break; + case C_EPSV: /* --epsv */ + config->disable_epsv = (!toggle)?TRUE:FALSE; + break; + case C_DNS_SERVERS: /* --dns-servers */ + if(!curlinfo->ares_num) /* c-ares is needed for this */ + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + /* IP addrs of DNS servers */ + err = getstr(&config->dns_servers, nextarg, DENY_BLANK); + break; + case C_TRACE: /* --trace */ + err = getstr(&global->trace_dump, nextarg, DENY_BLANK); + if(!err) { if(global->tracetype && (global->tracetype != TRACE_BIN)) warnf(global, "--trace overrides an earlier trace/verbose option"); global->tracetype = TRACE_BIN; - break; - case 'G': /* --npn */ - warnf(global, "--npn is no longer supported"); - break; - case 'h': /* --trace-ascii */ - GetStr(&global->trace_dump, nextarg); + } + break; + case C_NPN: /* --npn */ + warnf(global, "--npn is no longer supported"); + break; + case C_TRACE_ASCII: /* --trace-ascii */ + err = getstr(&global->trace_dump, nextarg, DENY_BLANK); + if(!err) { if(global->tracetype && (global->tracetype != TRACE_ASCII)) warnf(global, "--trace-ascii overrides an earlier trace/verbose option"); global->tracetype = TRACE_ASCII; - break; - case 'H': /* --alpn */ - config->noalpn = (!toggle)?TRUE:FALSE; - break; - case 'i': /* --limit-rate */ - { - curl_off_t value; - err = GetSizeParameter(global, nextarg, "rate", &value); - if(err) - break; + } + break; + case C_ALPN: /* --alpn */ + config->noalpn = (!toggle)?TRUE:FALSE; + break; + case C_LIMIT_RATE: /* --limit-rate */ + err = GetSizeParameter(global, nextarg, "rate", &value); + if(!err) { config->recvpersecond = value; config->sendpersecond = value; } break; - case 'I': /* --rate (request rate) */ - { - /* support a few different suffixes, extract the suffix first, then - get the number and convert to per hour. - /s == per second - /m == per minute - /h == per hour (default) - /d == per day (24 hours) - */ - char *div = strchr(nextarg, '/'); - char number[26]; - long denominator; - long numerator = 60*60*1000; /* default per hour */ - size_t numlen = div ? (size_t)(div - nextarg) : strlen(nextarg); - if(numlen > sizeof(number)-1) { - err = PARAM_NUMBER_TOO_LARGE; - break; - } - strncpy(number, nextarg, numlen); - number[numlen] = 0; - err = str2unum(&denominator, number); - if(err) - break; - - if(denominator < 1) { - err = PARAM_BAD_USE; - break; - } - if(div) { - char unit = div[1]; - switch(unit) { - case 's': /* per second */ - numerator = 1000; - break; - case 'm': /* per minute */ - numerator = 60*1000; - break; - case 'h': /* per hour */ - break; - case 'd': /* per day */ - numerator = 24*60*60*1000; - break; - default: - errorf(global, "unsupported --rate unit"); - err = PARAM_BAD_USE; - break; - } - } - - if(denominator > numerator) { - err = PARAM_NUMBER_TOO_LARGE; - break; - } - - global->ms_per_transfer = numerator/denominator; - } + case C_RATE: + err = set_rate(global, nextarg); break; - - case 'j': /* --compressed */ - if(toggle && !(feature_libz || feature_brotli || feature_zstd)) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + case C_COMPRESSED: /* --compressed */ + if(toggle && !(feature_libz || feature_brotli || feature_zstd)) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else config->encoding = toggle; - break; - - case 'J': /* --tr-encoding */ - config->tr_encoding = toggle; - break; + break; + case C_TR_ENCODING: /* --tr-encoding */ + config->tr_encoding = toggle; + break; + case C_DIGEST: /* --digest */ + if(toggle) + config->authtype |= CURLAUTH_DIGEST; + else + config->authtype &= ~CURLAUTH_DIGEST; + break; + case C_NEGOTIATE: /* --negotiate */ + if(!toggle) + config->authtype &= ~CURLAUTH_NEGOTIATE; + else if(feature_spnego) + config->authtype |= CURLAUTH_NEGOTIATE; + else + err = PARAM_LIBCURL_DOESNT_SUPPORT; + break; + case C_NTLM: /* --ntlm */ + if(!toggle) + config->authtype &= ~CURLAUTH_NTLM; + else if(feature_ntlm) + config->authtype |= CURLAUTH_NTLM; + else + err = PARAM_LIBCURL_DOESNT_SUPPORT; + break; + case C_NTLM_WB: /* --ntlm-wb */ + if(!toggle) + config->authtype &= ~CURLAUTH_NTLM_WB; + else if(feature_ntlm_wb) + config->authtype |= CURLAUTH_NTLM_WB; + else + err = PARAM_LIBCURL_DOESNT_SUPPORT; + break; + case C_BASIC: /* --basic */ + if(toggle) + config->authtype |= CURLAUTH_BASIC; + else + config->authtype &= ~CURLAUTH_BASIC; + break; + case C_ANYAUTH: /* --anyauth */ + if(toggle) + config->authtype = CURLAUTH_ANY; + /* --no-anyauth simply doesn't touch it */ + break; +#ifdef USE_WATT32 + case C_WDEBUG: /* --wdebug */ + dbug_init(); + break; +#endif + case C_FTP_CREATE_DIRS: /* --ftp-create-dirs */ + config->ftp_create_dirs = toggle; + break; + case C_CREATE_DIRS: /* --create-dirs */ + config->create_dirs = toggle; + break; + case C_CREATE_FILE_MODE: /* --create-file-mode */ + err = oct2nummax(&config->create_file_mode, nextarg, 0777); + break; + case C_MAX_REDIRS: /* --max-redirs */ + /* specified max no of redirects (http(s)), this accepts -1 as a + special condition */ + err = str2num(&config->maxredirs, nextarg); + if(!err && (config->maxredirs < -1)) + err = PARAM_BAD_NUMERIC; + break; + case C_IPFS_GATEWAY: /* --ipfs-gateway */ + err = getstr(&config->ipfs_gateway, nextarg, DENY_BLANK); + break; + case C_PROXY_NTLM: /* --proxy-ntlm */ + if(!feature_ntlm) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + config->proxyntlm = toggle; + break; + case C_CRLF: /* --crlf */ + /* LF -> CRLF conversion? */ + config->crlf = toggle; + break; + case C_AWS_SIGV4: /* --aws-sigv4 */ + config->authtype |= CURLAUTH_AWS_SIGV4; + err = getstr(&config->aws_sigv4, nextarg, DENY_BLANK); + break; + case C_STDERR: /* --stderr */ + tool_set_stderr_file(global, nextarg); + break; + case C_INTERFACE: /* --interface */ + /* interface */ + err = getstr(&config->iface, nextarg, DENY_BLANK); + break; + case C_KRB: /* --krb */ + /* kerberos level string */ + if(!feature_spnego) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->krblevel, nextarg, DENY_BLANK); + break; + case C_HAPROXY_PROTOCOL: /* --haproxy-protocol */ + config->haproxy_protocol = toggle; + break; + case C_HAPROXY_CLIENTIP: /* --haproxy-clientip */ + err = getstr(&config->haproxy_clientip, nextarg, DENY_BLANK); + break; + case C_MAX_FILESIZE: /* --max-filesize */ + err = GetSizeParameter(global, nextarg, "max-filesize", &value); + if(!err) + config->max_filesize = value; + break; + case C_DISABLE_EPRT: /* --disable-eprt */ + config->disable_eprt = toggle; + break; + case C_EPRT: /* --eprt */ + config->disable_eprt = (!toggle)?TRUE:FALSE; + break; + case C_XATTR: /* --xattr */ + config->xattr = toggle; + break; + case C_URL: /* --url */ + if(!config->url_get) + config->url_get = config->url_list; - case 'k': /* --digest */ - if(toggle) - config->authtype |= CURLAUTH_DIGEST; - else - config->authtype &= ~CURLAUTH_DIGEST; - break; + if(config->url_get) { + /* there's a node here, if it already is filled-in continue to find + an "empty" node */ + while(config->url_get && (config->url_get->flags & GETOUT_URL)) + config->url_get = config->url_get->next; + } - case 'l': /* --negotiate */ - if(!toggle) - config->authtype &= ~CURLAUTH_NEGOTIATE; - else if(feature_spnego) - config->authtype |= CURLAUTH_NEGOTIATE; - else { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - break; + /* now there might or might not be an available node to fill in! */ - case 'm': /* --ntlm */ - if(!toggle) - config->authtype &= ~CURLAUTH_NTLM; - else if(feature_ntlm) - config->authtype |= CURLAUTH_NTLM; - else { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - break; - - case 'M': /* --ntlm-wb */ - if(!toggle) - config->authtype &= ~CURLAUTH_NTLM_WB; - else if(feature_ntlm_wb) - config->authtype |= CURLAUTH_NTLM_WB; - else { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - break; - - case 'n': /* --basic for completeness */ - if(toggle) - config->authtype |= CURLAUTH_BASIC; - else - config->authtype &= ~CURLAUTH_BASIC; - break; - - case 'o': /* --anyauth, let libcurl pick it */ - if(toggle) - config->authtype = CURLAUTH_ANY; - /* --no-anyauth simply doesn't touch it */ - break; - -#ifdef USE_WATT32 - case 'p': /* --wdebug */ - dbug_init(); - break; -#endif - case 'q': /* --ftp-create-dirs */ - config->ftp_create_dirs = toggle; - break; - - case 'r': /* --create-dirs */ - config->create_dirs = toggle; - break; - - case 'R': /* --create-file-mode */ - err = oct2nummax(&config->create_file_mode, nextarg, 0777); - break; - - case 's': /* --max-redirs */ - /* specified max no of redirects (http(s)), this accepts -1 as a - special condition */ - err = str2num(&config->maxredirs, nextarg); - if(err) - break; - if(config->maxredirs < -1) - err = PARAM_BAD_NUMERIC; - break; - - case 'S': /* ipfs gateway url */ - GetStr(&config->ipfs_gateway, nextarg); - break; - - case 't': /* --proxy-ntlm */ - if(!feature_ntlm) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - config->proxyntlm = toggle; - break; - - case 'u': /* --crlf */ - /* LF -> CRLF conversion? */ - config->crlf = toggle; - break; - - case 'V': /* --aws-sigv4 */ - config->authtype |= CURLAUTH_AWS_SIGV4; - GetStr(&config->aws_sigv4, nextarg); - break; - - case 'v': /* --stderr */ - tool_set_stderr_file(global, nextarg); - break; - case 'w': /* --interface */ - /* interface */ - GetStr(&config->iface, nextarg); - break; - case 'x': /* --krb */ - /* kerberos level string */ - if(!feature_spnego) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->krblevel, nextarg); - break; - case 'X': /* --haproxy-protocol */ - config->haproxy_protocol = toggle; - break; - case 'P': /* --haproxy-clientip */ - GetStr(&config->haproxy_clientip, nextarg); - break; - case 'y': /* --max-filesize */ - { - curl_off_t value; - err = - GetSizeParameter(global, nextarg, "max-filesize", &value); - if(err) - break; - config->max_filesize = value; - } - break; - case 'z': /* --disable-eprt */ - config->disable_eprt = toggle; - break; - case 'Z': /* --eprt */ - config->disable_eprt = (!toggle)?TRUE:FALSE; - break; - case '~': /* --xattr */ - config->xattr = toggle; - break; - case '@': /* the URL! */ - { - struct getout *url; - - if(!config->url_get) - config->url_get = config->url_list; - - if(config->url_get) { - /* there's a node here, if it already is filled-in continue to find - an "empty" node */ - while(config->url_get && (config->url_get->flags & GETOUT_URL)) - config->url_get = config->url_get->next; - } - - /* now there might or might not be an available node to fill in! */ - - if(config->url_get) - /* existing node */ - url = config->url_get; - else - /* there was no free node, create one! */ - config->url_get = url = new_getout(config); - - if(!url) { - err = PARAM_NO_MEM; - break; - } + if(config->url_get) + /* existing node */ + url = config->url_get; + else + /* there was no free node, create one! */ + config->url_get = url = new_getout(config); + if(!url) + err = PARAM_NO_MEM; + else { /* fill in the URL */ - GetStr(&url->url, nextarg); + err = getstr(&url->url, nextarg, DENY_BLANK); url->flags |= GETOUT_URL; } - } break; - case '$': /* more options without a short option */ - switch(subletter) { - case 'a': /* --ssl */ - if(toggle && !feature_ssl) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + case C_SSL: /* --ssl */ + if(toggle && !feature_ssl) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else { config->ftp_ssl = toggle; if(config->ftp_ssl) warnf(global, "--ssl is an insecure option, consider --ssl-reqd instead"); - break; - case 'b': /* --ftp-pasv */ - Curl_safefree(config->ftpport); - break; - case 'c': /* --socks5 specifies a socks5 proxy to use, and resolves - the name locally and passes on the resolved address */ - GetStr(&config->proxy, nextarg); - config->proxyver = CURLPROXY_SOCKS5; - break; - case 't': /* --socks4 specifies a socks4 proxy to use */ - GetStr(&config->proxy, nextarg); - config->proxyver = CURLPROXY_SOCKS4; - break; - case 'T': /* --socks4a specifies a socks4a proxy to use */ - GetStr(&config->proxy, nextarg); - config->proxyver = CURLPROXY_SOCKS4A; - break; - case '2': /* --socks5-hostname specifies a socks5 proxy and enables name - resolving with the proxy */ - GetStr(&config->proxy, nextarg); - config->proxyver = CURLPROXY_SOCKS5_HOSTNAME; - break; - case 'd': /* --tcp-nodelay option */ - config->tcp_nodelay = toggle; - break; - case 'e': /* --proxy-digest */ - config->proxydigest = toggle; - break; - case 'f': /* --proxy-basic */ - config->proxybasic = toggle; - break; - case 'g': /* --retry */ - err = str2unum(&config->req_retry, nextarg); - break; - case 'V': /* --retry-connrefused */ - config->retry_connrefused = toggle; - break; - case 'h': /* --retry-delay */ - err = str2unummax(&config->retry_delay, nextarg, LONG_MAX/1000); - break; - case 'i': /* --retry-max-time */ - err = str2unummax(&config->retry_maxtime, nextarg, LONG_MAX/1000); - break; - case '!': /* --retry-all-errors */ - config->retry_all_errors = toggle; - break; - - case 'k': /* --proxy-negotiate */ - if(!feature_spnego) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + } + break; + case C_FTP_PASV: /* --ftp-pasv */ + Curl_safefree(config->ftpport); + break; + case C_SOCKS5: /* --socks5 */ + /* socks5 proxy to use, and resolves the name locally and passes on the + resolved address */ + err = getstr(&config->proxy, nextarg, DENY_BLANK); + config->proxyver = CURLPROXY_SOCKS5; + break; + case C_SOCKS4: /* --socks4 */ + err = getstr(&config->proxy, nextarg, DENY_BLANK); + config->proxyver = CURLPROXY_SOCKS4; + break; + case C_SOCKS4A: /* --socks4a */ + err = getstr(&config->proxy, nextarg, DENY_BLANK); + config->proxyver = CURLPROXY_SOCKS4A; + break; + case C_SOCKS5_HOSTNAME: /* --socks5-hostname */ + err = getstr(&config->proxy, nextarg, DENY_BLANK); + config->proxyver = CURLPROXY_SOCKS5_HOSTNAME; + break; + case C_TCP_NODELAY: /* --tcp-nodelay */ + config->tcp_nodelay = toggle; + break; + case C_PROXY_DIGEST: /* --proxy-digest */ + config->proxydigest = toggle; + break; + case C_PROXY_BASIC: /* --proxy-basic */ + config->proxybasic = toggle; + break; + case C_RETRY: /* --retry */ + err = str2unum(&config->req_retry, nextarg); + break; + case C_RETRY_CONNREFUSED: /* --retry-connrefused */ + config->retry_connrefused = toggle; + break; + case C_RETRY_DELAY: /* --retry-delay */ + err = str2unummax(&config->retry_delay, nextarg, LONG_MAX/1000); + break; + case C_RETRY_MAX_TIME: /* --retry-max-time */ + err = str2unummax(&config->retry_maxtime, nextarg, LONG_MAX/1000); + break; + case C_RETRY_ALL_ERRORS: /* --retry-all-errors */ + config->retry_all_errors = toggle; + break; + case C_PROXY_NEGOTIATE: /* --proxy-negotiate */ + if(!feature_spnego) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else config->proxynegotiate = toggle; - break; - - case 'l': /* --form-escape */ - config->mime_options &= ~CURLMIMEOPT_FORMESCAPE; - if(toggle) - config->mime_options |= CURLMIMEOPT_FORMESCAPE; - break; + break; + case C_FORM_ESCAPE: /* --form-escape */ + config->mime_options &= ~CURLMIMEOPT_FORMESCAPE; + if(toggle) + config->mime_options |= CURLMIMEOPT_FORMESCAPE; + break; + case C_FTP_ACCOUNT: /* --ftp-account */ + err = getstr(&config->ftp_account, nextarg, DENY_BLANK); + break; + case C_PROXY_ANYAUTH: /* --proxy-anyauth */ + config->proxyanyauth = toggle; + break; + case C_TRACE_TIME: /* --trace-time */ + global->tracetime = toggle; + break; + case C_IGNORE_CONTENT_LENGTH: /* --ignore-content-length */ + config->ignorecl = toggle; + break; + case C_FTP_SKIP_PASV_IP: /* --ftp-skip-pasv-ip */ + config->ftp_skip_ip = toggle; + break; + case C_FTP_METHOD: /* --ftp-method */ + config->ftp_filemethod = ftpfilemethod(config, nextarg); + break; + case C_LOCAL_PORT: { /* --local-port */ + /* 16bit base 10 is 5 digits, but we allow 6 so that this catches + overflows, not just truncates */ + char lrange[7]=""; + char *p = nextarg; + while(ISDIGIT(*p)) + p++; + if(*p) { + /* if there's anything more than a plain decimal number */ + rc = sscanf(p, " - %6s", lrange); + *p = 0; /* null-terminate to make str2unum() work below */ + } + else + rc = 0; - case 'm': /* --ftp-account */ - GetStr(&config->ftp_account, nextarg); - break; - case 'n': /* --proxy-anyauth */ - config->proxyanyauth = toggle; - break; - case 'o': /* --trace-time */ - global->tracetime = toggle; - break; - case 'p': /* --ignore-content-length */ - config->ignorecl = toggle; - break; - case 'q': /* --ftp-skip-pasv-ip */ - config->ftp_skip_ip = toggle; - break; - case 'r': /* --ftp-method (undocumented at this point) */ - config->ftp_filemethod = ftpfilemethod(config, nextarg); + err = str2unum(&config->localport, nextarg); + if(err || (config->localport > 65535)) { + err = PARAM_BAD_USE; break; - case 's': { /* --local-port */ - /* 16bit base 10 is 5 digits, but we allow 6 so that this catches - overflows, not just truncates */ - char lrange[7]=""; - char *p = nextarg; - while(ISDIGIT(*p)) - p++; - if(*p) { - /* if there's anything more than a plain decimal number */ - rc = sscanf(p, " - %6s", lrange); - *p = 0; /* null-terminate to make str2unum() work below */ - } - else - rc = 0; - - err = str2unum(&config->localport, nextarg); - if(err || (config->localport > 65535)) { + } + if(!rc) + config->localportrange = 1; /* default number of ports to try */ + else { + err = str2unum(&config->localportrange, lrange); + if(err || (config->localportrange > 65535)) err = PARAM_BAD_USE; - break; - } - if(!rc) - config->localportrange = 1; /* default number of ports to try */ else { - err = str2unum(&config->localportrange, lrange); - if(err || (config->localportrange > 65535)) + config->localportrange -= (config->localport-1); + if(config->localportrange < 1) err = PARAM_BAD_USE; - else { - config->localportrange -= (config->localport-1); - if(config->localportrange < 1) - err = PARAM_BAD_USE; - } } - break; } - case 'u': /* --ftp-alternative-to-user */ - GetStr(&config->ftp_alternative_to_user, nextarg); - break; - case 'v': /* --ssl-reqd */ - if(toggle && !feature_ssl) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - config->ftp_ssl_reqd = toggle; - break; - case 'w': /* --no-sessionid */ - config->disable_sessionid = (!toggle)?TRUE:FALSE; + break; + } + case C_FTP_ALTERNATIVE_TO_USER: /* --ftp-alternative-to-user */ + err = getstr(&config->ftp_alternative_to_user, nextarg, DENY_BLANK); + break; + case C_FTP_SSL_REQD: /* --ftp-ssl-reqd */ + case C_SSL_REQD: /* --ssl-reqd */ + if(toggle && !feature_ssl) { + err = PARAM_LIBCURL_DOESNT_SUPPORT; break; - case 'x': /* --ftp-ssl-control */ - if(toggle && !feature_ssl) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + } + config->ftp_ssl_reqd = toggle; + break; + case C_SESSIONID: /* --sessionid */ + config->disable_sessionid = (!toggle)?TRUE:FALSE; + break; + case C_FTP_SSL_CONTROL: /* --ftp-ssl-control */ + if(toggle && !feature_ssl) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else config->ftp_ssl_control = toggle; - break; - case 'y': /* --ftp-ssl-ccc */ - config->ftp_ssl_ccc = toggle; - if(!config->ftp_ssl_ccc_mode) - config->ftp_ssl_ccc_mode = CURLFTPSSL_CCC_PASSIVE; - break; - case 'j': /* --ftp-ssl-ccc-mode */ - config->ftp_ssl_ccc = TRUE; - config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg); - break; - case 'z': /* --libcurl */ + break; + case C_FTP_SSL_CCC: /* --ftp-ssl-ccc */ + config->ftp_ssl_ccc = toggle; + if(!config->ftp_ssl_ccc_mode) + config->ftp_ssl_ccc_mode = CURLFTPSSL_CCC_PASSIVE; + break; + case C_FTP_SSL_CCC_MODE: /* --ftp-ssl-ccc-mode */ + config->ftp_ssl_ccc = TRUE; + config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg); + break; + case C_LIBCURL: /* --libcurl */ #ifdef CURL_DISABLE_LIBCURL_OPTION - warnf(global, - "--libcurl option was disabled at build-time"); - err = PARAM_OPTION_UNKNOWN; - break; + warnf(global, + "--libcurl option was disabled at build-time"); + err = PARAM_OPTION_UNKNOWN; #else - GetStr(&global->libcurl, nextarg); - break; + err = getstr(&global->libcurl, nextarg, DENY_BLANK); #endif - case '#': /* --raw */ - config->raw = toggle; - break; - case '0': /* --post301 */ - config->post301 = toggle; - break; - case '1': /* --no-keepalive */ - config->nokeepalive = (!toggle)?TRUE:FALSE; - break; - case '3': /* --keepalive-time */ - err = str2unum(&config->alivetime, nextarg); - break; - case '4': /* --post302 */ - config->post302 = toggle; - break; - case 'I': /* --post303 */ - config->post303 = toggle; - break; - case '5': /* --noproxy */ - /* This specifies the noproxy list */ - GetStr(&config->noproxy, nextarg); - break; - case '7': /* --socks5-gssapi-nec */ - config->socks5_gssapi_nec = toggle; - break; - case '8': /* --proxy1.0 */ - /* http 1.0 proxy */ - GetStr(&config->proxy, nextarg); - config->proxyver = CURLPROXY_HTTP_1_0; - break; - case '9': /* --tftp-blksize */ - err = str2unum(&config->tftp_blksize, nextarg); - break; - case 'A': /* --mail-from */ - GetStr(&config->mail_from, nextarg); - break; - case 'B': /* --mail-rcpt */ - /* append receiver to a list */ - err = add2list(&config->mail_rcpt, nextarg); - break; - case 'C': /* --ftp-pret */ - config->ftp_pret = toggle; - break; - case 'D': /* --proto */ - config->proto_present = TRUE; - err = proto2num(config, built_in_protos, &config->proto_str, nextarg); - break; - case 'E': /* --proto-redir */ - config->proto_redir_present = TRUE; - if(proto2num(config, redir_protos, &config->proto_redir_str, - nextarg)) { - err = PARAM_BAD_USE; - break; - } - break; - case 'F': /* --resolve */ - err = add2list(&config->resolve, nextarg); - break; - case 'G': /* --delegation LEVEL */ - config->gssapi_delegation = delegation(config, nextarg); - break; - case 'H': /* --mail-auth */ - GetStr(&config->mail_auth, nextarg); - break; - case 'J': /* --metalink */ - errorf(global, "--metalink is disabled"); + break; + case C_RAW: /* --raw */ + config->raw = toggle; + break; + case C_KEEPALIVE: /* --keepalive */ + config->nokeepalive = (!toggle)?TRUE:FALSE; + break; + case C_KEEPALIVE_TIME: /* --keepalive-time */ + err = str2unum(&config->alivetime, nextarg); + break; + case C_POST301: /* --post301 */ + config->post301 = toggle; + break; + case C_POST302: /* --post302 */ + config->post302 = toggle; + break; + case C_POST303: /* --post303 */ + config->post303 = toggle; + break; + case C_NOPROXY: /* --noproxy */ + /* This specifies the noproxy list */ + err = getstr(&config->noproxy, nextarg, ALLOW_BLANK); + break; + case C_SOCKS5_GSSAPI_NEC: /* --socks5-gssapi-nec */ + config->socks5_gssapi_nec = toggle; + break; + case C_PROXY1_0: /* --proxy1.0 */ + /* http 1.0 proxy */ + err = getstr(&config->proxy, nextarg, DENY_BLANK); + config->proxyver = CURLPROXY_HTTP_1_0; + break; + case C_TFTP_BLKSIZE: /* --tftp-blksize */ + err = str2unum(&config->tftp_blksize, nextarg); + break; + case C_MAIL_FROM: /* --mail-from */ + err = getstr(&config->mail_from, nextarg, DENY_BLANK); + break; + case C_MAIL_RCPT: /* --mail-rcpt */ + /* append receiver to a list */ + err = add2list(&config->mail_rcpt, nextarg); + break; + case C_FTP_PRET: /* --ftp-pret */ + config->ftp_pret = toggle; + break; + case C_PROTO: /* --proto */ + config->proto_present = TRUE; + err = proto2num(config, built_in_protos, &config->proto_str, nextarg); + break; + case C_PROTO_REDIR: /* --proto-redir */ + config->proto_redir_present = TRUE; + if(proto2num(config, redir_protos, &config->proto_redir_str, + nextarg)) err = PARAM_BAD_USE; - break; - case '6': /* --sasl-authzid */ - GetStr(&config->sasl_authzid, nextarg); - break; - case 'K': /* --sasl-ir */ - config->sasl_ir = toggle; - break; - case 'L': /* --test-event */ + break; + case C_RESOLVE: /* --resolve */ + err = add2list(&config->resolve, nextarg); + break; + case C_DELEGATION: /* --delegation */ + config->gssapi_delegation = delegation(config, nextarg); + break; + case C_MAIL_AUTH: /* --mail-auth */ + err = getstr(&config->mail_auth, nextarg, DENY_BLANK); + break; + case C_METALINK: /* --metalink */ + errorf(global, "--metalink is disabled"); + err = PARAM_BAD_USE; + break; + case C_SASL_AUTHZID: /* --sasl-authzid */ + err = getstr(&config->sasl_authzid, nextarg, DENY_BLANK); + break; + case C_SASL_IR: /* --sasl-ir */ + config->sasl_ir = toggle; + break; + case C_TEST_EVENT: /* --test-event */ #ifdef CURLDEBUG - global->test_event_based = toggle; + global->test_event_based = toggle; #else - warnf(global, "--test-event is ignored unless a debug build"); + warnf(global, "--test-event is ignored unless a debug build"); #endif - break; - case 'M': /* --unix-socket */ - config->abstract_unix_socket = FALSE; - GetStr(&config->unix_socket_path, nextarg); - break; - case 'N': /* --path-as-is */ - config->path_as_is = toggle; - break; - case 'O': /* --proxy-service-name */ - GetStr(&config->proxy_service_name, nextarg); - break; - case 'P': /* --service-name */ - GetStr(&config->service_name, nextarg); - break; - case 'Q': /* --proto-default */ - GetStr(&config->proto_default, nextarg); + break; + case C_UNIX_SOCKET: /* --unix-socket */ + config->abstract_unix_socket = FALSE; + err = getstr(&config->unix_socket_path, nextarg, DENY_BLANK); + break; + case C_PATH_AS_IS: /* --path-as-is */ + config->path_as_is = toggle; + break; + case C_PROXY_SERVICE_NAME: /* --proxy-service-name */ + err = getstr(&config->proxy_service_name, nextarg, DENY_BLANK); + break; + case C_SERVICE_NAME: /* --service-name */ + err = getstr(&config->service_name, nextarg, DENY_BLANK); + break; + case C_PROTO_DEFAULT: /* --proto-default */ + err = getstr(&config->proto_default, nextarg, DENY_BLANK); + if(!err) err = check_protocol(config->proto_default); - break; - case 'R': /* --expect100-timeout */ - err = secs2ms(&config->expect100timeout_ms, nextarg); - break; - case 'S': /* --tftp-no-options */ - config->tftp_no_options = toggle; - break; - case 'U': /* --connect-to */ - err = add2list(&config->connect_to, nextarg); - break; - case 'W': /* --abstract-unix-socket */ - config->abstract_unix_socket = TRUE; - GetStr(&config->unix_socket_path, nextarg); - break; - case 'X': /* --tls-max */ - err = str2tls_max(&config->ssl_version_max, nextarg); - break; - case 'Y': /* --suppress-connect-headers */ - config->suppress_connect_headers = toggle; - break; - case 'Z': /* --compressed-ssh */ - config->ssh_compression = toggle; - break; - case '~': /* --happy-eyeballs-timeout-ms */ - err = str2unum(&config->happy_eyeballs_timeout_ms, nextarg); - /* 0 is a valid value for this timeout */ - break; - case '%': /* --trace-ids */ - global->traceids = toggle; - break; - case '&': /* --trace-config */ - if(set_trace_config(global, nextarg)) { - err = PARAM_NO_MEM; - } - break; - } break; - case '#': - switch(subletter) { - case 'm': /* --progress-meter */ - global->noprogress = !toggle; - break; - default: /* --progress-bar */ - global->progressmode = - toggle ? CURL_PROGRESS_BAR : CURL_PROGRESS_STATS; - break; - } + case C_EXPECT100_TIMEOUT: /* --expect100-timeout */ + err = secs2ms(&config->expect100timeout_ms, nextarg); break; - case ':': - switch(subletter) { - case 'a': /* --variable */ - err = setvariable(global, nextarg); - break; - default: /* --next */ - err = PARAM_NEXT_OPERATION; - break; - } + case C_TFTP_NO_OPTIONS: /* --tftp-no-options */ + config->tftp_no_options = toggle; break; - case '0': /* --http* options */ - switch(subletter) { - case '\0': - /* HTTP version 1.0 */ - sethttpver(global, config, CURL_HTTP_VERSION_1_0); - break; - case '1': - /* HTTP version 1.1 */ - sethttpver(global, config, CURL_HTTP_VERSION_1_1); - break; - case '2': - /* HTTP version 2.0 */ - if(!feature_http2) - return PARAM_LIBCURL_DOESNT_SUPPORT; - sethttpver(global, config, CURL_HTTP_VERSION_2_0); - break; - case '3': /* --http2-prior-knowledge */ - /* HTTP version 2.0 over clean TCP */ - if(!feature_http2) - return PARAM_LIBCURL_DOESNT_SUPPORT; - sethttpver(global, config, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); - break; - case '4': /* --http3 */ - /* Try HTTP/3, allow fallback */ - if(!feature_http3) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + case C_CONNECT_TO: /* --connect-to */ + err = add2list(&config->connect_to, nextarg); + break; + case C_ABSTRACT_UNIX_SOCKET: /* --abstract-unix-socket */ + config->abstract_unix_socket = TRUE; + err = getstr(&config->unix_socket_path, nextarg, DENY_BLANK); + break; + case C_TLS_MAX: /* --tls-max */ + err = str2tls_max(&config->ssl_version_max, nextarg); + break; + case C_SUPPRESS_CONNECT_HEADERS: /* --suppress-connect-headers */ + config->suppress_connect_headers = toggle; + break; + case C_COMPRESSED_SSH: /* --compressed-ssh */ + config->ssh_compression = toggle; + break; + case C_HAPPY_EYEBALLS_TIMEOUT_MS: /* --happy-eyeballs-timeout-ms */ + err = str2unum(&config->happy_eyeballs_timeout_ms, nextarg); + /* 0 is a valid value for this timeout */ + break; + case C_TRACE_IDS: /* --trace-ids */ + global->traceids = toggle; + break; + case C_TRACE_CONFIG: /* --trace-config */ + if(set_trace_config(global, nextarg)) + err = PARAM_NO_MEM; + break; + case C_PROGRESS_METER: /* --progress-meter */ + global->noprogress = !toggle; + break; + case C_PROGRESS_BAR: /* --progress-bar */ + global->progressmode = toggle ? CURL_PROGRESS_BAR : CURL_PROGRESS_STATS; + break; + case C_VARIABLE: /* --Variable */ + err = setvariable(global, nextarg); + break; + case C_NEXT: /* --next */ + err = PARAM_NEXT_OPERATION; + break; + case C_HTTP1_0: /* --http1.0 */ + /* HTTP version 1.0 */ + sethttpver(global, config, CURL_HTTP_VERSION_1_0); + break; + case C_HTTP1_1: /* --http1.1 */ + /* HTTP version 1.1 */ + sethttpver(global, config, CURL_HTTP_VERSION_1_1); + break; + case C_HTTP2: /* --http2 */ + /* HTTP version 2.0 */ + if(!feature_http2) + return PARAM_LIBCURL_DOESNT_SUPPORT; + sethttpver(global, config, CURL_HTTP_VERSION_2_0); + break; + case C_HTTP2_PRIOR_KNOWLEDGE: /* --http2-prior-knowledge */ + /* HTTP version 2.0 over clean TCP */ + if(!feature_http2) + return PARAM_LIBCURL_DOESNT_SUPPORT; + sethttpver(global, config, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); + break; + case C_HTTP3: /* --http3: */ + /* Try HTTP/3, allow fallback */ + if(!feature_http3) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else sethttpver(global, config, CURL_HTTP_VERSION_3); - break; - case '5': /* --http3-only */ - /* Try HTTP/3 without fallback */ - if(!feature_http3) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } + break; + case C_HTTP3_ONLY: /* --http3-only */ + /* Try HTTP/3 without fallback */ + if(!feature_http3) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else sethttpver(global, config, CURL_HTTP_VERSION_3ONLY); - break; - case '9': - /* Allow HTTP/0.9 responses! */ - config->http09_allowed = toggle; - break; - case 'a': - /* --proxy-http2 */ - if(!feature_httpsproxy || !feature_http2) - return PARAM_LIBCURL_DOESNT_SUPPORT; + break; + case C_HTTP0_9: /* --http0.9 */ + /* Allow HTTP/0.9 responses! */ + config->http09_allowed = toggle; + break; + case C_PROXY_HTTP2: /* --proxy-http2 */ + if(!feature_httpsproxy || !feature_http2) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else config->proxyver = CURLPROXY_HTTPS2; - break; - } break; - case '1': /* --tlsv1* options */ - switch(subletter) { - case '\0': - /* TLS version 1.x */ - config->ssl_version = CURL_SSLVERSION_TLSv1; - break; - case '0': - /* TLS version 1.0 */ - config->ssl_version = CURL_SSLVERSION_TLSv1_0; - break; - case '1': - /* TLS version 1.1 */ - config->ssl_version = CURL_SSLVERSION_TLSv1_1; - break; - case '2': - /* TLS version 1.2 */ - config->ssl_version = CURL_SSLVERSION_TLSv1_2; - break; - case '3': - /* TLS version 1.3 */ - config->ssl_version = CURL_SSLVERSION_TLSv1_3; - break; - case 'A': /* --tls13-ciphers */ - GetStr(&config->cipher13_list, nextarg); - break; - case 'B': /* --proxy-tls13-ciphers */ - GetStr(&config->proxy_cipher13_list, nextarg); - break; - } + case C_TLSV1: /* --tlsv1 */ + config->ssl_version = CURL_SSLVERSION_TLSv1; + break; + case C_TLSV1_0: /* --tlsv1.0 */ + config->ssl_version = CURL_SSLVERSION_TLSv1_0; + break; + case C_TLSV1_1: /* --tlsv1.1 */ + config->ssl_version = CURL_SSLVERSION_TLSv1_1; break; - case '2': - /* SSL version 2 */ + case C_TLSV1_2: /* --tlsv1.2 */ + config->ssl_version = CURL_SSLVERSION_TLSv1_2; + break; + case C_TLSV1_3: /* --tlsv1.3 */ + config->ssl_version = CURL_SSLVERSION_TLSv1_3; + break; + case C_TLS13_CIPHERS: /* --tls13-ciphers */ + err = getstr(&config->cipher13_list, nextarg, DENY_BLANK); + break; + case C_PROXY_TLS13_CIPHERS: /* --proxy-tls13-ciphers */ + err = getstr(&config->proxy_cipher13_list, nextarg, DENY_BLANK); + break; + case C_SSLV2: /* --sslv2 */ warnf(global, "Ignores instruction to use SSLv2"); break; - case '3': - /* SSL version 3 */ + case C_SSLV3: /* --sslv3 */ warnf(global, "Ignores instruction to use SSLv3"); break; - case '4': - /* IPv4 */ + case C_IPV4: /* --ipv4 */ config->ip_version = CURL_IPRESOLVE_V4; break; - case '6': - /* IPv6 */ + case C_IPV6: /* --ipv6 */ config->ip_version = CURL_IPRESOLVE_V6; break; - case 'a': + case C_APPEND: /* --append */ /* This makes the FTP sessions use APPE instead of STOR */ config->ftp_append = toggle; break; - case 'A': - /* This specifies the User-Agent name */ - GetStr(&config->useragent, nextarg); + case C_USER_AGENT: /* --user-agent */ + err = getstr(&config->useragent, nextarg, ALLOW_BLANK); break; - case 'b': - switch(subletter) { - case 'a': /* --alt-svc */ - if(!feature_altsvc) - err = PARAM_LIBCURL_DOESNT_SUPPORT; - else - GetStr(&config->altsvc, nextarg); - break; - case 'b': /* --hsts */ - if(!feature_hsts) - err = PARAM_LIBCURL_DOESNT_SUPPORT; - else - GetStr(&config->hsts, nextarg); + case C_ALT_SVC: /* --alt-svc */ + if(!feature_altsvc) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->altsvc, nextarg, ALLOW_BLANK); + break; + case C_HSTS: /* --hsts */ + if(!feature_hsts) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->hsts, nextarg, ALLOW_BLANK); + break; + case C_COOKIE: /* --cookie */ + if(strchr(nextarg, '=')) { + /* A cookie string must have a =-letter */ + err = add2list(&config->cookies, nextarg); break; - default: /* --cookie string coming up: */ - if(nextarg[0] == '@') { - nextarg++; - } - else if(strchr(nextarg, '=')) { - /* A cookie string must have a =-letter */ - err = add2list(&config->cookies, nextarg); - break; - } + } + else { /* We have a cookie file to read from! */ err = add2list(&config->cookiefiles, nextarg); } break; - case 'B': - /* use ASCII/text when transferring */ + case C_USE_ASCII: /* --use-ascii */ config->use_ascii = toggle; break; - case 'c': - /* get the file name to dump all cookies in */ - GetStr(&config->cookiejar, nextarg); + case C_COOKIE_JAR: /* --cookie-jar */ + err = getstr(&config->cookiejar, nextarg, DENY_BLANK); break; - case 'C': + case C_CONTINUE_AT: /* --continue-at */ /* This makes us continue an ftp transfer at given position */ if(strcmp(nextarg, "-")) { err = str2offset(&config->resume_from, nextarg); - if(err) - break; config->resume_from_current = FALSE; } else { @@ -1712,158 +2016,21 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } config->use_resume = TRUE; break; - case 'd': - /* postfield data */ - { - char *postdata = NULL; - FILE *file; - size_t size = 0; - bool raw_mode = (subletter == 'r'); - - if(subletter == 'g') { /* --url-query */ -#define MAX_QUERY_LEN 100000 /* larger is not likely to ever work */ - char *query; - struct curlx_dynbuf dyn; - curlx_dyn_init(&dyn, MAX_QUERY_LEN); - - if(*nextarg == '+') { - /* use without encoding */ - query = strdup(&nextarg[1]); - if(!query) { - err = PARAM_NO_MEM; - break; - } - } - else { - err = data_urlencode(global, nextarg, &query, &size); - if(err) - break; - } - - if(config->query) { - CURLcode result = - curlx_dyn_addf(&dyn, "%s&%s", config->query, query); - free(query); - if(result) { - err = PARAM_NO_MEM; - break; - } - free(config->query); - config->query = curlx_dyn_ptr(&dyn); - } - else - config->query = query; - - break; /* this is not a POST argument at all */ - } - else if(subletter == 'e') { /* --data-urlencode */ - err = data_urlencode(global, nextarg, &postdata, &size); - if(err) - break; - } - else if('@' == *nextarg && !raw_mode) { - /* the data begins with a '@' letter, it means that a file name - or - (stdin) follows */ - nextarg++; /* pass the @ */ - - if(!strcmp("-", nextarg)) { - file = stdin; - if(subletter == 'b') /* forced data-binary */ - set_binmode(stdin); - } - else { - file = fopen(nextarg, "rb"); - if(!file) { - errorf(global, "Failed to open %s", nextarg); - err = PARAM_READ_ERROR; - break; - } - } - - if((subletter == 'b') || /* --data-binary */ - (subletter == 'f') /* --json */) - /* forced binary */ - err = file2memory(&postdata, &size, file); - else { - err = file2string(&postdata, file); - if(postdata) - size = strlen(postdata); - } - - if(file && (file != stdin)) - fclose(file); - if(err) - break; - - if(!postdata) { - /* no data from the file, point to a zero byte string to make this - get sent as a POST anyway */ - postdata = strdup(""); - if(!postdata) { - err = PARAM_NO_MEM; - break; - } - } - } - else { - GetStr(&postdata, nextarg); - if(postdata) - size = strlen(postdata); - } - if(subletter == 'f') - config->jsoned = TRUE; - - if(config->postfields) { - /* we already have a string, we append this one with a separating - &-letter */ - char *oldpost = config->postfields; - curl_off_t oldlen = config->postfieldsize; - curl_off_t newlen = oldlen + curlx_uztoso(size) + 2; - config->postfields = malloc((size_t)newlen); - if(!config->postfields) { - Curl_safefree(oldpost); - Curl_safefree(postdata); - err = PARAM_NO_MEM; - break; - } - memcpy(config->postfields, oldpost, (size_t)oldlen); - if(subletter != 'f') { - /* skip this treatment for --json */ - /* use byte value 0x26 for '&' to accommodate non-ASCII platforms */ - config->postfields[oldlen] = '\x26'; - memcpy(&config->postfields[oldlen + 1], postdata, size); - config->postfields[oldlen + 1 + size] = '\0'; - config->postfieldsize += size + 1; - } - else { - memcpy(&config->postfields[oldlen], postdata, size); - config->postfields[oldlen + size] = '\0'; - config->postfieldsize += size; - } - Curl_safefree(oldpost); - Curl_safefree(postdata); - } - else { - config->postfields = postdata; - config->postfieldsize = curlx_uztoso(size); - } - } - /* - We can't set the request type here, as this data might be used in - a simple GET if -G is used. Already or soon. - - if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) { - Curl_safefree(postdata); - return PARAM_BAD_USE; - } - */ - break; - case 'D': - /* dump-header to given file name */ - GetStr(&config->headerfile, nextarg); + case C_DATA: /* --data */ + case C_DATA_ASCII: /* --data-ascii */ + case C_DATA_BINARY: /* --data-binary */ + case C_DATA_URLENCODE: /* --data-urlencode */ + case C_JSON: /* --json */ + case C_DATA_RAW: /* --data-raw */ + err = set_data(cmd, nextarg, global, config); break; - case 'e': - { + case C_URL_QUERY: /* --url-query */ + err = url_query(nextarg, global, config); + break; + case C_DUMP_HEADER: /* --dump-header */ + err = getstr(&config->headerfile, nextarg, DENY_BLANK); + break; + case C_REFERER: { /* --referer */ char *ptr = strstr(nextarg, ";auto"); if(ptr) { /* Automatic referer requested, this may be combined with a @@ -1874,322 +2041,263 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ else config->autoreferer = FALSE; ptr = *nextarg ? nextarg : NULL; - GetStr(&config->referer, ptr); + err = getstr(&config->referer, ptr, ALLOW_BLANK); } - break; - case 'E': - switch(subletter) { - case '\0': /* certificate file */ - cleanarg(clearthis); - GetFileAndPassword(nextarg, &config->cert, &config->key_passwd); - break; - case 'a': /* --cacert CA info PEM file */ - GetStr(&config->cacert, nextarg); - break; - case 'G': /* --ca-native */ - config->native_ca_store = toggle; - break; - case 'H': /* --proxy-ca-native */ - config->proxy_native_ca_store = toggle; - break; - case 'b': /* cert file type */ - GetStr(&config->cert_type, nextarg); - break; - case 'c': /* private key file */ - GetStr(&config->key, nextarg); - break; - case 'd': /* private key file type */ - GetStr(&config->key_type, nextarg); - break; - case 'e': /* private key passphrase */ - GetStr(&config->key_passwd, nextarg); - cleanarg(clearthis); - break; - case 'f': /* crypto engine */ - GetStr(&config->engine, nextarg); - if(config->engine && curl_strequal(config->engine, "list")) { - err = PARAM_ENGINES_REQUESTED; - break; - } - break; - case 'g': /* CA cert directory */ - GetStr(&config->capath, nextarg); - break; - case 'h': /* --pubkey public key file */ - GetStr(&config->pubkey, nextarg); - break; - case 'i': /* --hostpubmd5 md5 of the host public key */ - GetStr(&config->hostpubmd5, nextarg); - if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32) { + break; + case C_CERT: /* --cert */ + cleanarg(clearthis); + GetFileAndPassword(nextarg, &config->cert, &config->key_passwd); + break; + case C_CACERT: /* --cacert */ + err = getstr(&config->cacert, nextarg, DENY_BLANK); + break; + case C_CA_NATIVE: /* --ca-native */ + config->native_ca_store = toggle; + break; + case C_PROXY_CA_NATIVE: /* --proxy-ca-native */ + config->proxy_native_ca_store = toggle; + break; + case C_CERT_TYPE: /* --cert-type */ + err = getstr(&config->cert_type, nextarg, DENY_BLANK); + break; + case C_KEY: /* --key */ + err = getstr(&config->key, nextarg, DENY_BLANK); + break; + case C_KEY_TYPE: /* --key-type */ + err = getstr(&config->key_type, nextarg, DENY_BLANK); + break; + case C_PASS: /* --pass */ + err = getstr(&config->key_passwd, nextarg, DENY_BLANK); + cleanarg(clearthis); + break; + case C_ENGINE: /* --engine */ + err = getstr(&config->engine, nextarg, DENY_BLANK); + if(!err && + config->engine && !strcmp(config->engine, "list")) { + err = PARAM_ENGINES_REQUESTED; + } + break; + case C_CAPATH: /* --capath */ + err = getstr(&config->capath, nextarg, DENY_BLANK); + break; + case C_PUBKEY: /* --pubkey */ + err = getstr(&config->pubkey, nextarg, DENY_BLANK); + break; + case C_HOSTPUBMD5: /* --hostpubmd5 */ + err = getstr(&config->hostpubmd5, nextarg, DENY_BLANK); + if(!err) { + if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32) err = PARAM_BAD_USE; - break; - } - break; - case 'F': /* --hostpubsha256 sha256 of the host public key */ - GetStr(&config->hostpubsha256, nextarg); - break; - case 'j': /* CRL file */ - GetStr(&config->crlfile, nextarg); - break; - case 'k': /* TLS username */ - if(!feature_tls_srp) { - cleanarg(clearthis); - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->tls_username, nextarg); - cleanarg(clearthis); - break; - case 'l': /* TLS password */ - if(!feature_tls_srp) { - cleanarg(clearthis); - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->tls_password, nextarg); - cleanarg(clearthis); - break; - case 'm': /* TLS authentication type */ - if(!feature_tls_srp) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->tls_authtype, nextarg); - if(!curl_strequal(config->tls_authtype, "SRP")) { + } + break; + case C_HOSTPUBSHA256: /* --hostpubsha256 */ + err = getstr(&config->hostpubsha256, nextarg, DENY_BLANK); + break; + case C_CRLFILE: /* --crlfile */ + err = getstr(&config->crlfile, nextarg, DENY_BLANK); + break; + case C_TLSUSER: /* --tlsuser */ + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->tls_username, nextarg, DENY_BLANK); + cleanarg(clearthis); + break; + case C_TLSPASSWORD: /* --tlspassword */ + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->tls_password, nextarg, ALLOW_BLANK); + cleanarg(clearthis); + break; + case C_TLSAUTHTYPE: /* --tlsauthtype */ + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else { + err = getstr(&config->tls_authtype, nextarg, DENY_BLANK); + if(!err && strcmp(config->tls_authtype, "SRP")) err = PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */ - break; - } - break; - case 'n': /* no empty SSL fragments, --ssl-allow-beast */ - if(feature_ssl) - config->ssl_allow_beast = toggle; - break; - - case 'o': /* --ssl-auto-client-cert */ - if(feature_ssl) - config->ssl_auto_client_cert = toggle; - break; - - case 'O': /* --proxy-ssl-auto-client-cert */ - if(feature_ssl) - config->proxy_ssl_auto_client_cert = toggle; - break; - - case 'p': /* Pinned public key DER file */ - GetStr(&config->pinnedpubkey, nextarg); - break; - - case 'P': /* proxy pinned public key */ - GetStr(&config->proxy_pinnedpubkey, nextarg); - break; - - case 'q': /* --cert-status */ - config->verifystatus = TRUE; - break; - - case 'Q': /* --doh-cert-status */ - config->doh_verifystatus = TRUE; - break; - - case 'r': /* --false-start */ - config->falsestart = TRUE; - break; - - case 's': /* --ssl-no-revoke */ - if(feature_ssl) - config->ssl_no_revoke = TRUE; - break; - - case 'S': /* --ssl-revoke-best-effort */ - if(feature_ssl) - config->ssl_revoke_best_effort = TRUE; - break; - - case 't': /* --tcp-fastopen */ - config->tcp_fastopen = TRUE; - break; - - case 'u': /* TLS username for proxy */ - cleanarg(clearthis); - if(!feature_tls_srp) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->proxy_tls_username, nextarg); - break; - - case 'v': /* TLS password for proxy */ - cleanarg(clearthis); - if(!feature_tls_srp) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->proxy_tls_password, nextarg); - break; - - case 'w': /* TLS authentication type for proxy */ - if(!feature_tls_srp) { - err = PARAM_LIBCURL_DOESNT_SUPPORT; - break; - } - GetStr(&config->proxy_tls_authtype, nextarg); - if(!curl_strequal(config->proxy_tls_authtype, "SRP")) { + } + break; + case C_SSL_ALLOW_BEAST: /* --ssl-allow-beast */ + if(feature_ssl) + config->ssl_allow_beast = toggle; + break; + case C_SSL_AUTO_CLIENT_CERT: /* --ssl-auto-client-cert */ + if(feature_ssl) + config->ssl_auto_client_cert = toggle; + break; + case C_PROXY_SSL_AUTO_CLIENT_CERT: /* --proxy-ssl-auto-client-cert */ + if(feature_ssl) + config->proxy_ssl_auto_client_cert = toggle; + break; + case C_PINNEDPUBKEY: /* --pinnedpubkey */ + err = getstr(&config->pinnedpubkey, nextarg, DENY_BLANK); + break; + case C_PROXY_PINNEDPUBKEY: /* --proxy-pinnedpubkey */ + err = getstr(&config->proxy_pinnedpubkey, nextarg, DENY_BLANK); + break; + case C_CERT_STATUS: /* --cert-status */ + config->verifystatus = TRUE; + break; + case C_DOH_CERT_STATUS: /* --doh-cert-status */ + config->doh_verifystatus = TRUE; + break; + case C_FALSE_START: /* --false-start */ + config->falsestart = TRUE; + break; + case C_SSL_NO_REVOKE: /* --ssl-no-revoke */ + if(feature_ssl) + config->ssl_no_revoke = TRUE; + break; + case C_SSL_REVOKE_BEST_EFFORT: /* --ssl-revoke-best-effort */ + if(feature_ssl) + config->ssl_revoke_best_effort = TRUE; + break; + case C_TCP_FASTOPEN: /* --tcp-fastopen */ + config->tcp_fastopen = TRUE; + break; + case C_PROXY_TLSUSER: /* --proxy-tlsuser */ + cleanarg(clearthis); + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->proxy_tls_username, nextarg, ALLOW_BLANK); + break; + case C_PROXY_TLSPASSWORD: /* --proxy-tlspassword */ + cleanarg(clearthis); + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else + err = getstr(&config->proxy_tls_password, nextarg, DENY_BLANK); + break; + case C_PROXY_TLSAUTHTYPE: /* --proxy-tlsauthtype */ + if(!feature_tls_srp) + err = PARAM_LIBCURL_DOESNT_SUPPORT; + else { + err = getstr(&config->proxy_tls_authtype, nextarg, DENY_BLANK); + if(!err && strcmp(config->proxy_tls_authtype, "SRP")) err = PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */ - break; - } - break; - - case 'x': /* certificate file for proxy */ - cleanarg(clearthis); - GetFileAndPassword(nextarg, &config->proxy_cert, - &config->proxy_key_passwd); - break; - - case 'y': /* cert file type for proxy */ - GetStr(&config->proxy_cert_type, nextarg); - break; - - case 'z': /* private key file for proxy */ - GetStr(&config->proxy_key, nextarg); - break; - - case '0': /* private key file type for proxy */ - GetStr(&config->proxy_key_type, nextarg); - break; - - case '1': /* private key passphrase for proxy */ - GetStr(&config->proxy_key_passwd, nextarg); - cleanarg(clearthis); - break; - - case '2': /* ciphers for proxy */ - GetStr(&config->proxy_cipher_list, nextarg); - break; - - case '3': /* CRL file for proxy */ - GetStr(&config->proxy_crlfile, nextarg); - break; - - case '4': /* no empty SSL fragments for proxy */ - if(feature_ssl) - config->proxy_ssl_allow_beast = toggle; - break; - - case '5': /* --login-options */ - GetStr(&config->login_options, nextarg); - break; - - case '6': /* CA info PEM file for proxy */ - GetStr(&config->proxy_cacert, nextarg); - break; - - case '7': /* CA cert directory for proxy */ - GetStr(&config->proxy_capath, nextarg); - break; - - case '8': /* allow insecure SSL connects for proxy */ - config->proxy_insecure_ok = toggle; - break; - - case '9': /* --proxy-tlsv1 */ - /* TLS version 1 for proxy */ - config->proxy_ssl_version = CURL_SSLVERSION_TLSv1; - break; - - case 'A': - /* --socks5-basic */ - if(toggle) - config->socks5_auth |= CURLAUTH_BASIC; - else - config->socks5_auth &= ~CURLAUTH_BASIC; - break; - - case 'B': - /* --socks5-gssapi */ - if(toggle) - config->socks5_auth |= CURLAUTH_GSSAPI; - else - config->socks5_auth &= ~CURLAUTH_GSSAPI; - break; - - case 'C': - GetStr(&config->etag_save_file, nextarg); - break; - - case 'D': - GetStr(&config->etag_compare_file, nextarg); - break; - - case 'E': - GetStr(&config->ssl_ec_curves, nextarg); - break; - - default: /* unknown flag */ - err = PARAM_OPTION_UNKNOWN; - break; } break; - case 'f': - switch(subletter) { - case 'a': /* --fail-early */ - global->fail_early = toggle; - break; - case 'b': /* --styled-output */ - global->styled_output = toggle; - break; - case 'c': /* --mail-rcpt-allowfails */ - config->mail_rcpt_allowfails = toggle; - break; - case 'd': /* --fail-with-body */ - config->failwithbody = toggle; - break; - case 'e': /* --remove-on-error */ - config->rm_partial = toggle; - break; - default: /* --fail (hard on errors) */ - config->failonerror = toggle; - break; + case C_PROXY_CERT: /* --proxy-cert */ + cleanarg(clearthis); + GetFileAndPassword(nextarg, &config->proxy_cert, + &config->proxy_key_passwd); + break; + case C_PROXY_CERT_TYPE: /* --proxy-cert-type */ + err = getstr(&config->proxy_cert_type, nextarg, DENY_BLANK); + break; + case C_PROXY_KEY: /* --proxy-key */ + err = getstr(&config->proxy_key, nextarg, ALLOW_BLANK); + break; + case C_PROXY_KEY_TYPE: /* --proxy-key-type */ + err = getstr(&config->proxy_key_type, nextarg, DENY_BLANK); + break; + case C_PROXY_PASS: /* --proxy-pass */ + err = getstr(&config->proxy_key_passwd, nextarg, ALLOW_BLANK); + cleanarg(clearthis); + break; + case C_PROXY_CIPHERS: /* --proxy-ciphers */ + err = getstr(&config->proxy_cipher_list, nextarg, DENY_BLANK); + break; + case C_PROXY_CRLFILE: /* --proxy-crlfile */ + err = getstr(&config->proxy_crlfile, nextarg, DENY_BLANK); + break; + case C_PROXY_SSL_ALLOW_BEAST: /* --proxy-ssl-allow-beast */ + if(feature_ssl) + config->proxy_ssl_allow_beast = toggle; + break; + case C_LOGIN_OPTIONS: /* --login-options */ + err = getstr(&config->login_options, nextarg, ALLOW_BLANK); + break; + case C_PROXY_CACERT: /* --proxy-cacert */ + err = getstr(&config->proxy_cacert, nextarg, DENY_BLANK); + break; + case C_PROXY_CAPATH: /* --proxy-capath */ + err = getstr(&config->proxy_capath, nextarg, DENY_BLANK); + break; + case C_PROXY_INSECURE: /* --proxy-insecure */ + config->proxy_insecure_ok = toggle; + break; + case C_PROXY_TLSV1: /* --proxy-tlsv1 */ + /* TLS version 1 for proxy */ + config->proxy_ssl_version = CURL_SSLVERSION_TLSv1; + break; + case C_SOCKS5_BASIC: /* --socks5-basic */ + if(toggle) + config->socks5_auth |= CURLAUTH_BASIC; + else + config->socks5_auth &= ~CURLAUTH_BASIC; + break; + case C_SOCKS5_GSSAPI: /* --socks5-gssapi */ + if(toggle) + config->socks5_auth |= CURLAUTH_GSSAPI; + else + config->socks5_auth &= ~CURLAUTH_GSSAPI; + break; + case C_ETAG_SAVE: /* --etag-save */ + err = getstr(&config->etag_save_file, nextarg, DENY_BLANK); + break; + case C_ETAG_COMPARE: /* --etag-compare */ + err = getstr(&config->etag_compare_file, nextarg, DENY_BLANK); + break; + case C_CURVES: /* --curves */ + err = getstr(&config->ssl_ec_curves, nextarg, DENY_BLANK); + break; + case C_FAIL_EARLY: /* --fail-early */ + global->fail_early = toggle; + break; + case C_STYLED_OUTPUT: /* --styled-output */ + global->styled_output = toggle; + break; + case C_MAIL_RCPT_ALLOWFAILS: /* --mail-rcpt-allowfails */ + config->mail_rcpt_allowfails = toggle; + break; + case C_FAIL_WITH_BODY: /* --fail-with-body */ + config->failwithbody = toggle; + if(config->failonerror && config->failwithbody) { + errorf(config->global, "You must select either --fail or " + "--fail-with-body, not both."); + err = PARAM_BAD_USE; } + break; + case C_REMOVE_ON_ERROR: /* --remove-on-error */ + config->rm_partial = toggle; + break; + case C_FAIL: /* --fail */ + config->failonerror = toggle; if(config->failonerror && config->failwithbody) { errorf(config->global, "You must select either --fail or " "--fail-with-body, not both."); err = PARAM_BAD_USE; - break; } break; - case 'F': + case C_FORM: /* --form */ + case C_FORM_STRING: /* --form-string */ /* "form data" simulation, this is a little advanced so lets do our best to sort this out slowly and carefully */ if(formparse(config, nextarg, &config->mimeroot, &config->mimecurrent, - (subletter == 's')?TRUE:FALSE)) { /* 's' is literal - string */ + (cmd == C_FORM_STRING)?TRUE:FALSE)) /* literal string */ err = PARAM_BAD_USE; - break; - } - if(SetHTTPrequest(config, HTTPREQ_MIMEPOST, &config->httpreq)) { + else if(SetHTTPrequest(config, HTTPREQ_MIMEPOST, &config->httpreq)) err = PARAM_BAD_USE; - break; - } break; - - case 'g': /* g disables URLglobbing */ + case C_GLOBOFF: /* --globoff */ config->globoff = toggle; break; - - case 'G': /* HTTP GET */ - if(subletter == 'a') { /* --request-target */ - GetStr(&config->request_target, nextarg); - } - else - config->use_httpget = toggle; + case C_GET: /* --get */ + config->use_httpget = toggle; break; - - case 'h': /* h for help */ + case C_REQUEST_TARGET: /* --request-target */ + err = getstr(&config->request_target, nextarg, DENY_BLANK); + break; + case C_HELP: /* --help */ if(toggle) { - if(nextarg) { + if(*nextarg) { global->help_category = strdup(nextarg); if(!global->help_category) { err = PARAM_NO_MEM; @@ -2197,11 +2305,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } } err = PARAM_HELP_REQUESTED; - break; } /* we now actually support --no-help too! */ break; - case 'H': + case C_HEADER: /* --header */ + case C_PROXY_HEADER: /* --proxy-header */ /* A custom header to append to a list */ if(nextarg[0] == '@') { /* read many headers from a file or stdin */ @@ -2212,7 +2320,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ if(!file) { errorf(global, "Failed to open %s", &nextarg[1]); err = PARAM_READ_ERROR; - break; } else { err = file2memory(&string, &len, file); @@ -2221,7 +2328,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ /* !checksrc! disable BANNEDFUNC 2 */ char *h = strtok(string, "\r\n"); while(h) { - if(subletter == 'p') /* --proxy-header */ + if(cmd == C_PROXY_HEADER) /* --proxy-header */ err = add2list(&config->proxyheaders, h); else err = add2list(&config->headers, h); @@ -2233,115 +2340,97 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } if(!use_stdin) fclose(file); - if(err) - break; } } else { - if(subletter == 'p') /* --proxy-header */ + if(cmd == C_PROXY_HEADER) /* --proxy-header */ err = add2list(&config->proxyheaders, nextarg); else err = add2list(&config->headers, nextarg); } break; - case 'i': + case C_INCLUDE: /* --include */ config->show_headers = toggle; /* show the headers as well in the general output stream */ break; - case 'j': + case C_JUNK_SESSION_COOKIES: /* --junk-session-cookies */ config->cookiesession = toggle; break; - case 'I': /* --head */ + case C_HEAD: /* --head */ config->no_body = toggle; config->show_headers = toggle; if(SetHTTPrequest(config, (config->no_body)?HTTPREQ_HEAD:HTTPREQ_GET, - &config->httpreq)) { + &config->httpreq)) err = PARAM_BAD_USE; - break; - } break; - case 'J': /* --remote-header-name */ + case C_REMOTE_HEADER_NAME: /* --remote-header-name */ config->content_disposition = toggle; break; - case 'k': /* allow insecure SSL connects */ - if(subletter == 'd') /* --doh-insecure */ - config->doh_insecure_ok = toggle; - else - config->insecure_ok = toggle; + case C_INSECURE: /* --insecure */ + config->insecure_ok = toggle; break; - case 'K': /* parse config file */ + case C_DOH_INSECURE: /* --doh-insecure */ + config->doh_insecure_ok = toggle; + break; + case C_CONFIG: /* --config */ if(parseconfig(nextarg, global)) { errorf(global, "cannot read config from '%s'", nextarg); err = PARAM_READ_ERROR; - break; } break; - case 'l': + case C_LIST_ONLY: /* --list-only */ config->dirlistonly = toggle; /* only list the names of the FTP dir */ break; - case 'L': + case C_LOCATION_TRUSTED: /* --location-trusted */ + /* Continue to send authentication (user+password) when following + * locations, even when hostname changed */ + config->unrestricted_auth = toggle; + FALLTHROUGH(); + case C_LOCATION: /* --location */ config->followlocation = toggle; /* Follow Location: HTTP headers */ - switch(subletter) { - case 't': - /* Continue to send authentication (user+password) when following - * locations, even when hostname changed */ - config->unrestricted_auth = toggle; - break; - } break; - case 'm': + case C_MAX_TIME: /* --max-time */ /* specified max time */ err = secs2ms(&config->timeout_ms, nextarg); break; - case 'M': /* M for manual, huge help */ + case C_MANUAL: /* --manual */ if(toggle) { /* --no-manual shows no manual... */ #ifndef USE_MANUAL warnf(global, "built-in manual was disabled at build-time"); #endif err = PARAM_MANUAL_REQUESTED; - break; } break; - case 'n': - switch(subletter) { - case 'o': /* use .netrc or URL */ - config->netrc_opt = toggle; - break; - case 'e': /* netrc-file */ - GetStr(&config->netrc_file, nextarg); - break; - default: - /* pick info from .netrc, if this is used for http, curl will - automatically enforce user+password with the request */ - config->netrc = toggle; - break; - } + case C_NETRC_OPTIONAL: /* --netrc-optional */ + config->netrc_opt = toggle; + break; + case C_NETRC_FILE: /* --netrc-file */ + err = getstr(&config->netrc_file, nextarg, DENY_BLANK); + break; + case C_NETRC: /* --netrc */ + /* pick info from .netrc, if this is used for http, curl will + automatically enforce user+password with the request */ + config->netrc = toggle; break; - case 'N': + case C_BUFFER: /* --buffer */ /* disable the output I/O buffering. note that the option is called --buffer but is mostly used in the negative form: --no-buffer */ config->nobuffer = longopt ? !toggle : TRUE; break; - case 'O': /* --remote-name */ - if(subletter == 'a') { /* --remote-name-all */ - config->default_node_flags = toggle?GETOUT_USEREMOTE:0; - break; - } - else if(subletter == 'b') { /* --output-dir */ - GetStr(&config->output_dir, nextarg); - break; - } - else if(subletter == 'c') { /* --clobber / --no-clobber */ - config->file_clobber_mode = toggle ? CLOBBER_ALWAYS : CLOBBER_NEVER; - break; - } - /* FALLTHROUGH */ - case 'o': /* --output */ + case C_REMOTE_NAME_ALL: /* --remote-name-all */ + config->default_node_flags = toggle?GETOUT_USEREMOTE:0; + break; + case C_OUTPUT_DIR: /* --output-dir */ + err = getstr(&config->output_dir, nextarg, DENY_BLANK); + break; + case C_CLOBBER: /* --clobber */ + config->file_clobber_mode = toggle ? CLOBBER_ALWAYS : CLOBBER_NEVER; + break; + case C_OUTPUT: /* --output */ + case C_REMOTE_NAME: /* --remote-name */ /* output file */ - { - struct getout *url; if(!config->url_out) config->url_out = config->url_list; if(config->url_out) { @@ -2370,12 +2459,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ /* fill in the outfile */ if('o' == letter) { - if(!*nextarg) { - warnf(global, "output file name has no length"); - err = PARAM_BAD_USE; - break; - } - GetStr(&url->outfile, nextarg); + err = getstr(&url->outfile, nextarg, DENY_BLANK); url->flags &= ~GETOUT_USEREMOTE; /* switch off */ } else { @@ -2386,25 +2470,25 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ url->flags &= ~GETOUT_USEREMOTE; /* switch off */ } url->flags |= GETOUT_OUTFILE; - } - break; - case 'P': + break; + case C_FTP_PORT: /* --ftp-port */ /* This makes the FTP sessions use PORT instead of PASV */ /* use or <192.168.10.10> style addresses. Anything except this will make us try to get the "default" address. NOTE: this is a changed behavior since the released 4.1! */ - GetStr(&config->ftpport, nextarg); + err = getstr(&config->ftpport, nextarg, DENY_BLANK); break; - case 'p': + case C_PROXYTUNNEL: /* --proxytunnel */ /* proxy tunnel for non-http protocols */ config->proxytunnel = toggle; break; - case 'q': /* if used first, already taken care of, we do it like - this so we don't cause an error! */ + case C_DISABLE: /* --disable */ + /* if used first, already taken care of, we do it like this so we don't + cause an error! */ break; - case 'Q': + case C_QUOTE: /* --quote */ /* QUOTE command to send to FTP server */ switch(nextarg[0]) { case '-': @@ -2422,34 +2506,33 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ break; } break; - case 'r': + case C_RANGE: /* --range */ /* Specifying a range WITHOUT A DASH will create an illegal HTTP range (and won't actually be range by definition). The man page previously claimed that to be a good way, why this code is added to work-around it. */ if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) { char buffer[32]; - curl_off_t off; - if(curlx_strtoofft(nextarg, NULL, 10, &off)) { + if(curlx_strtoofft(nextarg, NULL, 10, &value)) { warnf(global, "unsupported range point"); err = PARAM_BAD_USE; - break; } - warnf(global, - "A specified range MUST include at least one dash (-). " - "Appending one for you"); - msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off); - Curl_safefree(config->range); - config->range = strdup(buffer); - if(!config->range) { - err = PARAM_NO_MEM; - break; + else { + warnf(global, + "A specified range MUST include at least one dash (-). " + "Appending one for you"); + msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", + value); + Curl_safefree(config->range); + config->range = strdup(buffer); + if(!config->range) + err = PARAM_NO_MEM; } } else { /* byte range requested */ const char *tmp_range = nextarg; - while(*tmp_range != '\0') { + while(*tmp_range) { if(!ISDIGIT(*tmp_range) && *tmp_range != '-' && *tmp_range != ',') { warnf(global, "Invalid character is found in given range. " "A specified range MUST have only digits in " @@ -2459,27 +2542,25 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } tmp_range++; } - GetStr(&config->range, nextarg); + err = getstr(&config->range, nextarg, DENY_BLANK); } break; - case 'R': + case C_REMOTE_TIME: /* --remote-time */ /* use remote file's time */ config->remote_time = toggle; break; - case 's': /* --silent */ + case C_SILENT: /* --silent */ global->silent = toggle; break; - case 'S': /* --show-error */ + case C_SHOW_ERROR: /* --show-error */ global->showerror = toggle; break; - case 't': + case C_TELNET_OPTION: /* --telnet-option */ /* Telnet options */ err = add2list(&config->telnet_options, nextarg); break; - case 'T': + case C_UPLOAD_FILE: /* --upload-file */ /* we are uploading */ - { - struct getout *url; if(!config->url_ul) config->url_ul = config->url_list; if(config->url_ul) { @@ -2508,46 +2589,42 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ url->flags |= GETOUT_NOUPLOAD; else { /* "-" equals stdin, but keep the string around for now */ - GetStr(&url->infile, nextarg); + err = getstr(&url->infile, nextarg, DENY_BLANK); } - } - break; - case 'u': + break; + case C_USER: /* --user */ /* user:password */ - GetStr(&config->userpwd, nextarg); + err = getstr(&config->userpwd, nextarg, ALLOW_BLANK); cleanarg(clearthis); break; - case 'U': + case C_PROXY_USER: /* --proxy-user */ /* Proxy user:password */ - GetStr(&config->proxyuserpwd, nextarg); + err = getstr(&config->proxyuserpwd, nextarg, ALLOW_BLANK); cleanarg(clearthis); break; - case 'v': + case C_VERBOSE: /* --verbose */ if(toggle) { /* the '%' thing here will cause the trace get sent to stderr */ Curl_safefree(global->trace_dump); global->trace_dump = strdup("%"); - if(!global->trace_dump) { + if(!global->trace_dump) err = PARAM_NO_MEM; - break; + else { + if(global->tracetype && (global->tracetype != TRACE_PLAIN)) + warnf(global, + "-v, --verbose overrides an earlier trace/verbose option"); + global->tracetype = TRACE_PLAIN; } - if(global->tracetype && (global->tracetype != TRACE_PLAIN)) - warnf(global, - "-v, --verbose overrides an earlier trace/verbose option"); - global->tracetype = TRACE_PLAIN; } else /* verbose is disabled here */ global->tracetype = TRACE_NONE; break; - case 'V': - if(toggle) { /* --no-version yields no output! */ + case C_VERSION: /* --version */ + if(toggle) /* --no-version yields no output! */ err = PARAM_VERSION_INFO_REQUESTED; - break; - } break; - - case 'w': + case C_WRITE_OUT: /* --write-out */ /* get the output string */ if('@' == *nextarg) { /* the data begins with a '@' letter, it means that a file name @@ -2578,69 +2655,57 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ warnf(global, "Failed to read %s", fname); } else - GetStr(&config->writeout, nextarg); + err = getstr(&config->writeout, nextarg, DENY_BLANK); break; - case 'x': - switch(subletter) { - case 'a': /* --preproxy */ - GetStr(&config->preproxy, nextarg); - break; - default: - /* --proxy */ - GetStr(&config->proxy, nextarg); - if(config->proxyver != CURLPROXY_HTTPS2) - config->proxyver = CURLPROXY_HTTP; - break; - } + case C_PREPROXY: /* --preproxy */ + err = getstr(&config->preproxy, nextarg, DENY_BLANK); + break; + case C_PROXY: /* --proxy */ + /* --proxy */ + err = getstr(&config->proxy, nextarg, ALLOW_BLANK); + if(config->proxyver != CURLPROXY_HTTPS2) + config->proxyver = CURLPROXY_HTTP; break; - case 'X': + case C_REQUEST: /* --request */ /* set custom request */ - GetStr(&config->customrequest, nextarg); + err = getstr(&config->customrequest, nextarg, DENY_BLANK); break; - case 'y': + case C_SPEED_TIME: /* --speed-time */ /* low speed time */ err = str2unum(&config->low_speed_time, nextarg); - if(err) - break; - if(!config->low_speed_limit) + if(!err && !config->low_speed_limit) config->low_speed_limit = 1; break; - case 'Y': + case C_SPEED_LIMIT: /* --speed-limit */ /* low speed limit */ err = str2unum(&config->low_speed_limit, nextarg); - if(err) - break; - if(!config->low_speed_time) + if(!err && !config->low_speed_time) config->low_speed_time = 30; break; - case 'Z': - switch(subletter) { - case '\0': /* --parallel */ - global->parallel = toggle; - break; - case 'b': { /* --parallel-max */ - long val; - err = str2unum(&val, nextarg); - if(err) - break; - if(val > MAX_PARALLEL) - global->parallel_max = MAX_PARALLEL; - else if(val < 1) - global->parallel_max = PARALLEL_DEFAULT; - else - global->parallel_max = (unsigned short)val; - break; - } - case 'c': /* --parallel-immediate */ - global->parallel_connect = toggle; + case C_PARALLEL: /* --parallel */ + global->parallel = toggle; + break; + case C_PARALLEL_MAX: { /* --parallel-max */ + long val; + err = str2unum(&val, nextarg); + if(err) break; - } + if(val > MAX_PARALLEL) + global->parallel_max = MAX_PARALLEL; + else if(val < 1) + global->parallel_max = PARALLEL_DEFAULT; + else + global->parallel_max = (unsigned short)val; + break; + } + case C_PARALLEL_IMMEDIATE: /* --parallel-immediate */ + global->parallel_connect = toggle; break; - case 'z': /* time condition coming up */ + case C_TIME_COND: /* --time-cond */ switch(*nextarg) { case '+': nextarg++; - /* FALLTHROUGH */ + FALLTHROUGH(); default: /* If-Modified-Since: (section 14.28 in RFC2068) */ config->timecond = CURL_TIMECOND_IFMODSINCE; @@ -2660,11 +2725,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ config->condtime = (curl_off_t)curl_getdate(nextarg, &now); if(-1 == config->condtime) { /* now let's see if it is a file name to get the time from instead! */ - curl_off_t filetime; - rc = getfiletime(nextarg, global, &filetime); + rc = getfiletime(nextarg, global, &value); if(!rc) /* pull the time out from the file */ - config->condtime = filetime; + config->condtime = value; else { /* failed, remove time condition */ config->timecond = CURL_TIMECOND_NONE; @@ -2679,7 +2743,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ err = PARAM_OPTION_UNKNOWN; break; } - hit = -1; + a = NULL; } while(!longopt && !singleopt && *++parse && !*usedarg && !err); diff --git a/src/tool_getparam.h b/src/tool_getparam.h index a8a9d4597..12a971d02 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -49,6 +49,7 @@ typedef enum { PARAM_CONTDISP_RESUME_FROM, /* --continue-at and --remote-header-name */ PARAM_READ_ERROR, PARAM_EXPAND_ERROR, /* --expand problem */ + PARAM_BLANK_STRING, PARAM_LAST } ParameterError; diff --git a/src/tool_help.c b/src/tool_help.c index c8aea295d..04ac24537 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -173,12 +173,30 @@ void tool_version_info(void) printf("Release-Date: %s\n", LIBCURL_TIMESTAMP); #endif if(built_in_protos[0]) { + const char *insert = NULL; + /* we have ipfs and ipns support if libcurl has http support */ + for(builtin = built_in_protos; *builtin; ++builtin) { + if(insert) { + /* update insertion so ipfs will be printed in alphabetical order */ + if(strcmp(*builtin, "ipfs") < 0) + insert = *builtin; + else + break; + } + else if(!strcmp(*builtin, "http")) { + insert = *builtin; + } + } printf("Protocols:"); for(builtin = built_in_protos; *builtin; ++builtin) { /* Special case: do not list rtmp?* protocols. They may only appear together with "rtmp" */ if(!curl_strnequal(*builtin, "rtmp", 4) || !builtin[0][4]) printf(" %s", *builtin); + if(insert && insert == *builtin) { + printf(" ipfs ipns"); + insert = NULL; + } } puts(""); /* newline */ } diff --git a/src/tool_helpers.c b/src/tool_helpers.c index 854bf777a..67924a26e 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -78,6 +78,8 @@ const char *param2text(int res) return "error encountered when reading a file"; case PARAM_EXPAND_ERROR: return "variable expansion failure"; + case PARAM_BLANK_STRING: + return "blank argument where content is expected"; default: return "unknown error"; } diff --git a/src/tool_ipfs.c b/src/tool_ipfs.c index 435d1697c..f3a20aa94 100644 --- a/src/tool_ipfs.c +++ b/src/tool_ipfs.c @@ -275,22 +275,19 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, curl_free(pathbuffer); curl_url_cleanup(gatewayurl); { - const char *msg = NULL; switch(result) { case CURLE_URL_MALFORMAT: - msg = "malformed target URL"; + helpf(tool_stderr, "malformed target URL"); break; case CURLE_FILE_COULDNT_READ_FILE: - msg = "IPFS automatic gateway detection failed"; + helpf(tool_stderr, "IPFS automatic gateway detection failed"); break; case CURLE_BAD_FUNCTION_ARGUMENT: - msg = "--ipfs-gateway was given a malformed URL"; + helpf(tool_stderr, "--ipfs-gateway was given a malformed URL"); break; default: break; } - if(msg) - helpf(tool_stderr, msg); } return result; } diff --git a/src/tool_listhelp.c b/src/tool_listhelp.c index 4e7a6dd63..32ed2533e 100644 --- a/src/tool_listhelp.c +++ b/src/tool_listhelp.c @@ -26,10 +26,10 @@ /* * DO NOT edit tool_listhelp.c manually. - * This source file is generated with the following command: - - cd $srcroot/docs/cmdline-opts - ./gen.pl listhelp *.d > $srcroot/src/tool_listhelp.c + * This source file is generated with the following command in an autotools + * build: + * + * "make listhelp" */ const struct helptxt helptext[] = { @@ -143,7 +143,7 @@ const struct helptxt helptext[] = { CURLHELP_FTP}, {" --disallow-username-in-url", "Disallow username in URL", - CURLHELP_CURL | CURLHELP_HTTP}, + CURLHELP_CURL}, {" --dns-interface ", "Interface to use for DNS requests", CURLHELP_DNS}, @@ -246,7 +246,7 @@ const struct helptxt helptext[] = { {" --happy-eyeballs-timeout-ms ", "Time for IPv6 before trying IPv4", CURLHELP_CONNECTION}, - {" --haproxy-clientip", + {" --haproxy-clientip ", "Sets client IP in HAProxy PROXY protocol v1 header", CURLHELP_HTTP | CURLHELP_PROXY}, {" --haproxy-protocol", diff --git a/src/tool_msgs.c b/src/tool_msgs.c index c914836db..09c9310a5 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -36,6 +36,11 @@ #define NOTE_PREFIX "Note: " #define ERROR_PREFIX "curl: " +static void voutf(struct GlobalConfig *config, + const char *prefix, + const char *fmt, + va_list ap) CURL_PRINTF(3, 0); + static void voutf(struct GlobalConfig *config, const char *prefix, const char *fmt, @@ -100,7 +105,6 @@ void notef(struct GlobalConfig *config, const char *fmt, ...) * Emit warning formatted message on configured 'errors' stream unless * mute (--silent) was selected. */ - void warnf(struct GlobalConfig *config, const char *fmt, ...) { va_list ap; @@ -108,6 +112,7 @@ void warnf(struct GlobalConfig *config, const char *fmt, ...) voutf(config, WARN_PREFIX, fmt, ap); va_end(ap); } + /* * Emit help formatted message on given stream. This is for errors with or * related to command line arguments. diff --git a/src/tool_msgs.h b/src/tool_msgs.h index 9458991c0..e963efaa0 100644 --- a/src/tool_msgs.h +++ b/src/tool_msgs.h @@ -26,9 +26,13 @@ #include "tool_setup.h" #include "tool_cfgable.h" -void warnf(struct GlobalConfig *config, const char *fmt, ...); -void notef(struct GlobalConfig *config, const char *fmt, ...); -void helpf(FILE *errors, const char *fmt, ...); -void errorf(struct GlobalConfig *config, const char *fmt, ...); +void warnf(struct GlobalConfig *config, const char *fmt, ...) + CURL_PRINTF(2, 3); +void notef(struct GlobalConfig *config, const char *fmt, ...) + CURL_PRINTF(2, 3); +void helpf(FILE *errors, const char *fmt, ...) + CURL_PRINTF(2, 3); +void errorf(struct GlobalConfig *config, const char *fmt, ...) + CURL_PRINTF(2, 3); #endif /* HEADER_CURL_TOOL_MSGS_H */ diff --git a/src/tool_operate.c b/src/tool_operate.c index c805b7732..ba811d773 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -343,22 +343,6 @@ static CURLcode pre_transfer(struct GlobalConfig *global, return result; } -#ifdef __AMIGA__ -static void AmigaSetComment(struct per_transfer *per, - CURLcode result) -{ - struct OutStruct *outs = &per->outs; - if(!result && outs->s_isreg && outs->filename) { - /* Set the url (up to 80 chars) as comment for the file */ - if(strlen(per->this_url) > 78) - per->this_url[79] = '\0'; - SetComment(outs->filename, per->this_url); - } -} -#else -#define AmigaSetComment(x,y) Curl_nop_stmt -#endif - /* When doing serial transfers, we use a single fixed error area */ static char global_errorbuffer[CURL_ERROR_SIZE]; @@ -372,7 +356,6 @@ void single_transfer_cleanup(struct OperationConfig *config) state->urls = NULL; } Curl_safefree(state->outfiles); - Curl_safefree(state->httpgetfields); Curl_safefree(state->uploadfile); if(state->inglob) { /* Free list of globbed upload files */ @@ -654,13 +637,20 @@ static CURLcode post_per_transfer(struct GlobalConfig *global, errorf(config->global, "curl: (%d) Failed writing body", result); } if(result && config->rm_partial) { - notef(global, "Removing output file: %s", outs->filename); - unlink(outs->filename); + struct_stat st; + if(!stat(outs->filename, &st) && + S_ISREG(st.st_mode)) { + if(!unlink(outs->filename)) + notef(global, "Removed output file: %s", outs->filename); + else + warnf(global, "Failed removing: %s", outs->filename); + } + else + warnf(global, "Skipping removal; not a regular file: %s", + outs->filename); } } - AmigaSetComment(per, result); - /* File time can only be set _after_ the file has been closed */ if(!result && config->remote_time && outs->s_isreg && outs->filename) { /* Ask libcurl if we got a remote file time */ @@ -762,15 +752,11 @@ static CURLcode single_transfer(struct GlobalConfig *global, if(config->use_httpget) { if(!httpgetfields) { /* Use the postfields data for an HTTP get */ - httpgetfields = state->httpgetfields = strdup(config->postfields); - Curl_safefree(config->postfields); - if(!httpgetfields) { - errorf(global, "out of memory"); - result = CURLE_OUT_OF_MEMORY; - } - else if(SetHTTPrequest(config, - (config->no_body?HTTPREQ_HEAD:HTTPREQ_GET), - &config->httpreq)) { + httpgetfields = state->httpgetfields = config->postfields; + config->postfields = NULL; + if(SetHTTPrequest(config, + (config->no_body?HTTPREQ_HEAD:HTTPREQ_GET), + &config->httpreq)) { result = CURLE_FAILED_INIT; } } @@ -1433,9 +1419,9 @@ static CURLcode single_transfer(struct GlobalConfig *global, } else { my_setopt_str(curl, CURLOPT_POSTFIELDS, - config->postfields); + curlx_dyn_ptr(&config->postdata)); my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, - config->postfieldsize); + (curl_off_t)curlx_dyn_len(&config->postdata)); } break; case HTTPREQ_MIMEPOST: diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index d70e80db4..272581500 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -88,8 +88,6 @@ ParameterError file2string(char **bufp, FILE *file) return PARAM_OK; } -#define MAX_FILE2MEMORY (1024*1024*1024) /* big enough ? */ - ParameterError file2memory(char **bufp, size_t *size, FILE *file) { if(file) { @@ -134,6 +132,8 @@ static ParameterError getnum(long *val, const char *str, int base) if(str) { char *endptr = NULL; long num; + if(!str[0]) + return PARAM_BLANK_STRING; errno = 0; num = strtol(str, &endptr, base); if(errno == ERANGE) @@ -408,7 +408,7 @@ ParameterError proto2num(struct OperationConfig *config, break; case set: protoset[0] = NULL; - /* FALLTHROUGH */ + FALLTHROUGH(); case allow: protoset_set(protoset, p); break; diff --git a/src/tool_paramhlp.h b/src/tool_paramhlp.h index edb878195..96c49ac59 100644 --- a/src/tool_paramhlp.h +++ b/src/tool_paramhlp.h @@ -30,6 +30,8 @@ struct getout *new_getout(struct OperationConfig *config); ParameterError file2string(char **bufp, FILE *file); +#define MAX_FILE2MEMORY (1024*1024*1024) /* big enough ? */ + ParameterError file2memory(char **bufp, size_t *size, FILE *file); ParameterError str2num(long *val, const char *str); diff --git a/src/tool_setopt.c b/src/tool_setopt.c index de3b78fab..b41b6d1d2 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -240,14 +240,10 @@ static char *c_escape(const char *str, curl_off_t len) if(p && *p) result = curlx_dyn_addn(&escaped, to + 2 * (p - from), 2); else { - const char *format = "\\x%02x"; - - if(len > 1 && ISXDIGIT(s[1])) { - /* Octal escape to avoid >2 digit hex. */ - format = "\\%03o"; - } - - result = curlx_dyn_addf(&escaped, format, + result = curlx_dyn_addf(&escaped, + /* Octal escape to avoid >2 digit hex. */ + (len > 1 && ISXDIGIT(s[1])) ? + "\\%03o" : "\\x%02x", (unsigned int) *(unsigned char *) s); } } @@ -431,7 +427,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, case TOOLMIME_STDIN: if(!filename) filename = "-"; - /* FALLTHROUGH */ + FALLTHROUGH(); case TOOLMIME_STDINDATA: /* Can only be reading stdin in the current context. */ CODE1("curl_mime_data_cb(part%d, -1, (curl_read_callback) fread, \\", @@ -653,7 +649,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global, if(escape) { curl_off_t len = ZERO_TERMINATED; if(tag == CURLOPT_POSTFIELDS) - len = config->postfieldsize; + len = curlx_dyn_len(&config->postdata); escaped = c_escape(value, len); NULL_CHECK(escaped); CODE2("curl_easy_setopt(hnd, %s, \"%s\");", name, escaped); diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index e45c7d10b..8ae28a3a6 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -127,7 +127,7 @@ static CURLcode glob_set(struct URLGlob *glob, char **patternp, if(multiply(amount, pat->content.Set.size + 1)) return GLOBERROR("range overflow", 0, CURLE_URL_MALFORMAT); - /* FALLTHROUGH */ + FALLTHROUGH(); case ',': *buf = '\0'; @@ -171,7 +171,7 @@ static CURLcode glob_set(struct URLGlob *glob, char **patternp, ++pattern; ++(*posp); } - /* FALLTHROUGH */ + FALLTHROUGH(); default: *buf++ = *pattern++; /* copy character to set element */ ++(*posp); diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 665d93eb8..5a8e78323 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -74,6 +74,17 @@ For example, to insert the word hello 100 times: %repeat[100 x hello]% +## Include file + +This instruction allows a test case to include another file. It is helpful to +remember that the ordinary variables are expanded before the include happens +so `%LOGDIR` and the others can be used in the include line. + +The file name cannot contain `%` as that letter is used to end the name for +the include instruction: + + %include filename% + ## Conditional lines Lines in the test file can be made to appear conditionally on a specific diff --git a/tests/Makefile.am b/tests/Makefile.am index 17e9ad049..a6d0708f7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,19 +22,35 @@ # ########################################################################### -HTMLPAGES = testcurl.html runtests.html -PDFPAGES = testcurl.pdf runtests.pdf MANDISTPAGES = runtests.1.dist testcurl.1.dist -EXTRA_DIST = appveyor.pm azure.pm badsymbols.pl check-deprecated.pl CMakeLists.txt \ - devtest.pl dictserver.py directories.pm disable-scan.pl error-codes.pl extern-scan.pl FILEFORMAT.md \ - processhelp.pm ftpserver.pl getpart.pm globalconfig.pm http-server.pl http2-server.pl \ - http3-server.pl manpage-scan.pl manpage-syntax.pl markdown-uppercase.pl mem-include-scan.pl \ - memanalyze.pl negtelnetserver.py nroff-scan.pl option-check.pl options-scan.pl \ - pathhelp.pm README.md rtspserver.pl runner.pm runtests.1 runtests.pl secureserver.pl \ - serverhelp.pm servers.pm smbserver.py sshhelp.pm sshserver.pl stunnel.pem symbol-scan.pl \ - testcurl.1 testcurl.pl testutil.pm tftpserver.pl util.py valgrind.pm \ - valgrind.supp version-scan.pl check-translatable-options.pl +# scripts used in test cases +TESTSCRIPTS = \ + test1119.pl \ + test1132.pl \ + test1135.pl \ + test1139.pl \ + test1140.pl \ + test1165.pl \ + test1167.pl \ + test1173.pl \ + test1175.pl \ + test1177.pl \ + test1222.pl \ + test1275.pl \ + test1276.pl \ + test1477.pl \ + test1544.pl \ + test971.pl + +EXTRA_DIST = appveyor.pm azure.pm CMakeLists.txt devtest.pl \ + dictserver.py directories.pm FILEFORMAT.md processhelp.pm ftpserver.pl \ + getpart.pm globalconfig.pm http-server.pl http2-server.pl \ + http3-server.pl memanalyze.pl negtelnetserver.py pathhelp.pm README.md \ + rtspserver.pl runner.pm runtests.1 runtests.pl secureserver.pl \ + serverhelp.pm servers.pm smbserver.py sshhelp.pm sshserver.pl \ + stunnel.pem testcurl.1 testcurl.pl testutil.pm tftpserver.pl util.py \ + valgrind.pm valgrind.supp $(TESTSCRIPTS) DISTCLEANFILES = configurehelp.pm @@ -56,8 +72,6 @@ PERLFLAGS = -I$(srcdir) CLEANFILES = .http.pid .https.pid .ftp.pid .ftps.pid $(MANDISTPAGES) -MAN2HTML= roffit $< >$@ - curl: @cd $(top_builddir) && $(MAKE) @@ -107,16 +121,6 @@ torture-test: perlcheck all event-test: perlcheck all $(TEST) $(TEST_E) $(TFLAGS) -.1.html: - $(MAN2HTML) - -.1.pdf: - @(foo=`echo $@ | sed -e 's/\.[0-9]$$//g'`; \ - groff -Tps -man $< >$$foo.ps; \ - ps2pdf $$foo.ps $@; \ - rm $$foo.ps; \ - echo "converted $< to $@") - checksrc: (cd libtest && $(MAKE) checksrc) (cd unit && $(MAKE) checksrc) diff --git a/tests/data/DISABLED b/tests/data/DISABLED index b077c67a0..a98dc8566 100644 --- a/tests/data/DISABLED +++ b/tests/data/DISABLED @@ -81,6 +81,8 @@ 2301 2302 2305 +# response body seem not to be handled by hyper +2307 %endif 2043 # The CRL test (313) doesn't work with rustls because rustls doesn't support diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index de13c525e..c3d496f64 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -72,7 +72,7 @@ test417 test418 test419 test420 test421 test422 test423 test424 test425 \ test426 test427 test428 test429 test430 test431 test432 test433 test434 \ test435 test436 test437 test438 test439 test440 test441 test442 test443 \ test444 test445 test446 test447 test448 test449 test450 test451 test452 \ -test453 test454 test455 test456 test457 test458 test459 \ +test453 test454 test455 test456 test457 test458 test459 test460 test461 \ \ test490 test491 test492 test493 test494 test495 test496 test497 test498 \ \ @@ -96,13 +96,13 @@ test644 test645 test646 test647 test648 test649 test650 test651 test652 \ test653 test654 test655 test656 test658 test659 test660 test661 test662 \ test663 test664 test665 test666 test667 test668 test669 test670 test671 \ test672 test673 test674 test675 test676 test677 test678 test679 test680 \ -test681 test682 test683 test684 test685 test686 test687 test688 \ +test681 test682 test683 test684 test685 test686 test687 test688 test689 \ \ test700 test701 test702 test703 test704 test705 test706 test707 test708 \ test709 test710 test711 test712 test713 test714 test715 test716 test717 \ test718 test719 test720 test721 test722 test723 test724 test725 test726 \ test727 test728 test729 test730 test731 test732 test733 test734 test735 \ -test736 test737 test738 test739 test740 test741 \ +test736 test737 test738 test739 test740 test741 test742 \ \ test799 test800 test801 test802 test803 test804 test805 test806 test807 \ test808 test809 test810 test811 test812 test813 test814 test815 test816 \ @@ -125,7 +125,7 @@ test952 test953 test954 test955 test956 test957 test958 test959 test960 \ test961 test962 test963 test964 test965 test966 test967 test968 test969 \ test970 test971 test972 test973 test974 test975 test976 test977 test978 \ test979 test980 test981 test982 test983 test984 test985 test986 test987 \ -test988 test989 test990 test991 \ +test988 test989 test990 test991 test992 \ \ test1000 test1001 test1002 test1003 test1004 test1005 test1006 test1007 \ test1008 test1009 test1010 test1011 test1012 test1013 test1014 test1015 \ @@ -186,7 +186,7 @@ test1439 test1440 test1441 test1442 test1443 test1444 test1445 test1446 \ test1447 test1448 test1449 test1450 test1451 test1452 test1453 test1454 \ test1455 test1456 test1457 test1458 test1459 test1460 test1461 test1462 \ test1463 test1464 test1465 test1466 test1467 test1468 test1469 test1470 \ -test1471 test1472 test1473 test1474 test1475 test1476 test1477 \ +test1471 test1472 test1473 test1475 test1476 test1477 test1478 \ \ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \ @@ -215,7 +215,7 @@ test1670 test1671 \ \ test1680 test1681 test1682 test1683 \ \ -test1700 test1701 test1702 test1703 \ +test1700 test1701 test1702 test1703 test1704 \ \ test1800 test1801 \ \ @@ -244,7 +244,7 @@ test2100 \ \ test2200 test2201 test2202 test2203 test2204 test2205 \ \ -test2300 test2301 test2302 test2303 test2304 test2305 test2306 \ +test2300 test2301 test2302 test2303 test2304 test2305 test2306 test2307 \ \ test2400 test2401 test2402 test2403 test2404 \ \ diff --git a/tests/data/test1026 b/tests/data/test1026 index d565f24d5..e310e6962 100644 --- a/tests/data/test1026 +++ b/tests/data/test1026 @@ -28,7 +28,7 @@ curl --manual # Search for these two sentinel lines in the manual output; if they are found, # then chances are good the entire manual is there. -perl -e 'open(IN,$ARGV[0]); my $lines=grep(/(curl\s*-\s*transfer\sa\s*URL)|(CONTRIBUTORS)/, ); exit ($lines != 2); # Let this file pass an XML syntax check: ' %LOGDIR/stdout%TESTNUMBER +perl -e 'open(IN,$ARGV[0]); my $lines=grep(/(curl\s*-\s*transfer\sa\s*URL)|(AUTHORS)/, ); exit ($lines != 2); # Let this file pass an XML syntax check: ' %LOGDIR/stdout%TESTNUMBER diff --git a/tests/data/test1119 b/tests/data/test1119 index 41f6dba2c..1a73439e6 100644 --- a/tests/data/test1119 +++ b/tests/data/test1119 @@ -18,7 +18,7 @@ Verify that symbols-in-versions and headers are in sync -%SRCDIR/symbol-scan.pl %SRCDIR/.. ../include/curl +%SRCDIR/test1119.pl %SRCDIR/.. ../include/curl diff --git a/tests/data/test1132 b/tests/data/test1132 index 613031bac..e7a802a71 100644 --- a/tests/data/test1132 +++ b/tests/data/test1132 @@ -18,7 +18,7 @@ Verify memory #include files in libcurl's C source files -%SRCDIR/mem-include-scan.pl %SRCDIR/../lib +%SRCDIR/test1132.pl %SRCDIR/../lib diff --git a/tests/data/test1135 b/tests/data/test1135 index d188989ed..de028a0c9 100644 --- a/tests/data/test1135 +++ b/tests/data/test1135 @@ -22,7 +22,7 @@ Verify CURL_EXTERN order -%SRCDIR/extern-scan.pl %SRCDIR/.. +%SRCDIR/test1135.pl %SRCDIR/.. diff --git a/tests/data/test1139 b/tests/data/test1139 index b5267b012..2704e0a21 100644 --- a/tests/data/test1139 +++ b/tests/data/test1139 @@ -20,7 +20,7 @@ Verify that all libcurl options have man pages -%SRCDIR/manpage-scan.pl %SRCDIR/.. %PWD/.. +%SRCDIR/test1139.pl %SRCDIR/.. %PWD/.. diff --git a/tests/data/test1140 b/tests/data/test1140 index 5aa997e78..5f26c73f4 100644 --- a/tests/data/test1140 +++ b/tests/data/test1140 @@ -19,7 +19,7 @@ Verify the nroff of man pages -%SRCDIR/nroff-scan.pl %SRCDIR/../docs/ %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3 %SRCDIR/../docs/*.1 +%SRCDIR/test1140.pl %PWD/../docs/ %PWD/../docs/libcurl/*.3 %PWD/../docs/libcurl/opts/*.3 %PWD/../docs/*.1 diff --git a/tests/data/test1154 b/tests/data/test1154 index b7349e17d..bd08ce26c 100644 --- a/tests/data/test1154 +++ b/tests/data/test1154 @@ -47,9 +47,9 @@ User-Agent: curl/%VERSION Accept: */* -# 27 == CURLE_OUT_OF_MEMORY +# 100 == CURLE_TOO_LARGE -27 +100 diff --git a/tests/data/test1165 b/tests/data/test1165 index de4283af2..89f02d719 100644 --- a/tests/data/test1165 +++ b/tests/data/test1165 @@ -18,7 +18,7 @@ Verify configure.ac and source code CURL_DISABLE_-sync -%SRCDIR/disable-scan.pl %SRCDIR/.. +%SRCDIR/test1165.pl %SRCDIR/.. diff --git a/tests/data/test1167 b/tests/data/test1167 index 3c2fb1a5f..76777f81b 100644 --- a/tests/data/test1167 +++ b/tests/data/test1167 @@ -17,7 +17,7 @@ Verify curl prefix of public symbols in header files -%SRCDIR/badsymbols.pl %SRCDIR/.. +%SRCDIR/test1167.pl %SRCDIR/.. diff --git a/tests/data/test1173 b/tests/data/test1173 index b5dafbb3b..97d338df3 100644 --- a/tests/data/test1173 +++ b/tests/data/test1173 @@ -19,7 +19,7 @@ Man page syntax checks -%SRCDIR/manpage-syntax.pl %SRCDIR/../docs/libcurl/symbols-in-versions %SRCDIR/../docs/*.1 %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3 +%SRCDIR/test1173.pl %SRCDIR/../docs/libcurl/symbols-in-versions %PWD/../docs/*.1 %PWD/../docs/libcurl/*.3 %PWD/../docs/libcurl/opts/*.3 diff --git a/tests/data/test1175 b/tests/data/test1175 index 5190dbe2a..6e99a616e 100644 --- a/tests/data/test1175 +++ b/tests/data/test1175 @@ -18,7 +18,7 @@ Verify that symbols-in-versions and libcurl-errors.3 are in sync -%SRCDIR/error-codes.pl %SRCDIR +%SRCDIR/test1175.pl %SRCDIR diff --git a/tests/data/test1177 b/tests/data/test1177 index 66fe49767..6cc94a5b1 100644 --- a/tests/data/test1177 +++ b/tests/data/test1177 @@ -18,7 +18,7 @@ Verify that feature names and CURL_VERSION_* in lib and docs are in sync -%SRCDIR/version-scan.pl %SRCDIR/../docs/libcurl/curl_version_info.3 %SRCDIR/../include/curl/curl.h %SRCDIR/../lib/version.c +%SRCDIR/test1177.pl %PWD/../docs/libcurl/curl_version_info.3 %SRCDIR/../include/curl/curl.h %SRCDIR/../lib/version.c diff --git a/tests/data/test1222 b/tests/data/test1222 index b56cf6879..b46fd1156 100644 --- a/tests/data/test1222 +++ b/tests/data/test1222 @@ -17,7 +17,7 @@ Verify deprecation statuses and versions -%SRCDIR/check-deprecated.pl %SRCDIR/.. +%SRCDIR/test1222.pl %SRCDIR/.. diff --git a/tests/data/test1254 b/tests/data/test1254 index a39cbd26e..07e77ed2a 100644 --- a/tests/data/test1254 +++ b/tests/data/test1254 @@ -27,7 +27,7 @@ foo http -Under condition using --proxy, override NO_PROXY by --nproxy and access target URL through proxy +override NO_PROXY by --noproxy and access target URL through proxy NO_PROXY=example.com diff --git a/tests/data/test1268 b/tests/data/test1268 index 806592fb8..05fe9d8e7 100644 --- a/tests/data/test1268 +++ b/tests/data/test1268 @@ -30,7 +30,7 @@ file name argument looks like a flag Warning: The file name argument '-k' looks like a flag. -curl: (1) Protocol "hej" not supported or disabled in libcurl +curl: (1) Protocol "hej" not supported # we expect an error since we provide a weird URL diff --git a/tests/data/test1275 b/tests/data/test1275 index d1cb223b8..31893f7ba 100644 --- a/tests/data/test1275 +++ b/tests/data/test1275 @@ -18,7 +18,7 @@ Verify capital letters after period in markdown files -%SRCDIR/markdown-uppercase.pl %SRCDIR/.. +%SRCDIR/test1275.pl %SRCDIR/.. diff --git a/tests/data/test1276 b/tests/data/test1276 index 3961bf4cb..b365f800a 100644 --- a/tests/data/test1276 +++ b/tests/data/test1276 @@ -18,7 +18,7 @@ Verify lib/optiontable.pl -%SRCDIR/option-check.pl %SRCDIR/.. +%SRCDIR/test1276.pl %SRCDIR/.. diff --git a/tests/data/test1279 b/tests/data/test1279 index fd3b34bd3..041f5449b 100644 --- a/tests/data/test1279 +++ b/tests/data/test1279 @@ -19,7 +19,7 @@ Verify libcurl.def against CURL_EXTERN declarations -%SRCDIR/extern-scan.pl --heading=EXPORTS --sort %SRCDIR/.. +%SRCDIR/test1135.pl --heading=EXPORTS --sort %SRCDIR/.. diff --git a/tests/data/test1474 b/tests/data/test1474 deleted file mode 100644 index a87044d1a..000000000 --- a/tests/data/test1474 +++ /dev/null @@ -1,121 +0,0 @@ - -# This test is quite timing dependent and tricky to set up. The time line of -# test operations looks like this: -# -# 1. curl sends a PUT request with Expect: 100-continue and waits only 1 msec -# for a 100 response. -# 2. The HTTP server accepts the connection but waits 500 msec before acting -# on the request. -# 3. curl doesn't receive the expected 100 response before its timeout expires, -# so it starts sending the body. It is throttled by a --limit-rate, so it -# sends the first 64 KiB then stops for 1000 msec due to this -# throttling. -# 4. The server sends its 417 response while curl is throttled. -# 5. curl responds to this 417 response by closing the connection (because it -# has a half-completed response outstanding) and starting a new one. This -# new request does not have an Expect: header so it is sent without delay. -# It's still throttled, however, so it takes about 16 seconds to finish -# sending. -# 6. The server receives the response and this time acks it with 200. -# -# Because of the timing sensitivity (scheduling delays of 500 msec can cause -# the test to fail), this test is marked flaky to avoid it being run in the CI -# builds which are often run on overloaded servers. -# Increasing the --limit-rate would decrease the test time, but at the cost of -# becoming even more sensitive to delays (going from 500 msec to 250 msec or -# less of accepted delay before failure). Adding a --speed-time would increase -# the 1 second delay between writes to longer, but it would also increase the -# total time needed by the test, which is already quite high. -# -# The assumption in step 3 is also broken on NetBSD 9.3, OpenBSD 7.3 and -# Solaris 10 as they only usually send about half the requested amount of data -# (see https://curl.se/mail/lib-2023-09/0021.html). - - -HTTP -HTTP PUT -Expect -flaky -timing-dependent - - -# Server-side - -# 417 means the server didn't like the Expect header - -HTTP/1.1 417 BAD swsbounce -Date: Tue, 09 Nov 2010 14:49:00 GMT -Server: test-server/fake -Content-Length: 0 - - - -HTTP/1.1 200 OK -Date: Tue, 09 Nov 2010 14:49:00 GMT -Server: test-server/fake -Content-Length: 10 - -blablabla - - -HTTP/1.1 417 BAD swsbounce -Date: Tue, 09 Nov 2010 14:49:00 GMT -Server: test-server/fake -Content-Length: 0 - -HTTP/1.1 200 OK -Date: Tue, 09 Nov 2010 14:49:00 GMT -Server: test-server/fake -Content-Length: 10 - -blablabla - - -no-expect -delay: 500 -connection-monitor - - - -# Client-side - - -http - - -HTTP PUT with Expect: 100-continue and 417 response during upload - - -http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -T %LOGDIR/test%TESTNUMBER.txt --limit-rate 64K --expect100-timeout 0.001 - - -perl -e "print 'Test does not work on this BSD system' if ( $^O eq 'netbsd' || $^O eq 'openbsd' || ($^O eq 'solaris' && qx/uname -r/ * 100 <= 510));" - -# Must be large enough to trigger curl's automatic 100-continue behaviour - -%repeat[132 x S]%%repeat[16462 x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%0a]% - - - -# Verify data after the test has been "shot" - - -PUT /we/want/%TESTNUMBER HTTP/1.1 -Host: %HOSTIP:%HTTPPORT -User-Agent: curl/%VERSION -Accept: */* -Content-Length: 1053701 -Expect: 100-continue - -%repeat[132 x S]%%repeat[1021 x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%0a]%%repeat[60 x x]%[DISCONNECT] -PUT /we/want/%TESTNUMBER HTTP/1.1 -Host: %HOSTIP:%HTTPPORT -User-Agent: curl/%VERSION -Accept: */* -Content-Length: 1053701 - -%repeat[132 x S]%%repeat[16462 x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%0a]% -[DISCONNECT] - - - diff --git a/tests/data/test1477 b/tests/data/test1477 index 2771d7f1d..a8c4659e4 100644 --- a/tests/data/test1477 +++ b/tests/data/test1477 @@ -17,7 +17,7 @@ Verify that error codes in headers and libcurl-errors.3 are in sync -%SRCDIR/errorcodes.pl %SRCDIR/.. +%SRCDIR/test1477.pl %SRCDIR/.. %PWD/.. diff --git a/tests/data/test1478 b/tests/data/test1478 new file mode 100644 index 000000000..b489ac038 --- /dev/null +++ b/tests/data/test1478 @@ -0,0 +1,32 @@ + + + +source analysis +documentation +--help + + + +# +# Client-side + + +none + + + +src/tool_listhelp.c is in sync with docs/cmdline-opts + + + +%SRCDIR/../docs/cmdline-opts/gen.pl listhelp %SRCDIR/../docs/cmdline-opts/*.md + + + + + +%include %SRCDIR/../src/tool_listhelp.c% + + + + diff --git a/tests/data/test1538 b/tests/data/test1538 index 59cd1628e..c0f038be4 100644 --- a/tests/data/test1538 +++ b/tests/data/test1538 @@ -132,7 +132,8 @@ e96: QUIC connection error e97: proxy handshake error e98: SSL Client Certificate required e99: Unrecoverable error in select/poll -e100: Unknown error +e100: A value or data field grew larger than allowed +e101: Unknown error m-1: Please call curl_multi_perform() soon m0: No error m1: Invalid multi handle @@ -186,7 +187,8 @@ u27: Bad scheme u28: Unsupported number of slashes following scheme u29: Bad user u30: libcurl lacks IDN support -u31: CURLUcode unknown +u31: A value or data field is larger than allowed +u32: CURLUcode unknown diff --git a/tests/data/test1544 b/tests/data/test1544 index f658f5a74..037caa0ac 100644 --- a/tests/data/test1544 +++ b/tests/data/test1544 @@ -17,7 +17,7 @@ Verify all string options are translated by OS/400 wrapper -%SRCDIR/check-translatable-options.pl %SRCDIR/.. +%SRCDIR/test1544.pl %SRCDIR/.. diff --git a/tests/data/test1704 b/tests/data/test1704 new file mode 100644 index 000000000..a8f285eea --- /dev/null +++ b/tests/data/test1704 @@ -0,0 +1,66 @@ + + + +HTTP +HTTP GET +HTTP/2 + + + +# +# Server-side + + +HTTP/2 101 OK + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Content-Length: 6 +Connection: close +Content-Type: text/html + +-maa- + + + +# +# Client-side + + +h2c + + +http + + +HTTP/1 doing HTTP/2 Upgrade: getting a HTTP/2 101 response + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER --http2 + + + +# +# Verify data after the test has been "shot" + + +^X-Forwarded-Proto:.* +^Via:.* + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* +Connection: Upgrade, HTTP2-Settings +Upgrade: h2c +HTTP2-Settings: AAMAAABkAAQAoAAAAAIAAAAA + + + +# CURLE_WEIRD_SERVER_REPLY (8) + +8 + + + diff --git a/tests/data/test19 b/tests/data/test19 index 265a74ad8..cf735a42f 100644 --- a/tests/data/test19 +++ b/tests/data/test19 @@ -24,7 +24,7 @@ http attempt connect to non-listening socket -%HOSTIP:%NOLISTENPORT +--trace-config all %HOSTIP:%NOLISTENPORT diff --git a/tests/data/test1940 b/tests/data/test1940 index 7f621b428..f4c6dd1a1 100644 --- a/tests/data/test1940 +++ b/tests/data/test1940 @@ -19,6 +19,8 @@ Content-Length: 0 Set-Cookie: onecookie=data; Set-Cookie: secondcookie=2data; Set-Cookie: cookie3=data3; +Blank: +Blank2: Location: /%TESTNUMBER0002 @@ -57,6 +59,8 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER - Set-Cookie == secondcookie=2data; (1/3) - Set-Cookie == cookie3=data3; (2/3) Fold == is folding a line + Blank == + Blank2 == diff --git a/tests/data/test2307 b/tests/data/test2307 new file mode 100644 index 000000000..ce260ac1c --- /dev/null +++ b/tests/data/test2307 @@ -0,0 +1,71 @@ + + + +WebSockets + + + +# +# Sends a PING with overlong payload + + +HTTP/1.1 101 Switching to WebSockets +Server: test-server/fake +Upgrade: websocket +Connection: Upgrade +Something: else +Sec-WebSocket-Accept: HkPsVga7+8LuxM4RGQ5p9tZHeYs= + +%hex[%19%7f%ff%30%30%30%30%30%30%30%30%30%30%30%30]hex% + +# allow upgrade + +upgrade + + + +# +# Client-side + +# require debug for the forced CURL_ENTROPY + +debug +ws +!hyper + + +http + + +WebSockets, overlong PING payload + + +lib2302 + + +ws://%HOSTIP:%HTTPPORT/%TESTNUMBER + + + +# +# PONG with no data and the 32 bit mask +# + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: webbie-sox/3 +Accept: */* +Upgrade: websocket +Connection: Upgrade +Sec-WebSocket-Version: 13 +Sec-WebSocket-Key: NDMyMTUzMjE2MzIxNzMyMQ== + + + +# 56 == CURLE_RECV_ERROR + +56 + + + diff --git a/tests/data/test250 b/tests/data/test250 index 3c16fcd7b..455d9ea1a 100644 --- a/tests/data/test250 +++ b/tests/data/test250 @@ -38,7 +38,7 @@ ftp FTP dir list PASV with slow response - + ftp://%HOSTIP:%FTPPORT/ diff --git a/tests/data/test285 b/tests/data/test285 index 7968e1a34..03dc96f6a 100644 --- a/tests/data/test285 +++ b/tests/data/test285 @@ -16,7 +16,7 @@ tftp TFTP send --T %LOGDIR/test%TESTNUMBER.txt tftp://%HOSTIP:%TFTPPORT// --connect-time 549 +-T %LOGDIR/test%TESTNUMBER.txt tftp://%HOSTIP:%TFTPPORT// --connect-timeout 549 a chunk of diff --git a/tests/data/test3012 b/tests/data/test3012 index 2bd329455..a9c950587 100644 --- a/tests/data/test3012 +++ b/tests/data/test3012 @@ -4,6 +4,7 @@ -O -J --output-dir +--remote-time # @@ -36,10 +37,10 @@ http http ---output-dir with -J +--output-dir with -J and -R -http://%HOSTIP:%HTTPPORT/this/is/the/%TESTNUMBER -OJ --output-dir %PWD/%LOGDIR +http://%HOSTIP:%HTTPPORT/this/is/the/%TESTNUMBER -OJR --output-dir %PWD/%LOGDIR diff --git a/tests/data/test421 b/tests/data/test421 index 0e4130b06..2c79c1f8f 100644 --- a/tests/data/test421 +++ b/tests/data/test421 @@ -71,7 +71,7 @@ Accept: */* "access-control-allow-methods":["GET, POST, PUT, DELETE, OPTIONS"], "access-control-max-age":["1728000"], "access-control-allow-headers":["Authorization, Content-Type, AuthorizationOauth, X-EARLY-ACCESS"], -"access-control-expose-headers":["\r"], +"access-control-expose-headers":[""], "etag":["W/\"2678f9ab2ba550d164e7cc014aefd31e\""], "cache-control":["max-age=0, private, must-revalidate"], "x-request-id":["375b343b3d2ecf9b442c0daf00fc4a9a"], diff --git a/tests/data/test460 b/tests/data/test460 new file mode 100644 index 000000000..824166a81 --- /dev/null +++ b/tests/data/test460 @@ -0,0 +1,28 @@ + + + +variables +expand + + + +# Client-side + + +none + + +try --expand without an argument + + +--expand-url + + + +# + + +2 + + + diff --git a/tests/data/test461 b/tests/data/test461 new file mode 100644 index 000000000..03d7c7a22 --- /dev/null +++ b/tests/data/test461 @@ -0,0 +1,48 @@ + + + +HTTP +HTTP GET +--header + + + +# +# Server-side + + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Content-Length: 6 +Connection: close +Content-Type: text/html + +-foo- + + + +# +# Client-side + + +http + + +disable Host: when specified as lower case + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER -H host: + + + +# +# Verify data after the test has been "shot" + + +GET /%TESTNUMBER HTTP/1.1 +User-Agent: curl/%VERSION +Accept: */* + + + + diff --git a/tests/data/test498 b/tests/data/test498 index 457c28043..b1fc02380 100644 --- a/tests/data/test498 +++ b/tests/data/test498 @@ -35,7 +35,7 @@ http Reject too large HTTP response headers on endless redirects -http://%HOSTIP:%HTTPPORT/%TESTNUMBER --max-redir 400 --location +http://%HOSTIP:%HTTPPORT/%TESTNUMBER --max-redirs 400 --location diff --git a/tests/data/test689 b/tests/data/test689 new file mode 100644 index 000000000..821556dec --- /dev/null +++ b/tests/data/test689 @@ -0,0 +1,53 @@ + + +#Informational + + +RTSP +OPTIONS + + + +# Server-side + + +RTSP/7.1 786 + +RTSP/ + + + + + +# Client-Side + + +rtsp + + +lib567 + + + +fuzzing crash issue #12701 + + +rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER + + + + + +OPTIONS rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER RTSP/1.0 +CSeq: 1 +User-Agent: test567 +Test-Number: 567 + + +# 8 == CURLE_WEIRD_SERVER_REPLY + +8 + + + + diff --git a/tests/data/test742 b/tests/data/test742 new file mode 100644 index 000000000..34e284d18 --- /dev/null +++ b/tests/data/test742 @@ -0,0 +1,66 @@ + + + +HTTP +SOCKS5 +all_proxy + + +# +# Server-side + + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT +ETag: "21025-dc7-39462498" +Accept-Ranges: bytes +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes + +-foo- + +# method 2 is SOCKS5 asking for user+password + +method 2 +user aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +password bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +backendport %HTTPPORT + + + +# +# Client-side + + +socks5 +http + + +SOCKS5-hostname with max length credentials and max host name length + + +# target a port that won't work without the SOCKS magic + +http://cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc:%HTTPPORT -x socks5h://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb@%HOSTIP:%SOCKSPORT + + +proxy + + + +# +# Verify data after the test has been "shot" + + +GET / HTTP/1.1 +Host: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + + diff --git a/tests/data/test80 b/tests/data/test80 index 21d9fd2ea..c6aa05b17 100644 --- a/tests/data/test80 +++ b/tests/data/test80 @@ -53,7 +53,7 @@ http-proxy HTTP 1.0 CONNECT with proxytunnel and proxy+host Basic authentication -http://test.%TESTNUMBER:%HTTPPORT/we/want/that/page/%TESTNUMBER -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself +http://test.%TESTNUMBER:%HTTPPORT/we/want/that/page/%TESTNUMBER -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself -A "" proxy @@ -67,7 +67,6 @@ proxy CONNECT test.%TESTNUMBER:%HTTPPORT HTTP/1.0 Host: test.%TESTNUMBER:%HTTPPORT Proxy-Authorization: Basic eW91YXJlOnlvdXJzZWxm -User-Agent: curl/%VERSION Proxy-Connection: Keep-Alive @@ -75,7 +74,6 @@ Proxy-Connection: Keep-Alive GET /we/want/that/page/%TESTNUMBER HTTP/1.1 Host: test.%TESTNUMBER:%HTTPPORT Authorization: Basic aWFtOm15c2VsZg== -User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test971 b/tests/data/test971 index 19260dfdf..6c6b95058 100644 --- a/tests/data/test971 +++ b/tests/data/test971 @@ -18,7 +18,7 @@ Verify that options-in-versions and docs/cmdline-opts are in sync -%SRCDIR/options-scan.pl %SRCDIR/../docs/options-in-versions %SRCDIR/../docs/cmdline-opts +%SRCDIR/test971.pl %SRCDIR/../docs/options-in-versions %SRCDIR/../docs/cmdline-opts diff --git a/tests/data/test992 b/tests/data/test992 new file mode 100644 index 000000000..dad0aa51a --- /dev/null +++ b/tests/data/test992 @@ -0,0 +1,52 @@ + + + +SASL + + + +# +# Server-side + + +AUTH OAUTHBEARER XOAUTH2 +REPLY AUTH 334 XOAUTH2 supported +REPLY dXNlcj11c2VyAWF1dGg9QmVhcmVyIG1GXzkuQjVmLTQuMUpxTQEB 235 Authenticated + + + +# +# Client-side + + +smtp + + +SASL verify default mechanisms are reset by login options + + +mail body + + +smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -u user --oauth2-bearer mF_9.B5f-4.1JqM --login-options "AUTH=XOAUTH2" -T - + + + +# +# Verify data after the test has been "shot" + + +EHLO %TESTNUMBER +AUTH XOAUTH2 +dXNlcj11c2VyAWF1dGg9QmVhcmVyIG1GXzkuQjVmLTQuMUpxTQEB +MAIL FROM: +RCPT TO: +DATA +QUIT + + +mail body +. + + + diff --git a/tests/errorcodes.pl b/tests/errorcodes.pl deleted file mode 100755 index 9c8f9e882..000000000 --- a/tests/errorcodes.pl +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### - -# Check that libcurl-errors.3 and the public header files have the same set of -# error codes. - -use strict; -use warnings; - -# we may get the dir roots pointed out -my $root=$ARGV[0] || "."; -my $manpge = "$root/docs/libcurl/libcurl-errors.3"; -my $curlh = "$root/include/curl"; -my $errors=0; - -my @hnames; -my %wherefrom; -my @mnames; -my %manfrom; - -sub scanheader { - my ($file)=@_; - open H, "<$file"; - my $line = 0; - while() { - $line++; - if($_ =~ /^ (CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { - my ($name)=($1); - if(($name !~ /OBSOLETE/) && ($name !~ /_LAST\z/)) { - push @hnames, $name; - if($wherefrom{$name}) { - print STDERR "double: $name\n"; - } - $wherefrom{$name}="$file:$line"; - } - } - } - close(H); -} - -sub scanmanpage { - my ($file)=@_; - open H, "<$file"; - my $line = 0; - while() { - $line++; - if($_ =~ /^\.IP \"(CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { - my ($name)=($1); - push @mnames, $name; - $manfrom{$name}="$file:$line"; - } - } - close(H); -} - - -opendir(my $dh, $curlh) || die "Can't opendir $curlh: $!"; -my @hfiles = grep { /\.h$/ } readdir($dh); -closedir $dh; - -for(sort @hfiles) { - scanheader("$curlh/$_"); -} -scanmanpage($manpge); - -print "Result\n"; -for my $h (sort @hnames) { - if(!$manfrom{$h}) { - printf "$h from %s, not in man page\n", $wherefrom{$h}; - } -} - -for my $m (sort @mnames) { - if(!$wherefrom{$m}) { - printf "$m from %s, not in any header\n", $manfrom{$m}; - } -} diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index d0be36f15..e250aa1cb 100644 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -412,7 +412,7 @@ sub sysread_or_die { sub startsf { my @mainsockfcmd = ("./server/sockfilt".exe_ext('SRV'), "--ipv$ipvnum", - "--port", $port, + "--port", $port, "--pidfile", $mainsockf_pidfile, "--portfile", $portfile, "--logfile", $mainsockf_logfile); @@ -2258,6 +2258,7 @@ sub SIZE_ftp { my $size = $data[0]; if($size) { + $size += 0; # make it a number if($size > -1) { sendcontrol "213 $size\r\n"; } diff --git a/tests/http/clients/.gitignore b/tests/http/clients/.gitignore index 8d885e16e..f461524b3 100644 --- a/tests/http/clients/.gitignore +++ b/tests/http/clients/.gitignore @@ -8,4 +8,4 @@ ws-data ws-pingpong h2-upgrade-extreme tls-session-reuse -h2-pausing \ No newline at end of file +h2-pausing diff --git a/tests/http/clients/h2-download.c b/tests/http/clients/h2-download.c index 53f3ac0d0..e6f001c7c 100644 --- a/tests/http/clients/h2-download.c +++ b/tests/http/clients/h2-download.c @@ -56,10 +56,7 @@ int my_trace(CURL *handle, curl_infotype type, switch(type) { case CURLINFO_TEXT: fprintf(stderr, "== Info: %s", data); - /* FALLTHROUGH */ - default: /* in case a new one is introduced to shock us */ return 0; - case CURLINFO_HEADER_OUT: text = "=> Send header"; break; @@ -76,6 +73,8 @@ int my_trace(CURL *handle, curl_infotype type, return 0; text = "<= Recv data"; break; + default: /* in case a new one is introduced to shock us */ + return 0; } fprintf(stderr, "%s, %lu bytes (0x%lx)\n", @@ -113,11 +112,11 @@ static size_t my_write_cb(char *buf, size_t nitems, size_t buflen, void *userdata) { struct transfer *t = userdata; - ssize_t nwritten; + size_t nwritten; if(!t->resumed && t->recv_size < t->pause_at && - ((curl_off_t)(t->recv_size + (nitems * buflen)) >= t->pause_at)) { + ((t->recv_size + (curl_off_t)(nitems * buflen)) >= t->pause_at)) { fprintf(stderr, "[t-%d] PAUSE\n", t->idx); t->paused = 1; return CURL_WRITEFUNC_PAUSE; @@ -132,11 +131,11 @@ static size_t my_write_cb(char *buf, size_t nitems, size_t buflen, } nwritten = fwrite(buf, nitems, buflen, t->out); - if(nwritten < 0) { + if(nwritten < buflen) { fprintf(stderr, "[t-%d] write failure\n", t->idx); return 0; } - t->recv_size += nwritten; + t->recv_size += (curl_off_t)nwritten; return (size_t)nwritten; } @@ -172,7 +171,7 @@ static void usage(const char *msg) " download a url with following options:\n" " -m number max parallel downloads\n" " -n number total downloads\n" - " -p number pause transfer after `number` response bytes\n" + " -P number pause transfer after `number` response bytes\n" ); } @@ -186,7 +185,7 @@ int main(int argc, char *argv[]) const char *url; size_t i, n, max_parallel = 1; size_t active_transfers; - long pause_offset = 0; + size_t pause_offset = 0; int abort_paused = 0; struct transfer *t; int ch; @@ -206,7 +205,7 @@ int main(int argc, char *argv[]) transfer_count = (size_t)strtol(optarg, NULL, 10); break; case 'P': - pause_offset = strtol(optarg, NULL, 10); + pause_offset = (size_t)strtol(optarg, NULL, 10); break; default: usage("invalid option"); @@ -235,7 +234,7 @@ int main(int argc, char *argv[]) for(i = 0; i < transfer_count; ++i) { t = &transfers[i]; t->idx = (int)i; - t->pause_at = (curl_off_t)pause_offset * i; + t->pause_at = (curl_off_t)(pause_offset * i); } n = (max_parallel < transfer_count)? max_parallel : transfer_count; diff --git a/tests/http/clients/h2-serverpush.c b/tests/http/clients/h2-serverpush.c index 742a67e59..13f804aa2 100644 --- a/tests/http/clients/h2-serverpush.c +++ b/tests/http/clients/h2-serverpush.c @@ -102,10 +102,7 @@ int my_trace(CURL *handle, curl_infotype type, switch(type) { case CURLINFO_TEXT: fprintf(stderr, "== Info: %s", data); - /* FALLTHROUGH */ - default: /* in case a new one is introduced to shock us */ return 0; - case CURLINFO_HEADER_OUT: text = "=> Send header"; break; @@ -124,6 +121,8 @@ int my_trace(CURL *handle, curl_infotype type, case CURLINFO_SSL_DATA_IN: text = "<= Recv SSL data"; break; + default: /* in case a new one is introduced to shock us */ + return 0; } dump(text, (unsigned char *)data, size, 1); diff --git a/tests/http/requirements.txt b/tests/http/requirements.txt index ff49a9629..fb0e01383 100644 --- a/tests/http/requirements.txt +++ b/tests/http/requirements.txt @@ -27,3 +27,4 @@ pytest cryptography multipart websockets +psutil diff --git a/tests/http/scorecard.py b/tests/http/scorecard.py index ae466129c..446a1bc5c 100644 --- a/tests/http/scorecard.py +++ b/tests/http/scorecard.py @@ -33,7 +33,7 @@ from statistics import mean from typing import Dict, Any, Optional, List -from testenv import Env, Httpd, Nghttpx, CurlClient, Caddy, ExecResult, NghttpxFwd +from testenv import Env, Httpd, Nghttpx, CurlClient, Caddy, ExecResult, NghttpxQuic, RunProfile log = logging.getLogger(__name__) @@ -122,57 +122,65 @@ def transfer_single(self, url: str, proto: str, count: int): count = 1 samples = [] errors = [] + profiles = [] self.info(f'single...') for i in range(sample_size): curl = CurlClient(env=self.env, silent=self._silent_curl) r = curl.http_download(urls=[url], alpn_proto=proto, no_save=True, - with_headers=False) + with_headers=False, with_profile=True) err = self._check_downloads(r, count) if err: errors.append(err) else: total_size = sum([s['size_download'] for s in r.stats]) samples.append(total_size / r.duration.total_seconds()) + profiles.append(r.profile) return { 'count': count, 'samples': sample_size, 'speed': mean(samples) if len(samples) else -1, - 'errors': errors + 'errors': errors, + 'stats': RunProfile.AverageStats(profiles), } def transfer_serial(self, url: str, proto: str, count: int): sample_size = 1 samples = [] errors = [] + profiles = [] url = f'{url}?[0-{count - 1}]' self.info(f'serial...') for i in range(sample_size): curl = CurlClient(env=self.env, silent=self._silent_curl) r = curl.http_download(urls=[url], alpn_proto=proto, no_save=True, - with_headers=False) + with_headers=False, with_profile=True) err = self._check_downloads(r, count) if err: errors.append(err) else: total_size = sum([s['size_download'] for s in r.stats]) samples.append(total_size / r.duration.total_seconds()) + profiles.append(r.profile) return { 'count': count, 'samples': sample_size, 'speed': mean(samples) if len(samples) else -1, - 'errors': errors + 'errors': errors, + 'stats': RunProfile.AverageStats(profiles), } def transfer_parallel(self, url: str, proto: str, count: int): sample_size = 1 samples = [] errors = [] + profiles = [] url = f'{url}?[0-{count - 1}]' self.info(f'parallel...') for i in range(sample_size): curl = CurlClient(env=self.env, silent=self._silent_curl) r = curl.http_download(urls=[url], alpn_proto=proto, no_save=True, with_headers=False, + with_profile=True, extra_args=['--parallel', '--parallel-max', str(count)]) err = self._check_downloads(r, count) @@ -181,21 +189,25 @@ def transfer_parallel(self, url: str, proto: str, count: int): else: total_size = sum([s['size_download'] for s in r.stats]) samples.append(total_size / r.duration.total_seconds()) + profiles.append(r.profile) return { 'count': count, 'samples': sample_size, 'speed': mean(samples) if len(samples) else -1, - 'errors': errors + 'errors': errors, + 'stats': RunProfile.AverageStats(profiles), } def download_url(self, label: str, url: str, proto: str, count: int): self.info(f' {count}x{label}: ') props = { 'single': self.transfer_single(url=url, proto=proto, count=10), - 'serial': self.transfer_serial(url=url, proto=proto, count=count), - 'parallel': self.transfer_parallel(url=url, proto=proto, - count=count), } + if count > 1: + props['serial'] = self.transfer_serial(url=url, proto=proto, + count=count) + props['parallel'] = self.transfer_parallel(url=url, proto=proto, + count=count) self.info(f'ok.\n') return props @@ -216,8 +228,7 @@ def downloads(self, proto: str, count: int, 'description': descr, } for fsize in fsizes: - label = f'{int(fsize / 1024)}KB' if fsize < 1024*1024 else \ - f'{int(fsize / (1024 * 1024))}MB' + label = self.fmt_size(fsize) fname = f'score{label}.data' self._make_docs_file(docs_dir=self.httpd.docs_dir, fname=fname, fsize=fsize) @@ -234,8 +245,7 @@ def downloads(self, proto: str, count: int, 'description': descr, } for fsize in fsizes: - label = f'{int(fsize / 1024)}KB' if fsize < 1024*1024 else \ - f'{int(fsize / (1024 * 1024))}MB' + label = self.fmt_size(fsize) fname = f'score{label}.data' self._make_docs_file(docs_dir=self.caddy.docs_dir, fname=fname, fsize=fsize) @@ -250,6 +260,7 @@ def do_requests(self, url: str, proto: str, count: int, sample_size = 1 samples = [] errors = [] + profiles = [] url = f'{url}?[0-{count - 1}]' extra_args = ['--parallel', '--parallel-max', str(max_parallel)] \ if max_parallel > 1 else [] @@ -257,7 +268,7 @@ def do_requests(self, url: str, proto: str, count: int, for i in range(sample_size): curl = CurlClient(env=self.env, silent=self._silent_curl) r = curl.http_download(urls=[url], alpn_proto=proto, no_save=True, - with_headers=False, + with_headers=False, with_profile=True, extra_args=extra_args) err = self._check_downloads(r, count) if err: @@ -265,30 +276,32 @@ def do_requests(self, url: str, proto: str, count: int, else: for _ in r.stats: samples.append(count / r.duration.total_seconds()) + profiles.append(r.profile) return { 'count': count, 'samples': sample_size, 'speed': mean(samples) if len(samples) else -1, - 'errors': errors + 'errors': errors, + 'stats': RunProfile.AverageStats(profiles), } def requests_url(self, url: str, proto: str, count: int): self.info(f' {url}: ') props = { - 'serial': self.do_requests(url=url, proto=proto, count=count), - 'par-6': self.do_requests(url=url, proto=proto, count=count, - max_parallel=6), - 'par-25': self.do_requests(url=url, proto=proto, count=count, - max_parallel=25), - 'par-50': self.do_requests(url=url, proto=proto, count=count, - max_parallel=50), - 'par-100': self.do_requests(url=url, proto=proto, count=count, - max_parallel=100), + '1': self.do_requests(url=url, proto=proto, count=count), + '6': self.do_requests(url=url, proto=proto, count=count, + max_parallel=6), + '25': self.do_requests(url=url, proto=proto, count=count, + max_parallel=25), + '50': self.do_requests(url=url, proto=proto, count=count, + max_parallel=50), + '100': self.do_requests(url=url, proto=proto, count=count, + max_parallel=100), } self.info(f'ok.\n') return props - def requests(self, proto: str) -> Dict[str, Any]: + def requests(self, proto: str, req_count) -> Dict[str, Any]: scores = {} if self.httpd: if proto == 'h3': @@ -305,7 +318,8 @@ def requests(self, proto: str) -> Dict[str, Any]: url1 = f'https://{self.env.domain1}:{port}/reqs10.data' scores[via] = { 'description': descr, - '10KB': self.requests_url(url=url1, proto=proto, count=10000), + 'count': req_count, + '10KB': self.requests_url(url=url1, proto=proto, count=req_count), } if self.caddy: port = self.caddy.port @@ -317,7 +331,8 @@ def requests(self, proto: str) -> Dict[str, Any]: url1 = f'https://{self.env.domain1}:{port}/req10.data' scores[via] = { 'description': descr, - '10KB': self.requests_url(url=url1, proto=proto, count=5000), + 'count': req_count, + '10KB': self.requests_url(url=url1, proto=proto, count=req_count), } return scores @@ -325,6 +340,7 @@ def score_proto(self, proto: str, handshakes: bool = True, downloads: Optional[List[int]] = None, download_count: int = 50, + req_count=5000, requests: bool = True): self.info(f"scoring {proto}\n") p = {} @@ -332,7 +348,7 @@ def score_proto(self, proto: str, p['name'] = 'h3' if not self.env.have_h3_curl(): raise ScoreCardException('curl does not support HTTP/3') - for lib in ['ngtcp2', 'quiche', 'msh3']: + for lib in ['ngtcp2', 'quiche', 'msh3', 'nghttp3']: if self.env.curl_uses_lib(lib): p['implementation'] = lib break @@ -368,15 +384,22 @@ def score_proto(self, proto: str, count=download_count, fsizes=downloads) if requests: - score['requests'] = self.requests(proto=proto) + score['requests'] = self.requests(proto=proto, req_count=req_count) self.info("\n") return score def fmt_ms(self, tval): return f'{int(tval*1000)} ms' if tval >= 0 else '--' - def fmt_mb(self, val): - return f'{val/(1024*1024):0.000f} MB' if val >= 0 else '--' + def fmt_size(self, val): + if val >= (1024*1024*1024): + return f'{val / (1024*1024*1024):0.000f}GB' + elif val >= (1024 * 1024): + return f'{val / (1024*1024):0.000f}MB' + elif val >= 1024: + return f'{val / 1024:0.000f}KB' + else: + return f'{val:0.000f}B' def fmt_mbs(self, val): return f'{val/(1024*1024):0.000f} MB/s' if val >= 0 else '--' @@ -398,46 +421,93 @@ def print_score(self, score): f'{"/".join(val["ipv4-errors"] + val["ipv6-errors"]):<20}' ) if 'downloads' in score: + # get the key names of all sizes and measurements made + sizes = [] + measures = [] + m_names = {} + mcol_width = 12 + mcol_sw = 17 + for server, server_score in score['downloads'].items(): + for sskey, ssval in server_score.items(): + if isinstance(ssval, str): + continue + if sskey not in sizes: + sizes.append(sskey) + for mkey, mval in server_score[sskey].items(): + if mkey not in measures: + measures.append(mkey) + m_names[mkey] = f'{mkey}({mval["count"]}x)' + print('Downloads') - print(f' {"Server":<8} {"Size":>8} {"Single":>12} {"Serial":>12}' - f' {"Parallel":>12} {"Errors":<20}') - skeys = {} - for dkey, dval in score["downloads"].items(): - for k in dval.keys(): - skeys[k] = True - for skey in skeys: - for dkey, dval in score["downloads"].items(): - if skey in dval: - sval = dval[skey] - if isinstance(sval, str): - continue - errors = [] - for key, val in sval.items(): - if 'errors' in val: - errors.extend(val['errors']) - print(f' {dkey:<8} {skey:>8} ' - f'{self.fmt_mbs(sval["single"]["speed"]):>12} ' - f'{self.fmt_mbs(sval["serial"]["speed"]):>12} ' - f'{self.fmt_mbs(sval["parallel"]["speed"]):>12} ' - f' {"/".join(errors):<20}') + print(f' {"Server":<8} {"Size":>8}', end='') + for m in measures: print(f' {m_names[m]:>{mcol_width}} {"[cpu/rss]":<{mcol_sw}}', end='') + print(f' {"Errors":^20}') + + for server in score['downloads']: + for size in sizes: + size_score = score['downloads'][server][size] + print(f' {server:<8} {size:>8}', end='') + errors = [] + for key, val in size_score.items(): + if 'errors' in val: + errors.extend(val['errors']) + for m in measures: + if m in size_score: + print(f' {self.fmt_mbs(size_score[m]["speed"]):>{mcol_width}}', end='') + s = f'[{size_score[m]["stats"]["cpu"]:>.1f}%'\ + f'/{self.fmt_size(size_score[m]["stats"]["rss"])}]' + print(f' {s:<{mcol_sw}}', end='') + else: + print(' '*mcol_width, end='') + if len(errors): + print(f' {"/".join(errors):<20}') + else: + print(f' {"-":^20}') + if 'requests' in score: - print('Requests, max in parallel') - print(f' {"Server":<8} {"Size":>8} ' - f'{"1 ":>12} {"6 ":>12} {"25 ":>12} ' - f'{"50 ":>12} {"100 ":>12} {"Errors":<20}') - for dkey, dval in score["requests"].items(): - for skey, sval in dval.items(): - if isinstance(sval, str): + sizes = [] + measures = [] + m_names = {} + mcol_width = 9 + mcol_sw = 13 + for server in score['requests']: + server_score = score['requests'][server] + for sskey, ssval in server_score.items(): + if isinstance(ssval, str) or isinstance(ssval, int): continue + if sskey not in sizes: + sizes.append(sskey) + for mkey, mval in server_score[sskey].items(): + if mkey not in measures: + measures.append(mkey) + m_names[mkey] = f'{mkey}' + + print('Requests, max in parallel') + print(f' {"Server":<8} {"Size":>6} {"Reqs":>6}', end='') + for m in measures: print(f' {m_names[m]:>{mcol_width}} {"[cpu/rss]":<{mcol_sw}}', end='') + print(f' {"Errors":^10}') + + for server in score['requests']: + for size in sizes: + size_score = score['requests'][server][size] + count = score['requests'][server]['count'] + print(f' {server:<8} {size:>6} {count:>6}', end='') errors = [] - for key, val in sval.items(): + for key, val in size_score.items(): if 'errors' in val: errors.extend(val['errors']) - line = f' {dkey:<8} {skey:>8} ' - for k in sval.keys(): - line += f'{self.fmt_reqs(sval[k]["speed"]):>12} ' - line += f' {"/".join(errors):<20}' - print(line) + for m in measures: + if m in size_score: + print(f' {self.fmt_reqs(size_score[m]["speed"]):>{mcol_width}}', end='') + s = f'[{size_score[m]["stats"]["cpu"]:>.1f}%'\ + f'/{self.fmt_size(size_score[m]["stats"]["rss"])}]' + print(f' {s:<{mcol_sw}}', end='') + else: + print(' '*mcol_width, end='') + if len(errors): + print(f' {"/".join(errors):<10}') + else: + print(f' {"-":^10}') def parse_size(s): @@ -445,7 +515,9 @@ def parse_size(s): if m is None: raise Exception(f'unrecognized size: {s}') size = int(m.group(1)) - if m.group(2).lower() == 'kb': + if not m.group(2): + pass + elif m.group(2).lower() == 'kb': size *= 1024 elif m.group(2).lower() == 'mb': size *= 1024 * 1024 @@ -466,13 +538,15 @@ def main(): parser.add_argument("-H", "--handshakes", action='store_true', default=False, help="evaluate handshakes only") parser.add_argument("-d", "--downloads", action='store_true', - default=False, help="evaluate downloads only") + default=False, help="evaluate downloads") parser.add_argument("--download", action='append', type=str, default=None, help="evaluate download size") parser.add_argument("--download-count", action='store', type=int, default=50, help="perform that many downloads") parser.add_argument("-r", "--requests", action='store_true', - default=False, help="evaluate requests only") + default=False, help="evaluate requests") + parser.add_argument("--request-count", action='store', type=int, + default=5000, help="perform that many requests") parser.add_argument("--httpd", action='store_true', default=False, help="evaluate httpd server only") parser.add_argument("--caddy", action='store_true', default=False, @@ -491,29 +565,23 @@ def main(): protocol = args.protocol handshakes = True - downloads = [1024*1024, 10*1024*1024, 100*1024*1024] + downloads = [1024 * 1024, 10 * 1024 * 1024, 100 * 1024 * 1024] + if args.download is not None: + downloads = [] + for x in args.download: + downloads.extend([parse_size(s) for s in x.split(',')]) requests = True + if args.downloads or args.requests or args.handshakes: + handshakes = args.handshakes + if not args.downloads: + downloads = None + requests = args.requests + test_httpd = protocol != 'h3' test_caddy = True - if args.handshakes: - downloads = None - requests = False - if args.downloads: - handshakes = False - requests = False - if args.download: - downloads = sorted([parse_size(x) for x in args.download]) - handshakes = False - requests = False - if args.requests: - handshakes = False - downloads = None - if args.caddy: - test_caddy = True - test_httpd = False - if args.httpd: - test_caddy = False - test_httpd = True + if args.caddy or args.httpd: + test_caddy = args.caddy + test_httpd = args.httpd rv = 0 env = Env() @@ -530,7 +598,7 @@ def main(): httpd.clear_logs() assert httpd.start() if 'h3' == protocol: - nghttpx = NghttpxFwd(env=env) + nghttpx = NghttpxQuic(env=env) nghttpx.clear_logs() assert nghttpx.start() if test_caddy and env.caddy: @@ -544,6 +612,7 @@ def main(): handshakes=handshakes, downloads=downloads, download_count=args.download_count, + req_count=args.request_count, requests=requests) if args.json: print(json.JSONEncoder(indent=2).encode(score)) diff --git a/tests/http/test_01_basic.py b/tests/http/test_01_basic.py index 7c1792d37..3902b75b7 100644 --- a/tests/http/test_01_basic.py +++ b/tests/http/test_01_basic.py @@ -84,3 +84,18 @@ def test_01_05_h3_get(self, env: Env, httpd, nghttpx): r = curl.http_get(url=url, extra_args=['--http3-only']) r.check_response(http_status=200, protocol='HTTP/3') assert r.json['server'] == env.domain1 + + # simple download, check connect/handshake timings + @pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason=f"curl without SSL") + @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) + def test_01_06_timings(self, env: Env, httpd, nghttpx, repeat, proto): + if proto == 'h3' and not env.have_h3(): + pytest.skip("h3 not supported") + curl = CurlClient(env=env) + url = f'https://{env.authority_for(env.domain1, proto)}/data.json' + r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True) + r.check_stats(http_status=200, count=1) + assert r.stats[0]['time_connect'] > 0, f'{r.stats[0]}' + assert r.stats[0]['time_appconnect'] > 0, f'{r.stats[0]}' + + diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index 391371c31..4db9c9d36 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -386,13 +386,10 @@ def test_02_26_session_shared_reuse(self, env: Env, httpd, repeat): r.check_exit_code(0) # test on paused transfers, based on issue #11982 - @pytest.mark.parametrize("proto", ['h2', 'h3']) - def test_02_27_paused_no_cl(self, env: Env, httpd, nghttpx, proto, repeat): - if proto == 'h3' and not env.have_h3(): - pytest.skip("h3 not supported") + def test_02_27_paused_no_cl(self, env: Env, httpd, nghttpx, repeat): + proto = 'h2' url = f'https://{env.authority_for(env.domain1, proto)}' \ - f'/tweak?'\ - '&chunks=2&chunk_size=16000' + '/tweak?&chunks=2&chunk_size=16000' client = LocalClient(env=env, name='h2-pausing') r = client.run(args=[url]) r.check_exit_code(0) diff --git a/tests/http/test_07_upload.py b/tests/http/test_07_upload.py index 018a56c6e..94534ffb1 100644 --- a/tests/http/test_07_upload.py +++ b/tests/http/test_07_upload.py @@ -28,6 +28,7 @@ import filecmp import logging import os +import time import pytest from testenv import Env, CurlClient @@ -189,6 +190,23 @@ def test_07_21_upload_parallel_large(self, env: Env, httpd, nghttpx, repeat, pro r.check_response(count=count, http_status=200) self.check_download(count, fdata, curl) + # upload large data parallel to a URL that denies uploads + @pytest.mark.parametrize("proto", ['h2', 'h3']) + def test_07_22_upload_parallel_fail(self, env: Env, httpd, nghttpx, repeat, proto): + if proto == 'h3' and not env.have_h3(): + pytest.skip("h3 not supported") + if proto == 'h3' and env.curl_uses_lib('msh3'): + pytest.skip("msh3 stalls here") + fdata = os.path.join(env.gen_dir, 'data-10m') + count = 100 + curl = CurlClient(env=env) + url = f'https://{env.authority_for(env.domain1, proto)}'\ + f'/curltest/tweak?status=400&delay=5ms&chunks=1&body_error=reset&id=[0-{count-1}]' + r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, + extra_args=['--parallel']) + exp_exit = 92 if proto == 'h2' else 95 + r.check_stats(count=count, exitcode=exp_exit) + # PUT 100k @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) def test_07_30_put_100k(self, env: Env, httpd, nghttpx, repeat, proto): @@ -444,3 +462,42 @@ def check_download(self, count, srcfile, curl): tofile=dfile, n=1)) assert False, f'download {dfile} differs:\n{diff}' + + # speed limited on put handler + @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) + def test_07_50_put_speed_limit(self, env: Env, httpd, nghttpx, proto, repeat): + if proto == 'h3' and not env.have_h3(): + pytest.skip("h3 not supported") + count = 1 + fdata = os.path.join(env.gen_dir, 'data-100k') + up_len = 100 * 1024 + speed_limit = 20 * 1024 + curl = CurlClient(env=env) + url = f'https://{env.authority_for(env.domain1, proto)}/curltest/put?id=[0-0]' + r = curl.http_put(urls=[url], fdata=fdata, alpn_proto=proto, + with_headers=True, extra_args=[ + '--limit-rate', f'{speed_limit}' + ]) + r.check_response(count=count, http_status=200) + assert r.responses[0]['header']['received-length'] == f'{up_len}', f'{r.responses[0]}' + up_speed = r.stats[0]['speed_upload'] + assert (speed_limit * 0.5) <= up_speed <= (speed_limit * 1.5), f'{r.stats[0]}' + + # speed limited on echo handler + @pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3']) + def test_07_51_echo_speed_limit(self, env: Env, httpd, nghttpx, proto, repeat): + if proto == 'h3' and not env.have_h3(): + pytest.skip("h3 not supported") + count = 1 + fdata = os.path.join(env.gen_dir, 'data-100k') + speed_limit = 20 * 1024 + curl = CurlClient(env=env) + url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo?id=[0-0]' + r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, + with_headers=True, extra_args=[ + '--limit-rate', f'{speed_limit}' + ]) + r.check_response(count=count, http_status=200) + up_speed = r.stats[0]['speed_upload'] + assert (speed_limit * 0.5) <= up_speed <= (speed_limit * 1.5), f'{r.stats[0]}' + diff --git a/tests/http/test_08_caddy.py b/tests/http/test_08_caddy.py index c95d8457a..c35bd27b7 100644 --- a/tests/http/test_08_caddy.py +++ b/tests/http/test_08_caddy.py @@ -163,3 +163,20 @@ def test_08_05_download_1mb_parallel(self, env: Env, caddy: Caddy, assert r.total_connects > 1, r.dump_logs() else: assert r.total_connects == 1, r.dump_logs() + + # upload data parallel, check that they were echoed + @pytest.mark.skipif(condition=Env().ci_run, reason="not suitable for CI runs") + @pytest.mark.parametrize("proto", ['h2', 'h3']) + def test_08_06_upload_parallel(self, env: Env, caddy, repeat, proto): + if proto == 'h3' and not env.have_h3(): + pytest.skip("h3 not supported") + if proto == 'h3' and env.curl_uses_lib('msh3'): + pytest.skip("msh3 stalls here") + # limit since we use a separate connection in h1 + count = 20 + data = '0123456789' + curl = CurlClient(env=env) + url = f'https://{env.domain1}:{caddy.port}/data10.data?[0-{count-1}]' + r = curl.http_upload(urls=[url], data=data, alpn_proto=proto, + extra_args=['--parallel']) + r.check_stats(count=count, http_status=200, exitcode=0) diff --git a/tests/http/test_14_auth.py b/tests/http/test_14_auth.py index 0cc0f925f..6d3db5931 100644 --- a/tests/http/test_14_auth.py +++ b/tests/http/test_14_auth.py @@ -133,5 +133,7 @@ def test_14_06_basic_very_large_pw(self, env: Env, httpd, nghttpx, repeat, proto r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto, extra_args=[ '--basic', '--user', f'test:{password}' ]) - # request was never sent - r.check_response(exitcode=55, http_status=0) + # Depending on protocl, we might have an error sending or + # the server might shutdown the connection and we see the error + # on receiving + assert r.exit_code in [55, 56], f'{self.dump_logs()}' diff --git a/tests/http/testenv/__init__.py b/tests/http/testenv/__init__.py index 2195634fd..c4c032028 100644 --- a/tests/http/testenv/__init__.py +++ b/tests/http/testenv/__init__.py @@ -32,7 +32,7 @@ from .certs import TestCA, Credentials from .caddy import Caddy from .httpd import Httpd -from .curl import CurlClient, ExecResult +from .curl import CurlClient, ExecResult, RunProfile from .client import LocalClient from .nghttpx import Nghttpx from .nghttpx import Nghttpx, NghttpxQuic, NghttpxFwd diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py index bc5b4881c..45fef7fd9 100644 --- a/tests/http/testenv/curl.py +++ b/tests/http/testenv/curl.py @@ -27,11 +27,13 @@ import json import logging import os +import psutil import re import shutil import subprocess +from statistics import mean, fmean from datetime import timedelta, datetime -from typing import List, Optional, Dict, Union +from typing import List, Optional, Dict, Union, Any from urllib.parse import urlparse from .env import Env @@ -40,18 +42,81 @@ log = logging.getLogger(__name__) +class RunProfile: + + STAT_KEYS = ['cpu', 'rss', 'vsz'] + + @classmethod + def AverageStats(cls, profiles: List['RunProfile']): + avg = {} + stats = [p.stats for p in profiles] + for key in cls.STAT_KEYS: + avg[key] = mean([s[key] for s in stats]) + return avg + + def __init__(self, pid: int, started_at: datetime, run_dir): + self._pid = pid + self._started_at = started_at + self._duration = timedelta(seconds=0) + self._run_dir = run_dir + self._samples = [] + self._psu = None + self._stats = None + + @property + def duration(self) -> timedelta: + return self._duration + + @property + def stats(self) -> Optional[Dict[str,Any]]: + return self._stats + + def sample(self): + elapsed = datetime.now() - self._started_at + try: + if self._psu is None: + self._psu = psutil.Process(pid=self._pid) + mem = self._psu.memory_info() + self._samples.append({ + 'time': elapsed, + 'cpu': self._psu.cpu_percent(), + 'vsz': mem.vms, + 'rss': mem.rss, + }) + except psutil.NoSuchProcess: + pass + + def finish(self): + self._duration = datetime.now() - self._started_at + if len(self._samples) > 0: + weights = [s['time'].total_seconds() for s in self._samples] + self._stats = {} + for key in self.STAT_KEYS: + self._stats[key] = fmean([s[key] for s in self._samples], weights) + else: + self._stats = None + self._psu = None + + def __repr__(self): + return f'RunProfile[pid={self._pid}, '\ + f'duration={self.duration.total_seconds():.3f}s, '\ + f'stats={self.stats}]' + + class ExecResult: def __init__(self, args: List[str], exit_code: int, stdout: List[str], stderr: List[str], duration: Optional[timedelta] = None, with_stats: bool = False, - exception: Optional[str] = None): + exception: Optional[str] = None, + profile: Optional[RunProfile] = None): self._args = args self._exit_code = exit_code self._exception = exception self._stdout = stdout self._stderr = stderr + self._profile = profile self._duration = duration if duration is not None else timedelta() self._response = None self._responses = [] @@ -116,6 +181,10 @@ def trace_lines(self) -> List[str]: def duration(self) -> timedelta: return self._duration + @property + def profile(self) -> Optional[RunProfile]: + return self._profile + @property def response(self) -> Optional[Dict]: return self._response @@ -247,7 +316,7 @@ def check_stats(self, count: int, http_status: Optional[int] = None, if exitcode is not None: for idx, x in enumerate(self.stats): if 'exitcode' in x: - assert x['exitcode'] == 0, \ + assert x['exitcode'] == exitcode, \ f'status #{idx} exitcode: expected {exitcode}, '\ f'got {x["exitcode"]}\n{self.dump_stat(x)}' @@ -344,14 +413,15 @@ def get_proxy_args(self, proto: str = 'http/1.1', return xargs def http_get(self, url: str, extra_args: Optional[List[str]] = None, - def_tracing: bool = True): + def_tracing: bool = True, with_profile: bool = False): return self._raw(url, options=extra_args, with_stats=False, - def_tracing=def_tracing) + def_tracing=def_tracing, with_profile=with_profile) def http_download(self, urls: List[str], alpn_proto: Optional[str] = None, with_stats: bool = True, with_headers: bool = False, + with_profile: bool = False, no_save: bool = False, extra_args: List[str] = None): if extra_args is None: @@ -373,12 +443,14 @@ def http_download(self, urls: List[str], ]) return self._raw(urls, alpn_proto=alpn_proto, options=extra_args, with_stats=with_stats, - with_headers=with_headers) + with_headers=with_headers, + with_profile=with_profile) def http_upload(self, urls: List[str], data: str, alpn_proto: Optional[str] = None, with_stats: bool = True, with_headers: bool = False, + with_profile: bool = False, extra_args: Optional[List[str]] = None): if extra_args is None: extra_args = [] @@ -391,12 +463,14 @@ def http_upload(self, urls: List[str], data: str, ]) return self._raw(urls, alpn_proto=alpn_proto, options=extra_args, with_stats=with_stats, - with_headers=with_headers) + with_headers=with_headers, + with_profile=with_profile) def http_put(self, urls: List[str], data=None, fdata=None, alpn_proto: Optional[str] = None, with_stats: bool = True, with_headers: bool = False, + with_profile: bool = False, extra_args: Optional[List[str]] = None): if extra_args is None: extra_args = [] @@ -414,7 +488,8 @@ def http_put(self, urls: List[str], data=None, fdata=None, return self._raw(urls, intext=data, alpn_proto=alpn_proto, options=extra_args, with_stats=with_stats, - with_headers=with_headers) + with_headers=with_headers, + with_profile=with_profile) def http_form(self, urls: List[str], form: Dict[str, str], alpn_proto: Optional[str] = None, @@ -439,7 +514,7 @@ def http_form(self, urls: List[str], form: Dict[str, str], def response_file(self, idx: int): return os.path.join(self._run_dir, f'download_{idx}.data') - def run_direct(self, args, with_stats: bool = False): + def run_direct(self, args, with_stats: bool = False, with_profile: bool = False): my_args = [self._curl] if with_stats: my_args.extend([ @@ -449,22 +524,48 @@ def run_direct(self, args, with_stats: bool = False): '-o', 'download.data', ]) my_args.extend(args) - return self._run(args=my_args, with_stats=with_stats) + return self._run(args=my_args, with_stats=with_stats, with_profile=with_profile) - def _run(self, args, intext='', with_stats: bool = False): + def _run(self, args, intext='', with_stats: bool = False, with_profile: bool = True): self._rmf(self._stdoutfile) self._rmf(self._stderrfile) self._rmf(self._headerfile) - start = datetime.now() + started_at = datetime.now() exception = None + profile = None try: with open(self._stdoutfile, 'w') as cout: with open(self._stderrfile, 'w') as cerr: - p = subprocess.run(args, stderr=cerr, stdout=cout, - cwd=self._run_dir, shell=False, - input=intext.encode() if intext else None, - timeout=self._timeout) - exitcode = p.returncode + if with_profile: + started_at = datetime.now() + end_at = started_at + timedelta(seconds=self._timeout) \ + if self._timeout else None + log.info(f'starting: {args}') + p = subprocess.Popen(args, stderr=cerr, stdout=cout, + cwd=self._run_dir, shell=False) + profile = RunProfile(p.pid, started_at, self._run_dir) + if intext is not None and False: + p.communicate(input=intext.encode(), timeout=1) + ptimeout = 0.0 + while True: + try: + p.wait(timeout=ptimeout) + break + except subprocess.TimeoutExpired: + if end_at and datetime.now() >= end_at: + p.kill() + raise subprocess.TimeoutExpired(cmd=args, timeout=self._timeout) + profile.sample() + ptimeout = 0.01 + exitcode = p.returncode + profile.finish() + log.info(f'done: exit={exitcode}, profile={profile}') + else: + p = subprocess.run(args, stderr=cerr, stdout=cout, + cwd=self._run_dir, shell=False, + input=intext.encode() if intext else None, + timeout=self._timeout) + exitcode = p.returncode except subprocess.TimeoutExpired: log.warning(f'Timeout after {self._timeout}s: {args}') exitcode = -1 @@ -473,20 +574,23 @@ def _run(self, args, intext='', with_stats: bool = False): cerrput = open(self._stderrfile).readlines() return ExecResult(args=args, exit_code=exitcode, exception=exception, stdout=coutput, stderr=cerrput, - duration=datetime.now() - start, - with_stats=with_stats) + duration=datetime.now() - started_at, + with_stats=with_stats, + profile=profile) def _raw(self, urls, intext='', timeout=None, options=None, insecure=False, alpn_proto: Optional[str] = None, force_resolve=True, with_stats=False, with_headers=True, - def_tracing=True): + def_tracing=True, + with_profile=False): args = self._complete_args( urls=urls, timeout=timeout, options=options, insecure=insecure, alpn_proto=alpn_proto, force_resolve=force_resolve, with_headers=with_headers, def_tracing=def_tracing) - r = self._run(args, intext=intext, with_stats=with_stats) + r = self._run(args, intext=intext, with_stats=with_stats, + with_profile=with_profile) if r.exit_code == 0 and with_headers: self._parse_headerfile(self._headerfile, r=r) if r.json: diff --git a/tests/http/testenv/mod_curltest/mod_curltest.c b/tests/http/testenv/mod_curltest/mod_curltest.c index 30fb765ae..ff1983d17 100644 --- a/tests/http/testenv/mod_curltest/mod_curltest.c +++ b/tests/http/testenv/mod_curltest/mod_curltest.c @@ -423,6 +423,7 @@ static int curltest_put_handler(request_rec *r) char buffer[16*1024]; const char *ct; apr_off_t rbody_len = 0; + const char *s_rbody_len; const char *request_id = "none"; apr_time_t chunk_delay = 0; apr_array_header_t *args = NULL; @@ -491,7 +492,9 @@ static int curltest_put_handler(request_rec *r) } } /* we are done */ - rv = apr_brigade_printf(bb, NULL, NULL, "%"APR_OFF_T_FMT, rbody_len); + s_rbody_len = apr_psprintf(r->pool, "%"APR_OFF_T_FMT, rbody_len); + apr_table_setn(r->headers_out, "Received-Length", s_rbody_len); + rv = apr_brigade_puts(bb, NULL, NULL, s_rbody_len); if(APR_SUCCESS != rv) goto cleanup; b = apr_bucket_eos_create(c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); diff --git a/tests/http/testenv/nghttpx.py b/tests/http/testenv/nghttpx.py index 4be060b56..9544ce05d 100644 --- a/tests/http/testenv/nghttpx.py +++ b/tests/http/testenv/nghttpx.py @@ -129,7 +129,9 @@ def wait_dead(self, timeout: timedelta): try_until = datetime.now() + timeout while datetime.now() < try_until: check_url = f'https://{self.env.domain1}:{self._port}/' - r = curl.http_get(url=check_url, extra_args=['--http3-only']) + r = curl.http_get(url=check_url, extra_args=[ + '--http3-only', '--connect-timeout', '1' + ]) if r.exit_code != 0: return True log.debug(f'waiting for nghttpx to stop responding: {r}') @@ -143,7 +145,8 @@ def wait_live(self, timeout: timedelta): while datetime.now() < try_until: check_url = f'https://{self.env.domain1}:{self._port}/' r = curl.http_get(url=check_url, extra_args=[ - '--http3-only', '--trace', 'curl.trace', '--trace-time' + '--http3-only', '--trace', 'curl.trace', '--trace-time', + '--connect-timeout', '1' ]) if r.exit_code == 0: return True @@ -193,6 +196,7 @@ def start(self, wait_live=True): f'--frontend-http3-max-window-size=10M', f'--frontend-http3-connection-window-size=10M', f'--frontend-http3-max-connection-window-size=100M', + # f'--frontend-quic-debug-log', ] ngerr = open(self._stderr, 'a') self._process = subprocess.Popen(args=args, stderr=ngerr) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 6d1380688..42c53c694 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -65,12 +65,16 @@ int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, void wait_ms(int ms) { + if(ms < 0) + return; #ifdef USE_WINSOCK - Sleep(ms); + Sleep((DWORD)ms); #else - struct timeval t; - curlx_mstotv(&t, ms); - select_wrapper(0, NULL, NULL, NULL, &t); + { + struct timeval t; + curlx_mstotv(&t, ms); + select_wrapper(0, NULL, NULL, NULL, &t); + } #endif } diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 87420a330..1509c76a7 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -1045,7 +1045,7 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags) while(p) { char *e = strchr(p, ','); if(e) { - size_t n = e-p; + size_t n = (size_t)(e - p); char buf[80]; char part[80]; char value[80]; @@ -1639,7 +1639,6 @@ static char bigpart[120000]; */ static int huge(void) { - const char *url = "%s://%s:%s@%s/%s?%s#%s"; const char *smallpart = "c"; int i; CURLU *urlp = curl_url(); @@ -1663,7 +1662,7 @@ static int huge(void) for(i = 0; i < 7; i++) { char *partp; msnprintf(total, sizeof(total), - url, + "%s://%s:%s@%s/%s?%s#%s", (i == 0)? &bigpart[1] : smallpart, (i == 1)? &bigpart[1] : smallpart, (i == 2)? &bigpart[1] : smallpart, diff --git a/tests/libtest/lib1940.c b/tests/libtest/lib1940.c index 8bc094362..05da9de30 100644 --- a/tests/libtest/lib1940.c +++ b/tests/libtest/lib1940.c @@ -35,6 +35,8 @@ static const char *show[]={ "set-cookie", "silly-thing", "fold", + "blank", + "Blank2", NULL }; diff --git a/tests/libtest/lib1947.c b/tests/libtest/lib1947.c index b7a013127..c81345f9d 100644 --- a/tests/libtest/lib1947.c +++ b/tests/libtest/lib1947.c @@ -39,7 +39,7 @@ int test(char *URL) CURLcode res = CURLE_OK; struct curl_header *h; int count = 0; - int origins; + unsigned int origins; global_init(CURL_GLOBAL_DEFAULT); diff --git a/tests/libtest/lib1960.c b/tests/libtest/lib1960.c index b01370e6e..9b82128e9 100644 --- a/tests/libtest/lib1960.c +++ b/tests/libtest/lib1960.c @@ -25,12 +25,6 @@ #ifdef HAVE_INET_PTON -#ifdef _WIN32 -#include -#include -#include -#endif - #ifdef HAVE_NETINET_IN_H #include #endif diff --git a/tests/libtest/lib3026.c b/tests/libtest/lib3026.c index 34dcafc50..6f31dabde 100644 --- a/tests/libtest/lib3026.c +++ b/tests/libtest/lib3026.c @@ -84,7 +84,7 @@ int test(char *URL) th = _beginthreadex(NULL, 0, run_thread, &results[i], 0, NULL); #endif if(!th) { - fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n", + fprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n", __FILE__, __LINE__, GetLastError()); tid_count = i; test_failure = -1; diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 7c65a659c..0d1ea2eb4 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -164,7 +164,7 @@ int test(char *URL) time_t out = curl_getdate(dates[i].input, NULL); if(out != dates[i].output) { printf("WRONGLY %s => %ld (instead of %ld)\n", - dates[i].input, out, dates[i].output); + dates[i].input, (long)out, (long)dates[i].output); error++; } } diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index e61d80a6f..200041239 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -99,25 +99,35 @@ static int fopen_works(void) return ret; } +static void rlim2str(char *buf, size_t len, rlim_t val) +{ +#ifdef RLIM_INFINITY + if(val == RLIM_INFINITY) { + msnprintf(buf, len, "INFINITY"); + return; + } +#endif +#ifdef HAVE_LONGLONG + if(sizeof(rlim_t) > sizeof(long)) + msnprintf(buf, len, "%llu", (unsigned long long)val); + else +#endif + { + if(sizeof(rlim_t) < sizeof(long)) + msnprintf(buf, len, "%u", (unsigned int)val); + else + msnprintf(buf, len, "%lu", (unsigned long)val); + } +} + static int rlimit(int keep_open) { - int nitems, i; + rlim_t nitems, i; int *memchunk = NULL; - char *fmt; struct rlimit rl; char strbuff[256]; char strbuff1[81]; char strbuff2[81]; - char fmt_u[] = "%u"; - char fmt_lu[] = "%lu"; -#ifdef HAVE_LONGLONG - char fmt_llu[] = "%llu"; - - if(sizeof(rl.rlim_max) > sizeof(long)) - fmt = fmt_llu; - else -#endif - fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu; /* get initial open file limits */ @@ -129,20 +139,10 @@ static int rlimit(int keep_open) /* show initial open file limits */ -#ifdef RLIM_INFINITY - if(rl.rlim_cur == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); fprintf(stderr, "initial soft limit: %s\n", strbuff); -#ifdef RLIM_INFINITY - if(rl.rlim_max == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); fprintf(stderr, "initial hard limit: %s\n", strbuff); /* show our constants */ @@ -195,20 +195,10 @@ static int rlimit(int keep_open) /* show current open file limits */ -#ifdef RLIM_INFINITY - if(rl.rlim_cur == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); fprintf(stderr, "current soft limit: %s\n", strbuff); -#ifdef RLIM_INFINITY - if(rl.rlim_max == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); fprintf(stderr, "current hard limit: %s\n", strbuff); } /* (rl.rlim_cur != rl.rlim_max) */ @@ -235,8 +225,8 @@ static int rlimit(int keep_open) (rl.rlim_cur != RLIM_INFINITY) && #endif (rl.rlim_cur <= num_open.rlim_cur)) { - msnprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff2, sizeof(strbuff2), rl.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s", strbuff1, strbuff2); store_errmsg(strbuff, 0); @@ -258,8 +248,8 @@ static int rlimit(int keep_open) if(nitems > 0x7fff) nitems = 0x40000; do { - num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems; - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + num_open.rlim_max = sizeof(*memchunk) * nitems; + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { @@ -287,7 +277,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); store_errmsg(strbuff, 0); @@ -298,7 +288,7 @@ static int rlimit(int keep_open) /* allocate array for file descriptors */ - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); @@ -318,7 +308,7 @@ static int rlimit(int keep_open) num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ @@ -346,21 +336,21 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); fprintf(stderr, "%s\n", strbuff); - msnprintf(strbuff1, sizeof(strbuff), fmt, num_open.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", - strbuff1); + strbuff1); fprintf(stderr, "%s\n", strbuff); num_open.rlim_max = NUM_NEEDED; - msnprintf(strbuff2, sizeof(strbuff2), fmt, num_open.rlim_max); - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff2, sizeof(strbuff2), num_open.rlim_max); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s", - strbuff2, strbuff1); + strbuff2, strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); @@ -372,12 +362,10 @@ static int rlimit(int keep_open) fd = NULL; free(memchunk); return -9; - } - } - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL_FINE) && !defined(USE_WINSOCK) @@ -396,7 +384,7 @@ static int rlimit(int keep_open) num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; if(num_open.rlim_max > num_open.rlim_cur) { msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); + FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); close_file_descriptors(); @@ -411,7 +399,7 @@ static int rlimit(int keep_open) if((fd[rl.rlim_cur] > 0) && ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); + FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); close_file_descriptors(); @@ -432,13 +420,11 @@ static int rlimit(int keep_open) */ if(!fopen_works()) { - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); - msnprintf(strbuff, sizeof(strbuff), - "fopen fails with %s fds open()", - strbuff1); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); + msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open", + strbuff1); fprintf(stderr, "%s\n", msgbuff); - msnprintf(strbuff, sizeof(strbuff), - "fopen fails with lots of fds open()"); + msnprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open"); store_errmsg(strbuff, 0); close_file_descriptors(); free(memchunk); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 8735947cf..b83e3ce31 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -59,8 +59,8 @@ static void store_errmsg(const char *msg, int err) if(!err) msnprintf(msgbuff, sizeof(msgbuff), "%s", msg); else - msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, err, - strerror(err)); + msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, + err, strerror(err)); } static void close_file_descriptors(void) @@ -99,25 +99,35 @@ static int fopen_works(void) return ret; } +static void rlim2str(char *buf, size_t len, rlim_t val) +{ +#ifdef RLIM_INFINITY + if(val == RLIM_INFINITY) { + msnprintf(buf, len, "INFINITY"); + return; + } +#endif +#ifdef HAVE_LONGLONG + if(sizeof(rlim_t) > sizeof(long)) + msnprintf(buf, len, "%llu", (unsigned long long)val); + else +#endif + { + if(sizeof(rlim_t) < sizeof(long)) + msnprintf(buf, len, "%u", (unsigned int)val); + else + msnprintf(buf, len, "%lu", (unsigned long)val); + } +} + static int rlimit(int keep_open) { int *tmpfd; rlim_t nitems, i; int *memchunk = NULL; - char *fmt; struct rlimit rl; char strbuff[256]; char strbuff1[81]; - char fmt_u[] = "%u"; - char fmt_lu[] = "%lu"; -#ifdef HAVE_LONGLONG - char fmt_llu[] = "%llu"; - - if(sizeof(rl.rlim_max) > sizeof(long)) - fmt = fmt_llu; - else -#endif - fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu; /* get initial open file limits */ @@ -129,20 +139,10 @@ static int rlimit(int keep_open) /* show initial open file limits */ -#ifdef RLIM_INFINITY - if(rl.rlim_cur == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); fprintf(stderr, "initial soft limit: %s\n", strbuff); -#ifdef RLIM_INFINITY - if(rl.rlim_max == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); fprintf(stderr, "initial hard limit: %s\n", strbuff); /* @@ -158,7 +158,7 @@ static int rlimit(int keep_open) #ifdef OPEN_MAX if((rl.rlim_cur > 0) && - (rl.rlim_cur < OPEN_MAX)) { + (rl.rlim_cur < OPEN_MAX)) { fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); rl.rlim_cur = OPEN_MAX; if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { @@ -189,20 +189,10 @@ static int rlimit(int keep_open) /* show current open file limits */ -#ifdef RLIM_INFINITY - if(rl.rlim_cur == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); fprintf(stderr, "current soft limit: %s\n", strbuff); -#ifdef RLIM_INFINITY - if(rl.rlim_max == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else -#endif - msnprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); fprintf(stderr, "current hard limit: %s\n", strbuff); } /* (rl.rlim_cur != rl.rlim_max) */ @@ -232,7 +222,7 @@ static int rlimit(int keep_open) nitems = 0x40000; do { num_open.rlim_max = sizeof(*memchunk) * nitems; - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { @@ -275,7 +265,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); store_errmsg(strbuff, 0); @@ -287,8 +277,9 @@ static int rlimit(int keep_open) /* allocate array for file descriptors */ do { - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); if(!fd) { fprintf(stderr, "fd, malloc() failed\n"); @@ -311,7 +302,7 @@ static int rlimit(int keep_open) num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ @@ -339,11 +330,11 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); fprintf(stderr, "%s\n", strbuff); - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); fprintf(stderr, "%s\n", strbuff); @@ -351,7 +342,7 @@ static int rlimit(int keep_open) num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; num_open.rlim_cur -= num_open.rlim_max; - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); msnprintf(strbuff, sizeof(strbuff), "closing %s file descriptors", strbuff1); fprintf(stderr, "%s\n", strbuff); @@ -363,7 +354,7 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; } - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); /* we don't care if we can't shrink it */ @@ -375,12 +366,10 @@ static int rlimit(int keep_open) } break; - } - } - msnprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL_FINE) && !defined(USE_WINSOCK) @@ -435,7 +424,7 @@ static int rlimit(int keep_open) */ if(!fopen_works()) { - msnprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); + rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open", strbuff1); fprintf(stderr, "%s\n", msgbuff); diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 13726c6b4..436b86ec0 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -96,10 +96,7 @@ int my_trace(CURL *handle, curl_infotype type, switch(type) { case CURLINFO_TEXT: fprintf(stderr, "== Info: %s", (char *)data); - /* FALLTHROUGH */ - default: /* in case a new one is introduced to shock us */ return 0; - case CURLINFO_HEADER_OUT: text = "=> Send header"; break; @@ -118,6 +115,8 @@ int my_trace(CURL *handle, curl_infotype type, case CURLINFO_SSL_DATA_IN: text = "<= Recv SSL data"; break; + default: /* in case a new one is introduced to shock us */ + return 0; } dump(text, stderr, (unsigned char *)data, size, config->trace_ascii); diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 6f96668da..c15769474 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -1181,12 +1181,49 @@ static int test_string_formatting(void) return errors; } +static int test_pos_arguments(void) +{ + int errors = 0; + char buf[256]; + + curl_msnprintf(buf, sizeof(buf), "%3$d %2$d %1$d", 500, 501, 502); + errors += string_check(buf, "502 501 500"); + + curl_msnprintf(buf, sizeof(buf), "%3$d %1$d %2$d", 500, 501, 502); + errors += string_check(buf, "502 500 501"); + + /* this is in invalid sequence but the output does not match + what glibc does */ + curl_msnprintf(buf, sizeof(buf), "%3$d %d %2$d", 500, 501, 502); + errors += string_check(buf, ""); + + return errors; +} + static int test_weird_arguments(void) { int errors = 0; char buf[256]; int rc; + /* verify %% */ + rc = curl_msnprintf(buf, sizeof(buf), "%-20d%% right? %%", 500); + errors += string_check(buf, "500 % right? %"); + + /* 100 x % */ + rc = curl_msnprintf(buf, sizeof(buf), "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + "%%%%%%%%%%%%%%%%%%%%%%"); + /* 50 x % */ + errors += string_check(buf, "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + "%%%%%%%%%%%%%%%"); + + rc = curl_msnprintf(buf, sizeof(buf), "%2 AA %d %K", 500, 501, 502); + errors += string_check(buf, "%2 AA 500 %K"); + + rc = curl_msnprintf(buf, sizeof(buf), "%2 %d %K", 500, 501, 502); + errors += string_check(buf, "%2 500 %K"); + /* MAX_PARAMETERS is 128, try exact 128! */ rc = curl_msnprintf(buf, sizeof(buf), "%d%d%d%d%d%d%d%d%d%d" /* 10 */ @@ -1276,18 +1313,6 @@ static int test_weird_arguments(void) errors += string_check(buf, ""); - /* Do not skip sanity checks with parameters! */ - buf[0] = 0; - rc = curl_msnprintf(buf, sizeof(buf), "%d, %.*1$d", 500, 1); - - if(rc != sizeof(buf) - 1) { - printf("curl_mprintf() returned %d and not %d!\n", rc, - sizeof(buf) - 1); - errors++; - } - - errors += strlen_check(buf, 255); - if(errors) printf("Some curl_mprintf() weird arguments tests failed!\n"); @@ -1374,9 +1399,10 @@ static int test_float_formatting(void) 123456789123456789123456789.2987654); errors += strlen_check(buf, 325); - /* check negative when used signed */ + /* check negative width argument when used signed, is treated as positive + and maxes out the internal float width == 325 */ curl_msnprintf(buf, sizeof(buf), "%*f", INT_MIN, 9.1); - errors += string_check(buf, "9.100000"); + errors += string_check(buf, "9.100000 "); /* curl_msnprintf() limits a single float output to 325 bytes maximum width */ @@ -1451,6 +1477,8 @@ int test(char *URL) setlocale(LC_NUMERIC, "C"); #endif + errors += test_pos_arguments(); + errors += test_weird_arguments(); errors += test_unsigned_short_formatting(); diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index 00937e71d..a912b1663 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -49,6 +49,7 @@ int test(char *URL) /* Dump data to stdout for protocol verification */ test_setopt(curl, CURLOPT_HEADERDATA, stdout); test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 97304fa58..044527499 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -93,6 +93,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_READDATA, sdpf); test_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* Do the ANNOUNCE */ res = curl_easy_perform(curl); diff --git a/tests/libtest/stub_gssapi.c b/tests/libtest/stub_gssapi.c index 85c760c2d..d581a91d5 100644 --- a/tests/libtest/stub_gssapi.c +++ b/tests/libtest/stub_gssapi.c @@ -91,8 +91,8 @@ OM_uint32 gss_init_sec_context(OM_uint32 *min, OM_uint32 *time_rec) { /* The token will be encoded in base64 */ - int length = APPROX_TOKEN_LEN * 3 / 4; - int used = 0; + size_t length = APPROX_TOKEN_LEN * 3 / 4; + size_t used = 0; char *token = NULL; const char *creds = NULL; gss_ctx_id_t ctx = NULL; @@ -219,8 +219,8 @@ OM_uint32 gss_init_sec_context(OM_uint32 *min, /* Token format: creds:target:type:padding */ /* Note: this is using the *real* snprintf() and not the curl provided one */ - used = snprintf(token, length, "%s:%s:%d:", creds, - (char *) target_name, ctx->sent); + used = (size_t) snprintf(token, length, "%s:%s:%d:", creds, + (char *) target_name, ctx->sent); if(used >= length) { free(token); diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index f78a9b943..49ff8ae20 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -117,10 +117,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, switch(type) { case CURLINFO_TEXT: fprintf(stderr, "%s== Info: %s", timestr, (char *)data); - /* FALLTHROUGH */ - default: /* in case a new one is introduced to shock us */ return 0; - case CURLINFO_HEADER_OUT: text = "=> Send header"; break; @@ -139,6 +136,8 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, case CURLINFO_SSL_DATA_IN: text = "<= Recv SSL data"; break; + default: /* in case a new one is introduced to shock us */ + return 0; } libtest_debug_dump(timebuf, text, stderr, data, size, trace_cfg->nohex); diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 4a3cd944a..efbbf9019 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -37,8 +37,8 @@ struct timeval tutil_tvnow(void) */ struct timeval now; DWORD milliseconds = GetTickCount(); - now.tv_sec = milliseconds / 1000; - now.tv_usec = (milliseconds % 1000) * 1000; + now.tv_sec = (long)(milliseconds / 1000); + now.tv_usec = (long)((milliseconds % 1000) * 1000); return now; } diff --git a/tests/manpage-scan.pl b/tests/manpage-scan.pl deleted file mode 100644 index c09e979d0..000000000 --- a/tests/manpage-scan.pl +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### -# -# Scan symbols-in-version (which is verified to be correct by test 1119), then -# verify that each option mention in there that should have its own man page -# actually does. -# -# In addition, make sure that every current option to curl_easy_setopt, -# curl_easy_getinfo and curl_multi_setopt are also mentioned in their -# corresponding main (index) man page. -# -# src/tool_getparam.c lists all options curl can parse -# docs/curl.1 documents all command line options -# src/tool_listhelp.c outputs all options with curl -h -# - make sure they're all in sync -# -# Output all deviances to stderr. - -use strict; -use warnings; - -# we may get the dir roots pointed out -my $root=$ARGV[0] || "."; -my $buildroot=$ARGV[1] || "."; -my $syms = "$root/docs/libcurl/symbols-in-versions"; -my $curlh = "$root/include/curl/curl.h"; -my $errors=0; - -# the prepopulated alias list is the CURLINFO_* defines that are used for the -# debug function callback and the fact that they use the same prefix as the -# curl_easy_getinfo options was a mistake. -my %alias = ( - 'CURLINFO_DATA_IN' => 'none', - 'CURLINFO_DATA_OUT' => 'none', - 'CURLINFO_END' => 'none', - 'CURLINFO_HEADER_IN' => 'none', - 'CURLINFO_HEADER_OUT' => 'none', - 'CURLINFO_LASTONE' => 'none', - 'CURLINFO_NONE' => 'none', - 'CURLINFO_SSL_DATA_IN' => 'none', - 'CURLINFO_SSL_DATA_OUT' => 'none', - 'CURLINFO_TEXT' => 'none' - ); - -sub scanmanpage { - my ($file, @words) = @_; - - open(my $mh, "<", "$file"); - my @m; - while(<$mh>) { - if($_ =~ /^\.IP (.*)/) { - my $w = $1; - # "unquote" minuses - $w =~ s/\\-/-/g; - push @m, $w; - } - } - close($mh); - - foreach my $m (@words) { - my @g = grep(/$m/, @m); - if(!$g[0]) { - print STDERR "Missing mention of $m in $file\n"; - $errors++; - } - } -} - -my $r; - -# check for define aliases -open($r, "<", "$curlh") || - die "no curl.h"; -while(<$r>) { - if(/^\#define (CURL(OPT|INFO|MOPT)_\w+) (.*)/) { - $alias{$1}=$3; - } -} -close($r); - -my @curlopt; -my @curlinfo; -my @curlmopt; -open($r, "<", "$syms") || - die "no input file"; -while(<$r>) { - chomp; - my $l= $_; - if($l =~ /(CURL(OPT|INFO|MOPT)_\w+) *([0-9.]*) *([0-9.-]*) *([0-9.]*)/) { - my ($opt, $type, $add, $dep, $rem) = ($1, $2, $3, $4, $5); - - if($alias{$opt}) { - #print "$opt => $alias{$opt}\n"; - } - elsif($rem) { - # $opt was removed in $rem - # so don't check for that - } - else { - if($type eq "OPT") { - push @curlopt, $opt, - } - elsif($type eq "INFO") { - push @curlinfo, $opt, - } - elsif($type eq "MOPT") { - push @curlmopt, $opt, - } - if(! -f "$root/docs/libcurl/opts/$opt.3") { - print STDERR "Missing $opt.3\n"; - $errors++; - } - } - } -} -close($r); - -scanmanpage("$root/docs/libcurl/curl_easy_setopt.3", @curlopt); -scanmanpage("$root/docs/libcurl/curl_easy_getinfo.3", @curlinfo); -scanmanpage("$root/docs/libcurl/curl_multi_setopt.3", @curlmopt); - -# using this hash array, we can skip specific options -my %opts = ( - # pretend these --no options exists in tool_getparam.c - '--no-alpn' => 1, - '--no-npn' => 1, - '-N, --no-buffer' => 1, - '--no-sessionid' => 1, - '--no-keepalive' => 1, - '--no-progress-meter' => 1, - '--no-clobber' => 1, - - # pretend these options without -no exist in curl.1 and tool_listhelp.c - '--alpn' => 6, - '--npn' => 6, - '--eprt' => 6, - '--epsv' => 6, - '--keepalive' => 6, - '-N, --buffer' => 6, - '--sessionid' => 6, - '--progress-meter' => 6, - '--clobber' => 6, - - # deprecated options do not need to be in tool_help.c nor curl.1 - '--krb4' => 6, - '--ftp-ssl' => 6, - '--ftp-ssl-reqd' => 6, - - # for tests and debug only, can remain hidden - '--test-event' => 6, - '--wdebug' => 6, - ); - - -######################################################################### -# parse the curl code that parses the command line arguments! -open($r, "<", "$root/src/tool_getparam.c") || - die "no input file"; -my $list; -my @getparam; # store all parsed parameters - -while(<$r>) { - chomp; - my $l= $_; - if(/struct LongShort aliases/) { - $list=1; - } - elsif($list) { - if( /^ \{([^,]*), *([^ ]*)/) { - my ($s, $l)=($1, $2); - my $sh; - my $lo; - my $title; - if($l =~ /\"(.*)\"/) { - # long option - $lo = $1; - $title="--$lo"; - } - if($s =~ /\"(.)\"/) { - # a short option - $sh = $1; - $title="-$sh, $title"; - } - push @getparam, $title; - $opts{$title} |= 1; - } - } -} -close($r); - -######################################################################### -# parse the curl.1 man page, extract all documented command line options -# The man page may or may not be rebuilt, so check both possible locations -open($r, "<", "$buildroot/docs/curl.1") || open($r, "<", "$root/docs/curl.1") || - die "no input file"; -my @manpage; # store all parsed parameters -while(<$r>) { - chomp; - my $l= $_; - $l =~ s/\\-/-/g; - if($l =~ /^\.IP \"(-[^\"]*)\"/) { - my $str = $1; - my $combo; - if($str =~ /^-(.), --([a-z0-9.-]*)/) { - # figure out the -short, --long combo - $combo = "-$1, --$2"; - } - elsif($str =~ /^--([a-z0-9.-]*)/) { - # figure out the --long name - $combo = "--$1"; - } - if($combo) { - push @manpage, $combo; - $opts{$combo} |= 2; - } - } -} -close($r); - - -######################################################################### -# parse the curl code that outputs the curl -h list -open($r, "<", "$root/src/tool_listhelp.c") || - die "no input file"; -my @toolhelp; # store all parsed parameters -while(<$r>) { - chomp; - my $l= $_; - if(/^ \{\" *(.*)/) { - my $str=$1; - my $combo; - if($str =~ /^-(.), --([a-z0-9.-]*)/) { - # figure out the -short, --long combo - $combo = "-$1, --$2"; - } - elsif($str =~ /^--([a-z0-9.-]*)/) { - # figure out the --long name - $combo = "--$1"; - } - if($combo) { - push @toolhelp, $combo; - $opts{$combo} |= 4; - } - - } -} -close($r); - -# -# Now we have three arrays with options to cross-reference. - -foreach my $o (keys %opts) { - my $where = $opts{$o}; - - if($where != 7) { - # this is not in all three places - $errors++; - my $exists; - my $missing; - if($where & 1) { - $exists=" tool_getparam.c"; - } - else { - $missing=" tool_getparam.c"; - } - if($where & 2) { - $exists.= " curl.1"; - } - else { - $missing.= " curl.1"; - } - if($where & 4) { - $exists .= " tool_listhelp.c"; - } - else { - $missing .= " tool_listhelp.c"; - } - - print STDERR "$o is not in$missing (but in$exists)\n"; - } -} - -print STDERR "$errors\n"; diff --git a/tests/markdown-uppercase.pl b/tests/markdown-uppercase.pl deleted file mode 100755 index 707f286cc..000000000 --- a/tests/markdown-uppercase.pl +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### - -my $root=$ARGV[0] || ".."; - -my @m = `git ls-files -- $root`; - -my $errors; - -my %accepted=('curl' => 1, - 'libcurl' => 1); - -sub checkfile { - my ($f) = @_; - chomp $f; - if($f !~ /\.md\z/) { - return; - } - open(my $fh, "<", "$f"); - my $l = 1; - my $prevl; - my $ignore = 0; - while(<$fh>) { - my $line = $_; - chomp $line; - if($line =~ /^(\`\`\`|\~\~\~)/) { - # start or stop ignore-mode - $ignore ^= 1; - } - if(!$ignore) { - if(($prevl =~ /\.\z/) && ($line =~ /^( *)([a-z]+)/)) { - my ($prefix, $word) = ($1, $2); - if(!$accepted{$word}) { - my $c = length($prefix); - print STDERR - "$f:$l:$c:error: lowercase $word after period\n"; - print STDERR "$line\n"; - print STDERR ' ' x $c; - print STDERR "^\n"; - $errors++; - } - } - elsif($line =~ /^(.*)\. +([a-z]+)/) { - my ($prefix, $word) = ($1, $2); - - if(($prefix =~ /\.\.\z/) || - ($prefix =~ /[0-9]\z/) || - ($prefix =~ /e.g\z/) || - ($prefix =~ /i.e\z/) || - ($prefix =~ /etc\z/) || - $accepted{$word}) { - } - else { - my $c = length($prefix) + 2; - print STDERR - "$f:$l:$c:error: lowercase $word after period\n"; - print STDERR "$line\n"; - print STDERR ' ' x $c; - print STDERR "^\n"; - $errors++; - } - } - } - $prevl = $line; - $l++; - } - close($fh); -} - - -for my $f (@m) { - checkfile($f); -} - -if($errors) { - exit 1; -} -print "ok\n"; diff --git a/tests/nroff-scan.pl b/tests/nroff-scan.pl deleted file mode 100644 index 4dddf7cf1..000000000 --- a/tests/nroff-scan.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### -# -# scan nroff pages to find basic syntactic problems such as unbalanced \f -# codes or references to non-existing curl man pages. - -my $docsroot = $ARGV[0]; - -if(!$docsroot || ($docsroot eq "-g")) { - print "Usage: nroff-scan.pl [nroff files]\n"; - exit; -} - - -shift @ARGV; - -my @f = @ARGV; - -my %manp; - -sub manpresent { - my ($man) = @_; - if($manp{$man}) { - return 1; - } - elsif(-r "$docsroot/$man" || - -r "$docsroot/libcurl/$man" || - -r "$docsroot/libcurl/opts/$man") { - $manp{$man}=1; - return 1; - } - return 0; -} - -sub file { - my ($f) = @_; - open(my $fh, "<", "$f") || - die "no file"; - my $line = 1; - while(<$fh>) { - chomp; - my $l = $_; - while($l =~ s/\\f(.)([^ ]*)\\f(.)//) { - my ($pre, $str, $post)=($1, $2, $3); - if($str =~ /^\\f[ib]/i) { - print "error: $f:$line: double-highlight\n"; - $errors++; - } - if($post ne "P") { - print "error: $f:$line: missing \\fP after $str\n"; - $errors++; - } - if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) { - my $man = "$1.3"; - if(!manpresent($man)) { - print "error: $f:$line: referring to non-existing man page $man\n"; - $errors++; - } - if($pre ne "I") { - print "error: $f:$line: use \\fI before $str\n"; - $errors++; - } - } - } - if($l =~ /(curl([^ ]*)\(3\))/i) { - print "error: $f:$line: non-referencing $1\n"; - $errors++; - } - if($l =~ /^\.BR (.*)/) { - my $i= $1; - while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) { - my $man = "$1.3"; - if(!manpresent($man)) { - print "error: $f:$line: referring to non-existing man page $man\n"; - $errors++; - } - } - } - $line++; - } - close($fh); -} - -foreach my $f (@f) { - file($f); -} - -print "OK\n" if(!$errors); - -exit $errors?1:0; diff --git a/tests/options-scan.pl b/tests/options-scan.pl deleted file mode 100755 index 2014dc4f6..000000000 --- a/tests/options-scan.pl +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 all options mentioned in the $cmddir. -# - Make sure they're all mentioned in the $opts document -# - Make sure that the version in $opts matches the version in the file in -# $cmddir -# - -my $opts = $ARGV[0]; -my $cmddir = $ARGV[1]; - -sub cmdfiles { - my ($dir)=@_; - - opendir(my $dh, $dir) || die "Can't opendir $dir: $!"; - my @opts = grep { /\.d$/ && -f "$dir/$_" } readdir($dh); - closedir $dh; - - for(@opts) { - $_ =~ s/\.d$//; - $file{$_}=1; - } - return @opts; -} - -sub mentions { - my ($f) = @_; - my @options; - open(my $fh, "<", "$f"); - while(<$fh>) { - chomp; - if(/(.*) +([0-9.]+)/) { - my ($flag, $version)=($1, $2); - - # store the name without the leading dashes - $flag =~ s/^--//; - - # cut out short option (if present) - $flag =~ s/ \(-.\)//; - - # store the name without trailing space - $flag =~ s/ +$//; - - push @options, $flag; - - # options-in-versions says... - $oiv{$flag} = $version; - } - } - close($fh); - return @options; -} - -sub versioncheck { - my ($f, $v)=@_; - open(my $fh, "<", "$cmddir/$f.d"); - while(<$fh>) { - chomp; - if(/^Added: ([0-9.]+)/) { - if($1 ne $v) { - print STDERR "$f lists $v in doc but $1 in file\n"; - $error++; - } - last; - } - } - close($fh); -} - -# get all the files -my @cmdopts = cmdfiles($cmddir); - -# get all the options mentioned in $o -my @veropts = mentions($opts); - -# check if all files are in the doc -for my $c (sort @cmdopts) { - if($oiv{$c}) { - # present, but at same version? - versioncheck($c, $oiv{$c}); - } - else { - print STDERR "--$c is in the option directory but not in $opts!\n"; - $error++; - } -} - -# check if the all options in the doc have files -for my $v (sort @veropts) { - if($file{$v}) { - # present - } - else { - print STDERR "$v is in the doc but NOT as a file!\n"; - $error++; - } -} - -print STDERR "ok\n" if(!$error); - -exit $error; diff --git a/tests/runner.pm b/tests/runner.pm index 8b61eb4b3..c0fb40cb3 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -115,7 +115,7 @@ our $DBGCURL=$CURL; #"../src/.libs/curl"; # alternative for debugging our $valgrind_logfile="--log-file"; # the option name for valgrind >=3 our $valgrind_tool="--tool=memcheck"; our $gdb = checktestcmd("gdb"); -our $gdbthis; # run test case with gdb debugger +our $gdbthis = 0; # run test case with debugger (gdb or lldb) our $gdbxwin; # use windowed gdb when using gdb # torture test variables @@ -945,9 +945,16 @@ sub singletest_run { if($gdbthis) { my $gdbinit = "$TESTDIR/gdbinit$testnum"; open(my $gdbcmd, ">", "$LOGDIR/gdbcmd") || die "Failure writing gdb file"; - print $gdbcmd "set args $cmdargs\n"; - print $gdbcmd "show args\n"; - print $gdbcmd "source $gdbinit\n" if -e $gdbinit; + if($gdbthis == 1) { + # gdb mode + print $gdbcmd "set args $cmdargs\n"; + print $gdbcmd "show args\n"; + print $gdbcmd "source $gdbinit\n" if -e $gdbinit; + } + else { + # lldb mode + print $gdbcmd "set args $cmdargs\n"; + } close($gdbcmd) || die "Failure writing gdb file"; } @@ -963,11 +970,18 @@ sub singletest_run { $testnum, "$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " -x $LOGDIR/gdbcmd"); } - elsif($gdbthis) { + elsif($gdbthis == 1) { + # gdb my $GDBW = ($gdbxwin) ? "-w" : ""; runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR/gdbcmd"); $cmdres=0; # makes it always continue after a debugged run } + elsif($gdbthis == 2) { + # $gdb is "lldb" + print "runs lldb -- $CURL $cmdargs\n"; + runclient("lldb -- $CURL $cmdargs"); + $cmdres=0; # makes it always continue after a debugged run + } else { # Convert the raw result code into a more useful one ($cmdres, $dumped_core) = normalize_cmdres(runclient("$CMDLINE")); diff --git a/tests/runtests.1 b/tests/runtests.1 index 6ea656d98..5b2b63143 100644 --- a/tests/runtests.1 +++ b/tests/runtests.1 @@ -117,6 +117,11 @@ Run the given test(s) with gdb. This is best used on a single test case and curl built --disable-shared. This then fires up gdb with command line set to run the specified test case. Simply (set a break-point and) type 'run' to start. +.IP "-gl" +Run the given test(s) with lldb. This is best used on a single test case and +curl built --disable-shared. This then fires up lldb with command line set to +run the specified test case. Simply (set a break-point and) type 'run' to +start. .IP "-gw" Run the given test(s) with gdb as a windowed application. .IP "-h, --help" diff --git a/tests/runtests.pl b/tests/runtests.pl index e7b9f01f6..17b0d3986 100644 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -1235,6 +1235,8 @@ sub singletest_check { # text mode when running on windows: fix line endings s/\r\n/\n/g for @validstdout; s/\n/\r\n/g for @validstdout; + s/\r\n/\n/g for @actual; + s/\n/\r\n/g for @actual; } if($hash{'nonewline'}) { @@ -2215,6 +2217,10 @@ sub pickrunner { # run this test with gdb $gdbthis=1; } + elsif ($ARGV[0] eq "-gl") { + # run this test with lldb + $gdbthis=2; + } elsif ($ARGV[0] eq "-gw") { # run this test with windowed gdb $gdbthis=1; diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 8a0da3ee6..38918a065 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -246,7 +246,7 @@ static int connack(FILE *dump, curl_socket_t fd) rc = swrite(fd, (char *)packet, sizeof(packet)); if(rc > 0) { - logmsg("WROTE %d bytes [CONNACK]", rc); + logmsg("WROTE %zd bytes [CONNACK]", rc); loghex(packet, rc); logprotocol(FROM_SERVER, "CONNACK", 2, dump, packet, sizeof(packet)); } @@ -270,7 +270,7 @@ static int suback(FILE *dump, curl_socket_t fd, unsigned short packetid) rc = swrite(fd, (char *)packet, sizeof(packet)); if(rc == sizeof(packet)) { - logmsg("WROTE %d bytes [SUBACK]", rc); + logmsg("WROTE %zd bytes [SUBACK]", rc); loghex(packet, rc); logprotocol(FROM_SERVER, "SUBACK", 3, dump, packet, rc); return 0; @@ -292,7 +292,7 @@ static int puback(FILE *dump, curl_socket_t fd, unsigned short packetid) rc = swrite(fd, (char *)packet, sizeof(packet)); if(rc == sizeof(packet)) { - logmsg("WROTE %d bytes [PUBACK]", rc); + logmsg("WROTE %zd bytes [PUBACK]", rc); loghex(packet, rc); logprotocol(FROM_SERVER, dump, packet, rc); return 0; @@ -310,7 +310,7 @@ static int disconnect(FILE *dump, curl_socket_t fd) }; ssize_t rc = swrite(fd, (char *)packet, sizeof(packet)); if(rc == sizeof(packet)) { - logmsg("WROTE %d bytes [DISCONNECT]", rc); + logmsg("WROTE %zd bytes [DISCONNECT]", rc); loghex(packet, rc); logprotocol(FROM_SERVER, "DISCONNECT", 0, dump, packet, rc); return 0; @@ -439,7 +439,7 @@ static int publish(FILE *dump, rc = swrite(fd, (char *)packet, sendamount); if(rc > 0) { - logmsg("WROTE %d bytes [PUBLISH]", rc); + logmsg("WROTE %zd bytes [PUBLISH]", rc); loghex(packet, rc); logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc); } @@ -465,10 +465,10 @@ static int fixedheader(curl_socket_t fd, ssize_t rc = sread(fd, (char *)buffer, 2); int i; if(rc < 2) { - logmsg("READ %d bytes [SHORT!]", rc); + logmsg("READ %zd bytes [SHORT!]", rc); return 1; /* fail */ } - logmsg("READ %d bytes", rc); + logmsg("READ %zd bytes", rc); loghex(buffer, rc); *bytep = buffer[0]; @@ -483,7 +483,7 @@ static int fixedheader(curl_socket_t fd, } } *remaining_lengthp = decode_length(&buffer[1], i, remaining_length_bytesp); - logmsg("Remaining Length: %ld [%d bytes]", (long) *remaining_lengthp, + logmsg("Remaining Length: %zu [%zu bytes]", *remaining_lengthp, *remaining_length_bytesp); return 0; } @@ -497,7 +497,7 @@ static curl_socket_t mqttit(curl_socket_t fd) unsigned short packet_id; size_t payload_len; size_t client_id_length; - unsigned int topic_len; + size_t topic_len; size_t remaining_length = 0; size_t bytes = 0; /* remaining length field size in bytes */ char client_id[MAX_CLIENT_ID_LENGTH]; @@ -546,7 +546,7 @@ static curl_socket_t mqttit(curl_socket_t fd) buff_size = remaining_length; buffer = realloc(buffer, buff_size); if(!buffer) { - logmsg("Failed realloc of size %lu", buff_size); + logmsg("Failed realloc of size %zu", buff_size); goto end; } } @@ -555,7 +555,7 @@ static curl_socket_t mqttit(curl_socket_t fd) /* reading variable header and payload into buffer */ rc = sread(fd, (char *)buffer, remaining_length); if(rc > 0) { - logmsg("READ %d bytes", rc); + logmsg("READ %zd bytes", rc); loghex(buffer, rc); } } @@ -569,7 +569,7 @@ static curl_socket_t mqttit(curl_socket_t fd) goto end; } /* ignore the connect flag byte and two keepalive bytes */ - payload_len = (buffer[10] << 8) | buffer[11]; + payload_len = (size_t)(buffer[10] << 8) | buffer[11]; /* first part of the payload is the client ID */ client_id_length = payload_len; @@ -579,20 +579,22 @@ static curl_socket_t mqttit(curl_socket_t fd) start_usr = client_id_offset + payload_len; if(usr_flag == (unsigned char)(conn_flags & usr_flag)) { logmsg("User flag is present in CONN flag"); - payload_len += (buffer[start_usr] << 8) | buffer[start_usr + 1]; + payload_len += (size_t)(buffer[start_usr] << 8) | + buffer[start_usr + 1]; payload_len += 2; /* MSB and LSB for user length */ } start_passwd = client_id_offset + payload_len; if(passwd_flag == (char)(conn_flags & passwd_flag)) { logmsg("Password flag is present in CONN flags"); - payload_len += (buffer[start_passwd] << 8) | buffer[start_passwd + 1]; + payload_len += (size_t)(buffer[start_passwd] << 8) | + buffer[start_passwd + 1]; payload_len += 2; /* MSB and LSB for password length */ } /* check the length of the payload */ if((ssize_t)payload_len != (rc - 12)) { - logmsg("Payload length mismatch, expected %x got %x", + logmsg("Payload length mismatch, expected %zx got %zx", rc - 12, payload_len); goto end; } @@ -631,9 +633,9 @@ static curl_socket_t mqttit(curl_socket_t fd) packet_id = (unsigned short)((buffer[0] << 8) | buffer[1]); /* two bytes topic length */ - topic_len = (buffer[2] << 8) | buffer[3]; + topic_len = (size_t)(buffer[2] << 8) | buffer[3]; if(topic_len != (remaining_length - 5)) { - logmsg("Wrong topic length, got %d expected %d", + logmsg("Wrong topic length, got %zu expected %zu", topic_len, remaining_length - 5); goto end; } @@ -676,8 +678,8 @@ static curl_socket_t mqttit(curl_socket_t fd) logprotocol(FROM_CLIENT, "PUBLISH", remaining_length, dump, buffer, rc); - topiclen = (buffer[1 + bytes] << 8) | buffer[2 + bytes]; - logmsg("Got %d bytes topic", topiclen); + topiclen = (size_t)(buffer[1 + bytes] << 8) | buffer[2 + bytes]; + logmsg("Got %zu bytes topic", topiclen); /* TODO: verify topiclen */ #ifdef QOS @@ -688,7 +690,7 @@ static curl_socket_t mqttit(curl_socket_t fd) /* get the request */ rc = sread(fd, (char *)&buffer[0], 2); - logmsg("READ %d bytes [DISCONNECT]", rc); + logmsg("READ %zd bytes [DISCONNECT]", rc); loghex(buffer, rc); logprotocol(FROM_CLIENT, "DISCONNECT", 0, dump, buffer, rc); goto end; @@ -767,12 +769,12 @@ static bool incoming(curl_socket_t listenfd) curl_socket_t newfd = accept(sockfd, NULL, NULL); if(CURL_SOCKET_BAD == newfd) { error = SOCKERRNO; - logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s", - sockfd, error, sstrerror(error)); + logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) " + "failed with error: (%d) %s", sockfd, error, sstrerror(error)); } else { - logmsg("====> Client connect, fd %d. Read config from %s", - newfd, configfile); + logmsg("====> Client connect, fd %" CURL_FORMAT_SOCKET_T ". " + "Read config from %s", newfd, configfile); set_advisor_read_lock(loglockfile); (void)mqttit(newfd); /* until done */ clear_advisor_read_lock(loglockfile); @@ -910,7 +912,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, rc = listen(sock, 5); if(0 != rc) { error = SOCKERRNO; - logmsg("listen(%d, 5) failed with error: (%d) %s", + logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s", sock, error, sstrerror(error)); sclose(sock); return CURL_SOCKET_BAD; diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index f87d1c8f9..0900f6564 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -551,14 +551,14 @@ static unsigned int WINAPI select_ws_wait_thread(void *lpParameter) continue; } else { - logmsg("[select_ws_wait_thread] PeekNamedPipe len: %d", length); + logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length); } } else { /* if the pipe has NOT been closed, sleep and continue waiting */ ret = GetLastError(); if(ret != ERROR_BROKEN_PIPE) { - logmsg("[select_ws_wait_thread] PeekNamedPipe error: %d", ret); + logmsg("[select_ws_wait_thread] PeekNamedPipe error: %lu", ret); SleepEx(0, FALSE); continue; } @@ -1159,8 +1159,8 @@ static bool juggle(curl_socket_t *sockfdp, curl_socket_t newfd = accept(sockfd, NULL, NULL); if(CURL_SOCKET_BAD == newfd) { error = SOCKERRNO; - logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s", - sockfd, error, sstrerror(error)); + logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) " + "failed with error: (%d) %s", sockfd, error, sstrerror(error)); } else { logmsg("====> Client connect"); @@ -1335,7 +1335,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, rc = listen(sock, 5); if(0 != rc) { error = SOCKERRNO; - logmsg("listen(%d, 5) failed with error: (%d) %s", + logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s", sock, error, sstrerror(error)); sclose(sock); return CURL_SOCKET_BAD; diff --git a/tests/server/socksd.c b/tests/server/socksd.c index 490085d49..b1d8220a3 100644 --- a/tests/server/socksd.c +++ b/tests/server/socksd.c @@ -193,8 +193,8 @@ static void getconfig(void) logmsg("parse config file"); while(fgets(buffer, sizeof(buffer), fp)) { char key[32]; - char value[32]; - if(2 == sscanf(buffer, "%31s %31s", key, value)) { + char value[260]; + if(2 == sscanf(buffer, "%31s %259s", key, value)) { if(!strcmp(key, "version")) { config.version = byteval(value); logmsg("version [%d] set", config.version); @@ -323,7 +323,7 @@ static curl_socket_t socks4(curl_socket_t fd, return CURL_SOCKET_BAD; } if(rc < 9) { - logmsg("SOCKS4 connect message too short: %d", rc); + logmsg("SOCKS4 connect message too short: %zd", rc); return CURL_SOCKET_BAD; } if(!config.port) @@ -350,7 +350,7 @@ static curl_socket_t socks4(curl_socket_t fd, logmsg("Sending SOCKS4 response failed!"); return CURL_SOCKET_BAD; } - logmsg("Sent %d bytes", rc); + logmsg("Sent %zd bytes", rc); loghex(response, rc); if(cd == 90) @@ -365,8 +365,8 @@ static curl_socket_t socks4(curl_socket_t fd, static curl_socket_t sockit(curl_socket_t fd) { - unsigned char buffer[256 + 16]; - unsigned char response[256 + 16]; + unsigned char buffer[2*256 + 16]; + unsigned char response[2*256 + 16]; ssize_t rc; unsigned char len; unsigned char type; @@ -380,18 +380,18 @@ static curl_socket_t sockit(curl_socket_t fd) rc = recv(fd, (char *)buffer, sizeof(buffer), 0); if(rc <= 0) { - logmsg("SOCKS identifier message missing, recv returned %d", rc); + logmsg("SOCKS identifier message missing, recv returned %zd", rc); return CURL_SOCKET_BAD; } - logmsg("READ %d bytes", rc); + logmsg("READ %zd bytes", rc); loghex(buffer, rc); if(buffer[SOCKS5_VERSION] == 4) return socks4(fd, buffer, rc); if(rc < 3) { - logmsg("SOCKS5 identifier message too short: %d", rc); + logmsg("SOCKS5 identifier message too short: %zd", rc); return CURL_SOCKET_BAD; } @@ -408,7 +408,7 @@ static curl_socket_t sockit(curl_socket_t fd) /* after NMETHODS follows that many bytes listing the methods the client says it supports */ if(rc != (buffer[SOCKS5_NMETHODS] + 2)) { - logmsg("Expected %d bytes, got %d", buffer[SOCKS5_NMETHODS] + 2, rc); + logmsg("Expected %d bytes, got %zd", buffer[SOCKS5_NMETHODS] + 2, rc); return CURL_SOCKET_BAD; } logmsg("Incoming request deemed fine!"); @@ -421,17 +421,17 @@ static curl_socket_t sockit(curl_socket_t fd) logmsg("Sending response failed!"); return CURL_SOCKET_BAD; } - logmsg("Sent %d bytes", rc); + logmsg("Sent %zd bytes", rc); loghex(response, rc); /* expect the request or auth */ rc = recv(fd, (char *)buffer, sizeof(buffer), 0); if(rc <= 0) { - logmsg("SOCKS5 request or auth message missing, recv returned %d", rc); + logmsg("SOCKS5 request or auth message missing, recv returned %zd", rc); return CURL_SOCKET_BAD; } - logmsg("READ %d bytes", rc); + logmsg("READ %zd bytes", rc); loghex(buffer, rc); if(config.responsemethod == 2) { @@ -446,7 +446,7 @@ static curl_socket_t sockit(curl_socket_t fd) unsigned char plen; bool login = TRUE; if(rc < 5) { - logmsg("Too short auth input: %d", rc); + logmsg("Too short auth input: %zd", rc); return CURL_SOCKET_BAD; } if(buffer[SOCKS5_VERSION] != 1) { @@ -455,12 +455,12 @@ static curl_socket_t sockit(curl_socket_t fd) } ulen = buffer[SOCKS5_ULEN]; if(rc < 4 + ulen) { - logmsg("Too short packet for username: %d", rc); + logmsg("Too short packet for username: %zd", rc); return CURL_SOCKET_BAD; } plen = buffer[SOCKS5_ULEN + ulen + 1]; if(rc < 3 + ulen + plen) { - logmsg("Too short packet for ulen %d plen %d: %d", ulen, plen, rc); + logmsg("Too short packet for ulen %d plen %d: %zd", ulen, plen, rc); return CURL_SOCKET_BAD; } if((ulen != strlen(config.user)) || @@ -478,7 +478,7 @@ static curl_socket_t sockit(curl_socket_t fd) logmsg("Sending auth response failed!"); return CURL_SOCKET_BAD; } - logmsg("Sent %d bytes", rc); + logmsg("Sent %zd bytes", rc); loghex(response, rc); if(!login) return CURL_SOCKET_BAD; @@ -486,15 +486,15 @@ static curl_socket_t sockit(curl_socket_t fd) /* expect the request */ rc = recv(fd, (char *)buffer, sizeof(buffer), 0); if(rc <= 0) { - logmsg("SOCKS5 request message missing, recv returned %d", rc); + logmsg("SOCKS5 request message missing, recv returned %zd", rc); return CURL_SOCKET_BAD; } - logmsg("READ %d bytes", rc); + logmsg("READ %zd bytes", rc); loghex(buffer, rc); } if(rc < 6) { - logmsg("Too short for request: %d", rc); + logmsg("Too short for request: %zd", rc); return CURL_SOCKET_BAD; } @@ -539,7 +539,7 @@ static curl_socket_t sockit(curl_socket_t fd) return CURL_SOCKET_BAD; } if(rc < (4 + len + 2)) { - logmsg("Request too short: %d, expected %d", rc, 4 + len + 2); + logmsg("Request too short: %zd, expected %d", rc, 4 + len + 2); return CURL_SOCKET_BAD; } logmsg("Received ATYP %d", type); @@ -620,12 +620,12 @@ static curl_socket_t sockit(curl_socket_t fd) memcpy(&response[SOCKS5_BNDADDR + len], &buffer[SOCKS5_DSTADDR + len], sizeof(socksport)); - rc = (send)(fd, (char *)response, len + 6, 0); + rc = (send)(fd, (char *)response, (size_t)(len + 6), 0); if(rc != (len + 6)) { logmsg("Sending connect response failed!"); return CURL_SOCKET_BAD; } - logmsg("Sent %d bytes", rc); + logmsg("Sent %zd bytes", rc); loghex(response, rc); if(!rep) @@ -754,13 +754,14 @@ static bool incoming(curl_socket_t listenfd) curl_socket_t newfd = accept(sockfd, NULL, NULL); if(CURL_SOCKET_BAD == newfd) { error = SOCKERRNO; - logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s", + logmsg("accept(%" CURL_FORMAT_SOCKET_T ", NULL, NULL) " + "failed with error: (%d) %s", sockfd, error, sstrerror(error)); } else { curl_socket_t remotefd; - logmsg("====> Client connect, fd %d. Read config from %s", - newfd, configfile); + logmsg("====> Client connect, fd %" CURL_FORMAT_SOCKET_T ". " + "Read config from %s", newfd, configfile); remotefd = sockit(newfd); /* SOCKS until done */ if(remotefd == CURL_SOCKET_BAD) { logmsg("====> Client disconnect"); @@ -943,7 +944,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, rc = listen(sock, 5); if(0 != rc) { error = SOCKERRNO; - logmsg("listen(%d, 5) failed with error: (%d) %s", + logmsg("listen(%" CURL_FORMAT_SOCKET_T ", 5) failed with error: (%d) %s", sock, error, sstrerror(error)); sclose(sock); return CURL_SOCKET_BAD; diff --git a/tests/server/sws.c b/tests/server/sws.c index fa9b1ac80..d91258597 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -374,7 +374,7 @@ static int ProcessRequest(struct httprequest *req) req->callcount++; - logmsg("Process %d bytes request%s", req->offset, + logmsg("Process %zu bytes request%s", req->offset, req->callcount > 1?" [CONTINUED]":""); /* try to figure out the request characteristics as soon as possible, but @@ -557,14 +557,14 @@ static int ProcessRequest(struct httprequest *req) logmsg("request not complete yet"); return 0; /* not complete yet */ } - logmsg("- request found to be complete (%d)", req->testno); + logmsg("- request found to be complete (%ld)", req->testno); if(req->testno == DOCNUMBER_NOTHING) { /* check for a Testno: header with the test case number */ char *testno = strstr(line, "\nTestno: "); if(testno) { req->testno = strtol(&testno[9], NULL, 10); - logmsg("Found test number %d in Testno: header!", req->testno); + logmsg("Found test number %ld in Testno: header!", req->testno); } else { logmsg("No Testno: header"); @@ -702,8 +702,8 @@ static int ProcessRequest(struct httprequest *req) /* Negotiate iterations */ static long prev_testno = -1; static long prev_partno = -1; - logmsg("Negotiate: prev_testno: %d, prev_partno: %d", - prev_testno, prev_partno); + logmsg("Negotiate: prev_testno: %ld, prev_partno: %ld", + prev_testno, prev_partno); if(req->testno != prev_testno) { prev_testno = req->testno; prev_partno = req->partno; @@ -1198,8 +1198,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) int intervals = msecs_left / MAX_SLEEP_TIME_MS; if(msecs_left%MAX_SLEEP_TIME_MS) intervals++; - logmsg("Pausing %d milliseconds after writing %d bytes", - msecs_left, written); + logmsg("Pausing %d milliseconds after writing %zd bytes", + msecs_left, written); while((intervals > 0) && !got_exit_signal) { int sleep_time = msecs_left > MAX_SLEEP_TIME_MS ? MAX_SLEEP_TIME_MS : msecs_left; @@ -2334,7 +2334,8 @@ int main(int argc, char *argv[]) curl_socket_t msgsock; do { msgsock = accept_connection(sock); - logmsg("accept_connection %d returned %d", sock, msgsock); + logmsg("accept_connection %" CURL_FORMAT_SOCKET_T + " returned %" CURL_FORMAT_SOCKET_T, sock, msgsock); if(CURL_SOCKET_BAD == msgsock) goto sws_cleanup; if(req->delay) diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 9f93f4c6b..9e839eafc 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -1129,7 +1129,7 @@ static int validate_access(struct testcase *test, if(!stream) { int error = errno; logmsg("fopen() failed with error: %d %s", error, strerror(error)); - logmsg("Couldn't open test file for test : %d", testno); + logmsg("Couldn't open test file for test: %ld", testno); return EACCESS; } else { diff --git a/tests/server/util.c b/tests/server/util.c index 5cfdab269..74d6d0807 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -39,9 +39,6 @@ #elif defined(HAVE_SYS_POLL_H) #include #endif -#ifdef __MINGW32__ -#include -#endif #define ENABLE_CURLX_PRINTF /* make the curlx header define all printf() functions to use the curlx_* @@ -58,15 +55,6 @@ #define EINVAL 22 /* errno.h value */ #endif -/* MinGW with w32api version < 3.6 declared in6addr_any as extern, - but lacked the definition */ -#if defined(ENABLE_IPV6) && defined(__MINGW32__) -#if (__W32API_MAJOR_VERSION < 3) || \ - ((__W32API_MAJOR_VERSION == 3) && (__W32API_MINOR_VERSION < 6)) -const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }}; -#endif /* w32api < 3.6 */ -#endif /* ENABLE_IPV6 && __MINGW32__ */ - static struct timeval tvnow(void); /* This function returns a pointer to STATIC memory. It converts the given @@ -149,9 +137,9 @@ void logmsg(const char *msg, ...) static const char *win32_strerror(int err, char *buf, size_t buflen) { if(!FormatMessageA((FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, + FORMAT_MESSAGE_IGNORE_INSERTS), NULL, (DWORD)err, LANG_NEUTRAL, buf, (DWORD)buflen, NULL)) - msnprintf(buf, buflen, "Unknown error %lu (%#lx)", err, err); + msnprintf(buf, buflen, "Unknown error %d (%#x)", err, err); return buf; } @@ -259,7 +247,7 @@ int wait_ms(int timeout_ms) #if defined(MSDOS) delay(timeout_ms); #elif defined(USE_WINSOCK) - Sleep(timeout_ms); + Sleep((DWORD)timeout_ms); #else pending_ms = timeout_ms; initial_tv = tvnow(); @@ -567,7 +555,7 @@ static void exit_signal_handler(int signum) static BOOL WINAPI ctrl_event_handler(DWORD dwCtrlType) { int signum = 0; - logmsg("ctrl_event_handler: %d", dwCtrlType); + logmsg("ctrl_event_handler: %lu", dwCtrlType); switch(dwCtrlType) { #ifdef SIGINT case CTRL_C_EVENT: signum = SIGINT; break; @@ -581,7 +569,7 @@ static BOOL WINAPI ctrl_event_handler(DWORD dwCtrlType) default: return FALSE; } if(signum) { - logmsg("ctrl_event_handler: %d -> %d", dwCtrlType, signum); + logmsg("ctrl_event_handler: %lu -> %d", dwCtrlType, signum); raise(signum); } return TRUE; diff --git a/tests/server/util.h b/tests/server/util.h index 4dff40e81..a91ecf477 100644 --- a/tests/server/util.h +++ b/tests/server/util.h @@ -26,7 +26,7 @@ #include "server_setup.h" char *data_to_hex(char *data, size_t len); -void logmsg(const char *msg, ...); +void logmsg(const char *msg, ...) CURL_PRINTF(1, 2); long timediff(struct timeval newer, struct timeval older); #define TEST_DATA_PATH "%s/data/test%ld" diff --git a/tests/servers.pm b/tests/servers.pm index 9416ba758..d4472d509 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -190,10 +190,10 @@ use File::Temp qw/ tempfile/; ####################################################################### # Initialize configuration variables sub initserverconfig { - my ($fh, $socks) = tempfile("/tmp/curl-socksd-XXXXXXXX"); + my ($fh, $socks) = tempfile("curl-socksd-XXXXXXXX", TMPDIR => 1); close($fh); unlink($socks); - my ($f2, $http) = tempfile("/tmp/curl-http-XXXXXXXX"); + my ($f2, $http) = tempfile("curl-http-XXXXXXXX", TMPDIR => 1); close($f2); unlink($http); $SOCKSUNIXPATH = $socks; # SOCKS Unix domain socket diff --git a/tests/symbol-scan.pl b/tests/test1119.pl similarity index 100% rename from tests/symbol-scan.pl rename to tests/test1119.pl diff --git a/tests/mem-include-scan.pl b/tests/test1132.pl similarity index 100% rename from tests/mem-include-scan.pl rename to tests/test1132.pl diff --git a/tests/extern-scan.pl b/tests/test1135.pl similarity index 100% rename from tests/extern-scan.pl rename to tests/test1135.pl diff --git a/tests/test1139.pl b/tests/test1139.pl new file mode 100644 index 000000000..c86081431 --- /dev/null +++ b/tests/test1139.pl @@ -0,0 +1,312 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### +# +# Scan symbols-in-version (which is verified to be correct by test 1119), then +# verify that each option mention in there that should have its own man page +# actually does. +# +# In addition, make sure that every current option to curl_easy_setopt, +# curl_easy_getinfo and curl_multi_setopt are also mentioned in their +# corresponding main (index) man page. +# +# src/tool_getparam.c lists all options curl can parse +# docs/curl.1 documents all command line options +# src/tool_listhelp.c outputs all options with curl -h +# - make sure they're all in sync +# +# Output all deviances to stderr. + +use strict; +use warnings; + +# we may get the dir roots pointed out +my $root=$ARGV[0] || "."; +my $buildroot=$ARGV[1] || "."; +my $syms = "$root/docs/libcurl/symbols-in-versions"; +my $curlh = "$root/include/curl/curl.h"; +my $errors=0; + +# the prepopulated alias list is the CURLINFO_* defines that are used for the +# debug function callback and the fact that they use the same prefix as the +# curl_easy_getinfo options was a mistake. +my %alias = ( + 'CURLINFO_DATA_IN' => 'none', + 'CURLINFO_DATA_OUT' => 'none', + 'CURLINFO_END' => 'none', + 'CURLINFO_HEADER_IN' => 'none', + 'CURLINFO_HEADER_OUT' => 'none', + 'CURLINFO_LASTONE' => 'none', + 'CURLINFO_NONE' => 'none', + 'CURLINFO_SSL_DATA_IN' => 'none', + 'CURLINFO_SSL_DATA_OUT' => 'none', + 'CURLINFO_TEXT' => 'none' + ); + +sub scanmanpage { + my ($file, @words) = @_; + + open(my $mh, "<", "$file") || + die "could not open $file"; + my @m; + while(<$mh>) { + if($_ =~ /^\.IP (.*)/) { + my $w = $1; + # "unquote" minuses + $w =~ s/\\-/-/g; + push @m, $w; + } + } + close($mh); + + foreach my $m (@words) { + my @g = grep(/$m/, @m); + if(!$g[0]) { + print STDERR "Missing mention of $m in $file\n"; + $errors++; + } + } +} + +my $r; + +# check for define aliases +open($r, "<", "$curlh") || + die "no curl.h"; +while(<$r>) { + if(/^\#define (CURL(OPT|INFO|MOPT)_\w+) (.*)/) { + $alias{$1}=$3; + } +} +close($r); + +my @curlopt; +my @curlinfo; +my @curlmopt; +open($r, "<", "$syms") || + die "no input file"; +while(<$r>) { + chomp; + my $l= $_; + if($l =~ /(CURL(OPT|INFO|MOPT)_\w+) *([0-9.]*) *([0-9.-]*) *([0-9.]*)/) { + my ($opt, $type, $add, $dep, $rem) = ($1, $2, $3, $4, $5); + + if($alias{$opt}) { + #print "$opt => $alias{$opt}\n"; + } + elsif($rem) { + # $opt was removed in $rem + # so don't check for that + } + else { + if($type eq "OPT") { + push @curlopt, $opt, + } + elsif($type eq "INFO") { + push @curlinfo, $opt, + } + elsif($type eq "MOPT") { + push @curlmopt, $opt, + } + if(! -f "$buildroot/docs/libcurl/opts/$opt.3") { + print STDERR "Missing $opt.3\n"; + $errors++; + } + } + } +} +close($r); + +scanmanpage("$buildroot/docs/libcurl/curl_easy_setopt.3", @curlopt); +scanmanpage("$buildroot/docs/libcurl/curl_easy_getinfo.3", @curlinfo); +scanmanpage("$buildroot/docs/libcurl/curl_multi_setopt.3", @curlmopt); + +# using this hash array, we can skip specific options +my %opts = ( + # pretend these --no options exists in tool_getparam.c + '--no-alpn' => 1, + '--no-npn' => 1, + '-N, --no-buffer' => 1, + '--no-sessionid' => 1, + '--no-keepalive' => 1, + '--no-progress-meter' => 1, + '--no-clobber' => 1, + + # pretend these options without -no exist in curl.1 and tool_listhelp.c + '--alpn' => 6, + '--npn' => 6, + '--eprt' => 6, + '--epsv' => 6, + '--keepalive' => 6, + '-N, --buffer' => 6, + '--sessionid' => 6, + '--progress-meter' => 6, + '--clobber' => 6, + + # deprecated options do not need to be in tool_help.c nor curl.1 + '--krb4' => 6, + '--ftp-ssl' => 6, + '--ftp-ssl-reqd' => 6, + + # for tests and debug only, can remain hidden + '--test-event' => 6, + '--wdebug' => 6, + ); + + +######################################################################### +# parse the curl code that parses the command line arguments! +open($r, "<", "$root/src/tool_getparam.c") || + die "no input file"; +my $list; +my @getparam; # store all parsed parameters + +my $prevlong = ""; +my $no = 0; +while(<$r>) { + $no++; + chomp; + if(/struct LongShort aliases/) { + $list=1; + } + elsif($list) { + if( /^ \{(\"[^,]*\").*\'(.)\', (.*)\}/) { + my ($l, $s, $rd)=($1, $2, $3); + my $sh; + my $lo; + my $title; + if(($l cmp $prevlong) < 0) { + print STDERR "tool_getparam.c:$no: '$l' is NOT placed in alpha-order\n"; + } + if($l =~ /\"(.*)\"/) { + # long option + $lo = $1; + $title="--$lo"; + } + if($s ne " ") { + # a short option + $sh = $s; + $title="-$sh, $title"; + } + push @getparam, $title; + $opts{$title} |= 1; + $prevlong = $l; + } + } +} +close($r); + +######################################################################### +# parse the curl.1 man page, extract all documented command line options +# The man page may or may not be rebuilt, so check both possible locations +open($r, "<", "$buildroot/docs/curl.1") || open($r, "<", "$root/docs/curl.1") || + die "no input file"; +my @manpage; # store all parsed parameters +while(<$r>) { + chomp; + my $l= $_; + $l =~ s/\\-/-/g; + if($l =~ /^\.IP \"(-[^\"]*)\"/) { + my $str = $1; + my $combo; + if($str =~ /^-(.), --([a-z0-9.-]*)/) { + # figure out the -short, --long combo + $combo = "-$1, --$2"; + } + elsif($str =~ /^--([a-z0-9.-]*)/) { + # figure out the --long name + $combo = "--$1"; + } + if($combo) { + push @manpage, $combo; + $opts{$combo} |= 2; + } + } +} +close($r); + + +######################################################################### +# parse the curl code that outputs the curl -h list +open($r, "<", "$root/src/tool_listhelp.c") || + die "no input file"; +my @toolhelp; # store all parsed parameters +while(<$r>) { + chomp; + my $l= $_; + if(/^ \{\" *(.*)/) { + my $str=$1; + my $combo; + if($str =~ /^-(.), --([a-z0-9.-]*)/) { + # figure out the -short, --long combo + $combo = "-$1, --$2"; + } + elsif($str =~ /^--([a-z0-9.-]*)/) { + # figure out the --long name + $combo = "--$1"; + } + if($combo) { + push @toolhelp, $combo; + $opts{$combo} |= 4; + } + + } +} +close($r); + +# +# Now we have three arrays with options to cross-reference. + +foreach my $o (keys %opts) { + my $where = $opts{$o}; + + if($where != 7) { + # this is not in all three places + $errors++; + my $exists; + my $missing; + if($where & 1) { + $exists=" tool_getparam.c"; + } + else { + $missing=" tool_getparam.c"; + } + if($where & 2) { + $exists.= " curl.1"; + } + else { + $missing.= " curl.1"; + } + if($where & 4) { + $exists .= " tool_listhelp.c"; + } + else { + $missing .= " tool_listhelp.c"; + } + + print STDERR "$o is not in$missing (but in$exists)\n"; + } +} + +print STDERR "$errors\n"; diff --git a/tests/test1140.pl b/tests/test1140.pl new file mode 100644 index 000000000..b9438dec0 --- /dev/null +++ b/tests/test1140.pl @@ -0,0 +1,114 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### +# +# scan nroff pages to find basic syntactic problems such as unbalanced \f +# codes or references to non-existing curl man pages. + +my $docsroot = $ARGV[0]; + +if(!$docsroot || ($docsroot eq "-g")) { + print "Usage: nroff-scan.pl [nroff files]\n"; + exit; +} + + +shift @ARGV; + +my @f = @ARGV; + +my %manp; + +sub manpresent { + my ($man) = @_; + if($manp{$man}) { + return 1; + } + elsif(-r "$docsroot/$man" || + -r "$docsroot/libcurl/$man" || + -r "$docsroot/libcurl/opts/$man") { + $manp{$man}=1; + return 1; + } + return 0; +} + +sub file { + my ($f) = @_; + open(my $fh, "<", "$f") || + die "no file"; + my $line = 1; + while(<$fh>) { + chomp; + my $l = $_; + while($l =~ s/\\f(.)([^ ]*)\\f(.)//) { + my ($pre, $str, $post)=($1, $2, $3); + if($str =~ /^\\f[ib]/i) { + print "error: $f:$line: double-highlight\n"; + $errors++; + } + if($post ne "P") { + print "error: $f:$line: missing \\fP after $str\n"; + $errors++; + } + if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) { + my $man = "$1.3"; + $man =~ s/\\//g; # cut off backslashes + if(!manpresent($man)) { + print "error: $f:$line: referring to non-existing man page $man\n"; + $errors++; + } + if($pre ne "I") { + print "error: $f:$line: use \\fI before $str\n"; + $errors++; + } + } + } + if($l =~ /(curl([^ ]*)\(3\))/i) { + print "error: $f:$line: non-referencing $1\n"; + $errors++; + } + if($l =~ /^\.BR (.*)/) { + my $i= $1; + while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) { + my $man = "$1.3"; + $man =~ s/\\//g; # cut off backslashes + if(!manpresent($man)) { + print "error: $f:$line: referring to non-existing man page $man\n"; + $errors++; + } + } + } + $line++; + } + close($fh); +} + +foreach my $f (@f) { + file($f); +} + +print "OK\n" if(!$errors); + +exit $errors?1:0; diff --git a/tests/disable-scan.pl b/tests/test1165.pl similarity index 100% rename from tests/disable-scan.pl rename to tests/test1165.pl diff --git a/tests/badsymbols.pl b/tests/test1167.pl similarity index 100% rename from tests/badsymbols.pl rename to tests/test1167.pl diff --git a/tests/manpage-syntax.pl b/tests/test1173.pl similarity index 100% rename from tests/manpage-syntax.pl rename to tests/test1173.pl diff --git a/tests/error-codes.pl b/tests/test1175.pl similarity index 100% rename from tests/error-codes.pl rename to tests/test1175.pl diff --git a/tests/test1177.pl b/tests/test1177.pl new file mode 100644 index 000000000..e989e3a89 --- /dev/null +++ b/tests/test1177.pl @@ -0,0 +1,94 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### +# +# Verify that curl_version_info.3 documents all the CURL_VERSION_ bits +# from the header. +# + +use strict; +use warnings; + +my $manpage=$ARGV[0]; +my $header=$ARGV[1]; +my $source=$ARGV[2]; +my %manversion; +my %headerversion; +my %manname; +my %sourcename; +my $error=0; + +open(my $m, "<", "$manpage"); +while(<$m>) { + if($_ =~ / mask bit: (CURL_VERSION_[A-Z0-9_]+)/i) { + $manversion{$1}++; + } + if($_ =~ /^\.ip (.*)/i) { + $manname{$1}++; + } +} +close($m); + +open(my $h, "<", "$header"); +while(<$h>) { + if($_ =~ /^\#define (CURL_VERSION_[A-Z0-9_]+)/i) { + $headerversion{$1}++; + } +} +close($h); + +open(my $s, "<", "$source"); +while(<$s>) { + if($_ =~ /FEATURE\("([^"]*)"/) { + $sourcename{$1}++; + } +} +close($s); + +for my $h (keys %headerversion) { + if(!$manversion{$h}) { + print STDERR "$manpage: missing $h\n"; + $error++; + } +} +for my $h (keys %manversion) { + if(!$headerversion{$h}) { + print STDERR "$manpage: $h is not in the header!\n"; + $error++; + } +} +for my $n (keys %sourcename) { + if(!$manname{$n}) { + print STDERR "$manpage: missing feature name $n\n"; + $error++; + } +} +for my $n (keys %manname) { + if(!$sourcename{$n} && ($n ne "\"no name\"")) { + print STDERR "$manpage: $n is not in the source!\n"; + $error++; + } +} + +exit $error; diff --git a/tests/check-deprecated.pl b/tests/test1222.pl similarity index 100% rename from tests/check-deprecated.pl rename to tests/test1222.pl diff --git a/tests/test1275.pl b/tests/test1275.pl new file mode 100755 index 000000000..082946a22 --- /dev/null +++ b/tests/test1275.pl @@ -0,0 +1,117 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +my $root=$ARGV[0] || ".."; + +my @m = `git ls-files -- $root`; + +my $errors; + +my %accepted=('curl' => 1, + 'libcurl' => 1, + 'c-ares' => 1); + +sub checkfile { + my ($f) = @_; + chomp $f; + if($f !~ /\.md\z/) { + return; + } + open(my $fh, "<", "$f"); + my $l; + my $prevl; + my $ignore = 0; + my $metadata = 0; + while(<$fh>) { + my $line = $_; + chomp $line; + $l++; + if(($l == 1) && ($line =~ /^---/)) { + # first line is a meta-data divider, skip to the next one + $metadata = 1; + print STDERR "skip meta-data in $f\n"; + next; + } + elsif($metadata) { + if($line !~ /^---/) { + next; + } + $metadata = 0; + next; + } + if($line =~ /^(\`\`\`|\~\~\~)/) { + # start or stop ignore-mode + $ignore ^= 1; + } + if(!$ignore) { + if(($prevl =~ /\.\z/) && ($line =~ /^( *)([a-z-]+)/)) { + my ($prefix, $word) = ($1, $2); + if($word =~ /^[a-z]/ && !$accepted{$word}) { + my $c = length($prefix); + print STDERR + "$f:$l:$c:error: lowercase $word after period\n"; + print STDERR "$line\n"; + print STDERR ' ' x $c; + print STDERR "^\n"; + $errors++; + } + } + elsif($line =~ /^(.*)\. +([a-z-]+)/) { + my ($prefix, $word) = ($1, $2); + + if(($prefix =~ /\.\.\z/) || + ($prefix =~ /[0-9]\z/) || + ($prefix =~ /e.g\z/) || + ($prefix =~ /i.e\z/) || + ($prefix =~ /E.g\z/) || + ($prefix =~ /etc\z/) || + ($word !~ /^[a-z]/) || + $accepted{$word}) { + } + else { + my $c = length($prefix) + 2; + print STDERR + "$f:$l:$c:error: lowercase $word after period\n"; + print STDERR "$line\n"; + print STDERR ' ' x $c; + print STDERR "^\n"; + $errors++; + } + } + } + $prevl = $line; + } + close($fh); +} + + +for my $f (@m) { + checkfile($f); +} + +if($errors) { + exit 1; +} +print "ok\n"; diff --git a/tests/option-check.pl b/tests/test1276.pl similarity index 100% rename from tests/option-check.pl rename to tests/test1276.pl diff --git a/tests/test1477.pl b/tests/test1477.pl new file mode 100755 index 000000000..ad564b26d --- /dev/null +++ b/tests/test1477.pl @@ -0,0 +1,100 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 +# +########################################################################### + +# Check that libcurl-errors.3 and the public header files have the same set of +# error codes. + +use strict; +use warnings; + +# we may get the dir roots pointed out +my $root=$ARGV[0] || "."; +my $buildroot=$ARGV[1] || "."; +my $manpge = "$buildroot/docs/libcurl/libcurl-errors.3"; +my $curlh = "$root/include/curl"; +my $errors=0; + +my @hnames; +my %wherefrom; +my @mnames; +my %manfrom; + +sub scanheader { + my ($file)=@_; + open H, "<$file"; + my $line = 0; + while() { + $line++; + if($_ =~ /^ (CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { + my ($name)=($1); + if(($name !~ /OBSOLETE/) && ($name !~ /_LAST\z/)) { + push @hnames, $name; + if($wherefrom{$name}) { + print STDERR "double: $name\n"; + } + $wherefrom{$name}="$file:$line"; + } + } + } + close(H); +} + +sub scanmanpage { + my ($file)=@_; + open H, "<$file"; + my $line = 0; + while() { + $line++; + if($_ =~ /^\.IP \"(CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) { + my ($name)=($1); + push @mnames, $name; + $manfrom{$name}="$file:$line"; + } + } + close(H); +} + + +opendir(my $dh, $curlh) || die "Can't opendir $curlh: $!"; +my @hfiles = grep { /\.h$/ } readdir($dh); +closedir $dh; + +for(sort @hfiles) { + scanheader("$curlh/$_"); +} +scanmanpage($manpge); + +print "Result\n"; +for my $h (sort @hnames) { + if(!$manfrom{$h}) { + printf "$h from %s, not in man page\n", $wherefrom{$h}; + } +} + +for my $m (sort @mnames) { + if(!$wherefrom{$m}) { + printf "$m from %s, not in any header\n", $manfrom{$m}; + } +} diff --git a/tests/check-translatable-options.pl b/tests/test1544.pl similarity index 100% rename from tests/check-translatable-options.pl rename to tests/test1544.pl diff --git a/tests/test971.pl b/tests/test971.pl new file mode 100755 index 000000000..1aeed9d48 --- /dev/null +++ b/tests/test971.pl @@ -0,0 +1,125 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , 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 all options mentioned in the $cmddir. +# - Make sure they're all mentioned in the $opts document +# - Make sure that the version in $opts matches the version in the file in +# $cmddir +# + +my $opts = $ARGV[0]; +my $cmddir = $ARGV[1]; + +sub cmdfiles { + my ($dir)=@_; + + opendir(my $dh, $dir) || die "Can't opendir $dir: $!"; + my @opts = grep { /[a-z0-9].*\.md$/ && -f "$dir/$_" } readdir($dh); + closedir $dh; + + for(@opts) { + $_ =~ s/\.md$//; + $file{$_}=1; + } + return @opts; +} + +sub mentions { + my ($f) = @_; + my @options; + open(my $fh, "<", "$f"); + while(<$fh>) { + chomp; + if(/(.*) +([0-9.]+)/) { + my ($flag, $version)=($1, $2); + + # store the name without the leading dashes + $flag =~ s/^--//; + + # cut out short option (if present) + $flag =~ s/ \(-.\)//; + + # store the name without trailing space + $flag =~ s/ +$//; + + push @options, $flag; + + # options-in-versions says... + $oiv{$flag} = $version; + } + } + close($fh); + return @options; +} + +sub versioncheck { + my ($f, $v)=@_; + open(my $fh, "<", "$cmddir/$f.md"); + while(<$fh>) { + chomp; + if(/^Added: ([0-9.]+)/) { + if($1 ne $v) { + print STDERR "$f lists $v in doc but $1 in file\n"; + $error++; + } + last; + } + } + close($fh); +} + +# get all the files +my @cmdopts = cmdfiles($cmddir); + +# get all the options mentioned in $o +my @veropts = mentions($opts); + +# check if all files are in the doc +for my $c (sort @cmdopts) { + if($oiv{$c}) { + # present, but at same version? + versioncheck($c, $oiv{$c}); + } + else { + print STDERR "--$c is in the option directory but not in $opts!\n"; + $error++; + } +} + +# check if the all options in the doc have files +for my $v (sort @veropts) { + if($file{$v}) { + # present + } + else { + print STDERR "$v is in the doc but NOT as a file!\n"; + $error++; + } +} + +print STDERR "ok\n" if(!$error); + +exit $error; diff --git a/tests/testutil.pm b/tests/testutil.pm index ece0b6e05..1a44083e1 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -94,6 +94,15 @@ sub clearlogs { ####################################################################### + +sub includefile { + my ($f) = @_; + open(F, "<$f"); + my @a = ; + close(F); + return join("", @a); +} + sub subbase64 { my ($thing) = @_; @@ -113,6 +122,7 @@ sub subbase64 { $d =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; $$thing =~ s/%%HEX%%/$d/; } + # repeat while($$thing =~ s/%repeat\[(\d+) x (.*?)\]%/%%REPEAT%%/i) { # decode %NN characters my ($d, $n) = ($2, $1); @@ -120,6 +130,9 @@ sub subbase64 { my $all = $d x $n; $$thing =~ s/%%REPEAT%%/$all/; } + + # include a file + $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1)/ge; } my $prevupdate; # module scope so it remembers the last value diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index bf8af12d3..4283a8d1b 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -92,7 +92,7 @@ fail_unless(rc == 15, "return code should be 15"); fail_unless(!strcmp(output, " 1234 567"), "wrong output"); /* double precision */ -rc = curl_msnprintf(output, 24, "%.*1$.99d", 3, 5678); +rc = curl_msnprintf(output, 24, "%2$.*1$.99d", 3, 5678); fail_unless(rc == 0, "return code should be 0"); UNITTEST_STOP diff --git a/tests/unit/unit1651.c b/tests/unit/unit1651.c index 58d2f1076..63f339394 100644 --- a/tests/unit/unit1651.c +++ b/tests/unit/unit1651.c @@ -368,7 +368,7 @@ UNITTEST_START happens */ for(byte = 1 ; byte < 255; byte += 17) { for(i = 0; i < 45; i++) { - char backup = cert[i]; + unsigned char backup = cert[i]; cert[i] = (unsigned char) (byte & 0xff); (void) Curl_extract_certinfo(data, 0, beg, end); cert[i] = backup; diff --git a/tests/unit/unit1652.c b/tests/unit/unit1652.c index ef2726216..68ddec3ea 100644 --- a/tests/unit/unit1652.c +++ b/tests/unit/unit1652.c @@ -21,6 +21,8 @@ * SPDX-License-Identifier: curl * ***************************************************************************/ +#define CURL_NO_FMT_CHECKS + #include "curlcheck.h" #include "urldata.h" @@ -105,7 +107,7 @@ fail_unless(verify(result, "Simple Test 42 testing 43\n") == 0, /* Variations of empty strings */ Curl_infof(data, ""); fail_unless(strlen(result) == 1, "Empty string"); -Curl_infof(data, "%s", NULL); +Curl_infof(data, "%s", (char *)NULL); fail_unless(verify(result, "(nil)") == 0, "Passing NULL as string"); /* A string just long enough to not be truncated */ diff --git a/tests/version-scan.pl b/tests/version-scan.pl deleted file mode 100644 index 3c055d9b3..000000000 --- a/tests/version-scan.pl +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , 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 -# -########################################################################### -# -# Verify that curl_version_info.3 documents all the CURL_VERSION_ bits -# from the header. -# - -use strict; -use warnings; - -my $manpage=$ARGV[0]; -my $header=$ARGV[1]; -my $source=$ARGV[2]; -my %manversion; -my %headerversion; -my %manname; -my %sourcename; -my $error=0; - -open(my $m, "<", "$manpage"); -while(<$m>) { - if($_ =~ / mask bit: (CURL_VERSION_[A-Z0-9_]+)/i) { - $manversion{$1}++; - } - if($_ =~ /^\.ip """([^"]+)"""/i) { - $manname{$1}++; - } -} -close($m); - -open(my $h, "<", "$header"); -while(<$h>) { - if($_ =~ /^\#define (CURL_VERSION_[A-Z0-9_]+)/i) { - $headerversion{$1}++; - } -} -close($h); - -open(my $s, "<", "$source"); -while(<$s>) { - if($_ =~ /FEATURE\("([^"]*)"/) { - $sourcename{$1}++; - } -} -close($s); - -for my $h (keys %headerversion) { - if(!$manversion{$h}) { - print STDERR "$manpage: missing $h\n"; - $error++; - } -} -for my $h (keys %manversion) { - if(!$headerversion{$h}) { - print STDERR "$manpage: $h is not in the header!\n"; - $error++; - } -} -for my $n (keys %sourcename) { - if(!$manname{$n}) { - print STDERR "$manpage: missing feature name $n\n"; - $error++; - } -} -for my $n (keys %manname) { - if(!$sourcename{$n}) { - print STDERR "$manpage: $n is not in the source!\n"; - $error++; - } -} - -exit $error;