Skip to content

Commit 3dc4add

Browse files
authored
Update curl submodule and crate versions (#330)
1 parent 6834908 commit 3dc4add

File tree

7 files changed

+112
-65
lines changed

7 files changed

+112
-65
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "curl"
3-
version = "0.4.28"
3+
version = "0.4.29"
44
authors = ["Alex Crichton <[email protected]>"]
55
license = "MIT"
66
repository = "https://github.com/alexcrichton/curl-rust"
@@ -16,7 +16,7 @@ appveyor = { repository = "alexcrichton/curl-rust" }
1616

1717
[dependencies]
1818
libc = "0.2.42"
19-
curl-sys = { path = "curl-sys", version = "0.4.30", default-features = false }
19+
curl-sys = { path = "curl-sys", version = "0.4.31", default-features = false }
2020
socket2 = "0.3.7"
2121

2222
# Unix platforms use OpenSSL for now to provide SSL functionality

curl-sys/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "curl-sys"
3-
version = "0.4.30+curl-7.69.1"
3+
version = "0.4.31+curl-7.70.0"
44
authors = ["Alex Crichton <[email protected]>"]
55
links = "curl"
66
build = "build.rs"

curl-sys/curl

Submodule curl updated 571 files

curl-sys/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,8 @@ pub const CURLVERSION_THIRD: CURLversion = 2;
799799
pub const CURLVERSION_FOURTH: CURLversion = 3;
800800
pub const CURLVERSION_FIFTH: CURLversion = 4;
801801
pub const CURLVERSION_SIXTH: CURLversion = 5;
802-
pub const CURLVERSION_NOW: CURLversion = CURLVERSION_SIXTH;
802+
pub const CURLVERSION_SEVENTH: CURLversion = 6;
803+
pub const CURLVERSION_NOW: CURLversion = CURLVERSION_SEVENTH;
803804

804805
#[repr(C)]
805806
pub struct curl_version_info_data {
@@ -822,6 +823,8 @@ pub struct curl_version_info_data {
822823
pub nghttp2_ver_num: c_uint,
823824
pub nghttp2_version: *const c_char,
824825
pub quic_version: *const c_char,
826+
pub cainfo: *const c_char,
827+
pub capath: *const c_char,
825828
}
826829

827830
pub const CURL_VERSION_IPV6: c_int = 1 << 0;
@@ -842,6 +845,8 @@ pub const CURL_VERSION_TLSAUTH_SRP: c_int = 1 << 14;
842845
pub const CURL_VERSION_NTLM_WB: c_int = 1 << 15;
843846
pub const CURL_VERSION_HTTP2: c_int = 1 << 16;
844847
pub const CURL_VERSION_UNIX_SOCKETS: c_int = 1 << 19;
848+
pub const CURL_VERSION_BROTLI: c_int = 1 << 23;
849+
pub const CURL_VERSION_HTTP3: c_int = 1 << 25;
845850

846851
pub const CURLPAUSE_RECV: c_int = 1 << 0;
847852
pub const CURLPAUSE_RECV_CONT: c_int = 0;

src/error.rs

+59-58
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ impl Error {
303303
self.code
304304
}
305305

306+
/// Returns the general description of this error code, using curl's
307+
/// builtin `strerror`-like functionality.
308+
pub fn description(&self) -> &str {
309+
unsafe {
310+
let s = curl_sys::curl_easy_strerror(self.code);
311+
assert!(!s.is_null());
312+
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
313+
}
314+
}
315+
306316
/// Returns the extra description of this error, if any is available.
307317
pub fn extra_description(&self) -> Option<&str> {
308318
self.extra.as_ref().map(|s| &**s)
@@ -311,7 +321,7 @@ impl Error {
311321

312322
impl fmt::Display for Error {
313323
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
314-
let desc = error::Error::description(self);
324+
let desc = self.description();
315325
match self.extra {
316326
Some(ref s) => write!(f, "[{}] {} ({})", self.code(), desc, s),
317327
None => write!(f, "[{}] {}", self.code(), desc),
@@ -322,22 +332,14 @@ impl fmt::Display for Error {
322332
impl fmt::Debug for Error {
323333
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
324334
f.debug_struct("Error")
325-
.field("description", &error::Error::description(self))
335+
.field("description", &self.description())
326336
.field("code", &self.code)
327337
.field("extra", &self.extra)
328338
.finish()
329339
}
330340
}
331341

332-
impl error::Error for Error {
333-
fn description(&self) -> &str {
334-
unsafe {
335-
let s = curl_sys::curl_easy_strerror(self.code);
336-
assert!(!s.is_null());
337-
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
338-
}
339-
}
340-
}
342+
impl error::Error for Error {}
341343

342344
/// An error returned from "share" operations.
343345
///
@@ -382,11 +384,20 @@ impl ShareError {
382384
pub fn code(&self) -> curl_sys::CURLSHcode {
383385
self.code
384386
}
387+
388+
/// Returns curl's human-readable version of this error.
389+
pub fn description(&self) -> &str {
390+
unsafe {
391+
let s = curl_sys::curl_share_strerror(self.code);
392+
assert!(!s.is_null());
393+
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
394+
}
395+
}
385396
}
386397

387398
impl fmt::Display for ShareError {
388399
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
389-
error::Error::description(self).fmt(f)
400+
self.description().fmt(f)
390401
}
391402
}
392403

@@ -395,21 +406,13 @@ impl fmt::Debug for ShareError {
395406
write!(
396407
f,
397408
"ShareError {{ description: {:?}, code: {} }}",
398-
error::Error::description(self),
409+
self.description(),
399410
self.code
400411
)
401412
}
402413
}
403414

404-
impl error::Error for ShareError {
405-
fn description(&self) -> &str {
406-
unsafe {
407-
let s = curl_sys::curl_share_strerror(self.code);
408-
assert!(!s.is_null());
409-
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
410-
}
411-
}
412-
}
415+
impl error::Error for ShareError {}
413416

414417
/// An error from "multi" operations.
415418
///
@@ -469,34 +472,33 @@ impl MultiError {
469472
pub fn code(&self) -> curl_sys::CURLMcode {
470473
self.code
471474
}
475+
476+
/// Returns curl's human-readable description of this error.
477+
pub fn description(&self) -> &str {
478+
unsafe {
479+
let s = curl_sys::curl_multi_strerror(self.code);
480+
assert!(!s.is_null());
481+
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
482+
}
483+
}
472484
}
473485

474486
impl fmt::Display for MultiError {
475487
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
476-
error::Error::description(self).fmt(f)
488+
self.description().fmt(f)
477489
}
478490
}
479491

480492
impl fmt::Debug for MultiError {
481493
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
482-
write!(
483-
f,
484-
"MultiError {{ description: {:?}, code: {} }}",
485-
error::Error::description(self),
486-
self.code
487-
)
494+
f.debug_struct("MultiError")
495+
.field("description", &self.description())
496+
.field("code", &self.code)
497+
.finish()
488498
}
489499
}
490500

491-
impl error::Error for MultiError {
492-
fn description(&self) -> &str {
493-
unsafe {
494-
let s = curl_sys::curl_multi_strerror(self.code);
495-
assert!(!s.is_null());
496-
str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap()
497-
}
498-
}
499-
}
501+
impl error::Error for MultiError {}
500502

501503
/// An error from "form add" operations.
502504
///
@@ -551,27 +553,9 @@ impl FormError {
551553
pub fn code(&self) -> curl_sys::CURLFORMcode {
552554
self.code
553555
}
554-
}
555-
556-
impl fmt::Display for FormError {
557-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
558-
error::Error::description(self).fmt(f)
559-
}
560-
}
561-
562-
impl fmt::Debug for FormError {
563-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
564-
write!(
565-
f,
566-
"FormError {{ description: {:?}, code: {} }}",
567-
error::Error::description(self),
568-
self.code
569-
)
570-
}
571-
}
572556

