Skip to content

Commit 431babf

Browse files
authored
feat: add three more curl multi options (#505)
* feat: new curlmopt * feat: method for setting max concurrent streams for http2 * test: skip newly added consts
1 parent 5089f37 commit 431babf

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

curl-sys/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,9 @@ pub const CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE: CURLMoption = CURLOPTTYPE_OFF_T +
998998
pub const CURLMOPT_PIPELINING_SITE_BL: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 11;
999999
pub const CURLMOPT_PIPELINING_SERVER_BL: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 12;
10001000
pub const CURLMOPT_MAX_TOTAL_CONNECTIONS: CURLMoption = CURLOPTTYPE_LONG + 13;
1001+
pub const CURLMOPT_PUSHFUNCTION: CURLMoption = CURLOPTTYPE_FUNCTIONPOINT + 14;
1002+
pub const CURLMOPT_PUSHDATA: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 15;
1003+
pub const CURLMOPT_MAX_CONCURRENT_STREAMS: CURLMoption = CURLOPTTYPE_LONG + 16;
10011004

10021005
// These enums are for use with the CURLMOPT_PIPELINING option.
10031006
pub const CURLPIPE_NOTHING: c_long = 0;

src/multi.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,15 @@ impl Multi {
371371
self.setopt_long(curl_sys::CURLMOPT_MAX_PIPELINE_LENGTH, val as c_long)
372372
}
373373

374+
/// Sets the number of max concurrent streams for http2.
375+
///
376+
/// This sets the max number will be used as the maximum number of
377+
/// concurrent streams for a connections that libcurl should support on
378+
/// connections done using HTTP/2. Defaults to 100.
379+
pub fn set_max_concurrent_streams(&mut self, val: usize) -> Result<(), MultiError> {
380+
self.setopt_long(curl_sys::CURLMOPT_MAX_CONCURRENT_STREAMS, val as c_long)
381+
}
382+
374383
fn setopt_long(&mut self, opt: curl_sys::CURLMoption, val: c_long) -> Result<(), MultiError> {
375384
unsafe { cvt(curl_sys::curl_multi_setopt(self.raw.handle, opt, val)) }
376385
}

systest/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ fn main() {
137137
_ => {}
138138
}
139139
}
140+
if version < 67 {
141+
match s {
142+
"CURLMOPT_MAX_CONCURRENT_STREAMS" => return true,
143+
_ => {}
144+
}
145+
}
140146
if version < 66 {
141147
match s {
142148
"CURL_HTTP_VERSION_3" => return true,
@@ -222,6 +228,12 @@ fn main() {
222228
return true;
223229
}
224230
}
231+
if version < 44 {
232+
match s {
233+
"CURLMOPT_PUSHDATA" | "CURLMOPT_PUSHFUNCTION" => return true,
234+
_ => {}
235+
}
236+
}
225237
if version < 43 {
226238
if s.starts_with("CURLPIPE_") {
227239
return true;

0 commit comments

Comments
 (0)