Commit graph

7554 commits

Author SHA1 Message Date
Josef Cejka
ba600296d2
http: prefer chunked encoding over Content-Length: 0
Call http_size() before checking the request for empty body to prefer
Transfer-Encoding: chunked even if Content-Length is 0.

Closes #21706
2026-06-01 23:40:28 +02:00
Viktor Szakats
28341c303d
lib505: tidy up slist pointer use
Bring code closer to `curl_slist_append()` man page and clarify variable
names.

Closes #21835
2026-06-01 23:36:04 +02:00
Viktor Szakats
4e98f6d225
units: drop redundant pointer check and workaround
All users of the `verify_memory()` macro used a fixed-length buffer for
the test output, which then needed a workaround to silence GCC
`-Waddress` warnings.

```
tests/unit/unit1615.c: In function 'test_unit1615':
tests/libtest/unitcheck.h:51:8: error: the address of 'output_buf' will always evaluate as 'true' [-Werror=address]
   51 |     if((dynamic) && memcmp(dynamic, check, len)) {                          \
      |        ^
tests/unit/unit1615.c:114:3: note: in expansion of macro 'verify_memory'
  114 |   verify_memory(output_buf, precomp_hash1, CURL_SHA512_256_DIGEST_LENGTH);
      |   ^~~~~~~~~~~~~
```

Drop redundant address check and the workarounds with it.

Closes #21833
2026-06-01 22:36:40 +02:00
Viktor Szakats
d229055549
tidy-up: miscellaneous
- drop more uses of the word "just". (not enforced here)
- drop some uses of the "will" word.
- "then" -> "than".
- tests/http/testenv/curl.py: fix copy-paste typo in error message.
- pytest: replace `shutdownh` with `shutdown` in test names.
  Spotted by GitHub Code Quality.
- comment typos.
- whitespace and newlines fixes.

Closes #21830
2026-06-01 22:33:57 +02:00
Stefan Eissing
032b15c434
cf-setup: improve readability
Restructure the code in cf-setup connect to make it better readable what
is happening for establishing the connection's filter chain.

Closes #21827
2026-06-01 16:47:24 +02:00
Viktor Szakats
5364e6e60e
cmake: add basic way to select pytests to run
Not documented and experimental, example:
`-D_CURL_PYTEST=/test_60_h3_proxy.py`

Ideally, this should be an env like `TFLAGS` and it should allow
selecting any test ID or a group of them, but so far could not figure
out how even a basic env could work.

Closes #21818
2026-06-01 15:07:17 +02:00
Viktor Szakats
2802e65f6d
pytest: pass --disable to curl
To avoid a local `.curlrc` interfering with tests.

Closes #21816
2026-06-01 15:07:17 +02:00
Viktor Szakats
d806323ffd
pytest: fixes and tidy-ups to h3-proxy tests
- merge tests into a single class.
  For shorter names, to fix sort order by test number, and to align with
  other tests.
- fix preconditions to make `test_60_04_guard_proxy_http3_unsupported`
  actually run.
- replace local precondition with constant of the same effect.
- drop redundant non-`ngtcp2` requirement for
  `test_60_04_guard_proxy_http3_unsupported`.
  (seemed relevant for no longer supported openssl-quic builds.)
- drop unused `NGTCP2_ONLY_MSG` constant.
  Follow-up to e4139a73c8 #21798
- avoid creating unnecessary test data blobs, and minimize their scopes.

Follow-up to 91facd7bb3 #21791
Follow-up to e78b1b3ecc #21153

Closes #21811
2026-06-01 15:07:17 +02:00
Daniel Stenberg
872c313d76
lib1560: drop unused variable 'url'
Spotted by Copilot

Closes #21821
2026-06-01 09:50:49 +02:00
Stefan Eissing
d3391229b0
vtls_config: adjust to origin
When a transfer goes against another origin than the initial one, do not
add the following to the ssl configuration: client cert, client key, srp
user/pass, pinned key.

Closes #21695
2026-06-01 09:39:17 +02:00
Daniel Stenberg
4beffe7737
Revert "tool: add a retry delay for transfers to same origin on 429"
This reverts commit c5fb460e7c.

This needs some further work before we can do this.

