http-rs / surf

Fast and friendly HTTP client framework for async Rust
https://docs.rs/surf
Apache License 2.0
1.45k stars 119 forks source link

Can't Increase Request Timeout #267

Closed tiberiusferreira closed 3 years ago

tiberiusferreira commented 3 years ago

Hello, thanks for the great crate!

The trick from https://github.com/http-rs/surf/issues/91 works for reducing the timeout, but how would one increase it (from the default one used by Isahc or other backends)?

Fishrock123 commented 3 years ago

There isn't presently an easy way, but if you are using the curl or hyper backends, something like this would work:

// https://docs.rs/isahc/0.9.13/isahc/config/trait.Configurable.html#method.timeout
let backing_client = isahc::httpClient::builder().timeout(duration).build();
// https://github.com/http-rs/http-client/blob/b7d904ffcc999baea6f69470bf59d2fb098871c7/src/isahc.rs#L24-L27
let http_client = http_client::isahc::IsahcClient::from_client(backing_client);
// https://docs.rs/surf/2.1.0/surf/struct.Client.html#method.with_http_client
let surf_client = surf::client::Client::with_http_client(http_client);

Sorry it's not yet nicer. :sweat:

tiberiusferreira commented 3 years ago

Nice, I'm glad there is a way. Thanks for the great work on Surf!