573-
impl error::Error for FormError {
574-
fn description(&self) -> &str {
557+
/// Returns a human-readable description of this error code.
558+
pub fn description(&self) -> &str {
575559
match self.code {
576560
curl_sys::CURL_FORMADD_MEMORY => "allocation failure",
577561
curl_sys::CURL_FORMADD_OPTION_TWICE => "one option passed twice",
@@ -587,6 +571,23 @@ impl error::Error for FormError {
587571
}
588572
}
589573

574+
impl fmt::Display for FormError {
575+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
576+
self.description().fmt(f)
577+
}
578+
}
579+
580+
impl fmt::Debug for FormError {
581+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
582+
f.debug_struct("FormError")
583+
.field("description", &self.description())
584+
.field("code", &self.code)
585+
.finish()
586+
}
587+
}
588+
589+
impl error::Error for FormError {}
590+
590591
impl From<ffi::NulError> for Error {
591592
fn from(_: ffi::NulError) -> Error {
592593
Error {

src/version.rs

+32
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ impl Version {
141141
self.flag(curl_sys::CURL_VERSION_HTTP2)
142142
}
143143

144+
/// Returns whether libcurl was built with support for HTTP3.
145+
pub fn feature_http3(&self) -> bool {
146+
self.flag(curl_sys::CURL_VERSION_HTTP3)
147+
}
148+
149+
/// Returns whether libcurl was built with support for Brotli.
150+
pub fn feature_brotli(&self) -> bool {
151+
self.flag(curl_sys::CURL_VERSION_BROTLI)
152+
}
153+
144154
fn flag(&self, flag: c_int) -> bool {
145155
unsafe { (*self.inner).features & flag != 0 }
146156
}
@@ -278,6 +288,28 @@ impl Version {
278288
}
279289
}
280290
}
291+
292+
/// If available, the built-in default of CURLOPT_CAINFO.
293+
pub fn cainfo(&self) -> Option<&str> {
294+
unsafe {
295+
if (*self.inner).age >= curl_sys::CURLVERSION_SEVENTH {
296+
::opt_str((*self.inner).cainfo)
297+
} else {
298+
None
299+
}
300+
}
301+
}
302+
303+
/// If available, the built-in default of CURLOPT_CAPATH.
304+
pub fn capath(&self) -> Option<&str> {
305+
unsafe {
306+
if (*self.inner).age >= curl_sys::CURLVERSION_SEVENTH {
307+
::opt_str((*self.inner).capath)
308+
} else {
309+
None
310+
}
311+
}
312+
}
281313
}
282314

283315
impl fmt::Debug for Version {

systest/build.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() {
5050
cfg.skip_signededness(|s| s.ends_with("callback") || s.ends_with("function"));
5151

5252
cfg.skip_struct(move |s| {
53-
if version < 65 {
53+
if version < 70 {
5454
match s {
5555
"curl_version_info_data" => return true,
5656
_ => {}
@@ -61,9 +61,18 @@ fn main() {
6161
});
6262

6363
cfg.skip_const(move |s| {
64+
if version < 70 {
65+
match s {
66+
"CURL_VERSION_HTTP3"
67+
| "CURL_VERSION_BROTLI"
68+
| "CURLVERSION_SEVENTH"
69+
| "CURLVERSION_NOW" => return true,
70+
_ => {}
71+
}
72+
}
6473
if version < 65 {
6574
match s {
66-
"CURLVERSION_SIXTH" | "CURLVERSION_NOW" => return true,
75+
"CURLVERSION_SIXTH" => return true,
6776
_ => {}
6877
}
6978
}

0 commit comments

Comments
 (0)