Fixes #21822
Closes #21824
2026-06-01 09:28:31 +02:00
htasta
c5fb460e7c
tool: add a retry delay for transfers to same origin on 429
Closes #21355
2026-06-01 08:40:58 +02:00
Daniel Stenberg
1b6724882c
urlapi: accept 0X prefix in IPv4 address as well
Extend test 1560 accordingly

Closes #21820
2026-05-31 23:44:30 +02:00
tiymat
780ccb256e
urlapi: drop base fragment on empty redirect
Extended test 1560 to verify

Fixes #21745
Closes #21763
2026-05-31 23:36:16 +02:00
Stefan Eissing
4ff212f8ed
url: connection reuse fixes for starttls
Add test_31_13 to check connection reuse on mixed --ssl-reqd setting.
For that add debug env var CURL_DBG_NO_USE_SSL_ON_FIRST to disable
--ssl-reqd for the first url. Check that the connection without SSL
from the first url is not reused on the second URL that requires it.

Tweak special ftp: protocol check to fail a DEBUGASSERT on mismatched
`use_ssl` settings as that should have been caught before in the
connection reuse matching (imap/smtp etc. do not have this extra check
and rely on the general part doing its job).

Closes #21665
2026-05-31 23:29:15 +02:00
Stefan Eissing
24874a4f04
scorecard: add support for http: testing
Add option `--http-plain` to test against httpd without
using TLS.

Closes #21805
2026-05-31 16:58:11 +02:00
Viktor Szakats
6ac42e5691
h3-proxy: disable frequently failing pytests
- test_60_02_connect_tunnel_fail[fail_h1_over_h3_proxytunnel]
- test_60_02_connect_tunnel_fail[fail_h3_over_h2_proxytunnel]
- test_60_02_connect_tunnel_fail[fail_h3_over_h3_proxytunnel]
- test_60_03_h3_target_auto_connect_udp[proxy_h3]
- test_60_15_connect_timeout

Further flaky ones may be disabled in future commits.
All to be re-enabled after stabilizing them.

Follow-up to 59213f8248 #21789
Follow-up to e78b1b3ecc #21153

Closes #21803
2026-05-29 00:15:47 +02:00
Viktor Szakats
c37405cb06
h3-proxy: fix callback return values, and a typo in tests
- replace literal -1 with `NGHTTP3_ERR_CALLBACK_FAILURE` in nghttp3
  callback.
- replace `NGHTTP3_ERR_CALLBACK_FAILURE` with
  `NGTCP2_ERR_CALLBACK_FAILURE` in ngtcp2 callbacks.
- test_60_h3_proxy: fix non-critical typo in symbol.

Spotted by GitHub Code Quality

Follow-up to e78b1b3ecc #21153

Closes #21802
2026-05-28 23:32:33 +02:00
Daniel Stenberg
5e66176733
http: don't pass on set cookies to new origins
Verified by test 2015

Reported-by: azraelxuemo on hackerone

Closes #21794
2026-05-28 17:45:04 +02:00
Stefan Eissing
e4139a73c8
h3-proxy: fixes around H3 proxy
code:
- less exception handling in existing code
- true ip happy eyeballing
- enable certificate verification
- cf-h2-proxy: abort connection when server closed connection

tests:
- remove all --insecure and --proxy-insecure args
- make session reuse test_60_12 a working one
- resolve port conflicts between h2o and nghttpx
- use proxy args better
- make test_60_06 run shorter
- kill h2o at the end of tests, normal stop takes too long

Ref: 59213f8248 #21789
Follow-up to e78b1b3ecc #21153

Closes #21798
2026-05-28 14:41:27 +02:00
Viktor Szakats
cfa735c40a
h3-proxy: rename feature 'Proxy/PROXY-HTTP3' to 'proxy-HTTP3'
For consistency and to follow existing 'HTTPS-proxy' (with lowercase
'proxy') feature tag more closely.

Follow-up to e78b1b3ecc #21153

Closes #21796
2026-05-28 12:52:50 +02:00
Aritra Basu
91facd7bb3
tests/http: fix HTTP/3 proxy pytest failures with h2o
Fix pytest failures in HTTP/3 proxy tests when h2o is not installed,
misconfigured, or fails to start at runtime.

This prevents:
- FileNotFoundError when h2o document root does not exist
- Fixture setup errors when h2o is configured but cannot start
- Unused test data file creation when h2o is absent or broken
- CI aborts on systems where h2o exists but is not runnable

