From 942309e2dd1a03d93281e1fc3f630680a0ecf45a Mon Sep 17 00:00:00 2001 From: Max <4990534+unix-system@users.noreply.github.com> Date: Tue, 7 Sep 2021 18:04:18 +0100 Subject: [PATCH] Update reqwest to a ClientBuilder, and extend the timeout to 3 minutes (#63) * Update reqwest to a ClientBuilder, and extend the timeout to 3 minutes * Fix rustfmt formatting * Move std imports to the top with a space, undoing rustfmt change * Move std import into std block * Cargo fmt (this time with the file stuff correct) --- src/remodel_api/remodel.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/remodel_api/remodel.rs b/src/remodel_api/remodel.rs index 36a5cdb..d17fec9 100644 --- a/src/remodel_api/remodel.rs +++ b/src/remodel_api/remodel.rs @@ -4,6 +4,7 @@ use std::{ io::{BufReader, BufWriter, Read}, path::Path, sync::Arc, + time::Duration, }; use rbx_dom_weak::{types::VariantType, InstanceBuilder, WeakDom}; @@ -196,7 +197,11 @@ impl Remodel { let auth_cookie = re_context.auth_cookie(); let url = format!("https://assetdelivery.roblox.com/v1/asset/?id={}", asset_id); - let client = reqwest::Client::new(); + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(60 * 3)) + .build() + .map_err(rlua::Error::external)?; + let mut request = client.get(&url); if let Some(auth_cookie) = auth_cookie { @@ -241,7 +246,10 @@ impl Remodel { let auth_cookie = re_context.auth_cookie(); let url = format!("https://assetdelivery.roblox.com/v1/asset/?id={}", asset_id); - let client = reqwest::Client::new(); + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(60 * 3)) + .build() + .map_err(rlua::Error::external)?; let mut request = client.get(&url); if let Some(auth_cookie) = auth_cookie { @@ -340,7 +348,11 @@ impl Remodel { asset_id ); - let client = reqwest::Client::new(); + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(60 * 3)) + .build() + .map_err(rlua::Error::external)?; + let build_request = move || { client .post(&url)