From a917115a858546ab48c0f0ccbcf5afb68e4794e4 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 3 Sep 2019 15:02:05 +0200 Subject: [PATCH] fix buffering middleware --- cmd/traefik/traefik.go | 4 ++-- pkg/server/middleware/middlewares.go | 4 ++-- pkg/server/middleware/middlewares_test.go | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 6c46fef78..8702855b9 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -299,14 +299,14 @@ You haven't specified the sendAnonymousUsage option, it will be enabled by defau Stats collection is enabled. Many thanks for contributing to Traefik's improvement by allowing us to receive anonymous information from your configuration. Help us improve Traefik by leaving this feature on :) -More details on: https://docs.traefik.io/basics/#collected-data +More details on: https://docs.traefik.io/v2.0/contributing/data-collection/ `) collect(staticConfiguration) } else { log.WithoutContext().Info(` Stats collection is disabled. Help us improve Traefik by turning this feature on :) -More details on: https://docs.traefik.io/basics/#collected-data +More details on: https://docs.traefik.io/v2.0/contributing/data-collection/ `) } } diff --git a/pkg/server/middleware/middlewares.go b/pkg/server/middleware/middlewares.go index 4fd747780..3e5d2c154 100644 --- a/pkg/server/middleware/middlewares.go +++ b/pkg/server/middleware/middlewares.go @@ -123,7 +123,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) ( } // Buffering - if config.Buffering != nil && config.InFlightReq.Amount != 0 { + if config.Buffering != nil { if middleware != nil { return nil, badConf } @@ -213,7 +213,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) ( } // InFlightReq - if config.InFlightReq != nil && config.InFlightReq.Amount != 0 { + if config.InFlightReq != nil { if middleware != nil { return nil, badConf } diff --git a/pkg/server/middleware/middlewares_test.go b/pkg/server/middleware/middlewares_test.go index a3d855c44..b747390c5 100644 --- a/pkg/server/middleware/middlewares_test.go +++ b/pkg/server/middleware/middlewares_test.go @@ -314,6 +314,14 @@ func TestBuilder_buildConstructor(t *testing.T) { Prefix: "foo/", }, }, + "buff-foo": { + Buffering: &dynamic.Buffering{ + MaxRequestBodyBytes: 1, + MemRequestBodyBytes: 2, + MaxResponseBodyBytes: 3, + MemResponseBodyBytes: 5, + }, + }, } rtConf := runtime.NewConfig(dynamic.Configuration{ @@ -338,6 +346,11 @@ func TestBuilder_buildConstructor(t *testing.T) { middlewareID: "cb-foo", expectedError: false, }, + { + desc: "Should create a buffering middleware", + middlewareID: "buff-foo", + expectedError: false, + }, { desc: "Should not create an empty AddPrefix middleware when given an empty prefix", middlewareID: "ap-empty",