Bug: https://github.com/curl/curl/pull/21789#issuecomment-4559098879
Bug: https://github.com/curl/curl/pull/21789#issuecomment-4559161907

Follow-up to e78b1b3ecc #21153

Closes #21791
2026-05-28 10:38:58 +02:00
Viktor Szakats
9591ff123d
tidy-up: add space around operators, where missing
Closes #21793
2026-05-28 10:12:00 +02:00
tiymat
f1959ae962
urlapi: fix an issue parsing file URLs
Fixes #21743
Closes #21764
2026-05-28 08:49:56 +02:00
Daniel Stenberg
d1b482caec
unit3400: repair after capsule_encap_udp_hdr went static
Access the static function with UNITTEST as designed.

Follow-up to 73c2b4b435

Closes #21788
2026-05-28 00:13:24 +02:00
Viktor Szakats
59320082b0
tidy-up: apply clang-format fixes
To lib, vtls/vauth, vtls/vquic, lib/vtls.

Also:
- unit3400: drop redundant `(void)arg`.
  Follow-up to e78b1b3ecc #21153
- fix comment typos.

Closes #21786
2026-05-28 00:05:47 +02:00
Viktor Szakats
cdb266738b
pytest: re-enable test test_05_01 and test_05_02 for quiche 0.29.0+
The upstream issue seems to have been fixed or mitigated in quiche
v0.29.0. Though the original upstream report and patch remain open at
the time of writing this.

Ref: https://github.com/cloudflare/quiche/issues/2277
Ref: https://github.com/cloudflare/quiche/pull/2278

Follow-up to 252b82f693 #21730
Follow-up to 91b422d356 #20952
Follow-up to 14478429e7 #19916

Closes #21784
2026-05-27 23:27:04 +02:00
Viktor Szakats
15356f0d36
lib1560: fix to propagate failure from get_nothing()
Also:
- check `curl_url()` for NULL where missing.
- free memory `curl_url_get()` return pointer where missing.
- propagate `curl_url_set()` errors in `clear_url()`, where missing.
- add missing NULL-check before `strcmp()` in `clear_url()`.

Closes #21780
2026-05-27 23:26:20 +02:00
Viktor Szakats
7e1001bcd6
tidy-up: miscellaneous
- H3 proxy: re-sync code with original source `curl_ngtcp2.c` to reduce
  differences, and to apply missed minor fixes. Also apply clang-format.
  Drop redundant `#undef`s, casts, `#endif` comments, includes, drop
  intermediate variables, sync include and macro order.
  Follow-up to e78b1b3ecc #21153
