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.
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/
`)
}
}

View file

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

View file

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