Skip to content
Merged
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 curl-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/easy/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions src/easy/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ struct Inner<H> {
handle: *mut curl_sys::CURL,
header_list: Option<List>,
resolve_list: Option<List>,
connect_to_list: Option<List>,
form: Option<Form>,
error_buf: RefCell<Vec<u8>>,
handler: H,
Expand Down Expand Up @@ -625,6 +626,7 @@ impl<H: Handler> Easy2<H> {
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,
Expand Down Expand Up @@ -858,6 +860,24 @@ impl<H> Easy2<H> {
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
Expand Down
5 changes: 3 additions & 2 deletions systest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
_ => {}
}
}

Expand Down