Commit Graph

2252 Commits

Author SHA1 Message Date
Viktor Szakats
1ccdad64ef
CI: add whitespace checker
Fix issues detected.

Also:

- One of the `.vc` files used LF EOLs, while the other didn't.
  Make that one also use LF EOLs, as this is apparently supported by
  `nmake`.

- Drop `.dsw` and `.btn` types from `.gitattributes`.
  The repository doesn't use them.

- Sync section order with the rest of files in
  `tests/certs/EdelCurlRoot-ca.prm`.

- Indent/align `.prm` and `.pem` files.

- Delete dummy `[something]` section from `.prm` and `.pem` files.

Mental note:
MSVC `.sln` files seem to accept spaces for indentation and also support
LF line-endings. I cannot test this and I don't know what's more
convenient when updating them, so left them as-is, with specific
exclusions.

Closes #14031
2024-06-27 13:33:30 +02:00
Stefan Eissing
c9b95c0bb3
lib: graceful connection shutdown
When libcurl discards a connection there are two phases this may go
through: "shutdown" and "closing". If a connection is aborted, the
shutdown phase is skipped and it is closed right away.

The connection filters attached to the connection implement the phases
in their `do_shutdown()` and `do_close()` callbacks. Filters carry now a
`shutdown` flags next to `connected` to keep track of the shutdown
operation.

Filters are shut down from top to bottom. If a filter is not connected,
its shutdown is skipped. Notable filters that *do* something during
shutdown are HTTP/2 and TLS. HTTP/2 sends the GOAWAY frame. TLS sends
its close notify and expects to receive a close notify from the server.

As sends and receives may EAGAIN on the network, a shutdown is often not
successful right away and needs to poll the connection's socket(s). To
facilitate this, such connections are placed on a new shutdown list
inside the connection cache.

Since managing this list requires the cooperation of a multi handle,
only the connection cache belonging to a multi handle is used. If a
connection was in another cache when being discarded, it is removed
there and added to the multi's cache. If no multi handle is available at
that time, the connection is shutdown and closed in a one-time,
best-effort attempt.

When a multi handle is destroyed, all connection still on the shutdown
list are discarded with a final shutdown attempt and close. In curl
debug builds, the environment variable `CURL_GRACEFUL_SHUTDOWN` can be
set to make this graceful with a timeout in milliseconds given by the
variable.

The shutdown list is limited to the max number of connections configured
for a multi cache. Set via CURLMOPT_MAX_TOTAL_CONNECTIONS. When the
limit is reached, the oldest connection on the shutdown list is
discarded.

- In multi_wait() and multi_waitfds(), collect all connection caches
  involved (each transfer might carry its own) into a temporary list.
  Let each connection cache on the list contribute sockets and
  POLLIN/OUT events it's connections are waiting for.

- in multi_perform() collect the connection caches the same way and let
  them peform their maintenance. This will make another non-blocking
  attempt to shutdown all connections on its shutdown list.

- for event based multis (multi->socket_cb set), add the sockets and
  their poll events via the callback. When `multi_socket()` is invoked
  for a socket not known by an active transfer, forward this to the
  multi's cache for processing. On closing a connection, remove its
  socket(s) via the callback.

TLS connection filters MUST NOT send close nofity messages in their
`do_close()` implementation. The reason is that a TLS close notify
signals a success. When a connection is aborted and skips its shutdown
phase, the server needs to see a missing close notify to detect
something has gone wrong.

A graceful shutdown of FTP's data connection is performed implicitly
before regarding the upload/download as complete and continuing on the
control connection. For FTP without TLS, there is just the socket close
happening. But with TLS, the sent/received close notify signals that the
transfer is complete and healthy. Servers like `vsftpd` verify that and
reject uploads without a TLS close notify.

- added test_19_* for shutdown related tests
- test_19_01 and test_19_02 test for TCP RST packets
  which happen without a graceful shutdown and should
  no longer appear otherwise.
- add test_19_03 for handling shutdowns by the server
- add test_19_04 for handling shutdowns by curl
- add test_19_05 for event based shutdowny by server
- add test_30_06/07 and test_31_06/07 for shutdown checks
  on FTP up- and downloads.

