'WebClient max header size
Is there any way I can configure the max header size for a response?
I get the following error from the netty framework :
io.netty.handler.codec.TooLongFrameException: HTTP header is larger than 8192 bytes.
at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.newException(HttpObjectDecoder.java:983)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Apparently reactor added an API for this, but I don't see how is this controllable in the WebClient of spring Web Flux. I am using the following version
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
Any ideas?
Solution 1:[1]
You can configure reactor's reactor.netty.http.client.HttpClient
to have custom maxHeaderSize
and plug this preconfigured HttpClient
in your WebClient instance.
HttpClient httpClient =
HttpClient.create().httpResponseDecoder(spec -> spec.maxHeaderSize(32 * 1024));
WebClient webClient =
WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
Solution 2:[2]
In a Spring Boot app, the max HTTP header size is configured using:
server.max-http-header-size=65536
I have found this solved the above issue on spring cloud gateway, so worth a try.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | charlb |