Skip to content

Commit

Permalink
Set connect timeout to 5 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
2bc4 committed Dec 30, 2023
1 parent f0baf34 commit 7966fea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pub const DEFAULT_CLIENT_ID: &str = "kimne78kx3ncx6brgo4mv6wki5h1ko";
pub const DEFAULT_CONFIG_PATH: &str = "twitch-hls-client/config";

pub const HTTP_RETRIES: u8 = 3;
pub const HTTP_CONNECT_TIMEOUT_SECS: u64 = 5;
2 changes: 2 additions & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{
fmt,
io::{self, Write},
str,
time::Duration,
};

use anyhow::Result;
Expand All @@ -28,6 +29,7 @@ impl fmt::Display for Error {

fn init_curl<T: Write>(handle: &mut Easy2<RequestHandler<T>>, url: &Url) -> Result<()> {
handle.verbose(log::max_level() == log::LevelFilter::Debug)?;
handle.connect_timeout(Duration::from_secs(constants::HTTP_CONNECT_TIMEOUT_SECS))?;
handle.tcp_nodelay(true)?;
handle.accept_encoding("")?;
handle.useragent(constants::USER_AGENT)?;
Expand Down

0 comments on commit 7966fea

Please sign in to comment.