From 9722dbe18a568b8229e07bafb6189a08fa3859e2 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 11 Jul 2019 22:02:47 -0600 Subject: Fix rehandling bug --- modules/caddyhttp/caddyhttp.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'modules/caddyhttp/caddyhttp.go') diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index ae73c98..467b40f 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -85,6 +85,10 @@ func (app *App) Provision(ctx caddy.Context) error { return fmt.Errorf("setting up server error handling routes: %v", err) } } + + if srv.MaxRehandles == nil { + srv.MaxRehandles = &DefaultMaxRehandles + } } return nil @@ -111,8 +115,8 @@ func (app *App) Validate() error { // each server's max rehandle value must be valid for srvName, srv := range app.Servers { - if srv.MaxRehandles < 0 { - return fmt.Errorf("%s: invalid max_rehandles value: %d", srvName, srv.MaxRehandles) + if srv.MaxRehandles != nil && *srv.MaxRehandles < 0 { + return fmt.Errorf("%s: invalid max_rehandles value: %d", srvName, *srv.MaxRehandles) } } @@ -435,6 +439,10 @@ const ( DefaultHTTPSPort = 443 ) +// DefaultMaxRehandles is the maximum number of rehandles to +// allow, if not specified explicitly. +var DefaultMaxRehandles = 3 + // Interface guards var ( _ caddy.App = (*App)(nil) -- cgit v1.2.3