Closes #13976
2024-06-26 08:33:17 +02:00
Daniel Stenberg
b84699bf4f
CURLOPT_RESOLVE.md: mention hostname can be wildcard ('*')
Closes #13983
2024-06-23 10:29:22 +02:00
Sergey Markelov
35c0117f47
mbedtls: support CURLOPT_CERTINFO
Closes #13113
2024-06-19 11:33:12 +02:00
Daniel Stenberg
66c4a398d7
CURLOPT_NETRC.md: clarify what it does on Windows
Closes #13956
2024-06-15 17:03:05 +02:00
Yedaya Katsman
9d09f9ec7a
docs: reference non deprecated libcurl options
There are a places where man pages reference deprecated CURLOPT options,
where it doesn't make sense, replace them with the reccomended
replacement option.

also remove reference to the removed mesalink TLS backend

Closes #13951
2024-06-14 13:24:41 +02:00
Andy Pan
b77d627d24
tcpkeepalive: add CURLOPT_TCP_KEEPCNT and --keepalive-cnt
Closes #13885
2024-06-12 09:31:17 +02:00
Daniel Stenberg
48952c1ab3
CURLOPT_ECH.md: remove repeated 'if'
Closes #13922
2024-06-11 16:43:35 +02:00
Daniel Stenberg
7d934267ab
CURLOPT_CONNECTTIMEOUT*: clarify, document the milliseond version
Provide an explanation in the CURLOPT_CONNECTTIMEOUT_MS page instead of
just referring to the non-MS version.

Closes #13905
2024-06-07 14:47:40 +02:00
Daniel Stenberg
1313da9a1d
CURLOPT_INTERFACE.md: quote the less-than and larger-than
Fixes the warnings shown on stderr.

Follow-up from 3060557af7

Closes #13883
2024-06-05 08:44:58 +02:00
Orgad Shaneh
3060557af7
socket: support binding to interface *AND* IP
Introduce new notation for CURLOPT_INTERFACE / --interface:
ifhost!<interface>!<host>

Binding to an interface doesn't set the address, and an interface can
have multiple addresses.

When binding to an address (without interface), the kernel is free to
choose the route, and it can route through any device that can access
the target address, not necessarily the one with the chosen address.

Moreover, it is possible for different interfaces to have the same IP
address, on which case we need to provide a way to be more specific.

Factor out the parsing part of interface option, and add unit tests:
1663.

Closes #13719
2024-06-04 23:47:54 +02:00
Stefan Eissing
5dd8f13bfc
gnutls: support CA caching
- similar to openssl, use a shared 'credentials' instance
  among TLS connections with a plain configuration.
- different to openssl, a connection with a client certificate
  is not eligible to sharing.
- document CURLOPT_CA_CACHE_TIMEOUT in man page

Closes #13795
2024-06-04 08:17:55 +02:00
Daniel Stenberg
655d44d139
urlapi: add CURLU_NO_GUESS_SCHEME
Used for extracting:

- when used asking for a scheme, it will return CURLUE_NO_SCHEME if the
  stored information was a guess

- when used asking for a URL, the URL is returned without a scheme, like
  when previously given to the URL parser when it was asked to guess

- as soon as the scheme is set explicitly, it is no longer internally
  marked as guessed

The idea being:

1. allow a user to figure out if a URL's scheme was set as a result of
  guessing

2. extract the URL without a guessed scheme

3. this makes it work similar to how we already deal with port numbers

Extend test 1560 to verify.

Closes #13616
2024-06-01 23:51:42 +02:00
Daniel Stenberg
80aa519545
wolfssl: support CA caching
As a bonus, add SSLSUPP_CA_CACHE to let TLS backends signal its support
for this so that *setopt() return error if there is no support.

Closes #13786
2024-06-01 23:50:36 +02:00
Daniel Stenberg
8df910b79c
curl_multi_poll.md: expand the example with an custom file descriptor
Closes #13842
2024-06-01 00:24:55 +02:00
Daniel Stenberg
abff12c5a9
curl_url_set.md: libcurl only parses :// URLs
Make it clearer in the documentation.

