alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1.02k stars 235 forks source link

Add Max Age CURL Option #360

Closed gsquire closed 4 years ago

gsquire commented 4 years ago

This would ideally be added to support the feature addition mentioned in https://github.com/sagebind/isahc/issues/93.

I found the constant listed here.

sagebind commented 4 years ago

Constants are validated against system libcurl which is dependent on versions. To add an exclusion configuration for a new constant, you can add a new match here:

https://github.com/alexcrichton/curl-rust/blob/badb4487f305e8ef6d15452ec2a9ab68a2c32d46/systest/build.rs#L63-L156

In this case, CURLOPT_MAXAGE_CONN was added in version 7.65.0. After updating this the tests should pass.

sagebind commented 4 years ago

Thanks for the PR! Can we also expose this in the Rust interface? Something like this:

impl Easy2 {
    pub fn maxage_conn(&mut self, maxage: Duration) -> Result<(), Error> {
        // todo
    }
}

See Easy2::tcp_keepidle for an example of how to set a curl option that takes a Duration:

https://github.com/alexcrichton/curl-rust/blob/badb4487f305e8ef6d15452ec2a9ab68a2c32d46/src/easy/handler.rs#L1067-L1069

We also more-or-less copy-paste every function into Easy to keep Easy2 and Easy in sync.