- INSTALL-CMAKE.md: move `CURL_ENABLE_SMB` to the enable section.
- tests/http/env: rename `tcpdmp` to `tcpdump` to match object variable.
- mbedtls: drop incorrect `mbedTLS 4+` comments.
  (features are also supported by 3+, meaning it's always supported.)
- lib1648: rename a variable to match purpose.
- CIPHERS.md: alpha-sort link list.
- replace rare `X''` hex markup with `0x`.
- `IP v4/6` -> `IPv4/6`.
- 'version X.Y' -> 'vX.Y', where sensible.
- 'VX.Y' -> 'vX.Y', where sensible.
- fix indents, casing, newlines, typos.

Closes #21772
2026-05-27 16:53:57 +02:00
Stefan Eissing
049ec8a363
content_encoding: fix limit failure message
The message triggered earlier than intended and did not take the
transfer/content type into account.

Ref #21603
Reported-by: Joshua Rogers
Closes #21756
2026-05-27 09:50:34 +02:00
tiymat
a8e6f90a69
urlapi: forbid '|' in host
Closes #21762
2026-05-27 09:39:37 +02:00
Aritra Basu
e78b1b3ecc
HTTP/3: add proxy CONNECT and MASQUE CONNECT-UDP support (ngtcp2 QUIC)
This patch adds two major proxy capabilities to curl (ngtcp2 QUIC):
- HTTP/3 Proxy CONNECT: Tunnel HTTP/1.1 or HTTP/2 traffic through an
  HTTPS proxy that speaks HTTP/3 (QUIC) using the standard CONNECT
  method over an HTTP/3 connection.
- MASQUE CONNECT-UDP: Tunnel HTTP/3 (QUIC) traffic through an HTTP
  proxy (speaking HTTP/1.1, HTTP/2, or HTTP/3) using the extended
  CONNECT method with the CONNECT-UDP protocol (RFC9297 & RFC9298).

Public API additions:
- `CURLPROXY_HTTPS3`: new proxy type constant for HTTP/3 proxy
- `--proxy-http3`: new CLI flag to negotiate HTTP/3 with HTTPS proxy

The implementation adds two new filters:
- `H3-PROXY` - enables negotiating HTTP/3 (QUIC) to the proxy and
  running CONNECT/CONNECT-UDP through that proxy transport.
- `CAPSULE` - dedicated filter inserted between QUIC transport and
  HTTP-PROXY to handle datagram capsule encapsulation/decapsulation.

Here is how the curl filter chaining looks in different scenarios:
- HTTP/3 Proxy CONNECT (tunneling TCP protocols over QUIC proxy):
  conn -> HTTP/1.1 or HTTP/2  -> SSL -> HTTP-PROXY ->
                                 H3-PROXY -> HAPPY-EYEBALLS -> UDP
- MASQUE CONNECT-UDP (tunneling QUIC over any proxy):
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H3-PROXY ->
                               HAPPY-EYEBALLS -> UDP
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H1-PROXY or H2-PROXY ->
                               SSL -> HAPPY-EYEBALLS -> TCP

- Both features currently require the ngtcp2 QUIC backend.
- Both features are experimental (disabled by default). Enable with
  `--enable-proxy-http3`(autotools) or `-DUSE_PROXY_HTTP3=ON`(CMake).

Tests:
- tests/unit/unit3400.c: Unit tests for capsule protocol encode/decode
- tests/http/test_60_h3_proxy.py: Comprehensive pytest integration suite
- tests/http/testenv/h2o.py: Managing h2o instances with HTTP/1.1, HTTP/2,
  and HTTP/3 (QUIC) listeners, proxy.connect and proxy.connect-udp enabled.

References:
  RFC 9297 - HTTP Datagrams and the Capsule Protocol
  RFC 9298 - Proxying UDP in HTTP
  RFC 9000 §16 — Variable-Length Integer Encoding

Signed-off-by: Aritra Basu <aritrbas+gh@cisco.com>

Closes #21153
2026-05-27 08:49:53 +02:00
Stefan Eissing
90a7732d46
test1981: explicitly set the locale
Otherwise we may get a different month name in the output.

Closes #21749
2026-05-26 21:59:48 +02:00
Stefan Eissing
f27233e984
GnuTLS: require 3.7.2 for earlydata
Since all API features we need for TLSv1.3 earlydata support do exist
only from version 3.7.2 onwards, make that the minimal version required.

Fixes #21750
Reported-by: Johannes Schlatow
Closes #21751
2026-05-26 13:41:21 +02:00
Daniel Stenberg
862e8a74a8
transfer: clear referer when set to NULL
Verify in test 1649

Closes #21741
2026-05-26 10:04:40 +02:00
Viktor Szakats
252b82f693
quiche: bump cloudflare/quiche to v0.29.0, update pytest workaround
Also:
- drop no longer necessary quiche build workaround.
- update build for boringssl's new location (since v0.29.0, it's no
  longer vendored) within the quiche tree.
- move boringssl install dir out of quiche tree, and shorten it.

Ref: https://github.com/cloudflare/quiche/issues/2277
Ref: https://github.com/cloudflare/quiche/pull/2278
Ref: #21620

Closes #21730
2026-05-24 14:16:38 +02:00
Daniel Stenberg
7e350dd147
urlapi: fix redirect handling if CURLU_NO_GUESS_SCHEME is set
Verified by test 1967

Reported-by: Joshua Rogers
Closes #21721
2026-05-22 07:48:20 +02:00
Viktor Szakats
bb5500a752
units: tidy up begin/end blocks
- use `UNITTEST_BEGIN_SIMPLE`/`UNITTEST_END_SIMPLE` where missing.
- drop redundant `(void)arg;` where using `UNITTEST_BEGIN*`.
- unit1636: drop redundant block after `UNITTEST_BEGIN*`.
- unit1609: fix typo in comment.
- unit1627: merge to `if`s.

Closes #21715
2026-05-21 17:28:38 +02:00
Viktor Szakats
af511a22cb
test1185: fix to previous commit
Follow-up to 419b1c0b75 #21703
2026-05-21 11:24:30 +02:00
Viktor Szakats
419b1c0b75
checksrc: detect curlx_safefree() opportunities
Follow-up to bcd0497c81 #21700
Follow-up to 1c3289c85e #21684
Follow-up to c0f0e400e0 #5968
Follow-up to 0f4a03cbb6

