Skip to content

Commit 372dcae

Browse files
committed
Implements method proxy_headers to add headers only to the proxy.
See <https://curl.se/libcurl/c/CURLOPT_PROXYHEADER.html>
1 parent 14d51cf commit 372dcae

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

curl-sys/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ pub const CURLOPT_SSL_OPTIONS: CURLoption = CURLOPTTYPE_LONG + 216;
588588
// pub const CURLOPT_DNS_LOCAL_IP6: CURLoption = CURLOPTTYPE_OBJECTPOINT + 223;
589589
// pub const CURLOPT_LOGIN_OPTIONS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 224;
590590
pub const CURLOPT_EXPECT_100_TIMEOUT_MS: CURLoption = CURLOPTTYPE_LONG + 227;
591+
pub const CURLOPT_PROXYHEADER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 228;
591592
pub const CURLOPT_PINNEDPUBLICKEY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 230;
592593
pub const CURLOPT_UNIX_SOCKET_PATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 231;
593594
pub const CURLOPT_PATH_AS_IS: CURLoption = CURLOPTTYPE_LONG + 234;

src/easy/handle.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,11 @@ impl Easy {
846846
self.inner.http_headers(list)
847847
}
848848

849+
/// Same as [`Easy2::proxy_headers`](struct.Easy2.html#method.proxy_headers)
850+
pub fn proxy_headers(&mut self, list: List) -> Result<(), Error> {
851+
self.inner.proxy_headers(list)
852+
}
853+
849854
/// Same as [`Easy2::cookie`](struct.Easy2.html#method.cookie)
850855
pub fn cookie(&mut self, cookie: &str) -> Result<(), Error> {
851856
self.inner.cookie(cookie)

src/easy/handler.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ struct Inner<H> {
384384
header_list: Option<List>,
385385
resolve_list: Option<List>,
386386
connect_to_list: Option<List>,
387+
proxy_header_list: Option<List>,
387388
form: Option<Form>,
388389
error_buf: RefCell<Vec<u8>>,
389390
handler: H,
@@ -594,6 +595,7 @@ impl<H: Handler> Easy2<H> {
594595
header_list: None,
595596
resolve_list: None,
596597
connect_to_list: None,
598+
proxy_header_list: None,
597599
form: None,
598600
error_buf: RefCell::new(vec![0; curl_sys::CURL_ERROR_SIZE]),
599601
handler,
@@ -1593,15 +1595,17 @@ impl<H> Easy2<H> {
15931595
self.setopt_ptr(curl_sys::CURLOPT_HTTPHEADER, ptr as *const _)
15941596
}
15951597

1596-
// /// Add some headers to send to the HTTP proxy.
1597-
// ///
1598-
// /// This function is essentially the same as `http_headers`.
1599-
// ///
1600-
// /// By default this option is not set and corresponds to
1601-
// /// `CURLOPT_PROXYHEADER`
1602-
// pub fn proxy_headers(&mut self, list: &'a List) -> Result<(), Error> {
1603-
// self.setopt_ptr(curl_sys::CURLOPT_PROXYHEADER, list.raw as *const _)
1604-
// }
1598+
/// Add some headers to send to the HTTP proxy.
1599+
///
1600+
/// This function is essentially the same as `http_headers`.
1601+
///
1602+
/// By default this option is not set and corresponds to
1603+
/// `CURLOPT_PROXYHEADER`
1604+
pub fn proxy_headers(&mut self, list: List) -> Result<(), Error> {
1605+
let ptr = list::raw(&list);
1606+
self.inner.proxy_header_list = Some(list);
1607+
self.setopt_ptr(curl_sys::CURLOPT_PROXYHEADER, ptr as *const _)
1608+
}
16051609

16061610
/// Set the contents of the HTTP Cookie header.
16071611
///

0 commit comments

Comments
 (0)