Set the default max request body size to 4mb

Align with
e4db3cb560
This commit is contained in:
Makis Maropoulos 2016-06-29 20:07:35 +03:00
parent f57d457d39
commit b2d1e6396d
2 changed files with 5 additions and 3 deletions

View File

@ -2,12 +2,14 @@ package config
import ( import (
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/valyala/fasthttp"
) )
// Default values for base Iris conf // Default values for base Iris conf
const ( const (
DefaultDisablePathCorrection = false DefaultDisablePathCorrection = false
DefaultDisablePathEscape = false DefaultDisablePathEscape = false
DefaultMaxRequestBodySize = fasthttp.DefaultMaxRequestBodySize
) )
type ( type (
@ -56,7 +58,7 @@ type (
// //
// The server rejects requests with bodies exceeding this limit. // The server rejects requests with bodies exceeding this limit.
// //
// By default request body size is -1, unlimited. // By default request body size is 4MB.
MaxRequestBodySize int64 MaxRequestBodySize int64
// ProfilePath a the route path, set it to enable http pprof tool // ProfilePath a the route path, set it to enable http pprof tool
@ -137,7 +139,7 @@ func Default() Iris {
DisablePathCorrection: DefaultDisablePathCorrection, DisablePathCorrection: DefaultDisablePathCorrection,
DisablePathEscape: DefaultDisablePathEscape, DisablePathEscape: DefaultDisablePathEscape,
DisableBanner: false, DisableBanner: false,
MaxRequestBodySize: -1, MaxRequestBodySize: DefaultMaxRequestBodySize,
ProfilePath: "", ProfilePath: "",
Logger: DefaultLogger(), Logger: DefaultLogger(),
Sessions: DefaultSessions(), Sessions: DefaultSessions(),

View File

@ -130,7 +130,7 @@ func (s *Framework) initialize() {
s.Handle(MethodGet, debugPath+"/*action", profileMiddleware(debugPath)...) s.Handle(MethodGet, debugPath+"/*action", profileMiddleware(debugPath)...)
} }
if s.Config.MaxRequestBodySize > 0 { if s.Config.MaxRequestBodySize > config.DefaultMaxRequestBodySize {
s.HTTPServer.MaxRequestBodySize = int(s.Config.MaxRequestBodySize) s.HTTPServer.MaxRequestBodySize = int(s.Config.MaxRequestBodySize)
} }
} }