Skip to content

Commit

Permalink
Alex's review
Browse files Browse the repository at this point in the history
  • Loading branch information
guscarreon committed Apr 25, 2024
1 parent 99c1461 commit ac6b5fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
12 changes: 12 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,18 @@ func TestRequestLimitsValidateAndLog(t *testing.T) {
},
expectFatal: true,
},
{
description: "Negative max_num_values, expect fatal level log and early exit",
inRequestLimitsCfg: &RequestLimits{MaxHeaderSize: -1},
expectedLogInfo: []logComponents{
{msg: `config.request_limits.allow_setting_keys: false`, lvl: logrus.InfoLevel},
{msg: `config.request_limits.max_ttl_seconds: 0`, lvl: logrus.InfoLevel},
{msg: `config.request_limits.max_size_bytes: 0`, lvl: logrus.InfoLevel},
{msg: `config.request_limits.max_num_values: 0`, lvl: logrus.InfoLevel},
{msg: `invalid config.request_limits.max_header_size_bytes: -1. Value cannot be negative.`, lvl: logrus.FatalLevel},
},
expectFatal: true,
},
}

//substitute logger exit function so execution doesn't get interrupted
Expand Down
15 changes: 8 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ func Listen(cfg config.Configuration, publicHandler http.Handler, adminHandler h
return
}

// newAdminServer returns an http.Server with the configured with the AdminPort and
// RequestLimits.MaxHeaderBytes values specified in Prebid Cache's config files or
// environment variables. If RequestLimits.MaxHeaderBytes is zero or non-specified,
// the http library sets server.MaxHeaderBytes to the value of http.DefaultMaxHeaderBytes
// newAdminServer returns an http.Server with the AdminPort and RequestLimits.MaxHeaderBytes
// from Prebid Cache's config files or environment variables. If RequestLimits.MaxHeaderBytes
// is zero or was not specified the the http library's DefaultMaxHeaderBytes value of 1 MB
// is set instead.
func newAdminServer(cfg config.Configuration, handler http.Handler) *http.Server {
server := &http.Server{
Addr: ":" + strconv.Itoa(cfg.AdminPort),
Expand All @@ -89,10 +89,11 @@ func newAdminServer(cfg config.Configuration, handler http.Handler) *http.Server
return server
}

// newMainServer returns an http.Server with the configured with the Port and
// newMainServer returns an http.Server with the configured Port and
// RequestLimits.MaxHeaderBytes values specified in Prebid Cache's config files
// or environment variables. If RequestLimits.MaxHeaderBytes is zero or non-specified,
// 1 MB, which is the value of the http library's DefaultMaxHeaderBytes, is set instead.
// or environment variables. If RequestLimits.MaxHeaderBytes is zero or was not
// specified, 1 MB, which is the value of the http library's DefaultMaxHeaderBytes,
// is set instead.
func newMainServer(cfg config.Configuration, handler http.Handler) *http.Server {
server := &http.Server{
Addr: ":" + strconv.Itoa(cfg.Port),
Expand Down

0 comments on commit ac6b5fb

Please sign in to comment.