Closes #13821
2024-05-30 08:30:17 +02:00
Daniel Stenberg
24b66a1de3
cd2nroff: use an empty "##" to signal end of .IP sequence
Like when we list a series of options and then want to add "normal" text
again afterwards.

Without this, the indentation level wrongly continues even after the
final "##" header, making following text wrongly appear to belong to the
header above.

Adjusted several curldown files to use this.

Fixes #13803
Reported-by: Jay Satiro
Closes #13806
2024-05-29 12:49:40 +02:00
Daniel Stenberg
6d1e144f12
CURLOPT_WRITEFUNCTION.md: fix the callback proto in the example
Reported-by: Michael Litwak
Fixes #13681
Closes #13687
2024-05-17 14:36:59 +02:00
Daniel Stenberg
76dba79028
curl_easy_pause.md: use correct defines in example
Spotted-by: Harry Sintonen
Closes #13664
2024-05-15 23:22:17 +02:00
Jay Satiro
798a37b25e lib: clear the easy handle's saved errno before transfer
- Clear data->state.os_errno before transfer.

- Explain the change in behavior in the CURLINFO_OS_ERRNO doc.

- Add to the CURLINFO_OS_ERRNO doc the list of libcurl network-related
  errors that may cause the errno to be saved.

data->state.os_errno is saved before libcurl returns a network-related
failure such as connection failure. It is accessible to the user via
CURLINFO_OS_ERRNO so they can get more information about the failure.

Prior to this change it wasn't cleared before transfer, so if a user
retrieved the saved errno it could be from a previous transfer. That is
because an errno is not always saved for network-related errors.

Closes https://github.com/curl/curl/pull/13574
2024-05-10 18:26:32 -04:00
Stefan Eissing
b7c7dffe35
ftp: add tracing support
- add `Curl_trc_feat_ftp` for tracing via trace config
- add macro CURL_TRC_FTP(data, fmt, ...)
- replace DEBUGF(infof()) statements in ftp.c by CURL_TRC_FTP()
- always trace FTP connection state

Closes #13580
2024-05-10 23:39:48 +02:00
Jay Satiro
edc5b3502c docs: fix some CURLINFO examples
- improve getinfo result check for example sections:
  CURLINFO_ACTIVESOCKET, CURLINFO_LASTSOCKET, CURLINFO_SSL_VERIFYRESULT,
  CURLINFO_PROXY_SSL_VERIFYRESULT

- fix getinfo result check for example sections:
  CURLINFO_NUM_CONNECTS, CURLINFO_OS_ERRNO

- fix verify result check for example sections:
  CURLINFO_PROXY_SSL_VERIFYRESULT

Bug: https://github.com/curl/curl/discussions/13557#discussion-6625507
Reported-by: farazrbx@users.noreply.github.com

Closes https://github.com/curl/curl/pull/13559
2024-05-10 01:12:36 -04:00
Daniel Stenberg
c294f9cb56
lib: make protocol handlers store scheme name lowercase
- saves a lowercase operation when the "[scheme]_proxy" name is
  generated
- appears less "shouting"
- update test 970, 972, 1438 and 1536

Closes #13553
2024-05-08 09:39:30 +02:00
Daniel Gustafsson
46d7214ca9 tls: Remove EXAMPLEs from deprecated options
CURLOPT_EGDSOCKET and CURLOPT_RANDOM_FILE are both completely dead
so remove their example sections since the code there is useless.
There is still a way to inject a random file for OpenSSL older than
1.1.0 but it's not what the example showed (and it's not even done
with this option) so we refrain from documenting it here.

