alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1k stars 234 forks source link

Use CURLOPT_CONNECTTIMEOUT if timeout too big #497

Closed LorenzoLeonardo closed 1 year ago

LorenzoLeonardo commented 1 year ago

If the time that was converted into millisecond is more than the capacity of c_long, it will overflow, thus we need to convert it into seconds and use CURLOPT_CONNECTTIMEOUT.

LorenzoLeonardo commented 1 year ago

I think tests may be failing though? (perhaps because curl is too old in the container?)

I will try to use i32:MAX instead of std::i32:MAX https://doc.rust-lang.org/std/i32/constant.MAX.html

LorenzoLeonardo commented 1 year ago

oh, that's weird, if I run the Unit Test locally this will succeed.

alexcrichton commented 1 year ago

I believe the failure is because c_ulong is u64 on Linux so u64::MAX fits. I think you'll want to specify a larger amount than u64::MAX milliseconds to guarantee failure.

LorenzoLeonardo commented 1 year ago

will try to use from_secs() to guarantee max value

LorenzoLeonardo commented 1 year ago

It seems there are test error not related to the change.

LorenzoLeonardo commented 1 year ago

it is ok now