[PATCHv2,7/7] http-client-functions.pl: Allow to user define the timeout value.

Message ID 20250418110741.7756-8-stefan.schantl@ipfire.org
State New
Headers
Series Introduce perl LWP-based flexible downloader function |

Commit Message

Stefan Schantl April 18, 2025, 10:54 a.m. UTC
  This allows to specify the the timeout value.
Defaults to to 60 seconds if not set.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/cfgroot/http-client-functions.pl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  

Patch

diff --git a/config/cfgroot/http-client-functions.pl b/config/cfgroot/http-client-functions.pl
index f1f7de309..c9484c575 100644
--- a/config/cfgroot/http-client-functions.pl
+++ b/config/cfgroot/http-client-functions.pl
@@ -89,6 +89,10 @@  sub downloader (%) {
 	$etagprefix = $args{"ETAGPREFIX"} if (exists($args{"ETAGPREFIX"}));
 	my $max_size = $args{"MAXSIZE"} if (exists($args{"MAXSIZE"}));
 
+	# Timeout defaults to 60 Seconds if not set.
+	my $timeout = 60;
+	$timeout = $args{"TIMEOUT"} if (exists($args{"TIMEOUT"}));
+
 	# Abort with error "no url", if no URL has been given.
 	die "downloader: No URL has been given." unless ($url);
 
@@ -110,8 +114,9 @@  sub downloader (%) {
 		},
 	);
 
-	# Set timeout to 10 seconds.
-	$ua->timeout(10);
+	# Set the timeout to the configured value.
+	# Defaults to 60 seconds if not set.
+	$ua->timeout($timeout);
 
 	# Assign maximum download size if set.
 	$ua->max_size($max_size) if ($max_size);