有什么方法可以配置响应的最大标头大小?
我从netty框架收到以下错误:
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:
显然是反应堆these S.O. answers,但是我看不到在Spring Web Flux的WebClient中如何控制它。我正在使用以下版本
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
有什么想法吗?
答案 0 :(得分:2)
您可以将反应堆的reactor.netty.http.client.HttpClient
配置为具有自定义maxHeaderSize
,并将此预先配置的HttpClient
插入您的WebClient实例中。
HttpClient httpClient =
HttpClient.create().httpResponseDecoder(spec -> spec.maxHeaderSize(32 * 1024));
WebClient webClient =
WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient))
.build();