diff options
author | Francis Lavoie <lavofr@gmail.com> | 2020-11-02 17:11:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 15:11:17 -0700 |
commit | eda9a1b377effed349f2e818a3ce71c3c8df6173 (patch) | |
tree | d4308305780a5f8aa7b94c6340d19d473c9e1983 /modules/caddyhttp | |
parent | 860cc6adfe6a5022baf5fd387e0d10c5e3a174fe (diff) |
fastcgi: Add timeouts support to Caddyfile adapter (#3842)
* fastcgi: Add timeouts support to Caddyfile adapter
* fastcgi: Use tabs instead of spaces
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go index 8228439..4d0b23b 100644 --- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go @@ -40,6 +40,9 @@ func init() { // split <at> // env <key> <value> // resolve_root_symlink +// dial_timeout <duration> +// read_timeout <duration> +// write_timeout <duration> // } // func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { @@ -69,8 +72,41 @@ func (t *Transport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { t.EnvVars[args[0]] = args[1] case "resolve_root_symlink": + if d.NextArg() { + return d.ArgErr() + } t.ResolveRootSymlink = true + case "dial_timeout": + if !d.NextArg() { + return d.ArgErr() + } + dur, err := caddy.ParseDuration(d.Val()) + if err != nil { + return d.Errf("bad timeout value %s: %v", d.Val(), err) + } + t.DialTimeout = caddy.Duration(dur) + + case "read_timeout": + if !d.NextArg() { + return d.ArgErr() + } + dur, err := caddy.ParseDuration(d.Val()) + if err != nil { + return d.Errf("bad timeout value %s: %v", d.Val(), err) + } + t.ReadTimeout = caddy.Duration(dur) + + case "write_timeout": + if !d.NextArg() { + return d.ArgErr() + } + dur, err := caddy.ParseDuration(d.Val()) + if err != nil { + return d.Errf("bad timeout value %s: %v", d.Val(), err) + } + t.WriteTimeout = caddy.Duration(dur) + default: return d.Errf("unrecognized subdirective %s", d.Val()) } @@ -208,6 +244,42 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error dispenser.Delete() } fcgiTransport.ResolveRootSymlink = true + + case "dial_timeout": + if !dispenser.NextArg() { + return nil, dispenser.ArgErr() + } + dur, err := caddy.ParseDuration(dispenser.Val()) + if err != nil { + return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err) + } + fcgiTransport.DialTimeout = caddy.Duration(dur) + dispenser.Delete() + dispenser.Delete() + + case "read_timeout": + if !dispenser.NextArg() { + return nil, dispenser.ArgErr() + } + dur, err := caddy.ParseDuration(dispenser.Val()) + if err != nil { + return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err) + } + fcgiTransport.ReadTimeout = caddy.Duration(dur) + dispenser.Delete() + dispenser.Delete() + + case "write_timeout": + if !dispenser.NextArg() { + return nil, dispenser.ArgErr() + } + dur, err := caddy.ParseDuration(dispenser.Val()) + if err != nil { + return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err) + } + fcgiTransport.WriteTimeout = caddy.Duration(dur) + dispenser.Delete() + dispenser.Delete() } } } |