Make proxy timeouts configurable
Change-Id: I761f8e1c3fe6e57936e7ac9cee7422e94ec94ee4
diff --git a/Changes b/Changes
index b34b0a8..aa1455f 100755
--- a/Changes
+++ b/Changes
@@ -29,6 +29,7 @@
- Refresh corpus statistics by clicking the
statistics button (#107, hebasta)
- Fixed links to Leibniz association (hebasta)
+ - Make proxy timeouts configurable.
0.36 2019-09-19
- Rename all cookies to be independent
diff --git a/kalamar.conf b/kalamar.conf
index a9d78b9..ee35197 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -56,6 +56,10 @@
## Add experimental features:
# experimental_proxy => 1,
+
+ ## Set proxy timeouts
+ # proxy_inactivity_timeout => 120,
+ # proxy_connect_timeout => 120,
},
# See Mojolicious::Plugin::TagHelpers::MailToChiffre
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index c597634..bf77ad2 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -37,7 +37,6 @@
# Add additional plugin path
push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
-
# Set secrets for signed cookies
if (-e (my $secret = $self->home->child('kalamar.secret'))) {
@@ -115,6 +114,14 @@
push @{$self->static->paths}, 'dev';
};
+ # Set proxy timeouts
+ if ($conf->{proxy_inactivity_timeout}) {
+ $self->ua->inactivity_timeout($conf->{proxy_inactivity_timeout});
+ };
+ if ($conf->{proxy_connect_timeout}) {
+ $self->ua->connect_timeout($conf->{proxy_connect_timeout});
+ };
+
# Client notifications
$self->plugin(Notifications => {
'Kalamar::Plugin::Notifications' => 1,
diff --git a/t/proxy.t b/t/proxy.t
index 41b0acf..7c54127 100644
--- a/t/proxy.t
+++ b/t/proxy.t
@@ -14,7 +14,9 @@
my $t = Test::Mojo->new('Kalamar' => {
Kalamar => {
plugins => ['Auth'],
- experimental_proxy => 1
+ experimental_proxy => 1,
+ proxy_inactivity_timeout => 99,
+ proxy_connect_timeout => 66,
}
});
@@ -105,6 +107,10 @@
});
# Set proxy timeout
+is($t->app->ua->inactivity_timeout, 99);
+is($t->app->ua->connect_timeout, 66);
+
+# Set proxy timeout
$t->app->ua->inactivity_timeout(1);
$t->get_ok('/api/v1.0/longwait')