Skip to content

Commit 33b7a0b

Browse files
authored
Define HTTP/3 constant (#331)
* Define HTTP/3 constant HTTP/3 support in libcurl is still experimental at this point, but the constant for requesting it is stable. This just defines the constant and makes it available in the `curl` crate. * Update ctests
1 parent 3dc4add commit 33b7a0b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

curl-sys/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ pub const CURL_HTTP_VERSION_2TLS: c_int = 4;
602602
/// Please use HTTP 2 without HTTP/1.1 Upgrade
603603
/// (Added in CURL 7.49.0)
604604
pub const CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE: c_int = 5;
605+
/// Makes use of explicit HTTP/3 without fallback.
606+
/// (Added in CURL 7.66.0)
607+
pub const CURL_HTTP_VERSION_3: c_int = 30;
605608

606609
// Note that the type here is wrong, it's just intended to just be an enum.
607610
pub const CURL_SSLVERSION_DEFAULT: CURLoption = 0;

src/easy/handler.rs

+11
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,17 @@ pub enum HttpVersion {
461461
/// (Added in CURL 7.49.0)
462462
V2PriorKnowledge = curl_sys::CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE as isize,
463463

464+
/// Setting this value will make libcurl attempt to use HTTP/3 directly to
465+
/// server given in the URL. Note that this cannot gracefully downgrade to
466+
/// earlier HTTP version if the server doesn't support HTTP/3.
467+
///
468+
/// For more reliably upgrading to HTTP/3, set the preferred version to
469+
/// something lower and let the server announce its HTTP/3 support via
470+
/// Alt-Svc:.
471+
///
472+
/// (Added in CURL 7.66.0)
473+
V3 = curl_sys::CURL_HTTP_VERSION_3 as isize,
474+
464475
/// Hidden variant to indicate that this enum should not be matched on, it
465476
/// may grow over time.
466477
#[doc(hidden)]

systest/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ fn main() {
7070
_ => {}
7171
}
7272
}
73+
if version < 66 {
74+
match s {
75+
"CURL_HTTP_VERSION_3" => return true,
76+
_ => {}
77+
}
78+
}
7379
if version < 65 {
7480
match s {
7581
"CURLVERSION_SIXTH" => return true,

0 commit comments

Comments
 (0)