Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

increases default HTTP timeout to 1 min #1392

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/http/cf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use cloudflare::framework::response::ApiFailure;
use cloudflare::framework::{Environment, HttpApiClient, HttpApiClientConfig};
use http::StatusCode;

use crate::http::{feature::headers, Feature};
use crate::http::{feature::headers, Feature, DEFAULT_HTTP_TIMEOUT_SECONDS};
use crate::settings::global_user::GlobalUser;
use crate::terminal::{emoji, message};

pub fn cf_v4_client(user: &GlobalUser) -> Result<HttpApiClient, failure::Error> {
let config = HttpApiClientConfig {
http_timeout: Duration::from_secs(30),
http_timeout: Duration::from_secs(DEFAULT_HTTP_TIMEOUT_SECONDS),
default_headers: headers(None),
};

Expand All @@ -28,7 +28,7 @@ pub fn featured_cf_v4_client(
feature: Feature,
) -> Result<HttpApiClient, failure::Error> {
let config = HttpApiClientConfig {
http_timeout: Duration::from_secs(30),
http_timeout: Duration::from_secs(DEFAULT_HTTP_TIMEOUT_SECONDS),
default_headers: headers(Some(feature)),
};

Expand Down
4 changes: 2 additions & 2 deletions src/http/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::redirect::Policy;
use std::time::Duration;

use crate::http::{feature::headers, Feature};
use crate::http::{feature::headers, Feature, DEFAULT_HTTP_TIMEOUT_SECONDS};
use crate::settings::global_user::GlobalUser;

// TODO: remove this and replace it entirely with cloudflare-rs
Expand Down Expand Up @@ -37,7 +37,7 @@ fn builder() -> ClientBuilder {
let builder = reqwest::blocking::Client::builder();
builder
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(30))
.timeout(Duration::from_secs(DEFAULT_HTTP_TIMEOUT_SECONDS))
}

fn add_auth_headers<'a>(headers: &'a mut HeaderMap, user: &GlobalUser) {
Expand Down
1 change: 1 addition & 0 deletions src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub(self) mod cf;
pub(crate) mod feature;
pub(self) mod legacy;

pub const DEFAULT_HTTP_TIMEOUT_SECONDS: u64 = 60;
pub use cf::{cf_v4_api_client_async, cf_v4_client, featured_cf_v4_client, format_error};
pub use feature::Feature;
pub use legacy::{client, featured_legacy_auth_client, legacy_auth_client};