1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 12:31:58 +00:00

Extend Read & Write BufferSize header and max request body size is 8mb now

This commit is contained in:
Makis Maropoulos
2016-07-12 15:40:06 +02:00
parent 4fd3460662
commit e61d1f8c3c
3 changed files with 43 additions and 10 deletions

View File

@@ -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