Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental HTTP/3 via Quiche #433

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ default = ["ssl"]
ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] # OpenSSL/system TLS backend
mesalink = ["curl-sys/mesalink"] # MesaLink TLS backend
http2 = ["curl-sys/http2"]
http3-quiche = ["curl-sys/http3-quiche"]
spnego = ["curl-sys/spnego"]
rustls = ["curl-sys/rustls"]
static-curl = ["curl-sys/static-curl"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ with various Cargo features:
Note that Rustls support is experimental within Curl itself and may have significant bugs, so we don't offer any sort of stability guarantee with this feature.
- `mesalink`: Enable SSL/TLS support via [MesaLink], an alternative TLS backend written in Rust based on [Rustls]. MesaLink is always statically linked. Disabled by default.
- `http2`: Enable HTTP/2 support via libnghttp2. Disabled by default.
- `http3-quiche`: Enable experimental HTTP/3 support via [Quiche](https://github.com/cloudflare/quiche). Disabled by default.
- `static-curl`: Use a bundled libcurl version and statically link to it. Disabled by default.
- `static-ssl`: Use a bundled OpenSSL version and statically link to it. Only applies on platforms that use OpenSSL. Disabled by default.
- `spnego`: Enable SPNEGO support. Disabled by default.
Expand Down
9 changes: 9 additions & 0 deletions curl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ optional = true
default-features = false
features = ["client_apis", "error_strings", "tls13", "aesgcm", "chachapoly", "x25519", "ecdh", "ecdsa", "verifier"]

[dependencies.quiche]
git = "https://github.com/sagebind/quiche"
branch = "include-metadata"
optional = true
default-features = false
features = ["ffi"]

[dependencies.rustls-ffi]
version = "0.8"
optional = true
Expand All @@ -52,6 +59,8 @@ cc = "1.0"
default = ["ssl"]
ssl = ["openssl-sys"]
http2 = ["libnghttp2-sys"]
http3-quiche = ["quiche"]
http3-quiche-boringssl-vendored = ["quiche/boringssl-vendored"]
rustls = ["rustls-ffi"]
static-curl = []
static-ssl = ["openssl-sys/vendored"]
Expand Down
8 changes: 8 additions & 0 deletions curl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ fn main() {
}
}

if cfg!(feature = "http3-quiche") {
cfg.define("USE_QUICHE", None)
.file("curl/lib/vquic/vquic.c")
.file("curl/lib/vquic/quiche.c");

cfg.include(env::var_os("DEP_QUICHE_INCLUDE").unwrap());
}

println!("cargo:rustc-cfg=link_libz");
if let Some(path) = env::var_os("DEP_Z_INCLUDE") {
cfg.include(path);
Expand Down
2 changes: 2 additions & 0 deletions curl-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ extern crate libz_sys;
extern crate mesalink;
#[cfg(link_openssl)]
extern crate openssl_sys;
#[cfg(feature = "http3-quiche")]
extern crate quiche;
#[cfg(feature = "rustls")]
extern crate rustls_ffi;

Expand Down
20 changes: 20 additions & 0 deletions examples/http3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Simple HTTP/3 GET
//!
//! This example is a Rust adaptation of the [C example of the same
//! name](https://curl.se/libcurl/c/http3.html).

use curl::easy::Easy;

fn main() -> Result<(), curl::Error> {
let mut curl = Easy::new();

// An HTTP/3-capable server.
curl.url("https://cloudflare-quic.com")?;

// Force HTTP/3 to be used.
curl.http_version(curl::easy::HttpVersion::V3)?;

curl.perform()?;

Ok(())
}