From b2d1e6396d27d3af936b1c1150be2f354cc4ebdf Mon Sep 17 00:00:00 2001 From: Makis Maropoulos <makis@ideopod.com> Date: Wed, 29 Jun 2016 20:07:35 +0300 Subject: [PATCH] Set the default max request body size to 4mb Align with https://github.com/valyala/fasthttp/commit/e4db3cb5600317e91d93e07036e4d20903c8fa17 --- config/iris.go | 6 ++++-- initiatory.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/iris.go b/config/iris.go index 4f267a94..0d6ec95d 100644 --- a/config/iris.go +++ b/config/iris.go @@ -2,12 +2,14 @@ package config import ( "github.com/imdario/mergo" + "github.com/valyala/fasthttp" ) // Default values for base Iris conf const ( DefaultDisablePathCorrection = false DefaultDisablePathEscape = false + DefaultMaxRequestBodySize = fasthttp.DefaultMaxRequestBodySize ) type ( @@ -56,7 +58,7 @@ type ( // // 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 // ProfilePath a the route path, set it to enable http pprof tool @@ -137,7 +139,7 @@ func Default() Iris { DisablePathCorrection: DefaultDisablePathCorrection, DisablePathEscape: DefaultDisablePathEscape, DisableBanner: false, - MaxRequestBodySize: -1, + MaxRequestBodySize: DefaultMaxRequestBodySize, ProfilePath: "", Logger: DefaultLogger(), Sessions: DefaultSessions(), diff --git a/initiatory.go b/initiatory.go index 2480f793..4139857f 100644 --- a/initiatory.go +++ b/initiatory.go @@ -130,7 +130,7 @@ func (s *Framework) initialize() { 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) } }