From b2b973e36c0a12d8752c282e40c6cedbdd4183e9 Mon Sep 17 00:00:00 2001 From: itsusinn Date: Tue, 18 Jan 2022 23:14:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=84=8F=E6=96=99=E5=A4=96=E7=9A=84?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由代理引起 --- src/net.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/net.rs b/src/net.rs index ea8135b..f539fd5 100644 --- a/src/net.rs +++ b/src/net.rs @@ -1,6 +1,20 @@ +use std::time::Duration; + fn default_reqwest_settings() -> reqwest::ClientBuilder { // maybe we should configure it by ourselves - teloxide_core::net::default_reqwest_settings() + use reqwest::header::{HeaderMap, CONNECTION}; + + let mut headers = HeaderMap::new(); + headers.insert(CONNECTION, "keep-alive".parse().unwrap()); + + let connect_timeout = Duration::from_secs(10); + let timeout = connect_timeout + Duration::from_secs(24); + + reqwest::Client::builder() + .connect_timeout(connect_timeout) + .timeout(timeout) + .tcp_nodelay(true) + .default_headers(headers) } pub fn client_from_config() -> reqwest::Client { use crate::config::CONFIG;