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

Commit

Permalink
increases default HTTP timeout to 1 min
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Jun 16, 2020
1 parent 5dcf0bb commit bb25620
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
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 = 5 * 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};

0 comments on commit bb25620

Please sign in to comment.