fix buffering middleware

This commit is contained in:
Ludovic Fernandez 2019-09-03 15:02:05 +02:00 committed by Traefiker Bot
parent b8ed6f1588
commit a917115a85
3 changed files with 17 additions and 4 deletions

View file

@ -299,14 +299,14 @@ You haven't specified the sendAnonymousUsage option, it will be enabled by defau
Stats collection is enabled. Stats collection is enabled.
Many thanks for contributing to Traefik's improvement by allowing us to receive anonymous information from your configuration. 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 :) 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) collect(staticConfiguration)
} else { } else {
log.WithoutContext().Info(` log.WithoutContext().Info(`
Stats collection is disabled. Stats collection is disabled.
Help us improve Traefik by turning this feature on :) 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/
`) `)
} }
} }

View file

@ -123,7 +123,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
} }
// Buffering // Buffering
if config.Buffering != nil && config.InFlightReq.Amount != 0 { if config.Buffering != nil {
if middleware != nil { if middleware != nil {
return nil, badConf return nil, badConf
} }
@ -213,7 +213,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
} }
// InFlightReq // InFlightReq
if config.InFlightReq != nil && config.InFlightReq.Amount != 0 { if config.InFlightReq != nil {
if middleware != nil { if middleware != nil {
return nil, badConf return nil, badConf
} }

View file

@ -314,6 +314,14 @@ func TestBuilder_buildConstructor(t *testing.T) {
Prefix: "foo/", Prefix: "foo/",
}, },
}, },
"buff-foo": {
Buffering: &dynamic.Buffering{
MaxRequestBodyBytes: 1,
MemRequestBodyBytes: 2,
MaxResponseBodyBytes: 3,
MemResponseBodyBytes: 5,
},
},
} }
rtConf := runtime.NewConfig(dynamic.Configuration{ rtConf := runtime.NewConfig(dynamic.Configuration{
@ -338,6 +346,11 @@ func TestBuilder_buildConstructor(t *testing.T) {
middlewareID: "cb-foo", middlewareID: "cb-foo",
expectedError: false, 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", desc: "Should not create an empty AddPrefix middleware when given an empty prefix",
middlewareID: "ap-empty", middlewareID: "ap-empty",