Stefan Eissing [Fri, 14 Apr 2023 09:38:14 +0000 (11:38 +0200)]
http2: support HTTP/2 to forward proxies, non-tunneling
- with `--proxy-http2` allow h2 ALPN negotiation to
forward proxies
- applies to http: requests against a https: proxy only,
as https: requests will auto-tunnel
- adding a HTTP/1 request parser in http1.c
- removed h2h3.c
- using new request parser in nghttp2 and all h3 backends
- adding test 2603 for request parser
- adding h2 proxy test cases to test_10_*
scorecard.py: request scoring accidentally always run curl
with '-v'. Removed that, expect double numbers.
labeller: added http1.* and h2-proxy sources to detection
Daniel Stenberg [Thu, 13 Apr 2023 11:52:08 +0000 (13:52 +0200)]
url: fix PVS nits
- expression 'hostptr' is always true
- a part of conditional expression is always true: proxypasswd
- expression 'proxyuser' is always true
- avoid multiple Curl_now() calls in allocate_conn
Stefan Eissing [Thu, 13 Apr 2023 15:46:52 +0000 (17:46 +0200)]
cf-socket: Disable socket receive buffer by default
- Disable socket receive buffer unless USE_RECV_BEFORE_SEND_WORKAROUND
is in place.
While we would like to use the receive buffer, we have stalls in
parallel transfers where not all buffered data is consumed and no socket
events happen.
Note USE_RECV_BEFORE_SEND_WORKAROUND is a Windows sockets workaround
that has been disabled by default since b4b6e4f1, due to other bugs.
Stefan Eissing [Thu, 13 Apr 2023 10:04:27 +0000 (12:04 +0200)]
cf-h2-proxy: fix processing ingress to stop too early
- progress ingress stopped too early, causing data
from the underlying filters to not be processed and
report that no tunnel data was available
- this lead to "hangers" where no socket activity was
seen but data rested in buffers
Stefan Eissing [Thu, 13 Apr 2023 09:03:50 +0000 (11:03 +0200)]
http3: check stream_ctx more thoroughly in all backends
- callbacks and filter methods might be invoked at unexpected
times, e.g. when the transfer's stream_ctx has not been initialized
yet or, more likely, has already been taken down.
- check for existance of stream_ctx in such places and return
an error or silently succeed the call.
Stefan Eissing [Thu, 30 Mar 2023 11:25:20 +0000 (13:25 +0200)]
cf-socket: add socket recv buffering for most tcp cases
- use bufq as recv buffer, also for Windows pre-receive handling
- catch small reads followed by larger ones in a single socket
call. A common pattern on TLS connections.
Daniel Stenberg [Tue, 11 Apr 2023 15:06:54 +0000 (17:06 +0200)]
urlapi: cleanups
- move host checks together
- simplify the scheme parser loop and the end of host name parser
- avoid itermediate buffer storing in multiple places
- reduce scope for several variables
- skip the Curl_dyn_tail() call for speed
- detect IPv6 earlier and skip extra checks for such hosts
- normalize directly in dynbuf instead of itermediate buffer
- split out the IPv6 parser into its own funciton
- call the IPv6 parser directly for ipv6 addresses
- remove (unused) special treatment of % in host names
- junkscan() once in the beginning instead of scattered
- make junkscan return error code
- remove unused query management from dedotdotify()
- make Curl_parse_login_details use memchr
- more use of memchr() instead of strchr() and less strlen() calls
- make junkscan check and return the URL length
An optimized build runs one of my benchmark URL parsing programs ~41%
faster using this branch. (compared against the shipped 7.88.1 library
in Debian)
Dan Fandrich [Wed, 5 Apr 2023 19:28:26 +0000 (12:28 -0700)]
tests: turn perl modules into full packages
This helps enforce more modularization and encapsulation. Enable and fix
warnings on a few packages. Also, rename ftp.pm to processhelp.pm since
there's really nothing ftp-specific in it.
V220 Suspicious sequence of types castings: memsize -> 32-bit integer ->
memsize. The value being cast: 'sizeof
(buf->data)'. curl\lib\vtls\vtls.c 2025
Dan Fandrich [Mon, 10 Apr 2023 18:05:55 +0000 (11:05 -0700)]
test1169: fix so it works properly everywhere
- Use an absolute path for the -L option since the module isn't in the
perl path
- Create the needed test file in a <file> section; <precheck> isn't
intended for this
- Fix the test number in the file name, which was wrong
Dan Fandrich [Mon, 10 Apr 2023 17:35:04 +0000 (10:35 -0700)]
tests: stop using strndup(), which isn't portable
It's not available on Solaris 10, for example. Since this is just test
code that doesn't need to use an optimized system version, replace it
with the implementation copied from tool_cb_hdr.c.
Daniel Stenberg [Sat, 8 Apr 2023 22:38:00 +0000 (00:38 +0200)]
urlapi: prevent setting invalid schemes with *url_set()
A typical mistake would be to try to set "https://" - including the
separator - this is now rejected as that would then lead to
url_get(... URL...) would get an invalid URL extracted.
Stefan Eissing [Thu, 6 Apr 2023 09:19:46 +0000 (11:19 +0200)]
tests: increase sws timeout for more robust testing
- for https CONNECT forwarding, this was fixed at 5 seconds
which led to spurious CI test failures
- add --keepalive parameter to sws to control this
- let httpserver use 30 seconds
Stefan Eissing [Thu, 6 Apr 2023 09:59:12 +0000 (11:59 +0200)]
http2: move HTTP/2 stream vars into local context
- remove NGHTTP2 members of `struct HTTP`
- add `void *h2_ctx` to `struct HTTP`
- add `void *h3_ctx` to `struct HTTP`
- separate h2/h3 pointers are needed for eyeballing
- manage local stream_ctx in http implementations
Stefan Eissing [Thu, 6 Apr 2023 07:54:57 +0000 (09:54 +0200)]
proxy: http2 proxy tunnel implementation
- currently only on debug build and when env variable
CURL_PROXY_TUNNEL_H2 is present.
- will ALPN negotiate with the proxy server and switch
tunnel filter based on the protocol negotiated.
- http/1.1 tunnel code moved into cf-h1-proxy.[ch]
- http/2 tunnel code implemented in cf-h2-proxy.[ch]
- tunnel start and ALPN set remains in http_proxy.c
- moving all haproxy related code into cf-haproxy.[ch]
VTLS changes
- SSL filters rely solely on the "alpn" specification they
are created with and no longer check conn->bits.tls_enable_alpn.
- checks on which ALPN specification to use (or none at all) are
done in vtls.c when creating the filter.
Testing
- added a nghttpx forward proxy to the pytest setup that
speaks HTTP/2 and forwards all requests to the Apache httpd
forward proxy server.
- extending test coverage in test_10 cases
- adding proxy tests for direct/tunnel h1/h2 use of basic auth.
- adding test for http/1.1 and h2 proxy tunneling to pytest
Stefan Eissing [Wed, 5 Apr 2023 12:52:16 +0000 (14:52 +0200)]
vtls and h2 improvements
- eliminate receive loop in vtls to fill buffer. This may
lead to partial reads of data which is counter productive
- let http2 instead loop smarter to process pending network
data without transfer switches
scorecard improvements
- do not start caddy when only httpd is requested
- allow curl -v to stderr file on --curl-verbose
Dan Fandrich [Sat, 1 Apr 2023 15:59:38 +0000 (08:59 -0700)]
unit tests: use the unit test infrastructure better
Allow UNITTEST_STOP to return the error code, use the fail & abort
macros to indicate test failure and return success instead of fail if
the unit test can't test anything because of missing features at
compile-time. A couple of tests could never fail because they were
overriding the failure return code.
Dan Fandrich [Fri, 31 Mar 2023 04:32:17 +0000 (21:32 -0700)]
tests: move server config files under the pid dir
These files are generated by the test servers and must therefore be
found in the log directory to make them available to only those servers
once multiple test runners are executing in parallel. They must also not
be deleted with the log files, so they are stored in the pidfile
directory.