Daniel Stenberg [Fri, 16 May 2025 21:18:34 +0000 (23:18 +0200)]
formdata: cleanups
- use memchr() instead of for() loop
- add and use free_formlist() instead of duplicate code
- shorten some variable names
- reduce flag struct field from 'long' to 'unsigned char'
- pass in struct pointer, not individual fields, to addhttppost()
Stefan Eissing [Fri, 16 May 2025 08:38:13 +0000 (10:38 +0200)]
asnyc-thrdd: explain how this is okay with a comment
Coverity assess correctly that a variable write under mutex lock could
overwrite values from another thread - if the function were ever called
from multiple thread for the same transfer - which it is not.
Stefan Eissing [Mon, 12 May 2025 13:49:49 +0000 (15:49 +0200)]
pytest-xdist: pytest in parallel
Require now pytest-xdist from tests/http/requirements.txt and
run pytest in 'auto' parallel mode (counts cpu cores).
For CI runs, set the worker count to 4, overriding the
core count of 2 exposed in the images.
- use Filelock to generate allocated ports at start for all
workers and have subsequent workers just read the file and
take the ports for their slot
- make httpd config clearing a function fixture so every test
starts with a clean httpd config
- have fixture `configures_httpd` as parameter of test cases
that configure httpd anyway, saving one reload
- add pytest-xdist and filelock to required pyhton modules
- add installs to ruff CI
- give live checks waiting for a server to start up longer time
- add fixtures to tests that rely on a server
- do not stop servers unnecessarily. failures may not start them
properly again, leading to unexpected fails in whatever follows
- add a https: port to httpd that is *not* back by QUIC to allow
failover tests without stopping the QUIC server
Daniel Stenberg [Thu, 15 May 2025 07:49:47 +0000 (09:49 +0200)]
tool_operate: move config2setopts to separate file, split into subs
To decrease size and complexity. Complexity taken down from 190 to 80.
Bonus:
- remove leftover HTTP/0.9 warning never triggered since hyper was dropped
- remove the ftp-skip-ip option unless FTP is used
- only set HTTP options if HTTP(S) is used
- remove use of the pointless SETOPT_CHECK macro
Side-effect:
- The order of the options in --libcurl is modified
Daniel Stenberg [Mon, 12 May 2025 10:55:20 +0000 (12:55 +0200)]
CONTRIBUTE: add project guidelines for AI use
Feedback-by: Daniel Fosco Feedback-by: Jimmy Sjölund Feedback-by: Christoph Jabs Feedback-by: Manuel Strehl Feedback-by: Dan Fandrich Feedback-by: Sarah Gooding
Closes #17325
Stefan Eissing [Thu, 15 May 2025 08:48:12 +0000 (10:48 +0200)]
ngtcp2: clarify ignoring of result
In shutdown, the result of a bufq_write() is intentionally ignored, but
it was not obvious why. Add a (void) cast to declare intent and a
comment explaining why.
Dan Fandrich [Tue, 13 May 2025 23:14:57 +0000 (16:14 -0700)]
scripts: move the ruff linter command into a script
This makes it easier for users to run it with the correct options
locally. Also, update the ruff, pytype and cmakelint versions to the
latest current ones.
Viktor Szakats [Tue, 13 May 2025 09:11:55 +0000 (11:11 +0200)]
spacecheck.pl: drop more exceptions
- replace ß (scharfes S) with links.
- replace § (section sign) with links.
- replace 🙏 emoji with `:pray:`.
Supported by GitHub, Forgejo/Gitea and most likely GitLab.
- docs/libcurl/curl_mprintf.md: replace Unicode ± with `{+|-}`.
- docs/CIPHERS.md: URL encode Unicode in URLs.
- lib1560: use hex encoding in `räksmörgås.se`.
- unit1307: use hex encoding in `Lindmätarv`.
- drop LATIN SMALL LETTER A WITH ACUTE exception.
No longer appears in tests.
This leaves the single character exception: `ö`
And file exceptions holding contributor names.
Daniel Stenberg [Tue, 13 May 2025 09:25:43 +0000 (11:25 +0200)]
setopt: provide info for CURLE_BAD_FUNCTION_ARGUMENT
If CURLE_BAD_FUNCTION_ARGUMENT is returned and failf() has not provided
any details, this adds a generic error string that includes the option
number.
This helps debugging for example the curl tool which does a lot of
setopt calls and in reading post fact logs it is not always easy to tell
exactly which call that failed.
Daniel Stenberg [Mon, 12 May 2025 20:48:47 +0000 (22:48 +0200)]
tests/server: stop using libcurl string comparisons
Further untangle the test server code from curl code. While the string
comparison functions are available in the libcurl API, the tests servers
don't link with libcurl. Use native functions instead.
Dan Fandrich [Wed, 7 May 2025 06:39:22 +0000 (23:39 -0700)]
test1621: Improve stripcredentials tests
- add more unusual input cases
- add a valid non-http protocol
- fix tests so an input that should be stripped but isn't is a failure
- fix detection of when stripcredentials() would be available to test
- avoid using a NULL pointer
Viktor Szakats [Fri, 9 May 2025 13:18:51 +0000 (15:18 +0200)]
windows: fix to preserve error code in `curlx_winapi_strerror()`
Drop the interim macro `PRESERVE_WINDOWS_ERROR_CODE` and always preserve
error code for `_WIN32`. To make sure this is always done in
`curlx_winapi_strerror()`.
Viktor Szakats [Thu, 8 May 2025 11:09:29 +0000 (13:09 +0200)]
cmake: test integration with old cmake (v3.11.4 2018-03-28)
Tests with old cmake are slow. (no Ninja, no unity, and running slower
than recent versions.)
It also revealed that 3.7.2 2017-01-13 is too old to consume curl via
`find_package()` due to:
```
CMake Error at bld-curl/_pkg/lib/cmake/CURL/CURLConfig.cmake:69 (add_library):
add_library cannot create ALIAS target "CURL::libcurl" because target
"CURL::libcurl_shared" is IMPORTED.
Call Stack (most recent call first):
CMakeLists.txt:48 (find_package)
CMake Error at bld-curl/_pkg/lib/cmake/CURL/CURLConfig.cmake:69 (add_library):
add_library cannot create ALIAS target "CURL::libcurl" because target
"CURL::libcurl_shared" is IMPORTED.
Call Stack (most recent call first):
CMakeLists.txt:49 (find_package)
```
The mitigation for this issue requires 3.11.
Also:
- rename a few existing envs to use the `TEST_` prefix.
- make the `find_package` test provider stage verbose.
- fix issue when consuming with cmake 3.7.2 (all platforms):
```
CMake Error at /home/runner/cmake-3.7.2-Linux-x86_64/share/cmake-3.7/Modules/CMakeFindDependencyMacro.cmake:25 (message):
Invalid arguments to find_dependency. VERSION is empty
Call Stack (most recent call first):
bld-curl/_pkg/lib/cmake/CURL/CURLConfig.cmake:52 (find_dependency)
CMakeLists.txt:48 (find_package)
```
Ref: https://github.com/curl/curl/actions/runs/14906066962/job/41868621979?pr=17293#step:9:1199
Daniel Stenberg [Wed, 7 May 2025 09:00:59 +0000 (11:00 +0200)]
curlx: move into to curlx/
Move curlx_ functions into its own subdir.
The idea is to use the curlx_ prefix proper on these functions, and use
these same function names both in tool, lib and test suite source code.
Stop the previous special #define setup for curlx_ names.
The printf defines are now done for the library alone. Tests no longer
use the printf defines. The tool code sets its own defines. The printf
functions are not curlx, they are publicly available.
The strcase defines are not curlx_ functions and should not be used by
tool or server code.
dynbuf, warnless, base64, strparse, timeval, timediff are now proper
curlx functions.
When libcurl is built statically, the functions from the library can be
used as-is. The key is then that the functions must work as-is, without
having to be recompiled for use in tool/tests. This avoids symbol
collisions - when libcurl is built statically, we use those functions
directly when building the tool/tests. When libcurl is shared, we
build/link them separately for the tool/tests.
Viktor Szakats [Tue, 6 May 2025 23:29:32 +0000 (01:29 +0200)]
cmake: set `BUILDING_LIBCURL` directly for unit test targets
To avoid adding this macro to the global `CURL_DEBUG_MACROS` variable,
which may be used for targets defined after unit tests, and where this
macro may not be necessary.
As of this commit unit tests are defined last, so extending the global
variable did not cause any issue.
Jay Satiro [Tue, 6 May 2025 21:47:37 +0000 (17:47 -0400)]
generate.bat: exclude curlinfo.c from legacy VS projects
- Do not include curlinfo.c as a ClCompile unit when compiling the curl
tool.
Prior to this change generate.bat would add curlinfo.c to the source
files for the curl tool because it is located in the src directory. That
caused ambiguous behavior in legacy versions of Visual Studio which had
to guess between two main entry points (one in curlinfo and one in
tool_main, the latter being correct).
Daniel Stenberg [Tue, 6 May 2025 13:03:46 +0000 (15:03 +0200)]
tests: separate tunit tests from unit tests more
- unit tests need no tool code as they are libcurl unit tests
- unit test 1621 is now tunit test 1621 instead, as it tests tool code
- build unit tests with BUILDING_LIBCURL as they pretent to be libcurl