Closes #21703
2026-05-21 11:07:34 +02:00
Viktor Szakats
bcd0497c81
tidy-up: use curlx_safefree()
Closes #21700
2026-05-21 01:31:03 +02:00
Dan Fandrich
d3b04e5600 tests: add an assert to avoid IPC blocking
If so much data is being sent over the internal IPC pipe that the pipe
buffer fills and the syscall blocks, the program will hang. Add an
assert to ensure that this limit is never reached. The buffer size is
going to be different on different platforms, so choose 1KB which is
likely to be a reasonable lower bound on just about any system.
Currently, the maximum amount ever written is <100 bytes, so this should
provide plenty of headroom.

Spotted by Codex Security

Closes #21688
2026-05-20 11:32:38 -07:00
Daniel Stenberg
88c7e16cce
setopt: clear proxy auth properly on NULL
Verify NULLed proxy credentials with test1648

Closes #21696
2026-05-20 15:54:41 +02:00
Stefan Eissing
77e4e5b86d
websockets: auto-tunnel through http proxy
When using a ws: or wss: url with a http proxy, automatically
switch to tunneling operation mode.

Add test_20_10 to check.

Fixes #21663
Closes #21691
2026-05-20 11:50:35 +02:00
Viktor Szakats
68e0b13209
runner.pm: apply minor correctness fix
"Lines 244-245 overwrite global variables `$runnerr` and `$runnerw` that
were already assigned in the child process (lines 205-206). In the
parent process context, these assignments appear incorrect and could
cause issues if `runner_init` is called multiple times. The parent
should only store references in the controller hashes."

It could never cause an actual issue, but clarifies the intent of the
code.

Spotted and fixed by GitHub Code Quality

Cherry-picked from #21646

Closes #21672
2026-05-20 03:14:26 +02:00
Viktor Szakats
b3f76b21c9
tidy-up: miscellaneous
- fix typos and wording in documentation and comments.
- KNOWN_BUGS: merge duplicate H1 section.
- test_10_proxy: delete stray expressions.
- Perl: `while()` -> `while(1)`.
- Perl: fix indent, whitespace, drop redundant quotes and parentheses.
- fix casing: URL, SSL, Windows.
- badwords: readd `threadsafe`, add `well-known` (and fix it).
- replace `WinXP` -> `Windows XP` to match other uses.

Closes #21646
2026-05-20 00:50:43 +02:00
Viktor Szakats
1c3289c85e
unit3303, unit3304: tidy-ups
- use `curlx_safefree()`.
- drop redundant blocks.

Follow-up to 7541ae569d #21667

Closes #21684
2026-05-20 00:48:54 +02:00
Joshua Rogers
7541ae569d
tls: fix incomplete mTLS config in conn reuse and session cache
cert_type, key, key_type, key_passwd and key_blob lived in
ssl_config_data but not in ssl_primary_config, so they were invisible to
match_ssl_primary_config() and to the TLS session cache peer key.

Two easy handles sharing a connection pool could reuse each other's
authenticated connections when they differed only on SSLKEY, SSLKEYTYPE,
KEYPASSWD, SSLCERTTYPE or SSLKEYBLOB. The second handle would silently
inherit the first handle's authenticated identity.

Promote all five fields into ssl_primary_config so the conn-reuse
predicate and session cache key cover the complete client credential
set. Also replace the fixed ":CCERT" session cache marker with the
actual clientcert path so sessions are not shared across different
client certificates.

Verified by test 3303 and 3304

Reported-By: Joshua Rogers (AISLE Research)
Closes #21667
2026-05-20 00:02:33 +02:00
Daniel Stenberg
5c225384b8
url: detect proxy changes read from environment
When a proxy is set from an environment variable, detect if that proxy
is not the same as previously and flush state.

Verified by test1647: verify changing proxy with env variables and make
sure Digest state is flushed in the second use

Closes #21666
2026-05-19 17:14:16 +02:00
Viktor Szakats
000de81fb1
tidy-up: rename more CURLcode variables to result
Follow-up to 885b553545 #21348

Closes #21676
2026-05-19 16:55:45 +02:00