Closes: #13540
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2024-05-06 20:55:27 +02:00
Ivan
a74f4d9518 misc: fix typos, quoting and spelling
Fix wording of comments, and misquotings where `' is markdown parsed
where it shouldn't be, and remove a misspelled preprocessor comment
which really isn't needed (and removing it makes it match surrounding
code better).

Closes: #13538
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
2024-05-06 10:35:53 +02:00
Daniel Stenberg
c04664ad35
curl_getdate.md: document two-digit year handling
Mentioned-by: Paul Gilmartin
Ref: https://curl.se/mail/archive-2024-04/0014.html
Closes #13494
2024-04-29 08:16:20 +02:00
Jan Venekamp
fba9afebba
mbedTLS: implement CURLOPT_SSL_CIPHER_LIST option
Use a lookup list to set the cipher suites, allowing the
ciphers to be set by either openssl or IANA names.

To keep the binary size of the lookup list down we compress
each entry in the cipher list down to 2 + 6 bytes using the
C preprocessor.

Closes #13442
2024-04-24 14:30:37 +02:00
Jay Satiro
7860f575fe dllmain: Call OpenSSL thread cleanup for Windows and Cygwin
- Call OPENSSL_thread_stop on thread termination (DLL_THREAD_DETACH)
  to prevent a memory leak in case OpenSSL is linked statically.

- Warn in libcurl-thread.3 that if OpenSSL is linked statically then it
  may require thread cleanup.

OpenSSL may need per-thread cleanup to stop a memory leak. For Windows
and Cygwin if libcurl was built as a DLL then we can do that for the
user by calling OPENSSL_thread_stop on thread termination. However, if
libcurl was built statically then we do not have notification of thread
termination and cannot do that for the user.

Also, there are several other unusual cases where it may be necessary
for the user to call OPENSSL_thread_stop, so in the libcurl-thread
warning I added a link to the OpenSSL documentation.

Co-authored-by: Viktor Szakats

Reported-by: southernedge@users.noreply.github.com
Reported-by: zmcx16@users.noreply.github.com

Ref: https://www.openssl.org/docs/man3.0/man3/OPENSSL_thread_stop.html#NOTES

Fixes https://github.com/curl/curl/issues/12327
Closes https://github.com/curl/curl/pull/12408
2024-04-24 04:04:25 -04:00
Jan Venekamp
3b8db84c1b
rustls: remove incorrect SSLSUPP_TLS13_CIPHERSUITES flag
The rustls backend advertises SSLSUPP_TLS13_CIPHERSUITES, but
the code does not actually seem to support it (yet?). Removed
the flag and corrected documentation.

Closes #13452
2024-04-24 08:59:14 +02:00
Daniel Stenberg
229c144fe8
curl_url_get.md: clarify queries and fragments and CURLU_GET_EMPTY
Follow-up to 3eac21d86b

Closes #13407
2024-04-18 16:13:34 +02:00
Daniel Stenberg
1634330474
curl_url_set.md: extended
Closes #13404
2024-04-18 11:10:46 +02:00
Daniel Stenberg
3eac21d86b
urlapi: add CURLU_GET_EMPTY for empty queries and fragments
By default the API inhibits empty queries and fragments extracted.
Unless this new flag is set.

This also makes the behavior more consistent: without it set, zero
length queries and fragments are considered not present in the URL. With
the flag set, they are returned as a zero length strings if they were in
fact present in the URL.

This applies when extracting the individual query and fragment
components and for the full URL.

Closes #13396
2024-04-18 10:37:28 +02:00
Daniel Stenberg
5e3fd347c5
version: add "ECH" as a feature
If available

Follow-up to a362962b7
Closes #13378
2024-04-16 13:24:08 +02:00
Daniel Stenberg
a1ecd0ba6b
CURLOPT_ECH: polish
- remove the pointer to build instructions, it won't work in manpages
- add see-also
- minor white space edits

Closes #13379
2024-04-16 09:58:45 +02:00
Stephen Farrell
a362962b72
TLS: add support for ECH (Encrypted Client Hello)
An EXPERIMENTAL feature used with CURLOPT_ECH and --ech.

Closes #11922
2024-04-16 08:10:53 +02:00
Daniel Stenberg
dde4b3855e
curl_version_info: provide librtmp version
Ref: https://github.com/curl/curl/pull/13364#issuecomment-2054151942
Reported-by: talregev on github
Closes #13368
2024-04-15 16:48:34 +02:00
blankie
e1f1ec028a
docs: clarify CURLOPT_MAXFILESIZE and CURLOPT_MAXFILESIZE_LARGE
The bounds of the size parameter were not specified, and nor was it
specified how to disable the maximum file size check.

The documentation also incorrectly stated that CURLOPT_MAXFILESIZE
always returns CURLE_OK and that CURLOPT_MAXFILESIZE_LARGE only returns
CURLE_OK or CURLE_UNKNOWN_OPTION.

It also did not mention what the default value is, which is zero. This
commit updates the documentation to make note of all these things.

Closes #13372
2024-04-15 13:38:27 +02:00
Toon Claes
0f7be5a519
docs: add CURLOPT_NOPROGRESS to CURLOPT_XFERINFOFUNCTION example
It's important to set `CURLOPT_NOPROGRESS` to `0` if you want your
transfer callback function, set by `CURLOPT_XFERINFOFUNCTION`, getting
called. To emphasize this to the users, add this to the code example.

Closes #13348
2024-04-11 15:59:53 +02:00
Colin Leroy-Mira
bfe54b0e88
file: add support for getting basic directory listings
Not supported on Windows (yet)

Closes #13137
2024-04-11 12:37:12 +02:00
Viktor Szakats
3d569aaaf8
cmake: use namespaced custom target names
Rename custom target to namespaced (unique) names to avoid colliding
with 3rd-party projects (e.g. libzip) built together with curl.

Reported-by: hammlee96 on github
Fixes #13324
Closes #13326
2024-04-09 21:20:54 +00:00
Daniel Stenberg
187b23b0a4
curl_multi_waitfds.md: add protocol mention
Follow-up to 02beac6bb6
2024-04-09 16:59:28 +02:00
Dmitry Karpov
02beac6bb6
lib: add curl_multi_waitfds
New function call, similar to curl_multi_fdset()

Closes #13135
2024-04-09 16:53:40 +02:00
Daniel Stenberg
50def7c881
NTLM_WB: drop support
The feature has not worked for months and has been marked as DEPRECATED
for six+ months.

Closes #13249
2024-04-08 13:58:58 +02:00
Stefan Eissing
0b28ece657
lib: add trace support for client reads and writes
- add `CURL_TRC_READ()` and `CURL_TRC_WRITE()`
- use in generic client writers and readers, as well
  as http headers, chunking and websockets

Closes #13223
2024-04-05 16:08:10 +02:00
Viktor Szakats
bb84f82476
cmake: speed up libcurl doc building again
This time limit the number of files per command to avoid exceeding
limitations of certain OS/shell envs.

Such known env is Windows with the `cmd.exe` shell, which features an
8K command-line length limit to this day.

Allowlisting `UNIX` to have no limit and using a limit of 200 for other
envs to be safe. If there is a way to detect `cmd.exe` and/or we know
which precise envs are sensitive to this, we can tweak these conditions
further.

Even with the low limit, this patch reduces external commands by 200x,
making builds much faster.

Ref: #12762 2620aa930b (initial)
Ref: #13047 f03c85635f (revert)

Reviewed-by: Daniel Stenberg
Closes #13207
2024-04-04 09:21:17 +00:00
Daniel Stenberg
df3d5ef25e
curl_global_trace.md: shorten the description
Closes #13263
2024-04-02 23:39:39 +02:00
Daniel Stenberg
6afac4f992
libcurl-opts: mention pipelining less
libcurl has not supported HTTP pipelining since many years. Remove a few
(more) mentions of the feature.

Closes #13254
2024-04-01 14:41:52 +02:00
Daniel Stenberg
1b2978403f
CURLOPT_POSTFIELDS.md: used for MQTT as well
Closes #13189
2024-03-26 14:09:06 +01:00
Daniel Stenberg
e3fe020089
docs/libcurl: generate PROTOCOLS from meta-data
Remove the PROTOCOLS section from the source files completely and
instead generate them based on the header data in the curldown files.

It also generates TLS backend information for options marked for TLS as
protocol.

Closes #13175
2024-03-23 18:13:03 +01:00
Daniel Stenberg
7bc61bf469
CURLMOPT_MAX*: mention what happens if changed mid-transfer
For CURLMOPT_MAXCONNECTS and CURLMOPT_MAX_HOST_CONNECTIONS

Ref: #13158
Closes #13176
2024-03-23 11:31:36 +01:00