Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKassio Borges <kassioborgesm@gmail.com>2023-05-17 18:02:06 +0300
committerKassio Borges <kassioborgesm@gmail.com>2023-05-17 18:02:06 +0300
commit89c333a866ceef7d6d970999a13778804d7a45cc (patch)
tree16d28a55611ed608b9a422f1d0cd19cb2b26d55a /server.go
parentf86f076800e10bac97c9d7cde04ba38300a2aa63 (diff)
Ensure to use configured timeouts in http.Server
Diffstat (limited to 'server.go')
-rw-r--r--server.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/server.go b/server.go
index 0c0c3c8d..9d667157 100644
--- a/server.go
+++ b/server.go
@@ -22,6 +22,15 @@ type listenerConfig struct {
limiter *netutil.Limiter
}
+func newHTTPServer(a *theApp) *http.Server {
+ return &http.Server{
+ ReadTimeout: a.config.Server.ReadTimeout,
+ ReadHeaderTimeout: a.config.Server.ReadHeaderTimeout,
+ WriteTimeout: a.config.Server.WriteTimeout,
+ ErrorLog: stdlog.New(logrus.StandardLogger().Writer(), "", 0),
+ }
+}
+
func (a *theApp) listenAndServe(server *http.Server, addr string, h http.Handler, opts ...option) error {
config := &listenerConfig{}
@@ -33,17 +42,12 @@ func (a *theApp) listenAndServe(server *http.Server, addr string, h http.Handler
server.Handler = h
server.TLSConfig = config.tlsConfig
- server.ErrorLog = stdlog.New(logrus.StandardLogger().Writer(), "", 0)
// ensure http2 is enabled even if TLSConfig is not null
// See https://github.com/golang/go/blob/97cee43c93cfccded197cd281f0a5885cdb605b4/src/net/http/server.go#L2947-L2954
if server.TLSConfig != nil {
server.TLSConfig.NextProtos = append(server.TLSConfig.NextProtos, "h2")
}
- server.ReadTimeout = a.config.Server.ReadTimeout
- server.ReadHeaderTimeout = a.config.Server.ReadHeaderTimeout
- server.WriteTimeout = a.config.Server.WriteTimeout
-
lc := net.ListenConfig{
KeepAlive: a.config.Server.ListenKeepAlive,
}