diff --git a/docs/config.md b/docs/config.md index b4d3b05..7c55007 100644 --- a/docs/config.md +++ b/docs/config.md @@ -44,6 +44,7 @@ The next sections describes how to set up project configuration. - `circuitbreaker.closed_state_calls_number` - size of circuit breaker sliding window. - `circuitbreaker.half_open_state_calls_number` - number of calls in half open state. - `sampling.rate` - logging sampling rate +- `server.max-http-body-size-kb` - sets max HTTP body size in kb. Default is 256 kb. Improper usage might lead to application running out of memory. ### Storage - `storage.default-ttl-seconds` - set the default ttl for the data diff --git a/src/main/java/org/prebid/cache/config/BodySizeConfig.java b/src/main/java/org/prebid/cache/config/BodySizeConfig.java new file mode 100644 index 0000000..5d2763b --- /dev/null +++ b/src/main/java/org/prebid/cache/config/BodySizeConfig.java @@ -0,0 +1,20 @@ +package org.prebid.cache.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.codec.ServerCodecConfigurer; +import org.springframework.web.reactive.config.WebFluxConfigurer; + +@Configuration +@ConditionalOnProperty(name = "server.max-http-body-size-kb") +public class BodySizeConfig implements WebFluxConfigurer { + + @Value("${server.max-http-body-size-kb}") + private int maxHttpBodySizeKb; + + @Override + public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { + configurer.defaultCodecs().maxInMemorySize(maxHttpBodySizeKb * 1024); + } +}