From 4e5c050d3e8d966d17c727e2bff0be56bea4496d Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Sun, 19 Apr 2020 15:42:19 +0200 Subject: [PATCH 1/2] Bumb fasthttp to v1.11 --- go.mod | 2 +- go.sum | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 01c7106dbe..dcd4a2a9d6 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.11 require ( github.com/gorilla/schema v1.1.0 github.com/json-iterator/go v1.1.9 - github.com/valyala/fasthttp v1.9.0 + github.com/valyala/fasthttp v1.11.0 ) diff --git a/go.sum b/go.sum index 1c40fec1d9..560f1f5a61 100644 --- a/go.sum +++ b/go.sum @@ -7,26 +7,19 @@ github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGn github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc= -github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw= -github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= +github.com/valyala/fasthttp v1.11.0 h1:CpWaRjWmZMkgcngl8P7ygGoHmfXSZDcKx3Vdv8Bdkuw= +github.com/valyala/fasthttp v1.11.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= From a88b58959b1ae74b38c8a32e81d92d26ba66d5d3 Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Sun, 19 Apr 2020 16:10:19 +0200 Subject: [PATCH 2/2] Update app.go --- app.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app.go b/app.go index f9bbd5a51c..566cfaa9ca 100644 --- a/app.go +++ b/app.go @@ -24,7 +24,7 @@ import ( ) // Version of current package -const Version = "1.9.0" +const Version = "1.9.1" // Map is a shortcut for map[string]interface{} type Map map[string]interface{} @@ -50,6 +50,14 @@ type Settings struct { Immutable bool // default: false // Max body size that the server accepts BodyLimit int // default: 4 * 1024 * 1024 + // Maximum number of concurrent connections. + Concurrency int // default: 256 * 1024 + // Disable keep-alive connections, the server will close incoming connections after sending the first response to client + DisableKeepalive bool // default: false + // When set to true causes the default date header to be excluded from the response. + DisableDefaultDate bool // default: false + // When set to true, causes the default Content-Type header to be excluded from the Response. + DisableDefaultContentType bool // default: false // Folder containing template files TemplateFolder string // default: "" // Template engine: html, amber, handlebars , mustache or pug @@ -88,9 +96,12 @@ func New(settings ...*Settings) *App { if !app.Settings.Prefork { // Default to -prefork flag if false app.Settings.Prefork = isPrefork() } - if app.Settings.BodyLimit == 0 { // Default MaxRequestBodySize + if app.Settings.BodyLimit <= 0 { // Default MaxRequestBodySize app.Settings.BodyLimit = 4 * 1024 * 1024 } + if app.Settings.Concurrency <= 0 { + app.Settings.Concurrency = 256 * 1024 + } if app.Settings.Immutable { // Replace unsafe conversion funcs getString = getStringImmutable getBytes = getBytesImmutable @@ -488,6 +499,10 @@ func (app *App) newServer() *fasthttp.Server { return &fasthttp.Server{ Handler: app.handler, Name: app.Settings.ServerHeader, + Concurrency: app.Settings.Concurrency, + NoDefaultDate: app.Settings.DisableDefaultDate, + NoDefaultContentType: app.Settings.DisableDefaultContentType, + DisableKeepalive: app.Settings.DisableKeepalive, MaxRequestBodySize: app.Settings.BodyLimit, NoDefaultServerHeader: app.Settings.ServerHeader == "", ReadTimeout: app.Settings.ReadTimeout,