diff --git a/config/config.go b/config/config.go index f96e041..f90f3ed 100755 --- a/config/config.go +++ b/config/config.go @@ -64,6 +64,9 @@ type Server struct { // ShutdownDelay represents the delay duration between the health check server shutdown and the api server shutdown. ShutdownDelay string `yaml:"shutdownDelay"` + // DisableKeepAlives represents whether HTTP keep-alive connections should be disabled between the client and the Provider Sidecar. + DisableKeepAlives bool `yaml:"disableKeepAlives"` + // TLS represents the TLS configuration of the authorization proxy. TLS TLS `yaml:"tls"` diff --git a/config/config_test.go b/config/config_test.go index b557508..e14761c 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -77,10 +77,11 @@ func TestNew(t *testing.T) { want: &Config{ Version: "v2.0.0", Server: Server{ - Port: 8082, - Timeout: "10s", - ShutdownTimeout: "10s", - ShutdownDelay: "9s", + Port: 8082, + Timeout: "10s", + ShutdownTimeout: "10s", + ShutdownDelay: "9s", + DisableKeepAlives: true, TLS: TLS{ Enable: true, CertPath: "test/data/dummyServer.crt", diff --git a/service/server.go b/service/server.go index 66c0c61..f3b3c19 100644 --- a/service/server.go +++ b/service/server.go @@ -126,7 +126,7 @@ func NewServer(opts ...Option) (Server, error) { Addr: fmt.Sprintf(":%d", s.cfg.Port), Handler: s.srvHandler, } - s.srv.SetKeepAlivesEnabled(true) + s.srv.SetKeepAlivesEnabled(!s.cfg.DisableKeepAlives) if s.cfg.TLS.Enable { s.srv.TLSConfig = s.tlsConfig } diff --git a/test/data/example_config.yaml b/test/data/example_config.yaml index 2e74360..c8978b0 100644 --- a/test/data/example_config.yaml +++ b/test/data/example_config.yaml @@ -5,6 +5,7 @@ server: timeout: 10s shutdownTimeout: 10s shutdownDelay: 9s + disableKeepAlives: true tls: enable: true certPath: "test/data/dummyServer.crt"