mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +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"
|
||||
)
|
||||
|
||||
// Default values for base Server conf
|
||||
const (
|
||||
// Default values for base Server conf, can be changed for global use
|
||||
var (
|
||||
// DefaultServerHostname returns the default hostname which is 127.0.0.1
|
||||
DefaultServerHostname = "127.0.0.1"
|
||||
// DefaultServerPort returns the default port which is 8080
|
||||
DefaultServerPort = 8080
|
||||
// DefaultMaxRequestBodySize is 4MB
|
||||
DefaultMaxRequestBodySize = fasthttp.DefaultMaxRequestBodySize
|
||||
// DefaultMaxRequestBodySize is 8MB
|
||||
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 (
|
||||
|
@ -39,8 +53,22 @@ type Server struct {
|
|||
//
|
||||
// The server rejects requests with bodies exceeding this limit.
|
||||
//
|
||||
// By default request body size is 4MB.
|
||||
MaxRequestBodySize int64
|
||||
// By default request body size is 8MB.
|
||||
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)
|
||||
//
|
||||
// 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
|
||||
func DefaultServer() Server {
|
||||
return Server{ListeningAddr: DefaultServerAddr,
|
||||
MaxRequestBodySize: DefaultMaxRequestBodySize}
|
||||
MaxRequestBodySize: DefaultMaxRequestBodySize,
|
||||
ReadBufferSize: DefaultReadBufferSize,
|
||||
WriteBufferSize: DefaultWriteBufferSize,
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
if s.Config.MaxRequestBodySize > config.DefaultMaxRequestBodySize {
|
||||
s.Server.MaxRequestBodySize = int(s.Config.MaxRequestBodySize)
|
||||
}
|
||||
s.Server.MaxRequestBodySize = s.Config.MaxRequestBodySize
|
||||
s.Server.ReadBufferSize = s.Config.ReadBufferSize
|
||||
s.Server.WriteBufferSize = s.Config.WriteBufferSize
|
||||
|
||||
if s.Config.RedirectTo != "" {
|
||||
// override the handler and redirect all requests to this addr
|
||||
|
|
Loading…
Reference in New Issue
Block a user