Skip to content

Commit

Permalink
Merge pull request #144 from LiilyZhang/zhangl/staticScan
Browse files Browse the repository at this point in the history
Issue142 - Configure ReadHeaderTimeout in http.Server
  • Loading branch information
LiilyZhang authored Feb 17, 2023
2 parents e76c2d0 + b31b396 commit f282c4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ type Config struct {
// default is 1
HTTPCSSObjDownloadConcurrencyMultiplier int `env:"HTTPCSSObjDownloadConcurrencyMultiplier"`

// HTTPServerReadHeaderTimeout is to specifyt the http server ReadHeaderTimout in second
// default is 60
HTTPServerReadHeaderTimeout int `env:"HTTPServerReadHeaderTimeout"`

// LogLevel specifies the logging level in string format
LogLevel string `env:"LOG_LEVEL"`

Expand Down Expand Up @@ -760,6 +764,7 @@ func SetDefaultConfig(config *Config) {
config.HTTPESSClientTimeout = 120
config.HTTPESSObjClientTimeout = 600
config.HTTPCSSObjDownloadConcurrencyMultiplier = 1
config.HTTPServerReadHeaderTimeout = 60
config.MessagingGroupCacheExpiration = 60
config.ShutdownQuiesceTime = 60
config.ESSConsumedObjectsKept = 1000
Expand Down
5 changes: 3 additions & 2 deletions core/base/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"

"github.com/open-horizon/edge-sync-service/common"
"github.com/open-horizon/edge-utilities/logger"
Expand All @@ -21,8 +22,8 @@ var secureHTTPServer http.Server
var unsecureHTTPServer http.Server

func startHTTPServer(ipAddress string, registerHandlers bool, swaggerFile string) common.SyncServiceError {
secureHTTPServer = http.Server{}
unsecureHTTPServer = http.Server{}
secureHTTPServer = http.Server{ReadHeaderTimeout: time.Second * time.Duration(common.Configuration.HTTPServerReadHeaderTimeout)}
unsecureHTTPServer = http.Server{ReadHeaderTimeout: time.Second * time.Duration(common.Configuration.HTTPServerReadHeaderTimeout)}

secureHTTPServer.Addr =
fmt.Sprintf("%s:%d", common.Configuration.ListeningAddress,
Expand Down

0 comments on commit f282c4a

Please sign in to comment.