diff --git a/curl-sys/lib.rs b/curl-sys/lib.rs index 685f3ef7c0..108382f977 100644 --- a/curl-sys/lib.rs +++ b/curl-sys/lib.rs @@ -576,6 +576,7 @@ pub const CURLOPT_SSL_OPTIONS: CURLoption = CURLOPTTYPE_LONG + 216; // pub const CURLOPT_LOGIN_OPTIONS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 224; pub const CURLOPT_UNIX_SOCKET_PATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 231; pub const CURLOPT_PIPEWAIT: CURLoption = CURLOPTTYPE_LONG + 237; +pub const CURLOPT_CONNECT_TO: CURLoption = CURLOPTTYPE_OBJECTPOINT + 243; pub const CURLOPT_PROXY_CAINFO: CURLoption = CURLOPTTYPE_OBJECTPOINT + 246; pub const CURLOPT_PROXY_CAPATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 247; pub const CURLOPT_PROXY_SSLCERT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 254; diff --git a/src/easy/handle.rs b/src/easy/handle.rs index 695b332b9f..da47da2da2 100644 --- a/src/easy/handle.rs +++ b/src/easy/handle.rs @@ -553,6 +553,11 @@ impl Easy { self.inner.port(port) } + /// Same as [`Easy2::connect_to`](struct.Easy2.html#method.connect_to) + pub fn connect_to(&mut self, list: List) -> Result<(), Error> { + self.inner.connect_to(list) + } + /// Same as [`Easy2::proxy`](struct.Easy2.html#method.proxy) pub fn proxy(&mut self, url: &str) -> Result<(), Error> { self.inner.proxy(url) diff --git a/src/easy/handler.rs b/src/easy/handler.rs index fd19884677..2991f99044 100644 --- a/src/easy/handler.rs +++ b/src/easy/handler.rs @@ -383,6 +383,7 @@ struct Inner { handle: *mut curl_sys::CURL, header_list: Option, resolve_list: Option, + connect_to_list: Option, form: Option
, error_buf: RefCell>, handler: H, @@ -625,6 +626,7 @@ impl Easy2 { handle: handle, header_list: None, resolve_list: None, + connect_to_list: None, form: None, error_buf: RefCell::new(vec![0; curl_sys::CURL_ERROR_SIZE]), handler: handler, @@ -858,6 +860,24 @@ impl Easy2 { self.setopt_long(curl_sys::CURLOPT_PORT, port as c_long) } + /// Connect to a specific host and port. + /// + /// Each single string should be written using the format + /// `HOST:PORT:CONNECT-TO-HOST:CONNECT-TO-PORT` where `HOST` is the host of + /// the request, `PORT` is the port of the request, `CONNECT-TO-HOST` is the + /// host name to connect to, and `CONNECT-TO-PORT` is the port to connect + /// to. + /// + /// The first string that matches the request's host and port is used. + /// + /// By default, this option is empty and corresponds to + /// [`CURLOPT_CONNECT_TO`](https://curl.haxx.se/libcurl/c/CURLOPT_CONNECT_TO.html). + pub fn connect_to(&mut self, list: List) -> Result<(), Error> { + let ptr = list::raw(&list); + self.inner.connect_to_list = Some(list); + self.setopt_ptr(curl_sys::CURLOPT_CONNECT_TO, ptr as *const _) + } + // /// Indicates whether sequences of `/../` and `/./` will be squashed or not. // /// // /// By default this option is `false` and corresponds to diff --git a/systest/build.rs b/systest/build.rs index 7b390af2c6..999f437a83 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -124,8 +124,9 @@ fn main() { } if version < 49 { - if s.starts_with("CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE") { - return true; + match s { + "CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE" | "CURLOPT_CONNECT_TO" => return true, + _ => {} } }