mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Extend Read & Write BufferSize header and max request body size is 8mb now
This commit is contained in:
parent
4fd3460662
commit
e61d1f8c3c
|
@ -9,14 +9,28 @@ import (
|
||||||
"github.com/kataras/fasthttp"
|
"github.com/kataras/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Default values for base Server conf
|
// Default values for base Server conf, can be changed for global use
|
||||||
const (
|
var (
|
||||||
// DefaultServerHostname returns the default hostname which is 127.0.0.1
|
// DefaultServerHostname returns the default hostname which is 127.0.0.1
|
||||||
DefaultServerHostname = "127.0.0.1"
|
DefaultServerHostname = "127.0.0.1"
|
||||||
// DefaultServerPort returns the default port which is 8080
|
// DefaultServerPort returns the default port which is 8080
|
||||||
DefaultServerPort = 8080
|
DefaultServerPort = 8080
|
||||||
// DefaultMaxRequestBodySize is 4MB
|
// DefaultMaxRequestBodySize is 8MB
|
||||||
DefaultMaxRequestBodySize = fasthttp.DefaultMaxRequestBodySize
|
DefaultMaxRequestBodySize = 2 * fasthttp.DefaultMaxRequestBodySize
|
||||||
|
|
||||||
|
// Per-connection buffer size for requests' reading.
|
||||||
|
// This also limits the maximum header size.
|
||||||
|
//
|
||||||
|
// Increase this buffer if your clients send multi-KB RequestURIs
|
||||||
|
// and/or multi-KB headers (for example, BIG cookies).
|
||||||
|
//
|
||||||
|
// Default buffer size is 8MB
|
||||||
|
DefaultReadBufferSize = 8096
|
||||||
|
|
||||||
|
// Per-connection buffer size for responses' writing.
|
||||||
|
//
|
||||||
|
// Default buffer size is 8MB
|
||||||
|
DefaultWriteBufferSize = 8096
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -39,8 +53,22 @@ type Server struct {
|
||||||
//
|
//
|
||||||
// The server rejects requests with bodies exceeding this limit.
|
// The server rejects requests with bodies exceeding this limit.
|
||||||
//
|
//
|
||||||
// By default request body size is 4MB.
|
// By default request body size is 8MB.
|
||||||
MaxRequestBodySize int64
|
MaxRequestBodySize int
|
||||||
|
|
||||||
|
// Per-connection buffer size for requests' reading.
|
||||||
|
// This also limits the maximum header size.
|
||||||
|
//
|
||||||
|
// Increase this buffer if your clients send multi-KB RequestURIs
|
||||||
|
// and/or multi-KB headers (for example, BIG cookies).
|
||||||
|
//
|
||||||
|
// Default buffer size is used if not set.
|
||||||
|
ReadBufferSize int
|
||||||
|
|
||||||
|
// Per-connection buffer size for responses' writing.
|
||||||
|
//
|
||||||
|
// Default buffer size is used if not set.
|
||||||
|
WriteBufferSize int
|
||||||
// RedirectTo, defaults to empty, set it in order to override the station's handler and redirect all requests to this address which is of form(HOST:PORT or :PORT)
|
// RedirectTo, defaults to empty, set it in order to override the station's handler and redirect all requests to this address which is of form(HOST:PORT or :PORT)
|
||||||
//
|
//
|
||||||
// NOTE: the http status is 'StatusMovedPermanently', means one-time-redirect(the browser remembers the new addr and goes to the new address without need to request something from this server
|
// NOTE: the http status is 'StatusMovedPermanently', means one-time-redirect(the browser remembers the new addr and goes to the new address without need to request something from this server
|
||||||
|
@ -86,7 +114,10 @@ func ServerParseAddr(listeningAddr string) string {
|
||||||
// DefaultServer returns the default configs for the server
|
// DefaultServer returns the default configs for the server
|
||||||
func DefaultServer() Server {
|
func DefaultServer() Server {
|
||||||
return Server{ListeningAddr: DefaultServerAddr,
|
return Server{ListeningAddr: DefaultServerAddr,
|
||||||
MaxRequestBodySize: DefaultMaxRequestBodySize}
|
MaxRequestBodySize: DefaultMaxRequestBodySize,
|
||||||
|
ReadBufferSize: DefaultReadBufferSize,
|
||||||
|
WriteBufferSize: DefaultWriteBufferSize,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge merges the default with the given config and returns the result
|
// Merge merges the default with the given config and returns the result
|
||||||
|
|
6
http.go
6
http.go
|
@ -399,9 +399,9 @@ func (s *Server) Open(h fasthttp.RequestHandler) error {
|
||||||
|
|
||||||
s.prepare() // do it again for any case
|
s.prepare() // do it again for any case
|
||||||
|
|
||||||
if s.Config.MaxRequestBodySize > config.DefaultMaxRequestBodySize {
|
s.Server.MaxRequestBodySize = s.Config.MaxRequestBodySize
|
||||||
s.Server.MaxRequestBodySize = int(s.Config.MaxRequestBodySize)
|
s.Server.ReadBufferSize = s.Config.ReadBufferSize
|
||||||
}
|
s.Server.WriteBufferSize = s.Config.WriteBufferSize
|
||||||
|
|
||||||
if s.Config.RedirectTo != "" {
|
if s.Config.RedirectTo != "" {
|
||||||
// override the handler and redirect all requests to this addr
|
// override the handler and redirect all requests to this addr
|
||||||
|
|
2
iris.go
2
iris.go
|
@ -372,6 +372,8 @@ func ListenTo(cfg config.Server) error {
|
||||||
// it's a blocking func
|
// it's a blocking func
|
||||||
func (s *Framework) ListenTo(cfg config.Server) (err error) {
|
func (s *Framework) ListenTo(cfg config.Server) (err error) {
|
||||||
s.Servers.Add(cfg)
|
s.Servers.Add(cfg)
|
||||||
|
c := config.DefaultServer().MergeSingle(cfg)
|
||||||
|
s.Servers.Add(c)
|
||||||
return s.Go()
|
return s.Go()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user