Update http client timeout, add env
@@ -33,7 +33,7 @@ use proxy::{proxy_unless_domain_exempted, ProxyInfo};
use ssl;
// Read and write TCP socket timeout for Hyper/HTTP client calls.
-const CLIENT_SOCKET_RW_TIMEOUT: u64 = 60;
+const CLIENT_SOCKET_RW_TIMEOUT_SEC: u64 = 120;
header! { (ProxyAuthorization, "Proxy-Authorization") => [String] }
@@ -248,7 +248,19 @@ impl ApiClient {
fn new_hyper_client(url: &Url, fs_root_path: Option<&Path>) -> Result<HyperClient> {
let connector = ssl_connector(fs_root_path)?;
let ssl_client = OpensslClient::from(connector);
- let timeout = Some(Duration::from_secs(CLIENT_SOCKET_RW_TIMEOUT));
+
+ let timeout_in_secs = match env::var("HAB_CLIENT_SOCKET_TIMEOUT") {
+ Ok(t) => {
+ match t.parse::<u64>() {
+ Ok(n) => n,
+ Err(_) => CLIENT_SOCKET_RW_TIMEOUT_SEC,
+ }
+ }
+ Err(_) => CLIENT_SOCKET_RW_TIMEOUT_SEC,
+ };
+ debug!("Client socket timeout: {} secs", timeout_in_secs);
+
+ let timeout = Some(Duration::from_secs(timeout_in_secs));
match proxy_unless_domain_exempted(Some(url))? {
Some(proxy) => {
@@ -317,7 +329,9 @@ fn ssl_connector(fs_root_path: Option<&Path>) -> Result<SslConnector> {
options.toggle(SSL_OP_NO_COMPRESSION);
ssl::set_ca(&mut conn, fs_root_path)?;
conn.set_options(options);
- conn.set_cipher_list("ALL!EXPORT!EXPORT40!EXPORT56!aNULL!LOW!RC4@STRENGTH")?;
+ conn.set_cipher_list(
+ "ALL!EXPORT!EXPORT40!EXPORT56!aNULL!LOW!RC4@STRENGTH",
+ )?;
if env::var("HAB_SSL_CERT_VERIFY_NONE").is_ok() {
conn.set_verify(SSL_VERIFY_NONE);
