Meta+RequestServer: Enable HTTP/3 for curl

This adds an overlay port for curl that adds the features required for
HTTP/3.

This is not quite compatible with the upstream vcpkg.json, because
enabling HTTP/2 makes it use the default SSL backend, which is
sectransp for macOS and schannel on Windows. These backends are not
compatible with ngtcp2. Additionally, we can not build curl with
multiple SSL backends when using ngtcp2.

I couldn't find a way to selectively disable/enable dependencies based
on what features are enabled, so I made HTTP/2 pick OpenSSL in our
overlay port. Upstream vcpkg will likely want to support wolfSSL and
GnuTLS backends for ngtcp2, so they'll be additional work to get this
into upstream.
This commit is contained in:
Luke Wilde 2025-07-07 16:03:37 +01:00 committed by Andrew Kaster
commit 08a03534af
Notes: github-actions[bot] 2025-07-09 20:46:16 +00:00
5 changed files with 30 additions and 2 deletions

View file

@ -14,6 +14,7 @@ vcpkg_from_github(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
http2 USE_NGHTTP2
http3 USE_NGTCP2
wolfssl CURL_USE_WOLFSSL
openssl CURL_USE_OPENSSL
mbedtls CURL_USE_MBEDTLS

View file

@ -65,12 +65,31 @@
"name": "curl",
"default-features": false,
"features": [
"ssl"
"openssl"
]
},
"nghttp2"
]
},
"http3": {
"description": "HTTP3 support",
"dependencies": [
{
"name": "curl",
"default-features": false,
"features": [
"openssl"
]
},
"nghttp3",
{
"name": "ngtcp2",
"features": [
"openssl"
]
}
]
},
"httpsrr": {
"description": "enable support for HTTPS RR"
},
@ -125,7 +144,7 @@
]
},
"non-http": {
"description": "Enables protocols beyond HTTP/HTTPS/HTTP2"
"description": "Enables protocols beyond HTTP/HTTPS/HTTP2/HTTP3"
},
"openssl": {
"description": "SSL support (OpenSSL)",

View file

@ -13,6 +13,7 @@
#include <LibCore/EventLoop.h>
#include <LibCore/Proxy.h>
#include <LibCore/Socket.h>
#include <LibCore/StandardPaths.h>
#include <LibRequests/NetworkError.h>
#include <LibRequests/RequestTimingInfo.h>
#include <LibRequests/WebSocket.h>
@ -315,6 +316,8 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transpo
{
s_connections.set(client_id(), *this);
m_alt_svc_cache_path = ByteString::formatted("{}/Ladybird/alt-svc-cache.txt", Core::StandardPaths::user_data_directory());
m_curl_multi = curl_multi_init();
auto set_option = [this](auto option, auto value) {
@ -488,6 +491,7 @@ void ConnectionFromClient::start_request(i32 request_id, ByteString method, URL:
set_option(CURLOPT_PORT, url.port_or_default());
set_option(CURLOPT_CONNECTTIMEOUT, s_connect_timeout_seconds);
set_option(CURLOPT_PIPEWAIT, 1L);
set_option(CURLOPT_ALTSVC, m_alt_svc_cache_path.characters());
bool did_set_body = false;

View file

@ -70,6 +70,7 @@ private:
HashMap<int, NonnullRefPtr<Core::Notifier>> m_read_notifiers;
HashMap<int, NonnullRefPtr<Core::Notifier>> m_write_notifiers;
NonnullRefPtr<Resolver> m_resolver;
ByteString m_alt_svc_cache_path;
};
// FIXME: Find a good home for this

View file

@ -14,9 +14,12 @@
},
{
"name": "curl",
"default-features": false,
"features": [
"brotli",
"non-http",
"http2",
"http3",
"openssl",
"websockets"
]