Skip to content

Commit 08a0353

Browse files
LubrsiADKaster
authored andcommitted
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.
1 parent 993d8df commit 08a0353

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

Meta/CMake/vcpkg/overlay-ports/curl/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ vcpkg_from_github(
1414
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
1515
FEATURES
1616
http2 USE_NGHTTP2
17+
http3 USE_NGTCP2
1718
wolfssl CURL_USE_WOLFSSL
1819
openssl CURL_USE_OPENSSL
1920
mbedtls CURL_USE_MBEDTLS

Meta/CMake/vcpkg/overlay-ports/curl/vcpkg.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,31 @@
6565
"name": "curl",
6666
"default-features": false,
6767
"features": [
68-
"ssl"
68+
"openssl"
6969
]
7070
},
7171
"nghttp2"
7272
]
7373
},
74+
"http3": {
75+
"description": "HTTP3 support",
76+
"dependencies": [
77+
{
78+
"name": "curl",
79+
"default-features": false,
80+
"features": [
81+
"openssl"
82+
]
83+
},
84+
"nghttp3",
85+
{
86+
"name": "ngtcp2",
87+
"features": [
88+
"openssl"
89+
]
90+
}
91+
]
92+
},
7493
"httpsrr": {
7594
"description": "enable support for HTTPS RR"
7695
},
@@ -125,7 +144,7 @@
125144
]
126145
},
127146
"non-http": {
128-
"description": "Enables protocols beyond HTTP/HTTPS/HTTP2"
147+
"description": "Enables protocols beyond HTTP/HTTPS/HTTP2/HTTP3"
129148
},
130149
"openssl": {
131150
"description": "SSL support (OpenSSL)",

Services/RequestServer/ConnectionFromClient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <LibCore/EventLoop.h>
1414
#include <LibCore/Proxy.h>
1515
#include <LibCore/Socket.h>
16+
#include <LibCore/StandardPaths.h>
1617
#include <LibRequests/NetworkError.h>
1718
#include <LibRequests/RequestTimingInfo.h>
1819
#include <LibRequests/WebSocket.h>
@@ -315,6 +316,8 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<IPC::Transport> transpo
315316
{
316317
s_connections.set(client_id(), *this);
317318

319+
m_alt_svc_cache_path = ByteString::formatted("{}/Ladybird/alt-svc-cache.txt", Core::StandardPaths::user_data_directory());
320+
318321
m_curl_multi = curl_multi_init();
319322

320323
auto set_option = [this](auto option, auto value) {
@@ -488,6 +491,7 @@ void ConnectionFromClient::start_request(i32 request_id, ByteString method, URL:
488491
set_option(CURLOPT_PORT, url.port_or_default());
489492
set_option(CURLOPT_CONNECTTIMEOUT, s_connect_timeout_seconds);
490493
set_option(CURLOPT_PIPEWAIT, 1L);
494+
set_option(CURLOPT_ALTSVC, m_alt_svc_cache_path.characters());
491495

492496
bool did_set_body = false;
493497

Services/RequestServer/ConnectionFromClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ConnectionFromClient final
7070
HashMap<int, NonnullRefPtr<Core::Notifier>> m_read_notifiers;
7171
HashMap<int, NonnullRefPtr<Core::Notifier>> m_write_notifiers;
7272
NonnullRefPtr<Resolver> m_resolver;
73+
ByteString m_alt_svc_cache_path;
7374
};
7475

7576
// FIXME: Find a good home for this

vcpkg.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
},
1515
{
1616
"name": "curl",
17+
"default-features": false,
1718
"features": [
1819
"brotli",
20+
"non-http",
1921
"http2",
22+
"http3",
2023
"openssl",
2124
"websockets"
2225
]

0 commit comments

Comments
 (0)